various offline fixes
This commit is contained in:
parent
8e3e5add77
commit
2103396489
@ -47,6 +47,7 @@ public class OfflineActivity extends CommonActivity {
|
||||
public void onDestroyActionMode(ActionMode mode) {
|
||||
deselectAllArticles();
|
||||
m_headlinesActionMode = null;
|
||||
initMenu();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -114,6 +115,47 @@ public class OfflineActivity extends CommonActivity {
|
||||
out.putBoolean("unreadOnly", m_unreadOnly);
|
||||
}
|
||||
|
||||
protected void selectArticles(int feedId, boolean isCat, int mode) {
|
||||
switch (mode) {
|
||||
case 0:
|
||||
SQLiteStatement stmtSelectAll = null;
|
||||
|
||||
if (isCat) {
|
||||
stmtSelectAll = getWritableDb().compileStatement(
|
||||
"UPDATE articles SET selected = 1 WHERE feed_id IN (SELECT "+BaseColumns._ID+" FROM feeds WHERE cat_id = ?)");
|
||||
} else {
|
||||
stmtSelectAll = getWritableDb().compileStatement(
|
||||
"UPDATE articles SET selected = 1 WHERE feed_id = ?");
|
||||
}
|
||||
|
||||
stmtSelectAll.bindLong(1, feedId);
|
||||
stmtSelectAll.execute();
|
||||
stmtSelectAll.close();
|
||||
|
||||
break;
|
||||
case 1:
|
||||
|
||||
SQLiteStatement stmtSelectUnread = null;
|
||||
|
||||
if (isCat) {
|
||||
stmtSelectUnread = getWritableDb().compileStatement(
|
||||
"UPDATE articles SET selected = 1 WHERE feed_id IN (SELECT "+BaseColumns._ID+" FROM feeds WHERE cat_id = ?) AND unread = 1");
|
||||
} else {
|
||||
stmtSelectUnread = getWritableDb().compileStatement(
|
||||
"UPDATE articles SET selected = 1 WHERE feed_id = ? AND unread = 1");
|
||||
}
|
||||
|
||||
stmtSelectUnread.bindLong(1, feedId);
|
||||
stmtSelectUnread.execute();
|
||||
stmtSelectUnread.close();
|
||||
|
||||
break;
|
||||
case 2:
|
||||
deselectAllArticles();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
final OfflineHeadlinesFragment ohf = (OfflineHeadlinesFragment) getSupportFragmentManager()
|
||||
@ -188,29 +230,8 @@ public class OfflineActivity extends CommonActivity {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog,
|
||||
int which) {
|
||||
switch (which) {
|
||||
case 0:
|
||||
SQLiteStatement stmtSelectAll = getWritableDb()
|
||||
.compileStatement(
|
||||
"UPDATE articles SET selected = 1 WHERE feed_id = ?");
|
||||
stmtSelectAll.bindLong(1, ohf.getFeedId());
|
||||
stmtSelectAll.execute();
|
||||
stmtSelectAll.close();
|
||||
break;
|
||||
case 1:
|
||||
SQLiteStatement stmtSelectUnread = getWritableDb()
|
||||
.compileStatement(
|
||||
"UPDATE articles SET selected = 1 WHERE feed_id = ? AND unread = 1");
|
||||
stmtSelectUnread
|
||||
.bindLong(1, ohf.getFeedId());
|
||||
stmtSelectUnread.execute();
|
||||
stmtSelectUnread.close();
|
||||
break;
|
||||
case 2:
|
||||
deselectAllArticles();
|
||||
break;
|
||||
}
|
||||
|
||||
selectArticles(ohf.getFeedId(), ohf.getFeedIsCat(), which);
|
||||
initMenu();
|
||||
refresh();
|
||||
|
||||
@ -225,9 +246,17 @@ public class OfflineActivity extends CommonActivity {
|
||||
case R.id.headlines_mark_as_read:
|
||||
if (ohf != null) {
|
||||
int feedId = ohf.getFeedId();
|
||||
boolean isCat = ohf.getFeedIsCat();
|
||||
|
||||
SQLiteStatement stmt = getWritableDb().compileStatement(
|
||||
SQLiteStatement stmt = null;
|
||||
|
||||
if (isCat) {
|
||||
stmt = getWritableDb().compileStatement(
|
||||
"UPDATE articles SET unread = 0 WHERE feed_id IN (SELECT "+BaseColumns._ID+" FROM feeds WHERE cat_id = ?)");
|
||||
} else {
|
||||
stmt = getWritableDb().compileStatement(
|
||||
"UPDATE articles SET unread = 0 WHERE feed_id = ?");
|
||||
}
|
||||
stmt.bindLong(1, feedId);
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
@ -309,12 +338,25 @@ public class OfflineActivity extends CommonActivity {
|
||||
case R.id.catchup_above:
|
||||
if (oap != null) {
|
||||
int articleId = oap.getSelectedArticleId();
|
||||
int feedId = oap.getFeedId();
|
||||
boolean isCat = oap.getFeedIsCat();
|
||||
|
||||
SQLiteStatement stmt = null;
|
||||
|
||||
if (isCat) {
|
||||
stmt = getWritableDb().compileStatement(
|
||||
"UPDATE articles SET unread = 0 WHERE " +
|
||||
"updated >= (SELECT updated FROM articles WHERE " + BaseColumns._ID + " = ?) " +
|
||||
"AND feed_id IN (SELECT "+BaseColumns._ID+" FROM feeds WHERE cat_id = ?)");
|
||||
} else {
|
||||
stmt = getWritableDb().compileStatement(
|
||||
"UPDATE articles SET unread = 0 WHERE " +
|
||||
"updated >= (SELECT updated FROM articles WHERE " + BaseColumns._ID + " = ?) " +
|
||||
"AND feed_id = ?");
|
||||
}
|
||||
|
||||
SQLiteStatement stmt = getWritableDb().compileStatement(
|
||||
"UPDATE articles SET unread = 0 WHERE updated >= "
|
||||
+ "(SELECT updated FROM articles WHERE "
|
||||
+ BaseColumns._ID + " = ?)");
|
||||
stmt.bindLong(1, articleId);
|
||||
stmt.bindLong(2, feedId);
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
|
||||
|
@ -28,6 +28,14 @@ public class OfflineArticlePager extends Fragment {
|
||||
private String m_searchQuery = "";
|
||||
private Cursor m_cursor;
|
||||
|
||||
public int getFeedId() {
|
||||
return m_feedId;
|
||||
}
|
||||
|
||||
public boolean getFeedIsCat() {
|
||||
return m_isCat;
|
||||
}
|
||||
|
||||
public Cursor createCursor() {
|
||||
String feedClause = null;
|
||||
|
||||
|
@ -177,7 +177,30 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
||||
m_activity.shareArticle(articleId);
|
||||
}
|
||||
return true;
|
||||
case R.id.catchup_above:
|
||||
case R.id.catchup_above:
|
||||
if (true) {
|
||||
int articleId = getArticleIdAtPosition(info.position);
|
||||
|
||||
SQLiteStatement stmt = null;
|
||||
|
||||
if (m_feedIsCat) {
|
||||
stmt = m_activity.getWritableDb().compileStatement(
|
||||
"UPDATE articles SET unread = 0 WHERE " +
|
||||
"updated >= (SELECT updated FROM articles WHERE " + BaseColumns._ID + " = ?) " +
|
||||
"AND feed_id IN (SELECT "+BaseColumns._ID+" FROM feeds WHERE cat_id = ?)");
|
||||
} else {
|
||||
stmt = m_activity.getWritableDb().compileStatement(
|
||||
"UPDATE articles SET unread = 0 WHERE " +
|
||||
"updated >= (SELECT updated FROM articles WHERE " + BaseColumns._ID + " = ?) " +
|
||||
"AND feed_id = ?");
|
||||
}
|
||||
|
||||
stmt.bindLong(1, articleId);
|
||||
stmt.bindLong(2, m_feedId);
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
}
|
||||
refresh();
|
||||
return true;
|
||||
default:
|
||||
Log.d(TAG, "onContextItemSelected, unhandled id=" + item.getItemId());
|
||||
|
Loading…
Reference in New Issue
Block a user