Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
CeuiLiSA committed Mar 5, 2021
1 parent 3ba068c commit 8684245
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 12 deletions.
18 changes: 14 additions & 4 deletions app/src/main/java/ceui/lisa/fragments/FragmentIllust.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,12 @@ public void onGlobalLayout() {
final int bottomCardHeight = baseBind.bottomBar.getHeight();
final int deltaY = slideMaxHeight - baseBind.bottomBar.getHeight();
sheetBehavior.setPeekHeight(bottomCardHeight, true);
baseBind.refreshLayout.setPadding(0, 0, 0, bottomCardHeight - DensityUtil.dp2px(16.0f));

//设置占位view大小
ViewGroup.LayoutParams headParams = baseBind.helperView.getLayoutParams();
headParams.height = bottomCardHeight - DensityUtil.dp2px(16.0f);
baseBind.helperView.setLayoutParams(headParams);

sheetBehavior.addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
Expand All @@ -247,7 +252,7 @@ public void onSlide(@NonNull View bottomSheet, float slideOffset) {

baseBind.recyclerView.setLayoutManager(new LinearLayoutManager(mContext));

recyHeight = baseBind.recyclerView.getHeight() - bottomCardHeight + DensityUtil.dp2px(16.0f);
recyHeight = baseBind.recyclerView.getHeight();
IllustAdapter adapter = new IllustAdapter(mContext, illust, recyHeight);
//设置图片加载成功的回调
adapter.setFeedBack(new FeedBack() {
Expand Down Expand Up @@ -481,8 +486,12 @@ public void onDestroy() {

@Override
public void onDestroyView() {
if (baseBind != null && baseBind.recyclerView != null) {
baseBind.recyclerView.setAdapter(null);
try {
if (baseBind != null && baseBind.recyclerView != null) {
baseBind.recyclerView.setAdapter(null);
}
} catch (Exception e) {
e.printStackTrace();
}
super.onDestroyView();
}
Expand All @@ -496,5 +505,6 @@ public void vertical() {
@Override
public SmartRefreshLayout getSmartRefreshLayout() {
return baseBind.refreshLayout;
// return null;
}
}
6 changes: 6 additions & 0 deletions app/src/main/java/ceui/lisa/helper/StaggeredtManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ protected int getVerticalSnapPreference() {
@Override
protected void onTargetFound(View targetView, RecyclerView.State state, Action action) {
try {
/*
* Android 判断一个 View 是否可见 getLocalVisibleRect(rect) 与 getGlobalVisibleRect(rect)
*
* https://www.bbsmax.com/A/ELPdow2d3a/
*/

if (!targetView.getGlobalVisibleRect(new Rect())) {
Rect rect = new Rect();
recyclerView.getGlobalVisibleRect(rect);
Expand Down
42 changes: 34 additions & 8 deletions app/src/main/res/layout/fragment_illust.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,46 @@
android:layout_height="match_parent"
android:layout_above="@+id/bottom_linear">

<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/refreshLayout"
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black">
android:background="@color/black"
android:layout_height="match_parent">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
<RelativeLayout
android:id="@+id/holder"
android:layout_above="@+id/helper_view"
android:clipChildren="false"
android:layout_width="match_parent"
android:layout_height="match_parent">

</androidx.recyclerview.widget.RecyclerView>
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/refreshLayout"
android:layout_centerInParent="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content">

</androidx.recyclerview.widget.RecyclerView>

</com.scwang.smartrefresh.layout.SmartRefreshLayout>

</RelativeLayout>

<View
android:layout_width="match_parent"
android:id="@+id/helper_view"
android:layout_alignParentBottom="true"
android:layout_height="1dp">

</View>

</RelativeLayout>


</com.scwang.smartrefresh.layout.SmartRefreshLayout>


<com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout
Expand Down

0 comments on commit 8684245

Please sign in to comment.