Commit | Line | Data |
---|---|---|
bdd8f09c PT |
1 | package ro.ieval.unical; |
2 | import java.io.BufferedReader; | |
3 | import java.io.IOException; | |
4 | import java.io.InputStreamReader; | |
819197b2 PT |
5 | import java.io.PrintStream; |
6 | import java.io.PrintWriter; | |
bdd8f09c PT |
7 | import java.net.MalformedURLException; |
8 | import java.net.URL; | |
9 | import java.net.URLConnection; | |
10 | import java.util.Date; | |
11 | ||
819197b2 PT |
12 | import javax.net.ssl.HttpsURLConnection; |
13 | ||
bdd8f09c PT |
14 | import ro.ieval.unical.R; |
15 | import com.google.gson.Gson; | |
16 | ||
7be52756 | 17 | import android.content.Intent; |
bdd8f09c PT |
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 | ||
7be52756 PT |
25 | import com.facebook.*; |
26 | ||
27 | import com.facebook.model.*; | |
bdd8f09c PT |
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); | |
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 | } |