experimentally implement actionbar-pulltorefresh for feeds and cats
This commit is contained in:
parent
7484ec13e7
commit
29cb4f17d8
@ -11,4 +11,6 @@
|
||||
target=android-17
|
||||
android.library.reference.1=..\\Android-ViewPagerIndicator\\library
|
||||
android.library.reference.2=..\\ActionBarSherlock\\actionbarsherlock
|
||||
android.library.reference.3=../SlidingMenu/library
|
||||
android.library.reference.3=..\\SlidingMenu\\library
|
||||
android.library.reference.4=../ActionBar-PullToRefresh/library
|
||||
android.library.reference.5=../ActionBar-PullToRefresh/extras/pulltorefresh-actionbarsherlock
|
||||
|
@ -11,6 +11,8 @@ import org.fox.ttrss.types.Feed;
|
||||
import org.fox.ttrss.types.FeedCategory;
|
||||
import org.fox.ttrss.types.FeedCategoryList;
|
||||
|
||||
import uk.co.senab.actionbarpulltorefresh.library.PullToRefreshAttacher.OnRefreshListener;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
@ -44,7 +46,7 @@ import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
public class FeedCategoriesFragment extends Fragment implements OnItemClickListener, OnSharedPreferenceChangeListener {
|
||||
public class FeedCategoriesFragment extends Fragment implements OnItemClickListener, OnSharedPreferenceChangeListener, OnRefreshListener {
|
||||
private final String TAG = this.getClass().getSimpleName();
|
||||
private SharedPreferences m_prefs;
|
||||
private FeedCategoryListAdapter m_adapter;
|
||||
@ -207,6 +209,8 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe
|
||||
list.setOnItemClickListener(this);
|
||||
registerForContextMenu(list);
|
||||
|
||||
m_activity.m_pullToRefreshAttacher.addRefreshableView(list, this);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@ -258,8 +262,8 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe
|
||||
final boolean unreadOnly = m_activity.getUnreadOnly();
|
||||
|
||||
if (sessionId != null) {
|
||||
m_activity.setLoadingStatus(R.string.blank, true);
|
||||
m_activity.setProgressBarVisibility(true);
|
||||
//m_activity.setLoadingStatus(R.string.blank, true);
|
||||
//m_activity.setProgressBarVisibility(true);
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
HashMap<String,String> map = new HashMap<String,String>() {
|
||||
@ -332,6 +336,10 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe
|
||||
//m_adapter.notifyDataSetChanged(); (done by sortCats)
|
||||
m_activity.setLoadingStatus(R.string.blank, false);
|
||||
|
||||
if (isAdded()) {
|
||||
m_activity.m_pullToRefreshAttacher.setRefreshComplete();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -502,5 +510,10 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe
|
||||
|
||||
public FeedCategory getSelectedCategory() {
|
||||
return m_selectedCat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefreshStarted(View view) {
|
||||
refresh(false);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.fox.ttrss;
|
||||
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.fox.ttrss.types.Article;
|
||||
@ -10,6 +11,7 @@ import org.fox.ttrss.util.AppRater;
|
||||
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
|
||||
import uk.co.senab.actionbarpulltorefresh.extras.actionbarsherlock.PullToRefreshAttacher;
|
||||
|
||||
import android.view.ViewGroup;
|
||||
import android.animation.LayoutTransition;
|
||||
@ -39,6 +41,8 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
private SlidingMenu m_slidingMenu;
|
||||
private boolean m_feedIsSelected = false;
|
||||
|
||||
protected PullToRefreshAttacher m_pullToRefreshAttacher;
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@ -55,6 +59,8 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
|
||||
GlobalState.getInstance().load(savedInstanceState);
|
||||
|
||||
m_pullToRefreshAttacher = PullToRefreshAttacher.get(this);
|
||||
|
||||
if (isSmallScreen() || findViewById(R.id.sw600dp_port_anchor) != null) {
|
||||
m_slidingMenu = new SlidingMenu(this);
|
||||
|
||||
|
@ -17,6 +17,8 @@ import org.fox.ttrss.types.Feed;
|
||||
import org.fox.ttrss.types.FeedCategory;
|
||||
import org.fox.ttrss.types.FeedList;
|
||||
|
||||
import uk.co.senab.actionbarpulltorefresh.library.PullToRefreshAttacher.OnRefreshListener;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
@ -57,7 +59,7 @@ import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
public class FeedsFragment extends Fragment implements OnItemClickListener, OnSharedPreferenceChangeListener {
|
||||
public class FeedsFragment extends Fragment implements OnItemClickListener, OnSharedPreferenceChangeListener, OnRefreshListener {
|
||||
private final String TAG = this.getClass().getSimpleName();
|
||||
private SharedPreferences m_prefs;
|
||||
private FeedListAdapter m_adapter;
|
||||
@ -244,6 +246,10 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
|
||||
|
||||
m_enableFeedIcons = m_prefs.getBoolean("download_feed_icons", false);
|
||||
|
||||
Log.d(TAG, "mpTRA=" + m_activity.m_pullToRefreshAttacher);
|
||||
|
||||
m_activity.m_pullToRefreshAttacher.addRefreshableView(list, this);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@ -260,6 +266,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
|
||||
m_prefs.registerOnSharedPreferenceChangeListener(this);
|
||||
|
||||
m_activity = (FeedsActivity)activity;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -315,7 +322,6 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
|
||||
@SuppressWarnings({ "unchecked", "serial" })
|
||||
public void refresh(boolean background) {
|
||||
//FeedCategory cat = m_onlineServices.getActiveCategory();
|
||||
m_activity.setProgressBarVisibility(true);
|
||||
|
||||
final int catId = (m_activeCategory != null) ? m_activeCategory.id : -4;
|
||||
|
||||
@ -325,7 +331,8 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
|
||||
FeedsRequest req = new FeedsRequest(getActivity().getApplicationContext(), catId);
|
||||
|
||||
if (sessionId != null) {
|
||||
m_activity.setLoadingStatus(R.string.blank, true);
|
||||
//m_activity.setLoadingStatus(R.string.blank, true);
|
||||
//m_activity.setProgressBarVisibility(true);
|
||||
|
||||
HashMap<String,String> map = new HashMap<String,String>() {
|
||||
{
|
||||
@ -459,10 +466,13 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
|
||||
m_activity.setLoadingStatus(R.string.blank, false);
|
||||
//m_adapter.notifyDataSetChanged(); (done by sortFeeds)
|
||||
|
||||
if (m_enableFeedIcons && !m_feedIconsChecked &&
|
||||
Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()))
|
||||
if (m_enableFeedIcons && !m_feedIconsChecked && Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()))
|
||||
getFeedIcons();
|
||||
|
||||
|
||||
if (isAdded()) {
|
||||
m_activity.m_pullToRefreshAttacher.setRefreshComplete();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -730,4 +740,9 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
|
||||
m_adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefreshStarted(View view) {
|
||||
refresh(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user