various tablet-mode refresh fixes
This commit is contained in:
parent
d3e0ce0f83
commit
9d283da0f0
@ -85,6 +85,8 @@ public class ArticlePager extends Fragment {
|
|||||||
|
|
||||||
int position = m_articles.indexOf(m_article);
|
int position = m_articles.indexOf(m_article);
|
||||||
|
|
||||||
|
m_listener.onArticleSelected(m_article, false);
|
||||||
|
|
||||||
pager.setAdapter(m_adapter);
|
pager.setAdapter(m_adapter);
|
||||||
pager.setCurrentItem(position);
|
pager.setCurrentItem(position);
|
||||||
pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||||
@ -149,9 +151,8 @@ public class ArticlePager extends Fragment {
|
|||||||
if (result != null) {
|
if (result != null) {
|
||||||
m_adapter.notifyDataSetChanged();
|
m_adapter.notifyDataSetChanged();
|
||||||
|
|
||||||
if (m_article.id == 0) {
|
if (m_article.id == 0 || m_articles.indexOf(m_article) == -1) {
|
||||||
if (m_articles.size() > 0) {
|
if (m_articles.size() > 0) {
|
||||||
Log.d(TAG, "blank id on refresh");
|
|
||||||
m_article = m_articles.get(0);
|
m_article = m_articles.get(0);
|
||||||
m_listener.onArticleSelected(m_article, false);
|
m_listener.onArticleSelected(m_article, false);
|
||||||
}
|
}
|
||||||
@ -235,8 +236,6 @@ public class ArticlePager extends Fragment {
|
|||||||
if (m_articles.size() == 0 || !m_feed.equals(GlobalState.getInstance().m_activeFeed)) {
|
if (m_articles.size() == 0 || !m_feed.equals(GlobalState.getInstance().m_activeFeed)) {
|
||||||
refresh(false);
|
refresh(false);
|
||||||
GlobalState.getInstance().m_activeFeed = m_feed;
|
GlobalState.getInstance().m_activeFeed = m_feed;
|
||||||
} else {
|
|
||||||
m_adapter.notifyDataSetChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_activity.initMenu();
|
m_activity.initMenu();
|
||||||
@ -247,12 +246,14 @@ public class ArticlePager extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setActiveArticle(Article article) {
|
public void setActiveArticle(Article article) {
|
||||||
m_article = article;
|
if (m_article != article) {
|
||||||
|
m_article = article;
|
||||||
|
|
||||||
int position = m_articles.indexOf(m_article);
|
int position = m_articles.indexOf(m_article);
|
||||||
|
|
||||||
ViewPager pager = (ViewPager) getView().findViewById(R.id.article_pager);
|
ViewPager pager = (ViewPager) getView().findViewById(R.id.article_pager);
|
||||||
|
|
||||||
pager.setCurrentItem(position);
|
pager.setCurrentItem(position);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
|
|||||||
public void onHeadlinesLoaded(boolean appended) {
|
public void onHeadlinesLoaded(boolean appended) {
|
||||||
HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
||||||
|
|
||||||
if (hf != null && !appended) {
|
if (hf != null) {
|
||||||
Article article = hf.getActiveArticle();
|
Article article = hf.getActiveArticle();
|
||||||
|
|
||||||
if (article == null) {
|
if (article == null) {
|
||||||
|
@ -374,6 +374,10 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
m_refreshInProgress = false;
|
m_refreshInProgress = false;
|
||||||
|
|
||||||
|
if (m_articles.indexOf(m_activeArticle) == -1)
|
||||||
|
m_activeArticle = null;
|
||||||
|
|
||||||
m_adapter.notifyDataSetChanged();
|
m_adapter.notifyDataSetChanged();
|
||||||
m_listener.onHeadlinesLoaded(fappend);
|
m_listener.onHeadlinesLoaded(fappend);
|
||||||
} else {
|
} else {
|
||||||
@ -817,14 +821,16 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setActiveArticle(Article article) {
|
public void setActiveArticle(Article article) {
|
||||||
m_activeArticle = article;
|
if (article != m_activeArticle) {
|
||||||
m_adapter.notifyDataSetChanged();
|
m_activeArticle = article;
|
||||||
|
m_adapter.notifyDataSetChanged();
|
||||||
|
|
||||||
ListView list = (ListView)getView().findViewById(R.id.headlines);
|
ListView list = (ListView)getView().findViewById(R.id.headlines);
|
||||||
|
|
||||||
if (list != null && article != null) {
|
if (list != null && article != null) {
|
||||||
int position = m_adapter.getPosition(article);
|
int position = m_adapter.getPosition(article);
|
||||||
list.setSelection(position);
|
list.setSelection(position);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user