Add ScrollToPositionDelegate and install in calls log fragment.

This commit is contained in:
Alex Hart
2023-04-18 10:45:24 -03:00
committed by Cody Henthorne
parent 6db71f4a39
commit 9081230286
5 changed files with 184 additions and 35 deletions

View File

@@ -5,6 +5,7 @@ import android.widget.TextView
import androidx.annotation.DrawableRes
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.view.doOnNextLayout
var View.visible: Boolean
get() {
@@ -31,6 +32,17 @@ inline fun View.doOnEachLayout(crossinline action: (view: View) -> Unit): View.O
return listener
}
/**
* OnLayout gets called prior to the view *actually* being laid out. This
* method will wait until the next layout and then post the action to happen
* afterwards.
*/
inline fun View.doAfterNextLayout(crossinline action: () -> Unit) {
doOnNextLayout {
post { action() }
}
}
fun TextView.setRelativeDrawables(
@DrawableRes start: Int = 0,
@DrawableRes top: Int = 0,

View File

@@ -45,6 +45,35 @@ public class PagingMappingAdapter<Key> extends MappingAdapter {
}
}
public boolean isAvailableAround(int position) {
int start = position - 10;
int end = position + 10;
if (isRangeAvailable(start, end)) {
return true;
} else {
getItem(position);
return false;
}
}
protected final boolean isRangeAvailable(int start, int end) {
if (end <= start || start >= getItemCount() || end <= 0) {
return false;
}
int clampedStart = Math.max(0, start);
int clampedEnd = Math.min(getItemCount(), end);
for (int i = clampedStart; i < clampedEnd; i++) {
if (super.getItem(i) == null) {
return false;
}
}
return true;
}
@Override
public int getItemViewType(int position) {
MappingModel<?> item = getItem(position);