]> iEval git - unical.git/commitdiff
Display event if the button is clicked
authorPetru Trimbitas <l3asketballplayer@yahoo.com>
Sun, 9 Jun 2013 11:14:02 +0000 (14:14 +0300)
committerPetru Trimbitas <l3asketballplayer@yahoo.com>
Sun, 9 Jun 2013 11:14:02 +0000 (14:14 +0300)
src/ro/ieval/unical/DisplayEventActivity.java
src/ro/ieval/unical/Event.java
src/ro/ieval/unical/EventButton.java [new file with mode: 0644]
src/ro/ieval/unical/EventListActivity.java
src/ro/ieval/unical/MainActivity.java

index af682248a8ec7db1f7a8c964f71ecd3f36deef23..8b8a767afdb805c586d7bac200378fa9e14c7b5e 100644 (file)
@@ -1,6 +1,5 @@
 package ro.ieval.unical;
 
-import java.util.Arrays;
 import java.util.Date;
 
 import android.app.Activity;
@@ -16,6 +15,7 @@ public class DisplayEventActivity extends Activity {
        public static final String EXTRA_EVENT = "event";
 
        public static void displayEvent(final Context context, final Event event){
+               System.out.println("Muie");
                final Intent i=new Intent(context,DisplayEventActivity.class);
                i.putExtra(DisplayEventActivity.EXTRA_EVENT, event);
                context.startActivity(i);
index cdeafaf5befb0300d5751c790080404492477380..23ccd74d5488b9ba411464bc294bf315c540a7ee 100644 (file)
@@ -1,7 +1,6 @@
 package ro.ieval.unical;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 
 import android.content.ContentResolver;
 import android.content.Context;
diff --git a/src/ro/ieval/unical/EventButton.java b/src/ro/ieval/unical/EventButton.java
new file mode 100644 (file)
index 0000000..3061d7d
--- /dev/null
@@ -0,0 +1,14 @@
+package ro.ieval.unical;
+import android.content.Context;
+import android.widget.Button;
+
+
+public class EventButton extends Button{
+       Event e;
+       public EventButton(Context context,Event z) {
+               super(context);
+               e=z;
+               // TODO Auto-generated constructor stub
+       }
+       
+}
index 793573b3eec05a220041d0ee046a1f492144903c..24732602009bb2377fd9aaa29561aa3c6f176e3e 100644 (file)
@@ -1,14 +1,15 @@
 package ro.ieval.unical;
 
 import java.util.Arrays;
-import java.util.GregorianCalendar;
-import java.text.DateFormat;
 import java.util.Date;
+import java.util.GregorianCalendar;
 
-import ro.ieval.unical.R;
 import android.app.Activity;
+import android.content.Intent;
+import android.graphics.Color;
 import android.os.Bundle;
-import android.text.format.DateUtils;
+import android.view.View;
+import android.view.View.OnClickListener;
 import android.widget.Button;
 import android.widget.LinearLayout;
 
@@ -29,12 +30,27 @@ public class EventListActivity extends Activity {
                
            Event r[]=Event.getAllEvents(getBaseContext());
            LinearLayout ll = (LinearLayout)findViewById(R.id.eventslayout);
-           Button[] b=new Button[10];
                Arrays.sort(r,new EventComparator());
-               for(int i=0; i<r.length; ++i) if(r[i].dtstart<=gc.getTimeInMillis()){
-                       Button EventButton=new Button(getBaseContext());
-                       EventButton.setText(r[i].title);
-                       ll.addView(EventButton);
+               EventButton[] b=new EventButton[10000];
+               for(int i=0; i<r.length; ++i) {
+                       b[i]=new EventButton(getBaseContext(),r[i]);
+                       b[i].setText(r[i].title);
+                       
+                       b[i].setTextColor(Color.BLACK);
+                       b[i].setOnClickListener(new OnClickListener() {
+                               
+                               @Override
+                               public void onClick(View v) {
+                                       // TODO Auto-generated method stub
+                                       EventButton b=(EventButton) v;
+                                       DisplayEventActivity.displayEvent(EventListActivity.this,b.e);
+                                       //Intent i=new Intent(getBaseContext(),DisplayEventActivity.class);
+                                       //i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                                       //startActivity(i);
+                               }
+                       });
+                       ll.addView(b[i]);
                }
        }
+       
 }
index 12ecca157948e89afa6be754f2e15655e65cc241..b70649e1be1816b4117bdf4bced87e02477eb358 100644 (file)
@@ -3,7 +3,6 @@ import android.content.Intent;
 import android.content.SharedPreferences;
 import android.os.Bundle;
 import android.preference.PreferenceManager;
-import android.provider.CalendarContract.Events;
 import android.view.Menu;
 import android.view.MenuInflater;
 import android.view.MenuItem;
@@ -21,8 +20,10 @@ public class MainActivity extends android.app.Activity {
                        startActivity(i);
                }
 
-               DisplayEventActivity.displayEvent(this, Event.getEventsByCalendar(this,
-                               Calendar.getAllCalendars(this)[0]._id, Events.DTSTART)[0]);
+               //DisplayEventActivity.displayEvent(this, Event.getEventsByCalendar(this,
+               //              Calendar.getAllCalendars(this)[0]._id, Events.DTSTART)[0]);
+               Intent i=new Intent(this,EventListActivity.class);
+               startActivity(i);
        }
        
        @Override
This page took 0.033242 seconds and 4 git commands to generate.