]>
Commit | Line | Data |
---|---|---|
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; | |
8 | import java.net.URL; | |
9 | import java.net.URLConnection; | |
10 | import java.util.Date; | |
11 | ||
12 | import javax.net.ssl.HttpsURLConnection; | |
13 | ||
14 | import ro.ieval.unical.R; | |
15 | import com.google.gson.Gson; | |
16 | ||
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; | |
24 | ||
25 | import com.facebook.*; | |
26 | ||
27 | import com.facebook.model.*; | |
28 | ||
29 | public 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); | |
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(); | |
43 | ||
44 | final PrintWriter ps=new PrintWriter(calConnection.getOutputStream()); | |
45 | ps.print("{}"); | |
46 | ps.close(); | |
47 | ||
48 | in = new InputStreamReader(calConnection.getInputStream()); | |
49 | Gson gson=new Gson(); | |
50 | events=gson.fromJson(in,Event[].class); | |
51 | in.close(); | |
52 | ||
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 | |
70 | super.onCreate(savedInstanceState); | |
71 | setContentView(R.layout.login); | |
72 | ||
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); | |
77 | ||
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 | |
85 | ||
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); | |
90 | } | |
91 | }); | |
92 | } | |
93 | }).start();*/ | |
94 | } | |
95 | } |