experimental: track selected feed/cat in phone mode

This commit is contained in:
Andrew Dolgov 2017-06-01 23:51:56 +03:00
parent 4fe7cacec8
commit 51dcfe817f
3 changed files with 22 additions and 15 deletions

View File

@ -425,7 +425,7 @@ public class FeedCategoriesFragment extends BaseFeedlistFragment implements OnIt
public int getItemViewType(int position) {
FeedCategory cat = items.get(position);
if (!m_activity.isSmallScreen() && m_selectedCat != null && cat.id == m_selectedCat.id) {
if (/*!m_activity.isSmallScreen() &&*/ m_selectedCat != null && cat.id == m_selectedCat.id) {
return VIEW_SELECTED;
} else {
return VIEW_NORMAL;
@ -509,6 +509,9 @@ public class FeedCategoriesFragment extends BaseFeedlistFragment implements OnIt
FeedCategory cat = (FeedCategory)list.getItemAtPosition(position);
m_selectedCat = null;
m_adapter.notifyDataSetChanged();
if (cat != null) {
if (cat.id < 0) {
m_activity.onCatSelected(cat, false);
@ -516,9 +519,6 @@ public class FeedCategoriesFragment extends BaseFeedlistFragment implements OnIt
m_activity.onCatSelected(cat);
}
m_selectedCat = cat;
m_adapter.notifyDataSetChanged();
}
}
}
@ -530,9 +530,6 @@ public class FeedCategoriesFragment extends BaseFeedlistFragment implements OnIt
m_adapter.notifyDataSetChanged();
}
}
public FeedCategory getSelectedCategory() {
return m_selectedCat;
}
}

View File

@ -458,9 +458,8 @@ public class FeedsFragment extends BaseFeedlistFragment implements OnItemClickLi
}
}
m_selectedFeed = feed;
m_adapter.notifyDataSetChanged();
//m_selectedFeed = feed;
//m_adapter.notifyDataSetChanged();
}
}
@ -508,7 +507,7 @@ public class FeedsFragment extends BaseFeedlistFragment implements OnItemClickLi
public int getItemViewType(int position) {
Feed feed = items.get(position);
if (!m_activity.isSmallScreen() && m_selectedFeed != null && feed.id == m_selectedFeed.id) {
if (/*!m_activity.isSmallScreen() &&*/ m_selectedFeed != null && feed.id == m_selectedFeed.id) {
return VIEW_SELECTED;
} else {
return VIEW_NORMAL;
@ -645,4 +644,12 @@ public class FeedsFragment extends BaseFeedlistFragment implements OnItemClickLi
return null;
}
}
public void setSelectedfeed(Feed feed) {
m_selectedFeed = feed;
if (m_adapter != null) {
m_adapter.notifyDataSetChanged();
}
}
}

View File

@ -242,7 +242,11 @@ public class MasterActivity extends OnlineActivity implements HeadlinesEventList
public void onFeedSelected(Feed feed, final boolean selectedByUser) {
//ImageLoader.getInstance().clearMemoryCache();
FeedsFragment ff = (FeedsFragment) getSupportFragmentManager().findFragmentByTag(FRAG_FEEDS);
if (ff != null && ff.isAdded()) {
ff.setSelectedfeed(feed);
}
FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction();
@ -256,7 +260,6 @@ public class MasterActivity extends OnlineActivity implements HeadlinesEventList
m_feedIsSelected = true;
m_userFeedSelected = selectedByUser;
//m_feedWasSelected = true;
if (m_drawerLayout != null) {
m_drawerLayout.closeDrawers();
@ -277,7 +280,7 @@ public class MasterActivity extends OnlineActivity implements HeadlinesEventList
if (!openAsFeed) {
if (fc != null) {
if (fc != null && fc.isAdded()) {
fc.setSelectedCategory(null);
}