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.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);
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // TODO Auto-generated method stub
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.options, 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;
+ }
}
}