com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayout Java Examples
The following examples show how to use
com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayout.
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: 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 #7
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 #8
Source File: SwipyRefreshBA.java From chaoli-forum-for-android-2 with GNU General Public License v3.0 | 5 votes |
@BindingAdapter("app:isRefreshing") public static void setRefreshing(final SwipyRefreshLayout swipyRefreshLayout, final Boolean isRefreshing) { swipyRefreshLayout.post(new Runnable() { @Override public void run() { swipyRefreshLayout.setRefreshing(isRefreshing); } }); }
Example #9
Source File: SwipyRefreshLayoutTest.java From SwipyRefreshLayout with MIT License | 5 votes |
/** * Test that the {@link SwipyRefreshLayout#getCircleView()} is shown in the right directions. */ public void testSwipyRefreshLayoutDirections() { //Wait for launch solo.waitForActivity(MainActivity.class); solo.assertCurrentActivity("MainActivity", MainActivity.class); solo.sleep(500); //Test TOP SwipyRefreshLayout swipyRefreshLayout = (SwipyRefreshLayout) solo.getView(R.id.swipyrefreshlayout); assertEquals(View.GONE, ((ImageView) swipyRefreshLayout.getCircleView()).getVisibility()); clickOnView(R.id.button_top); drag(true); assertEquals(View.VISIBLE, ((ImageView) swipyRefreshLayout.getCircleView()).getVisibility()); solo.sleep(MainActivity.DISMISS_TIMEOUT + 1000); assertEquals(View.GONE, ((ImageView) swipyRefreshLayout.getCircleView()).getVisibility()); //Test BOTTOM clickOnView(R.id.button_bottom); drag(true); assertEquals(View.GONE, ((ImageView) swipyRefreshLayout.getCircleView()).getVisibility()); drag(false); solo.sleep(500); drag(false); assertEquals(View.VISIBLE, ((ImageView) swipyRefreshLayout.getCircleView()).getVisibility()); solo.sleep(MainActivity.DISMISS_TIMEOUT + 1000); assertEquals(View.GONE, ((ImageView) swipyRefreshLayout.getCircleView()).getVisibility()); //Test BOTH clickOnView(R.id.button_both); drag(false); assertEquals(View.VISIBLE, ((ImageView) swipyRefreshLayout.getCircleView()).getVisibility()); solo.sleep(MainActivity.DISMISS_TIMEOUT + 1000); assertEquals(View.GONE, ((ImageView) swipyRefreshLayout.getCircleView()).getVisibility()); drag(true); solo.sleep(500); drag(true); assertEquals(View.VISIBLE, ((ImageView) swipyRefreshLayout.getCircleView()).getVisibility()); solo.sleep(MainActivity.DISMISS_TIMEOUT + 1000); assertEquals(View.GONE, ((ImageView) swipyRefreshLayout.getCircleView()).getVisibility()); }
Example #10
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 #11
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); }