Ver código fonte

Schedule now opens on current date.

seavenois 10 anos atrás
pai
commit
da60fa5450

+ 12 - 1
app/src/main/java/com/ivalentin/margolariak/ScheduleLayout.java

@@ -123,10 +123,21 @@ public class ScheduleLayout extends Fragment implements OnMapReadyCallback{
 		else{
 			cursor = db.rawQuery("SELECT DISTINCT date(start) FROM festival_event WHERE strftime('%Y', start) = '" + year + "' AND strftime('%H', start) > '06' AND gm = 0;", null);
 		}
+
+
+		//Get current date in the same format as retrieved from the database
+		DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
+		Date today = Calendar.getInstance().getTime();
+		String curDate = df.format(today);
+
+		//Log.e("Cur Date", curDate);
 		while (cursor.moveToNext()){
 			dates[dateCount] = cursor.getString(0);
-			dateCount ++;
 			//TODO: Check if some date is of today, and set selected
+			if (curDate.equals(cursor.getString(0))){
+				selected = dateCount;
+			}
+			dateCount ++;
 		}
 		cursor.close();
 		db.close();

+ 2 - 2
app/src/main/res/layout/fragment_layout_home.xml

@@ -226,7 +226,7 @@
                     android:layout_height="wrap_content"
                     android:textAppearance="@android:style/TextAppearance.Medium"
                     android:text="@string/schedule_now"
-					/>
+					android:textStyle="bold"/>
 
 				<LinearLayout
                     android:id="@+id/ll_home_section_cityschedule_now_list"
@@ -253,7 +253,7 @@
 					android:layout_height="wrap_content"
 					android:textAppearance="@android:style/TextAppearance.Medium"
 					android:text="@string/schedule_later"
-					/>
+					android:textStyle="bold"/>
 
 				<LinearLayout
 					android:id="@+id/ll_home_section_cityschedule_later_list"