com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayoutDirection Java Examples
The following examples show how to use
com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayoutDirection.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MyTripsActivity.java From Mobike with Apache License 2.0 | 6 votes |
private void initEvent() { mDialog = new SpotsDialog(this); mTitleCredit.setOnLeftButtonClickListener(new TabTitleView.OnLeftButtonClickListener() { @Override public void onClick() { MyTripsActivity.this.finish(); } }); mTitleCredit.setOnRightTextViewClickListener(new TabTitleView.OnRightButtonClickListener() { @Override public void onClick() { startActivity(new Intent(MyTripsActivity.this, LastTenTripHistoryActivity.class)); } }); mRefreshLayout.setOnRefreshListener(new SwipyRefreshLayout.OnRefreshListener() { @Override public void onRefresh(SwipyRefreshLayoutDirection direction) { requestData(); if (mRefreshLayout.isRefreshing()) mRefreshLayout.setRefreshing(false); } }); }
Example #2
Source File: RechargeHistoryActivity.java From Mobike with Apache License 2.0 | 6 votes |
private void initRefreshLayout() { mRefreshLayout.setOnRefreshListener(new SwipyRefreshLayout.OnRefreshListener() { @Override public void onRefresh(SwipyRefreshLayoutDirection direction) { if (!CommonUtils.isNetworkAvailable(RechargeHistoryActivity.this)) { unavailableView.setVisibility(View.VISIBLE); mRefreshLayout.setRefreshing(false); return; } requestData(); if (mRefreshLayout.isRefreshing()) mRefreshLayout.setRefreshing(false); } }); }
Example #3
Source File: DiscoveryFragment.java From coderfun with GNU General Public License v3.0 | 6 votes |
private void initSwipyRefreshLayout(View v) { swipyRefreshLayout = (SwipyRefreshLayout) v.findViewById(R.id.swipyrefreshlayout); swipyRefreshLayout.setColorSchemeResources( android.R.color.holo_blue_light, android.R.color.holo_red_light, android.R.color.holo_orange_light, android.R.color.holo_green_light); swipyRefreshLayout.setDirection(SwipyRefreshLayoutDirection.BOTH); swipyRefreshLayout.setOnRefreshListener(new SwipyRefreshLayout.OnRefreshListener() { @Override public void onRefresh(SwipyRefreshLayoutDirection direction) { Observable.timer(2, TimeUnit.SECONDS) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Action1<Long>() { @Override public void call(Long aLong) { swipyRefreshLayout.setRefreshing(false); } }); loadData(direction == SwipyRefreshLayoutDirection.TOP ? true : false); } }); }
Example #4
Source File: ReadFragment.java From coderfun with GNU General Public License v3.0 | 6 votes |
private void initSwipyRefreshLayout(View v) { swipyRefreshLayout = (SwipyRefreshLayout) v.findViewById(R.id.swipyrefreshlayout); swipyRefreshLayout.setColorSchemeResources( android.R.color.holo_blue_light, android.R.color.holo_red_light, android.R.color.holo_orange_light, android.R.color.holo_green_light); swipyRefreshLayout.setDirection(SwipyRefreshLayoutDirection.BOTH); swipyRefreshLayout.setOnRefreshListener(new SwipyRefreshLayout.OnRefreshListener() { @Override public void onRefresh(SwipyRefreshLayoutDirection direction) { Observable.timer(2, TimeUnit.SECONDS) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Action1<Long>() { @Override public void call(Long aLong) { swipyRefreshLayout.setRefreshing(false); } }); loadData(direction == SwipyRefreshLayoutDirection.TOP ? true : false); } }); }
Example #5
Source File: WebAcitivity.java From coderfun with GNU General Public License v3.0 | 6 votes |
private void initSwipyRefreshLayout() { swipyRefreshLayout = (SwipyRefreshLayout) findViewById(R.id.swipyrefreshlayout); swipyRefreshLayout.setColorSchemeResources( android.R.color.holo_blue_light, android.R.color.holo_red_light, android.R.color.holo_orange_light, android.R.color.holo_green_light); swipyRefreshLayout.setOnRefreshListener(new SwipyRefreshLayout.OnRefreshListener() { @Override public void onRefresh(SwipyRefreshLayoutDirection direction) { Observable.timer(2, TimeUnit.SECONDS) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Action1<Long>() { @Override public void call(Long aLong) { swipyRefreshLayout.setRefreshing(false); } }); webView.loadUrl(url); loadingView.setVisibility(View.GONE); } }); }
Example #6
Source File: MainActivity.java From SwipyRefreshLayout with MIT License | 6 votes |
/** * Called when the {@link com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayout} * is in refresh mode. Just for example purpose. */ @Override public void onRefresh(SwipyRefreshLayoutDirection direction) { Log.d("MainActivity", "Refresh triggered at " + (direction == SwipyRefreshLayoutDirection.TOP ? "top" : "bottom")); new Handler().postDelayed(new Runnable() { @Override public void run() { //Hide the refresh after 2sec MainActivity.this.runOnUiThread(new Runnable() { @Override public void run() { mBinding.swipyrefreshlayout.setRefreshing(false); } }); } }, DISMISS_TIMEOUT); }
Example #7
Source File: RedPocketDetailActivity.java From Mobike with Apache License 2.0 | 5 votes |
private void initRefreshLayout() { mRefreshLayout.setOnRefreshListener(new SwipyRefreshLayout.OnRefreshListener() { @Override public void onRefresh(SwipyRefreshLayoutDirection direction) { requestPoketData(); if (mRefreshLayout.isRefreshing()) mRefreshLayout.setRefreshing(false); } }); }
Example #8
Source File: MyMessagesActivity.java From Mobike with Apache License 2.0 | 5 votes |
private void initRefreshLayout() { // mRefreshLayout.setLoadMore(true); // mRefreshLayout.setMaterialRefreshListener(new MaterialRefreshListener() { // @Override // public void onRefresh(MaterialRefreshLayout materialRefreshLayout) { // requestMassage(); // mRecyclerMassage.scrollToPosition(0); // mRefreshLayout.finishRefresh(); // } // // @Override // public void onRefreshLoadMore(MaterialRefreshLayout materialRefreshLayout) { // requestMassage();//实际活动较少,上下拉刷新不需要分页 // mRefreshLayout.finishRefreshLoadMore(); // } // // }); mRefreshLayout.setOnRefreshListener(new SwipyRefreshLayout.OnRefreshListener() { @Override public void onRefresh(SwipyRefreshLayoutDirection direction) { requestMassage(); if (mRefreshLayout.isRefreshing()) mRefreshLayout.setRefreshing(false); } }); }
Example #9
Source File: HistoryFragment.java From chaoli-forum-for-android-2 with GNU General Public License v3.0 | 5 votes |
@Override public void onRefresh(SwipyRefreshLayoutDirection direction) { if (direction == SwipyRefreshLayoutDirection.TOP) { viewModel.refresh(); } else { viewModel.loadMore(); } }
Example #10
Source File: GankFragment.java From GankMeizhi with Apache License 2.0 | 5 votes |
private void setupSwipeRefreshLayout() { //设置卷内的颜色 swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); swipeRefreshLayout.setDirection(SwipyRefreshLayoutDirection.BOTH); //设置下拉刷新监听 swipeRefreshLayout.setOnRefreshListener((direction) -> { clearAdapterCache(direction); clearDbCache(); loadData(currentPage); }); }
Example #11
Source File: GankFragment.java From GankMeizhi with Apache License 2.0 | 5 votes |
private void clearAdapterCache(SwipyRefreshLayoutDirection direction) { if (direction == SwipyRefreshLayoutDirection.TOP) { currentPage = Constants.START; if (allAdapter != null) { allAdapter.getDatas().clear(); } if (meizhiAdapter != null) { meizhiAdapter.getDatas().clear(); } } }
Example #12
Source File: WebViewActivity.java From GankMeizhi with Apache License 2.0 | 5 votes |
private void setupSwipeRefreshLayout() { //设置卷内的颜色 swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); swipeRefreshLayout.setDirection(SwipyRefreshLayoutDirection.TOP); //设置下拉刷新监听 swipeRefreshLayout.setOnRefreshListener((direction) -> { webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT); webView.reload(); }); }
Example #13
Source File: MainActivity.java From SwipyRefreshLayout with MIT License | 5 votes |
@Override public void onClick(View v) { switch (v.getId()) { case R.id.button_top: mBinding.swipyrefreshlayout.setDirection(SwipyRefreshLayoutDirection.TOP); break; case R.id.button_bottom: mBinding.swipyrefreshlayout.setDirection(SwipyRefreshLayoutDirection.BOTTOM); break; case R.id.button_both: mBinding.swipyrefreshlayout.setDirection(SwipyRefreshLayoutDirection.BOTH); break; case R.id.button_refresh: mBinding.swipyrefreshlayout.setRefreshing(true); new Handler().postDelayed(new Runnable() { @Override public void run() { //Hide the refresh after 2sec MainActivity.this.runOnUiThread(new Runnable() { @Override public void run() { mBinding.swipyrefreshlayout.setRefreshing(false); } }); } }, 2000); break; } }
Example #14
Source File: GlobalSearchFragment.java From q-municate-android with Apache License 2.0 | 5 votes |
@Override public void onRefresh(SwipyRefreshLayoutDirection swipyRefreshLayoutDirection) { if (!usersList.isEmpty() && usersList.size() < totalEntries) { page++; searchUsers(); } else { swipyRefreshLayout.setRefreshing(false); } }
Example #15
Source File: MainActivity.java From chaoli-forum-for-android-2 with GNU General Public License v3.0 | 4 votes |
public void initUI(Bundle savedInstanceState) { Toolbar toolbar = (Toolbar) findViewById(R.id.tl_custom); configToolbar(R.string.app_name); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); actionBarDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.app_name, R.string.app_name); actionBarDrawerToggle.setDrawerIndicatorEnabled(false); actionBarDrawerToggle.setHomeAsUpIndicator(R.drawable.ic_menu_black_24dp); actionBarDrawerToggle.setToolbarNavigationClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mDrawerLayout.openDrawer(GravityCompat.START); } }); actionBarDrawerToggle.syncState(); mDrawerLayout.addDrawerListener(actionBarDrawerToggle); l = binding.conversationList; l.addItemDecoration(new android.support.v7.widget.DividerItemDecoration(mContext, android.support.v7.widget.DividerItemDecoration.VERTICAL)); layoutManager = new LinearLayoutManager(mContext); l.setLayoutManager(layoutManager); if (NightModeHelper.getViewModel() != null) { layoutManager.onRestoreInstanceState(savedInstanceState.getParcelable(LAYOUTMANAGER_STATE)); } swipyRefreshLayout = binding.conversationListRefreshLayout; if (NightModeHelper.getViewModel() != null) { MyUtils.setToolbarOffset(binding.cl, binding.appbar, savedInstanceState.getInt(TOOLBAR_OFFSET)); } binding.appbar.addOnOffsetChangedListener(this); binding.conversationList.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); //得到当前显示的最后一个item的view View lastChildView = recyclerView.getLayoutManager().getChildAt(recyclerView.getLayoutManager().getChildCount()-1); if (lastChildView == null) return; //得到lastChildView的bottom坐标值 int lastChildBottom = lastChildView.getBottom(); //得到Recyclerview的底部坐标减去底部padding值,也就是显示内容最底部的坐标 int recyclerBottom = recyclerView.getBottom()-recyclerView.getPaddingBottom(); //通过这个lastChildView得到这个view当前的position值 int lastVisiblePosition = layoutManager.findLastVisibleItemPosition(); //判断lastChildView的bottom值跟recyclerBottom //判断lastPosition是不是最后一个position //如果两个条件都满足则说明是真正的滑动到了底部 int lastPosition = recyclerView.getLayoutManager().getItemCount() - 1; if(lastChildBottom == recyclerBottom && lastVisiblePosition == lastPosition){ bottom = true; viewModel.canRefresh.set(true); }else{ bottom = false; } if (lastVisiblePosition >= lastPosition - 3) viewModel.tryToLoadFromBottom(); } }); final NavigationView navigationView = (NavigationView) findViewById(R.id.navigation_view); navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { if (item.getItemId()==R.id.nightMode){ NightModeHelper.changeMode(viewModel); getWindow().setWindowAnimations(R.style.modechange); recreate(); }else { selectItem(item.getOrder()); item.setChecked(true); } return true; } }); swipyRefreshLayout.setDirection(SwipyRefreshLayoutDirection.BOTH); swipyRefreshLayout.setOnRefreshListener(new SwipyRefreshLayout.OnRefreshListener() { @Override public void onRefresh(SwipyRefreshLayoutDirection direction) { if (direction == SwipyRefreshLayoutDirection.TOP) { viewModel.refresh(); } else { viewModel.loadMore(); } } }); NightModeHelper.removeViewModel(); }
Example #16
Source File: SwipyRefreshBA.java From chaoli-forum-for-android-2 with GNU General Public License v3.0 | 4 votes |
/** * 为了应对奇怪的事情:把方向设为BOTTOM就没法在setRefreshing(true)之后看到小圆圈 * @param swipyRefreshLayout .. * @param direction .. */ @BindingAdapter("app:direction") public static void setDirection(final SwipyRefreshLayout swipyRefreshLayout, final SwipyRefreshLayoutDirection direction) { Log.d(TAG, "setDirection() called with: swipyRefreshLayout = [" + swipyRefreshLayout + "], direction = [" + direction + "]"); swipyRefreshLayout.setDirection(direction); }