diff options
author | Andrew Dolgov <[email protected]> | 2012-09-20 09:40:32 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2012-09-20 09:40:32 +0400 |
commit | cf39cea333b48d2c78259357e7478aee66f20683 (patch) | |
tree | 9a67fe8235e4cd8c9a468420408205c3c4c36769 /src/org | |
parent | 349dc9d797386eb4e3ed9e0235e753f5bf2533b1 (diff) |
fix missing stuff for default_view_mode implementation in fragments
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/fox/ttrss/FeedCategoriesFragment.java | 2 | ||||
-rw-r--r-- | src/org/fox/ttrss/FeedsActivity.java | 3 | ||||
-rw-r--r-- | src/org/fox/ttrss/FeedsFragment.java | 12 | ||||
-rw-r--r-- | src/org/fox/ttrss/offline/OfflineActivity.java | 26 | ||||
-rw-r--r-- | src/org/fox/ttrss/offline/OfflineArticlePager.java | 29 | ||||
-rw-r--r-- | src/org/fox/ttrss/offline/OfflineFeedCategoriesFragment.java | 17 | ||||
-rw-r--r-- | src/org/fox/ttrss/offline/OfflineFeedsActivity.java | 11 | ||||
-rw-r--r-- | src/org/fox/ttrss/offline/OfflineFeedsFragment.java | 22 |
8 files changed, 91 insertions, 31 deletions
diff --git a/src/org/fox/ttrss/FeedCategoriesFragment.java b/src/org/fox/ttrss/FeedCategoriesFragment.java index e3186cf3..94a34304 100644 --- a/src/org/fox/ttrss/FeedCategoriesFragment.java +++ b/src/org/fox/ttrss/FeedCategoriesFragment.java @@ -406,7 +406,7 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe if (list != null) {
FeedCategory cat = (FeedCategory)list.getItemAtPosition(position);
- if ("ARTICLES".equals(m_prefs.getString("default_view_mode", "HEADLINES")) &&
+ if (m_activity.isSmallScreen() && "ARTICLES".equals(m_prefs.getString("default_view_mode", "HEADLINES")) &&
m_prefs.getBoolean("browse_cats_like_feeds", false)) {
m_activity.openFeedArticles(new Feed(cat.id, cat.title, true));
diff --git a/src/org/fox/ttrss/FeedsActivity.java b/src/org/fox/ttrss/FeedsActivity.java index e1126fe5..578d35db 100644 --- a/src/org/fox/ttrss/FeedsActivity.java +++ b/src/org/fox/ttrss/FeedsActivity.java @@ -244,9 +244,6 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe intent.putExtra("feed", feed);
intent.putExtra("article", new Article());
startActivityForResult(intent, 0);
-
- } else {
-
}
}
diff --git a/src/org/fox/ttrss/FeedsFragment.java b/src/org/fox/ttrss/FeedsFragment.java index 2ac6f617..d88134ac 100644 --- a/src/org/fox/ttrss/FeedsFragment.java +++ b/src/org/fox/ttrss/FeedsFragment.java @@ -255,16 +255,16 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh Feed feed = (Feed)list.getItemAtPosition(position);
if (feed.is_cat) {
- FeedCategory cat = new FeedCategory();
- cat.id = feed.id;
- cat.title = feed.title;
-
- if ("ARTICLES".equals(m_prefs.getString("default_view_mode", "HEADLINES")) &&
+ if (m_activity.isSmallScreen() && "ARTICLES".equals(m_prefs.getString("default_view_mode", "HEADLINES")) &&
m_prefs.getBoolean("browse_cats_like_feeds", false)) {
m_activity.openFeedArticles(feed);
- } else {
+ } else {
+ FeedCategory cat = new FeedCategory();
+ cat.id = feed.id;
+ cat.title = feed.title;
+
m_activity.onCatSelected(cat);
}
} else {
diff --git a/src/org/fox/ttrss/offline/OfflineActivity.java b/src/org/fox/ttrss/offline/OfflineActivity.java index 42f3effc..6444d88e 100644 --- a/src/org/fox/ttrss/offline/OfflineActivity.java +++ b/src/org/fox/ttrss/offline/OfflineActivity.java @@ -416,7 +416,7 @@ public class OfflineActivity extends CommonActivity { OfflineArticlePager af = (OfflineArticlePager) getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE);
- if (af != null) {
+ if (af != null && af.getSelectedArticleId() > 0) {
shareProvider.setShareIntent(getShareIntent(getArticleById(af.getSelectedArticleId())));
if (!isSmallScreen()) {
@@ -516,16 +516,20 @@ public class OfflineActivity extends CommonActivity { }
protected Intent getShareIntent(Cursor article) {
- String title = article.getString(article.getColumnIndex("title"));
- String link = article.getString(article.getColumnIndex("link"));
-
- Intent intent = new Intent(Intent.ACTION_SEND);
-
- intent.setType("text/plain");
- intent.putExtra(Intent.EXTRA_SUBJECT, title);
- intent.putExtra(Intent.EXTRA_TEXT, link);
-
- return intent;
+ if (article != null) {
+ String title = article.getString(article.getColumnIndex("title"));
+ String link = article.getString(article.getColumnIndex("link"));
+
+ Intent intent = new Intent(Intent.ACTION_SEND);
+
+ intent.setType("text/plain");
+ intent.putExtra(Intent.EXTRA_SUBJECT, title);
+ intent.putExtra(Intent.EXTRA_TEXT, link);
+
+ return intent;
+ } else {
+ return null;
+ }
}
protected void shareArticle(int articleId) {
diff --git a/src/org/fox/ttrss/offline/OfflineArticlePager.java b/src/org/fox/ttrss/offline/OfflineArticlePager.java index 3faf3415..9f8ae0f4 100644 --- a/src/org/fox/ttrss/offline/OfflineArticlePager.java +++ b/src/org/fox/ttrss/offline/OfflineArticlePager.java @@ -110,18 +110,31 @@ public class OfflineArticlePager extends Fragment { m_adapter = new PagerAdapter(getActivity().getSupportFragmentManager());
- m_cursor.moveToFirst();
-
int position = 0;
- while (!m_cursor.isLast()) {
- if (m_cursor.getInt(m_cursor.getColumnIndex(BaseColumns._ID)) == m_articleId) {
- position = m_cursor.getPosition();
- break;
- }
- m_cursor.moveToNext();
+ Log.d(TAG, "maId=" + m_articleId);
+
+ if (m_articleId != 0) {
+ if (m_cursor.moveToFirst()) {
+
+ while (!m_cursor.isLast()) {
+ if (m_cursor.getInt(m_cursor.getColumnIndex(BaseColumns._ID)) == m_articleId) {
+ position = m_cursor.getPosition();
+ break;
+ }
+ m_cursor.moveToNext();
+ }
+ }
+ } else {
+ if (m_cursor.moveToFirst()) {
+ m_articleId = m_cursor.getInt(m_cursor.getColumnIndex(BaseColumns._ID));
+ m_listener.onArticleSelected(m_articleId, false);
+
+ Log.d(TAG, "maId=" + m_articleId);
+ }
}
+
ViewPager pager = (ViewPager) view.findViewById(R.id.article_pager);
pager.setAdapter(m_adapter);
diff --git a/src/org/fox/ttrss/offline/OfflineFeedCategoriesFragment.java b/src/org/fox/ttrss/offline/OfflineFeedCategoriesFragment.java index a5595681..e27c6e4b 100644 --- a/src/org/fox/ttrss/offline/OfflineFeedCategoriesFragment.java +++ b/src/org/fox/ttrss/offline/OfflineFeedCategoriesFragment.java @@ -90,6 +90,14 @@ public class OfflineFeedCategoriesFragment extends Fragment implements OnItemCli if (true) {
int catId = getCatIdAtPosition(info.position);
if (catId != -10000) {
+ m_activity.openFeedArticles(catId, true);
+ }
+ }
+ return true;
+ case R.id.browse_headlines:
+ if (true) {
+ int catId = getCatIdAtPosition(info.position);
+ if (catId != -10000) {
m_activity.onCatSelected(catId, true);
}
}
@@ -178,7 +186,14 @@ public class OfflineFeedCategoriesFragment extends Fragment implements OnItemCli int feedId = (int) cursor.getLong(0);
Log.d(TAG, "clicked on feed " + feedId);
- m_activity.onCatSelected(feedId);
+ if (m_activity.isSmallScreen() && "ARTICLES".equals(m_prefs.getString("default_view_mode", "HEADLINES")) &&
+ m_prefs.getBoolean("browse_cats_like_feeds", false)) {
+
+ m_activity.openFeedArticles(feedId, true);
+
+ } else {
+ m_activity.onCatSelected(feedId);
+ }
if (!m_activity.isSmallScreen())
m_selectedCatId = feedId;
diff --git a/src/org/fox/ttrss/offline/OfflineFeedsActivity.java b/src/org/fox/ttrss/offline/OfflineFeedsActivity.java index 35bf05b7..7813c807 100644 --- a/src/org/fox/ttrss/offline/OfflineFeedsActivity.java +++ b/src/org/fox/ttrss/offline/OfflineFeedsActivity.java @@ -86,6 +86,17 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead initMenu();
}
+ public void openFeedArticles(int feedId, boolean isCat) {
+ if (isSmallScreen()) {
+ Intent intent = new Intent(OfflineFeedsActivity.this, OfflineFeedsActivity.class);
+
+ intent.putExtra("feed", feedId);
+ intent.putExtra("isCat", isCat);
+ intent.putExtra("article", 0);
+ startActivityForResult(intent, 0);
+ }
+ }
+
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
diff --git a/src/org/fox/ttrss/offline/OfflineFeedsFragment.java b/src/org/fox/ttrss/offline/OfflineFeedsFragment.java index 7eadd373..7de6bbdd 100644 --- a/src/org/fox/ttrss/offline/OfflineFeedsFragment.java +++ b/src/org/fox/ttrss/offline/OfflineFeedsFragment.java @@ -61,6 +61,22 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
.getMenuInfo();
switch (item.getItemId()) {
+ case R.id.browse_articles:
+ if (true) {
+ int feedId = getFeedIdAtPosition(info.position);
+ if (feedId != -10000) {
+ m_activity.openFeedArticles(feedId, false);
+ }
+ }
+ return true;
+ case R.id.browse_headlines:
+ if (true) {
+ int feedId = getFeedIdAtPosition(info.position);
+ if (feedId != -10000) {
+ m_activity.onFeedSelected(feedId);
+ }
+ }
+ return true;
case R.id.catchup_feed:
int feedId = getFeedIdAtPosition(info.position);
if (feedId != -10000) {
@@ -183,7 +199,11 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene int feedId = (int) cursor.getLong(0);
Log.d(TAG, "clicked on feed " + feedId);
- m_activity.onFeedSelected(feedId);
+ if (!m_activity.isSmallScreen() && "ARTICLES".equals(m_prefs.getString("default_view_mode", "HEADLINES"))) {
+ m_activity.openFeedArticles(feedId, false);
+ } else {
+ m_activity.onFeedSelected(feedId);
+ }
if (!m_activity.isSmallScreen())
m_selectedFeedId = feedId;
|