use delayed loading for several containers in tablet mode to visually
speed things up
This commit is contained in:
parent
41c115471a
commit
af5bcf926c
13
res/layout/loading_fragment.xml
Normal file
13
res/layout/loading_fragment.xml
Normal 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>
|
@ -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,11 +149,27 @@ 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();
|
||||
|
||||
if (date.getTime() - m_lastRefresh > 10000) {
|
||||
|
@ -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;
|
||||
|
18
src/org/fox/ttrss/LoadingFragment.java
Normal file
18
src/org/fox/ttrss/LoadingFragment.java
Normal 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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user