mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-19 08:09:12 +01:00
Add ScrollToPositionDelegate and install in calls log fragment.
This commit is contained in:
committed by
Cody Henthorne
parent
6db71f4a39
commit
9081230286
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user