Fix previous commit
[unical.git] / src / ro / ieval / unical / mainActivity.java
CommitLineData
bdd8f09c
PT
1package ro.ieval.unical;
2import java.io.BufferedReader;
3import java.io.IOException;
4import java.io.InputStreamReader;
819197b2
PT
5import java.io.PrintStream;
6import java.io.PrintWriter;
bdd8f09c
PT
7import java.net.MalformedURLException;
8import java.net.URL;
9import java.net.URLConnection;
10import java.util.Date;
11
819197b2
PT
12import javax.net.ssl.HttpsURLConnection;
13
bdd8f09c
PT
14import ro.ieval.unical.R;
15import com.google.gson.Gson;
16
7be52756 17import android.content.Intent;
bdd8f09c
PT
18import android.graphics.Color;
19import android.os.Bundle;
20import android.os.Handler;
21import android.util.Base64;
22import android.widget.EditText;
23import android.widget.TextView;
24
7be52756
PT
25import com.facebook.*;
26
27import com.facebook.model.*;
bdd8f09c
PT
28
29public class mainActivity extends android.app.Activity {
30 Event[] getEventList() {
31 Event events[];
32 URL hostUrlJson;
33 InputStreamReader in;
34 try {
35 hostUrlJson=new URL(Constants.searchUrl);
819197b2
PT
36 HttpsURLConnection calConnection = (HttpsURLConnection) hostUrlJson.openConnection();
37 calConnection.setDoOutput(true);
38 calConnection.setUseCaches(false);
cfd903b6 39 calConnection.setRequestProperty("Authorization", "Basic "+Base64.encodeToString( (Constants.user+':'+Constants.password).getBytes(), Base64.NO_WRAP));
819197b2
PT
40 //calConnection.setRequestMethod("POST");
41 //calConnection.setDoInput(true);
42 //calConnection.connect();
43
44 final PrintWriter ps=new PrintWriter(calConnection.getOutputStream());
45 ps.print("{}");
46 ps.close();
47
bdd8f09c
PT
48 in = new InputStreamReader(calConnection.getInputStream());
49 Gson gson=new Gson();
50 events=gson.fromJson(in,Event[].class);
51 in.close();
819197b2 52
bdd8f09c
PT
53 return events;
54 } catch (MalformedURLException e) {
55 // TODO Auto-generated catch block
56 System.err.println("catch1");
57 e.printStackTrace();
58 } catch (IOException e) {
59 // TODO Auto-generated catch block
60 System.err.println("catch2");
61 e.printStackTrace();
62 }
63 throw new AssertionError();
64 }
65
66 @Override
67 protected void onCreate(Bundle savedInstanceState) {
68 // All Begins here :)
69 // And here it began the olympic app that does olympic thing
7be52756
PT
70 super.onCreate(savedInstanceState);
71 setContentView(R.layout.login);
72
73 /*setContentView(R.layout.eventview);
bdd8f09c
PT
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);
819197b2 77
bdd8f09c
PT
78 final Handler h=new Handler();
79 new Thread(new Runnable() {
80 public void run() {
81 final Event events[]=getEventList();
82 h.post(new Runnable() {
83 public void run() {
84 // aici incepe
7be52756 85
bdd8f09c
PT
86 eventTitle.setText(events[0].title);
87 date.setText((new Date(events[0].date)).toString());
88 description.setText(events[0].description);
7be52756 89 DatabaseInteract db=new DatabaseInteract(mainActivity.this);
bdd8f09c
PT
90 }
91 });
92 }
7be52756 93 }).start();*/
bdd8f09c
PT
94 }
95}
This page took 0.016303 seconds and 4 git commands to generate.