update RecyclerView utils

androidx
Ztiany 5 years ago
parent 6ff17b6930
commit add179c578
  1. 1
      lib_base/src/main/java/com/android/base/widget/recyclerview/DividerItemDecoration.java
  2. 40
      lib_base/src/main/java/com/android/base/widget/recyclerview/MarginDecoration.java
  3. 33
      lib_base/src/main/java/com/android/base/widget/recyclerview/MarginDecoration.kt
  4. 3
      lib_base/src/main/java/com/android/base/widget/recyclerview/OnRecyclerViewScrollBottomListener.java

@ -174,4 +174,5 @@ public class DividerItemDecoration extends RecyclerView.ItemDecoration {
outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
}
}
}

@ -1,40 +0,0 @@
package com.android.base.widget.recyclerview;
import android.graphics.Rect;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
public class MarginDecoration extends RecyclerView.ItemDecoration {
private int mTop;
private int mLeft;
private int mRight;
private int mBottom;
public MarginDecoration(int left, int top, int right, int bottom) {
mTop = top;
mBottom = bottom;
mRight = right;
mLeft = left;
}
public MarginDecoration(int margin) {
mTop = margin;
mBottom = margin;
mRight = margin;
mLeft = margin;
}
@Override
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
outRect.top = mTop;
outRect.bottom = mBottom;
outRect.left = mLeft;
outRect.right = mRight;
}
}

@ -0,0 +1,33 @@
package com.android.base.widget.recyclerview
import android.graphics.Rect
import android.view.View
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.ItemDecoration
import androidx.recyclerview.widget.RecyclerView.State
class MarginDecoration : ItemDecoration {
private var top: Int
private var left: Int
private var right: Int
private var bottom: Int
constructor(left: Int = 0, top: Int = 0, right: Int = 0, bottom: Int = 0) {
this.top = top
this.bottom = bottom
this.right = right
this.left = left
}
constructor(margin: Int) : this(margin, margin, margin, margin)
override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: State) {
super.getItemOffsets(outRect, view, parent, state)
outRect.top = top
outRect.bottom = bottom
outRect.left = left
outRect.right = right
}
}

@ -85,16 +85,13 @@ public abstract class OnRecyclerViewScrollBottomListener extends RecyclerView.On
return max;
}
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
}
protected abstract void onBottom();
protected abstract void onLeaveBottom();
}
Loading…
Cancel
Save