implement headlines fragment pull to refresh
use indeterminate progressbar under actionbar
This commit is contained in:
parent
3c4324eee2
commit
94a468b2a3
@ -13,6 +13,8 @@ import org.fox.ttrss.types.Feed;
|
|||||||
import org.fox.ttrss.util.HeadlinesRequest;
|
import org.fox.ttrss.util.HeadlinesRequest;
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
|
|
||||||
|
import uk.co.senab.actionbarpulltorefresh.library.PullToRefreshAttacher.OnRefreshListener;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
@ -47,7 +49,7 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
|
|
||||||
public class HeadlinesFragment extends Fragment implements OnItemClickListener, OnScrollListener {
|
public class HeadlinesFragment extends Fragment implements OnItemClickListener, OnScrollListener, OnRefreshListener {
|
||||||
public static enum ArticlesSelection { ALL, NONE, UNREAD };
|
public static enum ArticlesSelection { ALL, NONE, UNREAD };
|
||||||
|
|
||||||
public static final int HEADLINES_REQUEST_SIZE = 30;
|
public static final int HEADLINES_REQUEST_SIZE = 30;
|
||||||
@ -293,6 +295,8 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
//list.setEmptyView(view.findViewById(R.id.no_headlines));
|
//list.setEmptyView(view.findViewById(R.id.no_headlines));
|
||||||
registerForContextMenu(list);
|
registerForContextMenu(list);
|
||||||
|
|
||||||
|
m_activity.m_pullToRefreshAttacher.addRefreshableView(list, this);
|
||||||
|
|
||||||
//if (m_activity.isSmallScreen())
|
//if (m_activity.isSmallScreen())
|
||||||
//view.findViewById(R.id.headlines_fragment).setPadding(0, 0, 0, 0);
|
//view.findViewById(R.id.headlines_fragment).setPadding(0, 0, 0, 0);
|
||||||
|
|
||||||
@ -414,6 +418,11 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
|
|
||||||
m_adapter.notifyDataSetChanged();
|
m_adapter.notifyDataSetChanged();
|
||||||
m_listener.onHeadlinesLoaded(fappend);
|
m_listener.onHeadlinesLoaded(fappend);
|
||||||
|
|
||||||
|
if (isAdded()) {
|
||||||
|
m_activity.m_pullToRefreshAttacher.setRefreshComplete();
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (m_lastError == ApiError.LOGIN_FAILED) {
|
if (m_lastError == ApiError.LOGIN_FAILED) {
|
||||||
m_activity.login();
|
m_activity.login();
|
||||||
@ -945,5 +954,10 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
return m_feed;
|
return m_feed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRefreshStarted(View view) {
|
||||||
|
refresh(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
requestWindowFeature(Window.FEATURE_PROGRESS);
|
requestWindowFeature(Window.FEATURE_PROGRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
|
//requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
|
||||||
|
|
||||||
setProgressBarVisibility(false);
|
setProgressBarVisibility(false);
|
||||||
setProgressBarIndeterminateVisibility(false);
|
setProgressBarIndeterminateVisibility(false);
|
||||||
@ -1000,6 +1000,7 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
return true;
|
return true;
|
||||||
case R.id.update_headlines:
|
case R.id.update_headlines:
|
||||||
if (hf != null) {
|
if (hf != null) {
|
||||||
|
m_pullToRefreshAttacher.setRefreshing(true);
|
||||||
hf.refresh(false);
|
hf.refresh(false);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -1582,6 +1583,8 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void refresh(boolean includeHeadlines) {
|
protected void refresh(boolean includeHeadlines) {
|
||||||
|
m_pullToRefreshAttacher.setRefreshing(true);
|
||||||
|
|
||||||
FeedCategoriesFragment cf = (FeedCategoriesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_CATS);
|
FeedCategoriesFragment cf = (FeedCategoriesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_CATS);
|
||||||
|
|
||||||
if (cf != null) {
|
if (cf != null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user