simplify back stack handling a bit
disable feed fragments selected state in small screen mode
This commit is contained in:
parent
4101ecebee
commit
12de7c7973
@ -280,7 +280,7 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe
|
|||||||
public int getItemViewType(int position) {
|
public int getItemViewType(int position) {
|
||||||
FeedCategory cat = items.get(position);
|
FeedCategory cat = items.get(position);
|
||||||
|
|
||||||
if (m_selectedCat != null && cat.id == m_selectedCat.id) {
|
if (!m_onlineServices.isSmallScreen() && m_selectedCat != null && cat.id == m_selectedCat.id) {
|
||||||
return VIEW_SELECTED;
|
return VIEW_SELECTED;
|
||||||
} else {
|
} else {
|
||||||
return VIEW_NORMAL;
|
return VIEW_NORMAL;
|
||||||
|
@ -375,7 +375,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
|
|||||||
public int getItemViewType(int position) {
|
public int getItemViewType(int position) {
|
||||||
Feed feed = items.get(position);
|
Feed feed = items.get(position);
|
||||||
|
|
||||||
if (m_selectedFeed != null && feed.id == m_selectedFeed.id) {
|
if (!m_onlineServices.isSmallScreen() && m_selectedFeed != null && feed.id == m_selectedFeed.id) {
|
||||||
return VIEW_SELECTED;
|
return VIEW_SELECTED;
|
||||||
} else {
|
} else {
|
||||||
return VIEW_NORMAL;
|
return VIEW_NORMAL;
|
||||||
|
@ -561,29 +561,25 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
private synchronized void refresh() {
|
private synchronized void refresh() {
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
|
|
||||||
boolean canRefresh = date.getTime() - m_lastRefresh > 5000;
|
if (m_sessionId != null && date.getTime() - m_lastRefresh > 5000) {
|
||||||
|
|
||||||
if (m_sessionId != null) {
|
|
||||||
|
|
||||||
FeedsFragment ff = (FeedsFragment) getSupportFragmentManager()
|
FeedsFragment ff = (FeedsFragment) getSupportFragmentManager()
|
||||||
.findFragmentByTag(FRAG_FEEDS);
|
.findFragmentByTag(FRAG_FEEDS);
|
||||||
|
|
||||||
if (ff != null) {
|
if (ff != null) {
|
||||||
Log.d(TAG, "Refreshing feeds...");
|
Log.d(TAG, "Refreshing feeds/" + m_activeFeed);
|
||||||
if (canRefresh) ff.refresh(true);
|
ff.refresh(true);
|
||||||
ff.setSelectedFeed(m_activeFeed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FeedCategoriesFragment cf = (FeedCategoriesFragment) getSupportFragmentManager()
|
FeedCategoriesFragment cf = (FeedCategoriesFragment) getSupportFragmentManager()
|
||||||
.findFragmentByTag(FRAG_CATS);
|
.findFragmentByTag(FRAG_CATS);
|
||||||
|
|
||||||
if (cf != null) {
|
if (cf != null) {
|
||||||
Log.d(TAG, "Refreshing categories...");
|
Log.d(TAG, "Refreshing categories/" + m_activeCategory);
|
||||||
if (canRefresh) cf.refresh(true);
|
cf.refresh(true);
|
||||||
cf.setSelectedCategory(m_activeCategory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canRefresh) m_lastRefresh = date.getTime();
|
m_lastRefresh = date.getTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1011,7 +1007,30 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
if (m_selectedArticle != null) {
|
if (m_selectedArticle != null) {
|
||||||
closeArticle();
|
closeArticle();
|
||||||
} else if (m_activeFeed != null) {
|
} else if (m_activeFeed != null) {
|
||||||
closeFeed();
|
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||||
|
if (m_activeFeed.is_cat) {
|
||||||
|
|
||||||
|
Fragment headlines = getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
||||||
|
FeedCategoriesFragment cats = (FeedCategoriesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_CATS);
|
||||||
|
|
||||||
|
ft.show(cats);
|
||||||
|
ft.remove(headlines);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Fragment headlines = getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
||||||
|
FeedsFragment feeds = (FeedsFragment) getSupportFragmentManager().findFragmentByTag(FRAG_FEEDS);
|
||||||
|
|
||||||
|
ft.show(feeds);
|
||||||
|
ft.remove(headlines);
|
||||||
|
}
|
||||||
|
ft.commit();
|
||||||
|
|
||||||
|
m_activeFeed = null;
|
||||||
|
|
||||||
|
refresh();
|
||||||
|
|
||||||
|
initMainMenu();
|
||||||
|
|
||||||
} else if (m_activeCategory != null) {
|
} else if (m_activeCategory != null) {
|
||||||
closeCategory();
|
closeCategory();
|
||||||
} else if (allowQuit) {
|
} else if (allowQuit) {
|
||||||
@ -1021,16 +1040,8 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
if (m_selectedArticle != null) {
|
if (m_selectedArticle != null) {
|
||||||
closeArticle();
|
closeArticle();
|
||||||
refresh();
|
refresh();
|
||||||
} else if (m_activeFeed != null) {
|
/* } else if (m_activeFeed != null) {
|
||||||
m_activeFeed = null;
|
closeFeed(); */
|
||||||
|
|
||||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
|
||||||
ft.replace(R.id.headlines_fragment, new DummyFragment(), "");
|
|
||||||
ft.commit();
|
|
||||||
|
|
||||||
refresh();
|
|
||||||
|
|
||||||
initMainMenu();
|
|
||||||
} else if (m_activeCategory != null) {
|
} else if (m_activeCategory != null) {
|
||||||
closeCategory();
|
closeCategory();
|
||||||
} else if (allowQuit) {
|
} else if (allowQuit) {
|
||||||
@ -1577,11 +1588,11 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
getActionBar().setTitle(R.string.app_name);
|
getActionBar().setTitle(R.string.app_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (m_smallScreenMode) {
|
if (m_smallScreenMode) {
|
||||||
getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticle != null || m_activeCategory != null || m_activeFeed != null);
|
getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticle != null || m_activeCategory != null || m_activeFeed != null);
|
||||||
//} else {
|
} else {
|
||||||
// getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticle != null || m_activeCategory != null || m_activeFeed != null);
|
getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticle != null || m_activeCategory != null);
|
||||||
//}
|
}
|
||||||
|
|
||||||
if (android.os.Build.VERSION.SDK_INT >= 14) {
|
if (android.os.Build.VERSION.SDK_INT >= 14) {
|
||||||
ShareActionProvider shareProvider = (ShareActionProvider) m_menu.findItem(R.id.share_article).getActionProvider();
|
ShareActionProvider shareProvider = (ShareActionProvider) m_menu.findItem(R.id.share_article).getActionProvider();
|
||||||
@ -2308,45 +2319,9 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
toast.show();
|
toast.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void closeFeed() {
|
private void _closeFeed() {
|
||||||
if (m_activeFeed != null) {
|
if (m_activeFeed != null) {
|
||||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
|
||||||
|
|
||||||
if (m_smallScreenMode) {
|
|
||||||
if (m_activeFeed.is_cat) {
|
|
||||||
|
|
||||||
Fragment headlines = getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
|
||||||
FeedCategoriesFragment cats = (FeedCategoriesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_CATS);
|
|
||||||
|
|
||||||
ft.show(cats);
|
|
||||||
ft.remove(headlines);
|
|
||||||
|
|
||||||
//cats.setSelectedCategory(null);
|
|
||||||
|
|
||||||
//ft.replace(R.id.fragment_container, new FeedCategoriesFragment(), FRAG_CATS);
|
|
||||||
} else {
|
|
||||||
Fragment headlines = getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
|
||||||
FeedsFragment feeds = (FeedsFragment) getSupportFragmentManager().findFragmentByTag(FRAG_FEEDS);
|
|
||||||
|
|
||||||
ft.show(feeds);
|
|
||||||
ft.remove(headlines);
|
|
||||||
|
|
||||||
//feeds.setSelectedFeed(null);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Fragment headlines = getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
|
||||||
ft.remove(headlines);
|
|
||||||
}
|
|
||||||
ft.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_activeFeed = null;
|
|
||||||
|
|
||||||
refresh();
|
|
||||||
|
|
||||||
initMainMenu();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -502,7 +502,7 @@ public class OfflineActivity extends FragmentActivity implements
|
|||||||
} else {
|
} else {
|
||||||
if (m_selectedArticleId != 0) {
|
if (m_selectedArticleId != 0) {
|
||||||
closeArticle();
|
closeArticle();
|
||||||
} else if (m_activeFeedId != 0) {
|
/* } else if (m_activeFeedId != 0) {
|
||||||
m_activeFeedId = 0;
|
m_activeFeedId = 0;
|
||||||
|
|
||||||
OfflineFeedsFragment ff = (OfflineFeedsFragment) getSupportFragmentManager()
|
OfflineFeedsFragment ff = (OfflineFeedsFragment) getSupportFragmentManager()
|
||||||
@ -524,7 +524,7 @@ public class OfflineActivity extends FragmentActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
refreshViews();
|
refreshViews();
|
||||||
initMainMenu();
|
initMainMenu(); */
|
||||||
} else if (m_activeCatId != -1) {
|
} else if (m_activeCatId != -1) {
|
||||||
closeCategory();
|
closeCategory();
|
||||||
} else if (allowQuit) {
|
} else if (allowQuit) {
|
||||||
@ -1033,11 +1033,11 @@ public class OfflineActivity extends FragmentActivity implements
|
|||||||
getActionBar().setTitle(R.string.app_name);
|
getActionBar().setTitle(R.string.app_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (!m_smallScreenMode) {
|
if (m_smallScreenMode) {
|
||||||
// getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticleId != 0);
|
|
||||||
//} else {
|
|
||||||
getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticleId != 0 || m_activeFeedId != 0 || m_activeCatId != -1);
|
getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticleId != 0 || m_activeFeedId != 0 || m_activeCatId != -1);
|
||||||
//}
|
} else {
|
||||||
|
getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticleId != 0 || m_activeCatId != -1);
|
||||||
|
}
|
||||||
|
|
||||||
if (android.os.Build.VERSION.SDK_INT >= 14) {
|
if (android.os.Build.VERSION.SDK_INT >= 14) {
|
||||||
ShareActionProvider shareProvider = (ShareActionProvider) m_menu.findItem(R.id.share_article).getActionProvider();
|
ShareActionProvider shareProvider = (ShareActionProvider) m_menu.findItem(R.id.share_article).getActionProvider();
|
||||||
|
@ -175,7 +175,7 @@ public class OfflineFeedCategoriesFragment extends Fragment implements OnItemCli
|
|||||||
public int getItemViewType(int position) {
|
public int getItemViewType(int position) {
|
||||||
Cursor cursor = (Cursor) this.getItem(position);
|
Cursor cursor = (Cursor) this.getItem(position);
|
||||||
|
|
||||||
if (cursor.getLong(0) == m_selectedCatId) {
|
if (!m_offlineServices.isSmallScreen() && cursor.getLong(0) == m_selectedCatId) {
|
||||||
return VIEW_SELECTED;
|
return VIEW_SELECTED;
|
||||||
} else {
|
} else {
|
||||||
return VIEW_NORMAL;
|
return VIEW_NORMAL;
|
||||||
|
@ -199,7 +199,7 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene
|
|||||||
public int getItemViewType(int position) {
|
public int getItemViewType(int position) {
|
||||||
Cursor cursor = (Cursor) this.getItem(position);
|
Cursor cursor = (Cursor) this.getItem(position);
|
||||||
|
|
||||||
if (cursor.getLong(0) == m_selectedFeedId) {
|
if (!m_offlineServices.isSmallScreen() && cursor.getLong(0) == m_selectedFeedId) {
|
||||||
return VIEW_SELECTED;
|
return VIEW_SELECTED;
|
||||||
} else {
|
} else {
|
||||||
return VIEW_NORMAL;
|
return VIEW_NORMAL;
|
||||||
|
Loading…
Reference in New Issue
Block a user