+package ro.ieval.unical;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Date;
+
+import ro.ieval.unical.R;
+import com.google.gson.Gson;
+
+import android.graphics.Color;
+import android.os.Bundle;
+import android.os.Handler;
+import android.util.Base64;
+import android.widget.EditText;
+import android.widget.TextView;
+
+
+public class mainActivity extends android.app.Activity {
+ Event[] getEventList() {
+ Event events[];
+ URL hostUrlJson;
+ InputStreamReader in;
+ try {
+ hostUrlJson=new URL(Constants.searchUrl);
+ URLConnection calConnection = hostUrlJson.openConnection();
+ calConnection.setRequestProperty("Authorization", "Basic "+Base64.encodeToString( (Constants.user+':'+Constants.password).getBytes(), Base64.NO_WRAP));
+ in = new InputStreamReader(calConnection.getInputStream());
+ Gson gson=new Gson();
+ events=gson.fromJson(in,Event[].class);
+ in.close();
+ return events;
+ } catch (MalformedURLException e) {
+ // TODO Auto-generated catch block
+ System.err.println("catch1");
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ System.err.println("catch2");
+ e.printStackTrace();
+ }
+ throw new AssertionError();
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ // All Begins here :)
+ // And here it began the olympic app that does olympic thing
+ setContentView(R.layout.eventview);
+ final TextView eventTitle= (TextView) findViewById(R.id.eventTitle);
+ final TextView date=(TextView) findViewById(R.id.date);
+ final TextView description=(TextView) findViewById(R.id.description);
+ super.onCreate(savedInstanceState);
+ System.err.println("MuieLaComisie");
+ final Handler h=new Handler();
+ new Thread(new Runnable() {
+ public void run() {
+ final Event events[]=getEventList();
+ h.post(new Runnable() {
+ public void run() {
+ // aici incepe
+ eventTitle.setText(events[0].title);
+ date.setText((new Date(events[0].date)).toString());
+ description.setText(events[0].description);
+ }
+ });
+ }
+ }).start();
+ }
+}