修复同日搜索0点跨日
This commit is contained in:
parent
71f9ab42a7
commit
5e7b520c41
|
@ -55,7 +55,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||
public Cursor query(String s) {
|
||||
db = getWritableDatabase();
|
||||
Cursor c;
|
||||
if (s.equals("")) {
|
||||
if (s.isEmpty()) {
|
||||
c = db.query(TableName, null, null, null, null, null, "time desc");
|
||||
} else {
|
||||
c = db.query(TableName, null, "location LIKE '%" + s + "%' or event LIKE '%" + s + "%'", null, null, null, "time desc");
|
||||
|
@ -67,9 +67,9 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||
db = getWritableDatabase();
|
||||
Cursor c;
|
||||
if (date_start != date_end)
|
||||
c = db.query(TableName, null, "time >= " + date_start + " and time <= " + (date_end + 24*60*60*1000), null, null, null, "time asc");
|
||||
c = db.query(TableName, null, "time >= " + date_start + " and time < " + (date_end + 24*60*60*1000), null, null, null, "time asc");
|
||||
else
|
||||
c = db.query(TableName, null, "time >= " + date_start + " and time <= " + (date_start + 24*60*60*1000), null, null, null, "time asc");
|
||||
c = db.query(TableName, null, "time >= " + date_start + " and time < " + (date_start + 24*60*60*1000), null, null, null, "time asc");
|
||||
return c;
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||
String selection = "";
|
||||
for (int year=year_max; year>year_min; year--) {
|
||||
date = new Date(year, month, day);
|
||||
selection += "(time >= " + date.getTime() + " and time <= " + (date.getTime() + 24*60*60*1000) + ")";
|
||||
selection += "(time >= " + date.getTime() + " and time < " + (date.getTime() + 24*60*60*1000) + ")";
|
||||
if (year > year_min + 1) {
|
||||
selection += " or ";
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ public class MainActivity extends Activity {
|
|||
}
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
if (s.toString().equals("")) {
|
||||
if (s.toString().isEmpty()) {
|
||||
imageButton_clear.setVisibility(View.GONE);
|
||||
} else {
|
||||
imageButton_clear.setVisibility(View.VISIBLE);
|
||||
|
@ -366,7 +366,7 @@ public class MainActivity extends Activity {
|
|||
}
|
||||
s += "</table>\n</body>\n</html>";
|
||||
String filename = "event.htm";
|
||||
if (!editText_search.getText().toString().equals(""))
|
||||
if (!editText_search.getText().toString().isEmpty())
|
||||
filename = editText_search.getText().toString() + ".htm";
|
||||
writeFile(filename, s);
|
||||
break;
|
||||
|
@ -529,8 +529,8 @@ public class MainActivity extends Activity {
|
|||
datePicker.init(date.getYear() + 1900, date.getMonth(), date.getDate(), null);
|
||||
timePicker.setCurrentHour(date.getHours());
|
||||
timePicker.setCurrentMinute(date.getMinutes());
|
||||
} catch (Exception e){
|
||||
Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_SHORT);
|
||||
} catch (Exception e) {
|
||||
Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
editText_location.setText(location);
|
||||
editText_event.setText(event);
|
||||
|
@ -550,7 +550,7 @@ public class MainActivity extends Activity {
|
|||
field.setAccessible(true);//设置该属性可以访问
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
if (!location.equals("") && !event.equals("")) {
|
||||
if (!location.isEmpty() && !event.isEmpty()) {
|
||||
int year = datePicker.getYear();
|
||||
int month = datePicker.getMonth();
|
||||
int day = datePicker.getDayOfMonth();
|
||||
|
|
|
@ -1,40 +1,38 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_event"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<DatePicker
|
||||
android:id="@+id/datePicker"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:calendarViewShown="false" />
|
||||
android:orientation="vertical">
|
||||
|
||||
<TimePicker
|
||||
android:id="@+id/timePicker"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<DatePicker
|
||||
android:id="@+id/datePicker"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:calendarViewShown="false" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editText_location"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="地点"
|
||||
android:singleLine="true" />
|
||||
<TimePicker
|
||||
android:id="@+id/timePicker"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editText_event"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="事件"
|
||||
android:maxLines="5" />
|
||||
<EditText
|
||||
android:id="@+id/editText_location"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="地点"
|
||||
android:singleLine="true" />
|
||||
|
||||
</LinearLayout>
|
||||
<EditText
|
||||
android:id="@+id/editText_event"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="事件"
|
||||
android:maxLines="5" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
Loading…
Reference in New Issue