code cleanup, use separate menu for offline mode, start implementing
menu actions
This commit is contained in:
parent
d1cb963452
commit
72a8b558e6
@ -1,12 +1,5 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<item
|
||||
android:id="@+id/go_online"
|
||||
android:icon="@drawable/ic_menu_cloud"
|
||||
android:showAsAction="ifRoom|withText"
|
||||
android:title="@string/go_online"
|
||||
android:visible="false"/>
|
||||
|
||||
<group android:id="@+id/menu_group_logged_in" >
|
||||
|
||||
<item
|
||||
|
115
res/menu/offline_menu.xml
Normal file
115
res/menu/offline_menu.xml
Normal file
@ -0,0 +1,115 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<group android:id="@+id/menu_group_feeds" >
|
||||
|
||||
<item
|
||||
android:id="@+id/go_online"
|
||||
android:icon="@drawable/ic_menu_cloud"
|
||||
android:showAsAction="ifRoom|withText"
|
||||
android:title="@string/go_online"
|
||||
android:visible="false"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/back_to_categories"
|
||||
android:icon="@android:drawable/ic_menu_close_clear_cancel"
|
||||
android:showAsAction="ifRoom|withText"
|
||||
android:title="@string/back_to_categories"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/show_feeds"
|
||||
android:icon="@android:drawable/ic_menu_agenda"
|
||||
android:showAsAction=""
|
||||
android:title="@string/menu_all_feeds"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/logout"
|
||||
android:icon="@drawable/ic_menu_exit"
|
||||
android:showAsAction=""
|
||||
android:title="@string/logout"/>
|
||||
</group>
|
||||
|
||||
<group android:id="@+id/menu_group_headlines" >
|
||||
|
||||
<item
|
||||
android:id="@+id/headlines_mark_as_read"
|
||||
android:icon="@drawable/ic_menu_tick"
|
||||
android:title="@string/headlines_mark_as_read"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/headlines_select"
|
||||
android:icon="@drawable/ic_menu_database"
|
||||
android:title="@string/headlines_select"/>
|
||||
</group>
|
||||
|
||||
<group android:id="@+id/menu_group_headlines_selection" >
|
||||
|
||||
<item
|
||||
android:id="@+id/selection_toggle_unread"
|
||||
android:icon="@android:drawable/ic_menu_rotate"
|
||||
android:showAsAction=""
|
||||
android:title="@string/selection_toggle_unread"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/selection_toggle_marked"
|
||||
android:icon="@drawable/ic_menu_marked"
|
||||
android:showAsAction=""
|
||||
android:title="@string/selection_toggle_marked"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/selection_toggle_published"
|
||||
android:icon="@drawable/ic_menu_rss"
|
||||
android:showAsAction=""
|
||||
android:title="@string/selection_toggle_published"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/selection_select_none"
|
||||
android:icon="@android:drawable/ic_menu_close_clear_cancel"
|
||||
android:showAsAction=""
|
||||
android:title="@string/selection_select_none"/>
|
||||
</group>
|
||||
|
||||
<group android:id="@+id/menu_group_article" >
|
||||
|
||||
<item
|
||||
android:id="@+id/share_article"
|
||||
android:icon="@android:drawable/ic_menu_share"
|
||||
android:showAsAction="ifRoom"
|
||||
android:title="@string/share_article"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/toggle_marked"
|
||||
android:icon="@drawable/ic_menu_marked"
|
||||
android:showAsAction=""
|
||||
android:title="@string/article_toggle_marked"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/toggle_published"
|
||||
android:icon="@drawable/ic_menu_rss"
|
||||
android:showAsAction=""
|
||||
android:title="@string/article_toggle_published"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/set_unread"
|
||||
android:icon="@android:drawable/ic_menu_recent_history"
|
||||
android:showAsAction=""
|
||||
android:title="@string/article_set_unread"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/close_article"
|
||||
android:icon="@android:drawable/ic_menu_close_clear_cancel"
|
||||
android:showAsAction="ifRoom"
|
||||
android:title="@string/close_article"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/catchup_above"
|
||||
android:icon="@drawable/ic_menu_tick"
|
||||
android:title="@string/article_mark_read_above"/>
|
||||
</group>
|
||||
|
||||
<item
|
||||
android:id="@+id/preferences"
|
||||
android:icon="@android:drawable/ic_menu_preferences"
|
||||
android:showAsAction=""
|
||||
android:title="@string/preferences"/>
|
||||
|
||||
</menu>
|
@ -696,10 +696,7 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
HeadlinesFragment hf = null;
|
||||
|
||||
if (m_sessionId != null)
|
||||
hf = (HeadlinesFragment)getSupportFragmentManager().findFragmentById(R.id.headlines_fragment);
|
||||
final HeadlinesFragment hf = (HeadlinesFragment)getSupportFragmentManager().findFragmentById(R.id.headlines_fragment);
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.preferences:
|
||||
@ -732,7 +729,6 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
|
||||
return true;
|
||||
case R.id.headlines_select:
|
||||
if (hf != null) {
|
||||
final HeadlinesFragment fhf = hf;
|
||||
Dialog dialog = new Dialog(this);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(R.string.headlines_select_dialog);
|
||||
@ -743,13 +739,13 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
switch (which) {
|
||||
case 0:
|
||||
fhf.setSelection(HeadlinesFragment.ArticlesSelection.ALL);
|
||||
hf.setSelection(HeadlinesFragment.ArticlesSelection.ALL);
|
||||
break;
|
||||
case 1:
|
||||
fhf.setSelection(HeadlinesFragment.ArticlesSelection.UNREAD);
|
||||
hf.setSelection(HeadlinesFragment.ArticlesSelection.UNREAD);
|
||||
break;
|
||||
case 2:
|
||||
fhf.setSelection(HeadlinesFragment.ArticlesSelection.NONE);
|
||||
hf.setSelection(HeadlinesFragment.ArticlesSelection.NONE);
|
||||
break;
|
||||
}
|
||||
dialog.cancel();
|
||||
@ -1014,13 +1010,13 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
|
||||
m_menu.setGroupVisible(R.id.menu_group_article, false);
|
||||
m_menu.setGroupVisible(R.id.menu_group_headlines_selection, false);
|
||||
|
||||
if (m_isOffline) {
|
||||
/* if (m_isOffline) {
|
||||
m_menu.setGroupVisible(R.id.menu_group_logged_out, false);
|
||||
m_menu.findItem(R.id.go_online).setVisible(true);
|
||||
|
||||
} else {
|
||||
} else { */
|
||||
m_menu.setGroupVisible(R.id.menu_group_logged_out, true);
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteStatement;
|
||||
import android.net.ConnectivityManager;
|
||||
@ -51,8 +52,8 @@ public class OfflineActivity extends FragmentActivity {
|
||||
private boolean m_compatMode = false;
|
||||
private boolean m_enableCats = false;
|
||||
|
||||
private int m_activeOfflineFeedId = 0;
|
||||
private int m_selectedOfflineArticleId = 0;
|
||||
private int m_activeFeedId = 0;
|
||||
private int m_selectedArticleId = 0;
|
||||
|
||||
private SQLiteDatabase m_readableDb;
|
||||
private SQLiteDatabase m_writableDb;
|
||||
@ -82,8 +83,8 @@ public class OfflineActivity extends FragmentActivity {
|
||||
if (savedInstanceState != null) {
|
||||
m_unreadOnly = savedInstanceState.getBoolean("unreadOnly");
|
||||
m_unreadArticlesOnly = savedInstanceState.getBoolean("unreadArticlesOnly");
|
||||
m_activeOfflineFeedId = savedInstanceState.getInt("offlineActiveFeedId");
|
||||
m_selectedOfflineArticleId = savedInstanceState.getInt("offlineArticleId");
|
||||
m_activeFeedId = savedInstanceState.getInt("offlineActiveFeedId");
|
||||
m_selectedArticleId = savedInstanceState.getInt("offlineArticleId");
|
||||
}
|
||||
|
||||
m_enableCats = m_prefs.getBoolean("enable_cats", false);
|
||||
@ -119,7 +120,7 @@ public class OfflineActivity extends FragmentActivity {
|
||||
findViewById(R.id.loading_container).setVisibility(View.INVISIBLE);
|
||||
findViewById(R.id.main).setVisibility(View.VISIBLE);
|
||||
|
||||
if (m_activeOfflineFeedId == 0) {
|
||||
if (m_activeFeedId == 0) {
|
||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||
OfflineFeedsFragment frag = new OfflineFeedsFragment();
|
||||
ft.replace(R.id.feeds_fragment, frag);
|
||||
@ -154,7 +155,7 @@ public class OfflineActivity extends FragmentActivity {
|
||||
}
|
||||
|
||||
public int getActiveOfflineFeedId() {
|
||||
return m_activeOfflineFeedId;
|
||||
return m_activeFeedId;
|
||||
}
|
||||
|
||||
public void setLoadingStatus(int status, boolean showProgress) {
|
||||
@ -177,8 +178,23 @@ public class OfflineActivity extends FragmentActivity {
|
||||
|
||||
out.putBoolean("unreadOnly", m_unreadOnly);
|
||||
out.putBoolean("unreadArticlesOnly", m_unreadArticlesOnly);
|
||||
out.putInt("offlineActiveFeedId", m_activeOfflineFeedId);
|
||||
out.putInt("offlineArticleId", m_selectedOfflineArticleId);
|
||||
out.putInt("offlineActiveFeedId", m_activeFeedId);
|
||||
out.putInt("offlineArticleId", m_selectedArticleId);
|
||||
}
|
||||
|
||||
public void setUnreadOnly(boolean unread) {
|
||||
m_unreadOnly = unread;
|
||||
|
||||
refreshFeeds();
|
||||
|
||||
/*if (!m_enableCats || m_activeCategory != null )
|
||||
refreshFeeds();
|
||||
else
|
||||
refreshCategories(); */
|
||||
}
|
||||
|
||||
public boolean getUnreadOnly() {
|
||||
return m_unreadOnly;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -198,7 +214,7 @@ public class OfflineActivity extends FragmentActivity {
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.main_menu, menu);
|
||||
inflater.inflate(R.menu.offline_menu, menu);
|
||||
|
||||
m_menu = menu;
|
||||
|
||||
@ -206,11 +222,11 @@ public class OfflineActivity extends FragmentActivity {
|
||||
|
||||
MenuItem item = menu.findItem(R.id.show_feeds);
|
||||
|
||||
/* if (getUnreadOnly()) {
|
||||
if (getUnreadOnly()) {
|
||||
item.setTitle(R.string.menu_all_feeds);
|
||||
} else {
|
||||
item.setTitle(R.string.menu_unread_feeds);
|
||||
} */
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -228,9 +244,9 @@ public class OfflineActivity extends FragmentActivity {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
|
||||
if (m_smallScreenMode) {
|
||||
if (m_selectedOfflineArticleId != 0) {
|
||||
if (m_selectedArticleId != 0) {
|
||||
closeArticle();
|
||||
} else if (m_activeOfflineFeedId != 0) {
|
||||
} else if (m_activeFeedId != 0) {
|
||||
if (m_compatMode) {
|
||||
findViewById(R.id.main).setAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_right));
|
||||
}
|
||||
@ -244,14 +260,14 @@ public class OfflineActivity extends FragmentActivity {
|
||||
findViewById(R.id.headlines_fragment).setVisibility(View.GONE);
|
||||
findViewById(R.id.feeds_fragment).setVisibility(View.VISIBLE);
|
||||
//}
|
||||
m_activeOfflineFeedId = 0;
|
||||
m_activeFeedId = 0;
|
||||
initMainMenu();
|
||||
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
} else {
|
||||
if (m_selectedOfflineArticleId != 0) {
|
||||
if (m_selectedArticleId != 0) {
|
||||
closeArticle();
|
||||
} else {
|
||||
finish();
|
||||
@ -263,7 +279,33 @@ public class OfflineActivity extends FragmentActivity {
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Cursor getArticleById(int articleId) {
|
||||
Cursor c = getReadableDb().query("articles", null, BaseColumns._ID + "=?",
|
||||
new String[] { String.valueOf(articleId) }, null, null, null);
|
||||
|
||||
c.moveToFirst();
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
public void shareArticle(int articleId) {
|
||||
|
||||
Cursor article = getArticleById(articleId);
|
||||
|
||||
if (article.isFirst()) {
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
|
||||
intent.setType("text/plain");
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, article.getString(article.getColumnIndex("title")));
|
||||
intent.putExtra(Intent.EXTRA_TEXT, article.getString(article.getColumnIndex("link")));
|
||||
|
||||
startActivity(Intent.createChooser(intent, getString(R.id.share_article)));
|
||||
}
|
||||
|
||||
article.close();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
@ -273,6 +315,19 @@ public class OfflineActivity extends FragmentActivity {
|
||||
return true;
|
||||
case R.id.go_online:
|
||||
switchOnline();
|
||||
return true;
|
||||
case R.id.share_article:
|
||||
shareArticle(m_selectedArticleId);
|
||||
return true;
|
||||
case R.id.show_feeds:
|
||||
setUnreadOnly(!getUnreadOnly());
|
||||
|
||||
if (getUnreadOnly()) {
|
||||
item.setTitle(R.string.menu_all_feeds);
|
||||
} else {
|
||||
item.setTitle(R.string.menu_unread_feeds);
|
||||
}
|
||||
|
||||
return true;
|
||||
default:
|
||||
Log.d(TAG, "onOptionsItemSelected, unhandled id=" + item.getItemId());
|
||||
@ -281,7 +336,11 @@ public class OfflineActivity extends FragmentActivity {
|
||||
}
|
||||
|
||||
public void refreshFeeds() {
|
||||
// TODO
|
||||
OfflineFeedsFragment frag = (OfflineFeedsFragment)getSupportFragmentManager().findFragmentById(R.id.feeds_fragment);
|
||||
|
||||
if (frag != null) {
|
||||
frag.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private void closeArticle() {
|
||||
@ -297,7 +356,7 @@ public class OfflineActivity extends FragmentActivity {
|
||||
|
||||
}
|
||||
|
||||
m_selectedOfflineArticleId = 0;
|
||||
m_selectedArticleId = 0;
|
||||
|
||||
initMainMenu();
|
||||
refreshFeeds();
|
||||
@ -306,13 +365,57 @@ public class OfflineActivity extends FragmentActivity {
|
||||
|
||||
public void initMainMenu() {
|
||||
if (m_menu != null) {
|
||||
m_menu.setGroupVisible(R.id.menu_group_logged_in, false);
|
||||
m_menu.setGroupVisible(R.id.menu_group_feeds, false);
|
||||
m_menu.setGroupVisible(R.id.menu_group_headlines, false);
|
||||
m_menu.setGroupVisible(R.id.menu_group_article, false);
|
||||
m_menu.setGroupVisible(R.id.menu_group_headlines_selection, false);
|
||||
|
||||
if (m_selectedArticleId != 0) {
|
||||
m_menu.setGroupVisible(R.id.menu_group_article, true);
|
||||
|
||||
m_menu.setGroupVisible(R.id.menu_group_feeds, false);
|
||||
|
||||
if (m_smallScreenMode) {
|
||||
m_menu.setGroupVisible(R.id.menu_group_headlines, false);
|
||||
m_menu.setGroupVisible(R.id.menu_group_headlines_selection, false);
|
||||
} else {
|
||||
m_menu.setGroupVisible(R.id.menu_group_headlines, true);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (m_activeFeedId != 0) {
|
||||
|
||||
OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment)getSupportFragmentManager().findFragmentById(R.id.headlines_fragment);
|
||||
|
||||
if (hf != null) {
|
||||
int numSelected = hf.getSelectedArticles().size();
|
||||
|
||||
if (numSelected != 0) {
|
||||
m_menu.setGroupVisible(R.id.menu_group_headlines, false);
|
||||
m_menu.setGroupVisible(R.id.menu_group_headlines_selection, true);
|
||||
} else {
|
||||
m_menu.setGroupVisible(R.id.menu_group_headlines, true);
|
||||
m_menu.setGroupVisible(R.id.menu_group_headlines_selection, false);
|
||||
}
|
||||
|
||||
} else {
|
||||
m_menu.setGroupVisible(R.id.menu_group_headlines, true);
|
||||
m_menu.setGroupVisible(R.id.menu_group_headlines_selection, false);
|
||||
}
|
||||
|
||||
m_menu.setGroupVisible(R.id.menu_group_feeds, false);
|
||||
} else {
|
||||
m_menu.setGroupVisible(R.id.menu_group_feeds, true);
|
||||
}
|
||||
|
||||
m_menu.setGroupVisible(R.id.menu_group_logged_out, false);
|
||||
if (!m_smallScreenMode || m_activeFeedId == 0) {
|
||||
m_menu.findItem(R.id.show_feeds).setVisible(true);
|
||||
}
|
||||
|
||||
//m_menu.findItem(R.id.back_to_categories).setVisible(m_activeCategory != null);
|
||||
m_menu.findItem(R.id.back_to_categories).setVisible(false);
|
||||
|
||||
}
|
||||
m_menu.findItem(R.id.go_online).setVisible(true);
|
||||
}
|
||||
}
|
||||
@ -403,8 +506,8 @@ public class OfflineActivity extends FragmentActivity {
|
||||
}
|
||||
} */
|
||||
|
||||
public void offlineViewFeed(int feedId) {
|
||||
m_activeOfflineFeedId = feedId;
|
||||
public void viewFeed(int feedId) {
|
||||
m_activeFeedId = feedId;
|
||||
|
||||
initMainMenu();
|
||||
|
||||
@ -420,8 +523,8 @@ public class OfflineActivity extends FragmentActivity {
|
||||
|
||||
}
|
||||
|
||||
public void openOfflineArticle(int articleId, int compatAnimation) {
|
||||
m_selectedOfflineArticleId = articleId;
|
||||
public void openArticle(int articleId, int compatAnimation) {
|
||||
m_selectedArticleId = articleId;
|
||||
|
||||
initMainMenu();
|
||||
|
||||
@ -456,7 +559,7 @@ public class OfflineActivity extends FragmentActivity {
|
||||
|
||||
}
|
||||
|
||||
public int getSelectedOfflineArticleId() {
|
||||
return m_selectedOfflineArticleId;
|
||||
public int getSelectedArticleId() {
|
||||
return m_selectedArticleId;
|
||||
}
|
||||
}
|
@ -205,7 +205,7 @@ public class OfflineArticleFragment extends Fragment implements OnClickListener
|
||||
|
||||
m_prefs = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext());
|
||||
|
||||
m_articleId = ((OfflineActivity)activity).getSelectedOfflineArticleId();
|
||||
m_articleId = ((OfflineActivity)activity).getSelectedArticleId();
|
||||
/* m_articleOps = (ArticleOps)activity;
|
||||
m_article = m_articleOps.getSelectedArticle();
|
||||
|
||||
|
@ -54,14 +54,18 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene
|
||||
}
|
||||
|
||||
public Cursor createCursor() {
|
||||
if (m_cursor != null) m_cursor.close();
|
||||
String unreadOnly = ((OfflineActivity)getActivity()).getUnreadOnly() ? "unread > 0" : null;
|
||||
|
||||
return ((OfflineActivity)getActivity()).getReadableDb().query("feeds_unread",
|
||||
null, null, null, null, null, "title");
|
||||
null, unreadOnly, null, null, null, "title");
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
m_adapter.changeCursor(createCursor());
|
||||
if (m_cursor != null) m_cursor.close();
|
||||
|
||||
m_cursor = createCursor();
|
||||
|
||||
m_adapter.changeCursor(m_cursor);
|
||||
m_adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@ -127,7 +131,7 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene
|
||||
int feedId = (int) cursor.getLong(0);
|
||||
Log.d(TAG, "clicked on feed " + feedId);
|
||||
|
||||
((OfflineActivity)getActivity()).offlineViewFeed(feedId);
|
||||
((OfflineActivity)getActivity()).viewFeed(feedId);
|
||||
|
||||
m_selectedFeedId = feedId;
|
||||
|
||||
|
@ -54,8 +54,6 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
||||
private Cursor m_cursor;
|
||||
private ArticleListAdapter m_adapter;
|
||||
|
||||
private ArticleOps m_articleOps;
|
||||
|
||||
private ImageGetter m_dummyGetter = new ImageGetter() {
|
||||
|
||||
@Override
|
||||
@ -97,7 +95,11 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
m_adapter.changeCursor(createCursor());
|
||||
if (m_cursor != null) m_cursor.close();
|
||||
|
||||
m_cursor = createCursor();
|
||||
|
||||
m_adapter.changeCursor(m_cursor);
|
||||
m_adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@ -129,8 +131,6 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
||||
}
|
||||
|
||||
public Cursor createCursor() {
|
||||
if (m_cursor != null) m_cursor.close();
|
||||
|
||||
return ((OfflineActivity)getActivity()).getReadableDb().query("articles",
|
||||
null, "feed_id = ?", new String[] { String.valueOf(m_feedId) }, null, null, "updated DESC");
|
||||
}
|
||||
@ -140,7 +140,6 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
||||
super.onAttach(activity);
|
||||
m_feedId = ((OfflineActivity)activity).getActiveOfflineFeedId();
|
||||
m_prefs = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext());
|
||||
m_articleOps = (ArticleOps) activity;
|
||||
m_combinedMode = m_prefs.getBoolean("combined_mode", false);
|
||||
}
|
||||
|
||||
@ -154,21 +153,19 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
||||
Cursor cursor = (Cursor)list.getItemAtPosition(position);
|
||||
|
||||
m_activeArticleId = cursor.getInt(0);
|
||||
|
||||
if (m_combinedMode) {
|
||||
SQLiteStatement stmtUpdate = ((OfflineActivity)getActivity()).getWritableDb().compileStatement("UPDATE articles SET unread = 0 " +
|
||||
"WHERE " + BaseColumns._ID + " = ?");
|
||||
|
||||
stmtUpdate.bindLong(1, m_activeArticleId);
|
||||
stmtUpdate.execute();
|
||||
stmtUpdate.close();
|
||||
|
||||
refresh();
|
||||
} else {
|
||||
((OfflineActivity)getActivity()).openOfflineArticle(m_activeArticleId, 0);
|
||||
SQLiteStatement stmtUpdate = ((OfflineActivity)getActivity()).getWritableDb().compileStatement("UPDATE articles SET unread = 0 " +
|
||||
"WHERE " + BaseColumns._ID + " = ?");
|
||||
|
||||
stmtUpdate.bindLong(1, m_activeArticleId);
|
||||
stmtUpdate.execute();
|
||||
stmtUpdate.close();
|
||||
|
||||
if (!m_combinedMode) {
|
||||
((OfflineActivity)getActivity()).openArticle(m_activeArticleId, 0);
|
||||
}
|
||||
|
||||
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user