use of android.support.v4.widget.SwipeRefreshLayout in project LeMondeRssReader by MBach.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
initCategories();
// TODO
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mainActivityRecyclerView = (RecyclerView) findViewById(R.id.mainActivityRecyclerView);
mainActivityRecyclerView.setLayoutManager(new LinearLayoutManager(this));
swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
String category = selectedMenuItem == null ? Constants.CAT_NEWS : rssCats.get(selectedMenuItem.getItemId());
getFeedFromCategory(category);
}
});
initToolbar();
setupDrawerLayout();
mainActivityRecyclerView.setAdapter(adapter);
getFeedFromCategory(Constants.CAT_NEWS);
}
use of android.support.v4.widget.SwipeRefreshLayout in project twicalico by moko256.
the class ShowTweetActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_show_tweet);
subscriptions = new CompositeSubscription();
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeAsUpIndicator(R.drawable.ic_back_white_24dp);
}
statusId = getIntent().getLongExtra("statusId", -1);
if (statusId == -1) {
ShowTweetActivity.this.finish();
return;
}
Status status = GlobalApplication.statusCache.get(statusId);
if (status == null) {
subscriptions.add(updateStatus().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(result -> {
if (result == null) {
finish();
return;
}
updateView(result);
}, e -> {
e.printStackTrace();
finish();
}));
} else {
updateView(status);
}
SwipeRefreshLayout swipeRefreshLayout = findViewById(R.id.tweet_show_swipe_refresh);
swipeRefreshLayout.setColorSchemeResources(R.color.color_primary);
swipeRefreshLayout.setOnRefreshListener(() -> subscriptions.add(updateStatus().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(result -> {
if (result == null) {
finish();
return;
}
updateView(result);
swipeRefreshLayout.setRefreshing(false);
}, e -> {
e.printStackTrace();
Toast.makeText(this, R.string.error_occurred, Toast.LENGTH_SHORT).show();
swipeRefreshLayout.setRefreshing(false);
})));
}
use of android.support.v4.widget.SwipeRefreshLayout in project curb by irijwj.
the class InformationFragment method onCreateView.
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View info = inflater.inflate(R.layout.fragment_information, container, false);
ButterKnife.bind(this, info);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
infoRecycler.setLayoutManager(layoutManager);
infoRecycler.setAdapter(m_minfoAdapter);
// 设置一些动画,但是没有显示出来
infoRecycler.addItemDecoration(new DividerItemDecoration(checkNotNull(getActivity()), DividerItemDecoration.HORIZONTAL));
// 设置一些颜色,但是我并不知道在哪里用的
refreshInfoLayout.setColorSchemeColors(ContextCompat.getColor(checkNotNull(getActivity()), R.color.colorPrimary), ContextCompat.getColor(checkNotNull(getActivity()), R.color.colorAccent), ContextCompat.getColor(checkNotNull(getActivity()), R.color.colorPrimaryDark));
// Set the scrolling view in the custom SwipeRefreshLayout.
refreshInfoLayout.setScrollUpChild(infoRecycler);
refreshInfoLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
presenter.loadInformation(true);
}
});
setHasOptionsMenu(true);
unbinder = ButterKnife.bind(this, info);
return info;
}
use of android.support.v4.widget.SwipeRefreshLayout in project IITB-App by wncc.
the class FeedFragment method onStart.
@Override
public void onStart() {
super.onStart();
appDatabase = AppDatabase.getAppDatabase(getContext());
final List<Event> events = appDatabase.dbDao().getAllEvents();
FeedAdapter feedAdapter = new FeedAdapter(events, new ItemClickListener() {
@Override
public void onItemClick(View v, int position) {
String eventJson = new Gson().toJson(events.get(position));
Bundle bundle = new Bundle();
bundle.putString(Constants.EVENT_JSON, eventJson);
EventFragment eventFragment = new EventFragment();
eventFragment.setArguments(bundle);
FragmentManager manager = getActivity().getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.replace(R.id.framelayout_for_fragment, eventFragment, eventFragment.getTag());
transaction.commit();
}
});
feedRecyclerView = (RecyclerView) getActivity().findViewById(R.id.feed_recycler_view);
feedRecyclerView.setAdapter(feedAdapter);
feedRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
// }
updateFeed();
feedSwipeRefreshLayout = (SwipeRefreshLayout) getActivity().findViewById(R.id.feed_swipe_refresh_layout);
feedSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
updateFeed();
}
});
}
use of android.support.v4.widget.SwipeRefreshLayout in project todo-mvp-rxjava by albertizzy.
the class TasksFragment method setLoadingIndicator.
@Override
public void setLoadingIndicator(final boolean active) {
if (getView() == null) {
return;
}
final SwipeRefreshLayout srl = getView().findViewById(R.id.refresh_layout);
// Make sure setRefreshing() is called after the layout is done with everything else.
srl.post(() -> srl.setRefreshing(active));
// TODO lambda
// srl.post(new Runnable() {
// @Override
// public void run() {
// srl.setRefreshing(active);
// }
// });
}
Aggregations