diff --git a/res/layout/loading_fragment.xml b/res/layout/loading_fragment.xml new file mode 100644 index 00000000..ab820170 --- /dev/null +++ b/res/layout/loading_fragment.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/src/org/fox/ttrss/FeedsActivity.java b/src/org/fox/ttrss/FeedsActivity.java index 578d35db..0d712688 100644 --- a/src/org/fox/ttrss/FeedsActivity.java +++ b/src/org/fox/ttrss/FeedsActivity.java @@ -12,6 +12,7 @@ import android.annotation.SuppressLint; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; +import android.os.Handler; import android.preference.PreferenceManager; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentTransaction; @@ -148,10 +149,26 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe FragmentTransaction ft = getSupportFragmentManager() .beginTransaction(); - HeadlinesFragment hf = new HeadlinesFragment(feed); - ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES); - + ft.replace(R.id.headlines_fragment, new LoadingFragment(), null); ft.commit(); + + Handler handler = new Handler(); + + final Feed fFeed = feed; + + handler.postDelayed(new Runnable() { + @Override + public void run() { + FragmentTransaction ft = getSupportFragmentManager() + .beginTransaction(); + + HeadlinesFragment hf = new HeadlinesFragment(fFeed); + ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES); + + ft.commit(); + } + }, 25); + Date date = new Date(); diff --git a/src/org/fox/ttrss/HeadlinesActivity.java b/src/org/fox/ttrss/HeadlinesActivity.java index 6fad6c66..179f393e 100644 --- a/src/org/fox/ttrss/HeadlinesActivity.java +++ b/src/org/fox/ttrss/HeadlinesActivity.java @@ -8,6 +8,7 @@ import android.annotation.SuppressLint; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; +import android.os.Handler; import android.preference.PreferenceManager; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentTransaction; @@ -46,24 +47,39 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL Intent i = getIntent(); if (i.getExtras() != null) { - Feed feed = i.getParcelableExtra("feed"); - Article article = i.getParcelableExtra("article"); - String searchQuery = i.getStringExtra("searchQuery"); - - HeadlinesFragment hf = new HeadlinesFragment(feed, article); - ArticlePager af = new ArticlePager(hf.getArticleById(article.id), feed); - - hf.setSearchQuery(searchQuery); - af.setSearchQuery(searchQuery); + final Feed feed = i.getParcelableExtra("feed"); + final Article article = i.getParcelableExtra("article"); + final String searchQuery = i.getStringExtra("searchQuery"); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES); - ft.replace(R.id.article_fragment, af, FRAG_ARTICLE); + ft.replace(R.id.headlines_fragment, new LoadingFragment(), null); + ft.replace(R.id.article_fragment, new LoadingFragment(), null); ft.commit(); setTitle(feed.title); + + Handler handler = new Handler(); + + handler.postDelayed(new Runnable() { + @Override + public void run() { + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + + HeadlinesFragment hf = new HeadlinesFragment(feed, article); + hf.setSearchQuery(searchQuery); + + ArticlePager af = new ArticlePager(hf.getArticleById(article.id), feed); + af.setSearchQuery(searchQuery); + + ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES); + ft.replace(R.id.article_fragment, af, FRAG_ARTICLE); + + ft.commit(); + } + }, 25); + } } } @@ -152,7 +168,9 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL ft.commit(); } else { HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES); - hf.setActiveArticle(article); + if (hf != null) { + hf.setActiveArticle(article); + } } GlobalState.getInstance().m_activeArticle = article; diff --git a/src/org/fox/ttrss/LoadingFragment.java b/src/org/fox/ttrss/LoadingFragment.java new file mode 100644 index 00000000..2203d66d --- /dev/null +++ b/src/org/fox/ttrss/LoadingFragment.java @@ -0,0 +1,18 @@ +package org.fox.ttrss; + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +public class LoadingFragment extends Fragment { + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + + View view = inflater.inflate(R.layout.loading_fragment, container, false); + + return view; + } + +}