本文整理汇总了Java中com.jakewharton.rxbinding.support.v4.widget.RxSwipeRefreshLayout类的典型用法代码示例。如果您正苦于以下问题:Java RxSwipeRefreshLayout类的具体用法?Java RxSwipeRefreshLayout怎么用?Java RxSwipeRefreshLayout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RxSwipeRefreshLayout类属于com.jakewharton.rxbinding.support.v4.widget包,在下文中一共展示了RxSwipeRefreshLayout类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: SwipeRefresher
import com.jakewharton.rxbinding.support.v4.widget.RxSwipeRefreshLayout; //导入依赖的package包/类
/**
*
* @param activity Activity to bind lifecycle events for.
* @param layout Layout to subscribe to for refresh events, send signals when no longer refreshing.
* @param refreshAction Action to call when a refresh event is emitted, likely a viewModel input.
* @param isRefreshing Observable that emits events when the refreshing status changes.
*/
public SwipeRefresher(final @NonNull BaseActivity<? extends ActivityViewModel> activity,
final @NonNull SwipeRefreshLayout layout,
final @NonNull Action0 refreshAction,
final @NonNull Func0<Observable<Boolean>> isRefreshing) {
// Iterate through colors in loading spinner while waiting for refresh
layout.setColorSchemeResources(R.color.ksr_green_500, R.color.ksr_green_700, R.color.ksr_green_800);
// Emits when user has signaled to refresh layout
RxSwipeRefreshLayout.refreshes(layout)
.compose(activity.bindToLifecycle())
.subscribe(__ -> refreshAction.call());
// Emits when the refreshing status changes. Hides loading spinner when feed is no longer refreshing.
isRefreshing.call()
.filter(refreshing -> !refreshing)
.compose(activity.bindToLifecycle())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(layout::setRefreshing);
}
开发者ID:kickstarter,项目名称:android-oss,代码行数:28,代码来源:SwipeRefresher.java
示例2: onCreate
import com.jakewharton.rxbinding.support.v4.widget.RxSwipeRefreshLayout; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
calendar = new ObservableCalendar(Calendar.getInstance());
binding.setDate(calendar);
setUpPager();
RxSwipeRefreshLayout.refreshes(binding.swipeRefreshLayout)
.doOnUnsubscribe(() -> {
binding.swipeRefreshLayout.setRefreshing(false);
})
.compose(bindToLifecycle())
.subscribe(aVoid -> {
binding.swipeRefreshLayout.setRefreshing(false);
});
binding.swipeRefreshLayout.setColorSchemeResources(R.color.colorAccent, R.color.colorPrimaryLight, R.color.colorPrimary);
}
开发者ID:RunziiMo,项目名称:grooo,代码行数:17,代码来源:OrderActivity.java
示例3: onViewCreated
import com.jakewharton.rxbinding.support.v4.widget.RxSwipeRefreshLayout; //导入依赖的package包/类
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
orderOb = NetworkWrapper.get().getOrders()
.compose(bindToLifecycle())
.compose(RxNetWorking.bindRefreshing(bind.swipeRefreshLayout));
bind.recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
bind.recyclerView.setEmptyView(bind.tvEmptyview);
RxSwipeRefreshLayout.refreshes(bind.swipeRefreshLayout)
.compose(bindToLifecycle())
.subscribe(aVoid -> {
loadOrder();
}, errorHandle("获取所有订单"));
setAdapter();
loadOrder();
}
开发者ID:RunziiMo,项目名称:grooo,代码行数:17,代码来源:OrderListFragment.java
示例4: onViewCreated
import com.jakewharton.rxbinding.support.v4.widget.RxSwipeRefreshLayout; //导入依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
shopObservable = NetworkWrapper.get()
.getAllShop(AppPreferences.get().getProfile().getSchool().getId())
.compose(RxNetWorking.bindRefreshing(bind.swipeRefreshLayout))
.compose(bindToLifecycle());
RxSwipeRefreshLayout.refreshes(bind.swipeRefreshLayout)
.compose(bindToLifecycle())
.subscribe(aVoid -> {
loadShop();
});
pagerAdapter = new ShopViewPagerAdapter(getLayoutInflater(savedInstanceState));
setUpViewPager();
loadShop();
}
开发者ID:RunziiMo,项目名称:grooo,代码行数:17,代码来源:ShopFragment.java
示例5: createApi
import com.jakewharton.rxbinding.support.v4.widget.RxSwipeRefreshLayout; //导入依赖的package包/类
@Override
protected void createApi(ImApp app) {
RxSwipeRefreshLayout.refreshes(getBinding().refresher)
.doOnUnsubscribe(() -> unsubcribe("refresher"))
.observeOn(AndroidSchedulers.mainThread())
.map(avoid -> {
doRefresh();
return null;
})
.compose(bindToLifecycle())
.subscribe(avoid -> LogUtils.d(TAG, "refresher success"), e -> e.printStackTrace());
}
开发者ID:iQuick,项目名称:NewsMe,代码行数:13,代码来源:WebActivity.java
示例6: setUpData
import com.jakewharton.rxbinding.support.v4.widget.RxSwipeRefreshLayout; //导入依赖的package包/类
private void setUpData() {
observableRefreshData = NetworkWrapper.get()
.getMenu(AppPreferences.get().getAuth(), AppManager.getShopInfo().getId())
.compose(RxNetWorking.bindRefreshing(binding.swipeRefreshLayout));
binding.swipeRefreshLayout.setColorSchemeResources(R.color.colorAccent, R.color.colorPrimaryLight, R.color.colorPrimary);
RxSwipeRefreshLayout.refreshes(binding.swipeRefreshLayout)
.doOnUnsubscribe(() -> {
binding.swipeRefreshLayout.setRefreshing(false);
})
.compose(bindToLifecycle())
.subscribe(aVoid -> {
refreshData();
});
}
开发者ID:RunziiMo,项目名称:grooo,代码行数:15,代码来源:MenuActivity.java
示例7: swipeRefresh
import com.jakewharton.rxbinding.support.v4.widget.RxSwipeRefreshLayout; //导入依赖的package包/类
private void swipeRefresh() {
RxSwipeRefreshLayout.refreshes(binding.refreshLayout)
.compose(bindToLifecycle())
.subscribe(aVoid -> {
page = 1;
refreshing = true;
fetchGirlData();
});
}
开发者ID:Assassinss,项目名称:pretty-girl,代码行数:10,代码来源:MainActivity.java
示例8: initObservables
import com.jakewharton.rxbinding.support.v4.widget.RxSwipeRefreshLayout; //导入依赖的package包/类
private void initObservables() {
Observable.Transformer<List<News>, List<News>> networkingIndicator = RxNetworking.bindRefreshing(getBinding().refresher);
observableRefresherNewsData = Observable.defer(() -> mNewApi.queryNewsByCName(getArguments().getString(BUNDLE_NAME), 1))
.doOnUnsubscribe(() -> this.unsubcribe("observableNewsData"))
.flatMap(data -> Observable.just(data.contentlist))
.flatMap(list -> getApp().getDB().putList(Const.DB_NEWS_NAME, list, News.class))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.compose(networkingIndicator);
observableLoadMoreNewsData = Observable.defer(() -> mNewApi.queryNewsByCName(getArguments().getString(BUNDLE_NAME), mCurrPage + 1))
.doOnUnsubscribe(() -> this.unsubcribe("observableNewsData"))
.map(data -> {
mCurrPage = data.currentPage;
return data.contentlist;
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.compose(networkingIndicator);
// 刷新/加载更多
RxSwipeRefreshLayout.refreshes(getBinding().refresher)
.doOnUnsubscribe(() -> this.unsubcribe("SwipeRefreshLayout"))
.flatMap(avoid -> observableRefresherNewsData)
.compose(bindToLifecycle())
.subscribe(RxList.prependTo(mNews, getBinding().content), this::showError);
RxEndlessRecyclerView.reachesEnd(getBinding().content)
.doOnUnsubscribe(() -> this.unsubcribe("Recycler"))
.flatMap(avoid -> observableLoadMoreNewsData)
.compose(bindToLifecycle())
.subscribe(RxList.appendTo(mNews), this::showError);
// 首次进入手动加载
observableRefresherNewsData
.map(list -> {
mNews.clear();
return list;
})
.compose(bindToLifecycle())
.subscribe(RxList.prependTo(mNews, getBinding().content), this::showError);
}
开发者ID:iQuick,项目名称:NewsMe,代码行数:45,代码来源:NewsChannelFragment.java
示例9: initObservable
import com.jakewharton.rxbinding.support.v4.widget.RxSwipeRefreshLayout; //导入依赖的package包/类
private void initObservable() {
Observable.Transformer<List<Joke>, List<Joke>> networkingIndicator = RxNetworking.bindRefreshing(getBinding().refresher);
observableJokeRefreshData = Observable.defer(() -> mJokeApi.joke("latest", 1))
.doOnUnsubscribe(() -> unsubcribe("observable refresh data"))
.flatMap(data -> Observable.just(data.data))
.flatMap(list -> getApp().getDB().putList(Const.DB_JOKES_NAME, list, Joke.class))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.compose(networkingIndicator);
observableJokeLoadMoreData = Observable.defer(() -> mJokeApi.joke("latest", mCurrPage + 1))
.doOnUnsubscribe(() -> unsubcribe("observable loadmore data"))
.map(data -> {
mCurrPage = data.page;
return data.data;
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.compose(networkingIndicator);
RxSwipeRefreshLayout.refreshes(getBinding().refresher)
.doOnUnsubscribe(() -> unsubcribe("swipe refresh"))
.flatMap(avoid -> observableJokeRefreshData)
.compose(bindToLifecycle())
.subscribe(RxList.prependTo(mJokes, getBinding().content), this::showError);
RxEndlessRecyclerView.reachesEnd(getBinding().content)
.doOnUnsubscribe(() -> unsubcribe("load more"))
.flatMap(avoid -> observableJokeLoadMoreData)
.compose(bindToLifecycle())
.subscribe(RxList.appendTo(mJokes), this::showError);
// 首次进入
observableJokeRefreshData
.map(list -> {
mJokes.clear();
return list;
})
.compose(bindToLifecycle())
.subscribe(RxList.prependTo(mJokes, getBinding().content), this::showError);
}
开发者ID:iQuick,项目名称:NewsMe,代码行数:44,代码来源:JokeFragment.java
示例10: refreshes
import com.jakewharton.rxbinding.support.v4.widget.RxSwipeRefreshLayout; //导入依赖的package包/类
@Override public rx.Observable<Void> refreshes() {
return RxSwipeRefreshLayout.refreshes(swipeRefreshLayout);
}
开发者ID:Aptoide,项目名称:aptoide-client-v8,代码行数:4,代码来源:TimelineFragment.java
示例11: onCreate
import com.jakewharton.rxbinding.support.v4.widget.RxSwipeRefreshLayout; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MiuiStatusBarCompat.enableLightStatusBar(getWindow());
binding = DataBindingUtil.setContentView(this, R.layout.main_activity);
setSupportActionBar(binding.toolbar);
images = MrSharedState.getInstance().getImages();
Glide.get(this).setMemoryCategory(MemoryCategory.HIGH);
binding.content.setAdapter(new MainAdapter(this, images, Glide.with(this), this));
setExitSharedElementCallback(new SharedElementCallback() {
@Override
public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
if (reenterState != null) {
int index = reenterState.getInt("index", 0);
Image image = images.get(index);
MainAdapter.ViewHolder holder = (MainAdapter.ViewHolder) binding.content
.findViewHolderForLayoutPosition(index);
sharedElements.clear();
if (holder != null && holder.binding != null) {
sharedElements.put(String.format("%s.image", image.getObjectId()), holder.binding.image);
}
reenterState = null;
}
}
});
Observable<List<Image>> load = Observable.just(images)
.doOnSubscribe(() -> binding.refresher.setRefreshing(true))
.doOnCompleted(() -> binding.refresher.setRefreshing(false))
.map(whatever -> images.isEmpty() ? Image.all() : Image.since(images.get(0)))
.observeOn(Schedulers.io())
.flatMap(RxAVQuery::find)
.observeOn(AndroidSchedulers.mainThread())
.doOnNext(RxList.prependTo(images));
RxSwipeRefreshLayout.refreshes(binding.refresher)
.compose(bindToLifecycle())
.flatMap(whatever -> load)
.retry((count, tr) -> {
Log.e(TAG, "An error occurred while fetching images", tr);
ToastUtil.shorts(this, tr.getMessage());
binding.refresher.setRefreshing(false);
return true;
})
.filter(loaded -> !loaded.isEmpty())
.subscribe(loaded -> binding.content.smoothScrollToPosition(0));
load.compose(bindToLifecycle())
.onErrorReturn(tr -> {
Log.e(TAG, "An error occurred while fetching images", tr);
ToastUtil.shorts(this, tr.getMessage());
binding.refresher.setRefreshing(false);
return null;
})
.subscribe();
UpdateUtil.checkForUpdate(version -> UpdateUtil.promptUpdate(this, version));
}
开发者ID:oxoooo,项目名称:mr-mantou-android,代码行数:70,代码来源:MainActivity.java
注:本文中的com.jakewharton.rxbinding.support.v4.widget.RxSwipeRefreshLayout类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论