1 package ro
.ieval
.unical
;
2 import java
.io
.BufferedReader
;
3 import java
.io
.IOException
;
4 import java
.io
.InputStreamReader
;
5 import java
.io
.PrintStream
;
6 import java
.io
.PrintWriter
;
7 import java
.net
.MalformedURLException
;
9 import java
.net
.URLConnection
;
10 import java
.util
.Date
;
12 import javax
.net
.ssl
.HttpsURLConnection
;
14 import ro
.ieval
.unical
.R
;
15 import com
.google
.gson
.Gson
;
17 import android
.content
.Intent
;
18 import android
.graphics
.Color
;
19 import android
.os
.Bundle
;
20 import android
.os
.Handler
;
21 import android
.util
.Base64
;
22 import android
.widget
.EditText
;
23 import android
.widget
.TextView
;
25 import com
.facebook
.*;
27 import com
.facebook
.model
.*;
29 public class mainActivity
extends android
.app
.Activity
{
30 Event
[] getEventList() {
35 hostUrlJson
=new URL(Constants
.searchUrl
);
36 HttpsURLConnection calConnection
= (HttpsURLConnection
) hostUrlJson
.openConnection();
37 calConnection
.setDoOutput(true);
38 calConnection
.setUseCaches(false);
39 calConnection
.setRequestProperty("Authorization", "Basic "+Base64
.encodeToString( (Constants
.user
+':'+Constants
.password
).getBytes(), Base64
.NO_WRAP
));
40 //calConnection.setRequestMethod("POST");
41 //calConnection.setDoInput(true);
42 //calConnection.connect();
44 final PrintWriter ps
=new PrintWriter(calConnection
.getOutputStream());
48 in
= new InputStreamReader(calConnection
.getInputStream());
50 events
=gson
.fromJson(in
,Event
[].class);
54 } catch (MalformedURLException e
) {
55 // TODO Auto-generated catch block
56 System
.err
.println("catch1");
58 } catch (IOException e
) {
59 // TODO Auto-generated catch block
60 System
.err
.println("catch2");
63 throw new AssertionError();
67 protected void onCreate(Bundle savedInstanceState
) {
69 // And here it began the olympic app that does olympic thing
70 super.onCreate(savedInstanceState
);
71 setContentView(R
.layout
.login
);
73 /*setContentView(R.layout.eventview);
74 final TextView eventTitle= (TextView) findViewById(R.id.eventTitle);
75 final TextView date=(TextView) findViewById(R.id.date);
76 final TextView description=(TextView) findViewById(R.id.description);
78 final Handler h=new Handler();
79 new Thread(new Runnable() {
81 final Event events[]=getEventList();
82 h.post(new Runnable() {
86 eventTitle.setText(events[0].title);
87 date.setText((new Date(events[0].date)).toString());
88 description.setText(events[0].description);
89 DatabaseInteract db=new DatabaseInteract(mainActivity.this);