首页滑动优化

This commit is contained in:
oujunhui
2020-05-26 19:20:55 +08:00
parent 1f0cf1e274
commit 18e07a6777
5 changed files with 39 additions and 2 deletions

View File

@@ -0,0 +1,12 @@
package com.yizhuan.erban.home.event;
import lombok.Data;
@Data
public class HomeScrollEvent {
private boolean nestScrollEnable;
public HomeScrollEvent(boolean nestScrollEnable) {
this.nestScrollEnable = nestScrollEnable;
}
}

View File

@@ -20,6 +20,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.core.widget.NestedScrollView;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
@@ -48,6 +49,7 @@ import com.yizhuan.erban.home.activity.HomeMoreRoomActivity;
import com.yizhuan.erban.home.adapter.BannerAdapter;
import com.yizhuan.erban.home.adapter.HomeConcernsAdapter;
import com.yizhuan.erban.home.adapter.MainMagicIndicatorAdapter;
import com.yizhuan.erban.home.event.HomeScrollEvent;
import com.yizhuan.erban.home.presenter.MainFragmentPresenter;
import com.yizhuan.erban.home.view.IMainFragmentView;
import com.yizhuan.erban.location.LocationManager;
@@ -249,6 +251,17 @@ public class GameHomeFragment extends BaseMvpFragment<IMainFragmentView, MainFra
}
}, 1800);
mBinding.rvFollowRoom.setVisibility(View.VISIBLE);
mBinding.stickyScrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
@Override
public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
if (scrollY == (v.getChildAt(0).getMeasuredHeight() - v.getMeasuredHeight())) {
EventBus.getDefault().post(new HomeScrollEvent(true));
}else {
EventBus.getDefault().post(new HomeScrollEvent(false));
}
}
});
}

View File

@@ -8,6 +8,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@@ -15,6 +16,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.yizhuan.erban.R;
import com.yizhuan.erban.base.BaseFragment;
import com.yizhuan.erban.home.adapter.HomeDynamicAdapter;
import com.yizhuan.erban.home.event.HomeScrollEvent;
import com.yizhuan.xchat_android_core.home.bean.HomeDynamicInfo;
import com.yizhuan.xchat_android_core.home.event.HomeDynamicEvent;
import com.yizhuan.xchat_android_core.home.event.RefreshHomeDataEvent;
@@ -164,6 +166,11 @@ public class HomeDynamicFragment extends BaseFragment{
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onHomeScrollEvent(HomeScrollEvent event) {
recyclerView.setNestedScrollingEnabled(event.isNestScrollEnable());
}
@Override
public int getRootLayoutId() {

View File

@@ -12,6 +12,7 @@ import android.view.ViewGroup;
import com.yizhuan.erban.R;
import com.yizhuan.erban.base.BaseFragment;
import com.yizhuan.erban.home.adapter.HomePlayAdapter;
import com.yizhuan.erban.home.event.HomeScrollEvent;
import com.yizhuan.xchat_android_core.home.bean.HomePlayInfo;
import com.yizhuan.xchat_android_core.home.event.RefreshHomeDataEvent;
import com.yizhuan.xchat_android_core.home.model.GameHomeModel;
@@ -133,6 +134,10 @@ public class HomePlayFragment extends BaseFragment{
loadData();
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onHomeScrollEvent(HomeScrollEvent event) {
recyclerView.setNestedScrollingEnabled(event.isNestScrollEnable());
}
@Override
public int getRootLayoutId() {

View File

@@ -210,10 +210,10 @@
<!-- </com.google.android.material.appbar.AppBarLayout>-->
<com.yizhuan.erban.ui.widget.ContentWrapViewPager
<androidx.viewpager.widget.ViewPager
android:id="@+id/view_pager_bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="900dp"
app:layout_constraintBottom_toTopOf="@+id/view"
app:layout_constraintTop_toBottomOf="@id/fl_indicator"
/>