when selecting feed in a drawer use runnable

This commit is contained in:
Andrew Dolgov 2017-06-05 14:16:00 +03:00
parent 5c437de607
commit 213c21190b
2 changed files with 23 additions and 18 deletions

View File

@ -211,7 +211,7 @@ public class DetailActivity extends OnlineActivity implements HeadlinesEventList
}
@Override
public void onArticleSelected(Article article, boolean open) {
public void onArticleSelected(final Article article, boolean open) {
if (article == null) return;
@ -230,18 +230,16 @@ public class DetailActivity extends OnlineActivity implements HeadlinesEventList
if (open) {
final Article fArticle = article;
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
ArticlePager af = (ArticlePager) getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE);
if (af != null) {
af.setActiveArticle(fArticle);
af.setActiveArticle(article);
}
}
}, 10);
}, 250);
} else {
HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);

View File

@ -9,6 +9,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
@ -240,7 +241,7 @@ public class MasterActivity extends OnlineActivity implements HeadlinesEventList
onFeedSelected(feed, true);
}
public void onFeedSelected(Feed feed, final boolean selectedByUser) {
public void onFeedSelected(final Feed feed, final boolean selectedByUser) {
FeedsFragment ff = (FeedsFragment) getSupportFragmentManager().findFragmentByTag(FRAG_FEEDS);
@ -248,22 +249,28 @@ public class MasterActivity extends OnlineActivity implements HeadlinesEventList
ff.setSelectedfeed(feed);
}
FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction();
if (m_drawerLayout != null) {
m_drawerLayout.closeDrawers();
}
HeadlinesFragment hf = new HeadlinesFragment();
hf.initialize(feed);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction();
ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES);
HeadlinesFragment hf = new HeadlinesFragment();
hf.initialize(feed);
ft.commit();
ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES);
m_feedIsSelected = true;
m_userFeedSelected = selectedByUser;
ft.commit();
if (m_drawerLayout != null) {
m_drawerLayout.closeDrawers();
}
m_feedIsSelected = true;
m_userFeedSelected = selectedByUser;
}
}, 250);
Date date = new Date();