]> iEval git - unical.git/blobdiff - src/ro/ieval/unical/mainActivity.java
add interface to delete event
[unical.git] / src / ro / ieval / unical / mainActivity.java
index eba46042e83accc88ecc59570fca4efb9f2e5a49..2c6a95bacbc254bc2d5206724e1280f0762ee021 100644 (file)
@@ -1,72 +1,53 @@
 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.content.Intent;
+import android.content.SharedPreferences;
 import android.os.Bundle;
-import android.os.Handler;
-import android.util.Base64;
-import android.widget.EditText;
-import android.widget.TextView;
-
+import android.preference.PreferenceManager;
+import android.provider.CalendarContract.Events;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
 
 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);
+               
+               //log in
                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();
+               
+               final SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(this);
+               if(prefs.getBoolean("FirstTime", true)) {
+                       prefs.edit().putBoolean("FirstTime", false).commit();
+                       Intent i=new Intent(this,loginActivity.class);
+                       startActivity(i);
+               }
+               Intent i=new Intent(this,displayEventActivity.class);
+               Event e[]=Event.getEventsByCalendar(this, Calendar.getAllCalendars(this)[0]._id, Events.DTSTART);
+               i.putExtra(displayEventActivity.EXTRA_EVENT, e[0]);
+               startActivity(i);
+       }
+       
+       @Override
+       public boolean onCreateOptionsMenu(Menu menu) {
+               // TODO Auto-generated method stub
+               MenuInflater inflater = getMenuInflater();
+           inflater.inflate(R.menu.mainmenu, menu);
+               return true;
+       }
+       
+       @Override
+       public boolean onOptionsItemSelected(MenuItem item) {
+           // Handle item selection
+           switch (item.getItemId()) {
+               case R.id.NewEvent:
+                       Intent i=new Intent(this,addEventActivity.class);
+                               startActivity(i);
+                   return true;
+               default:
+                   return true;
+           }
        }
 }
This page took 0.025661 seconds and 4 git commands to generate.