use delayed loading for several containers in tablet mode to visually

speed things up
This commit is contained in:
Andrew Dolgov 2012-09-20 22:57:40 +04:00
parent 41c115471a
commit af5bcf926c
4 changed files with 81 additions and 15 deletions

View File

@ -0,0 +1,13 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</FrameLayout>

View File

@ -12,6 +12,7 @@ import android.annotation.SuppressLint;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
@ -148,10 +149,26 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
FragmentTransaction ft = getSupportFragmentManager() FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction(); .beginTransaction();
HeadlinesFragment hf = new HeadlinesFragment(feed); 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.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES);
ft.commit(); ft.commit();
}
}, 25);
Date date = new Date(); Date date = new Date();

View File

@ -8,6 +8,7 @@ import android.annotation.SuppressLint;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
@ -46,24 +47,39 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
Intent i = getIntent(); Intent i = getIntent();
if (i.getExtras() != null) { if (i.getExtras() != null) {
Feed feed = i.getParcelableExtra("feed"); final Feed feed = i.getParcelableExtra("feed");
Article article = i.getParcelableExtra("article"); final Article article = i.getParcelableExtra("article");
String searchQuery = i.getStringExtra("searchQuery"); final 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);
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
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.headlines_fragment, hf, FRAG_HEADLINES);
ft.replace(R.id.article_fragment, af, FRAG_ARTICLE); ft.replace(R.id.article_fragment, af, FRAG_ARTICLE);
ft.commit(); ft.commit();
}
}, 25);
setTitle(feed.title);
} }
} }
} }
@ -152,8 +168,10 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
ft.commit(); ft.commit();
} else { } else {
HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES); HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
if (hf != null) {
hf.setActiveArticle(article); hf.setActiveArticle(article);
} }
}
GlobalState.getInstance().m_activeArticle = article; GlobalState.getInstance().m_activeArticle = article;

View File

@ -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;
}
}