1 package ro
.ieval
.unical
;
2 import java
.io
.BufferedReader
;
3 import java
.io
.IOException
;
4 import java
.io
.InputStreamReader
;
5 import java
.net
.MalformedURLException
;
7 import java
.net
.URLConnection
;
10 import ro
.ieval
.unical
.R
;
11 import com
.google
.gson
.Gson
;
13 import android
.graphics
.Color
;
14 import android
.os
.Bundle
;
15 import android
.os
.Handler
;
16 import android
.util
.Base64
;
17 import android
.widget
.EditText
;
18 import android
.widget
.TextView
;
21 public class mainActivity
extends android
.app
.Activity
{
22 Event
[] getEventList() {
27 hostUrlJson
=new URL(Constants
.searchUrl
);
28 URLConnection calConnection
= hostUrlJson
.openConnection();
29 calConnection
.setRequestProperty("Authorization", "Basic "+Base64
.encodeToString( (Constants
.user
+':'+Constants
.password
).getBytes(), Base64
.NO_WRAP
));
30 in
= new InputStreamReader(calConnection
.getInputStream());
32 events
=gson
.fromJson(in
,Event
[].class);
35 } catch (MalformedURLException e
) {
36 // TODO Auto-generated catch block
37 System
.err
.println("catch1");
39 } catch (IOException e
) {
40 // TODO Auto-generated catch block
41 System
.err
.println("catch2");
44 throw new AssertionError();
48 protected void onCreate(Bundle savedInstanceState
) {
50 // And here it began the olympic app that does olympic thing
51 setContentView(R
.layout
.eventview
);
52 final TextView eventTitle
= (TextView
) findViewById(R
.id
.eventTitle
);
53 final TextView date
=(TextView
) findViewById(R
.id
.date
);
54 final TextView description
=(TextView
) findViewById(R
.id
.description
);
55 super.onCreate(savedInstanceState
);
56 System
.err
.println("MuieLaComisie");
57 final Handler h
=new Handler();
58 new Thread(new Runnable() {
60 final Event events
[]=getEventList();
61 h
.post(new Runnable() {
64 eventTitle
.setText(events
[0].title
);
65 date
.setText((new Date(events
[0].date
)).toString());
66 description
.setText(events
[0].description
);