mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 02:10:44 +01:00
Remove LifecycleViewHolder / Adapter.
This commit is contained in:
committed by
Cody Henthorne
parent
12ec0ca84c
commit
0ab66f81be
@@ -1,19 +0,0 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public abstract class LifecycleRecyclerAdapter<VH extends LifecycleViewHolder> extends RecyclerView.Adapter<VH> {
|
||||
|
||||
@Override
|
||||
public void onViewAttachedToWindow(@NonNull VH holder) {
|
||||
super.onViewAttachedToWindow(holder);
|
||||
holder.onAttachedToWindow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewDetachedFromWindow(@NonNull VH holder) {
|
||||
super.onViewDetachedFromWindow(holder);
|
||||
holder.onDetachedFromWindow();
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.LifecycleRegistry;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public abstract class LifecycleViewHolder extends RecyclerView.ViewHolder implements LifecycleOwner {
|
||||
|
||||
private final LifecycleRegistry lifecycleRegistry;
|
||||
|
||||
public LifecycleViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
|
||||
lifecycleRegistry = new LifecycleRegistry(this);
|
||||
}
|
||||
|
||||
void onAttachedToWindow() {
|
||||
lifecycleRegistry.setCurrentState(Lifecycle.State.RESUMED);
|
||||
}
|
||||
|
||||
void onDetachedFromWindow() {
|
||||
lifecycleRegistry.setCurrentState(Lifecycle.State.DESTROYED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Lifecycle getLifecycle() {
|
||||
return lifecycleRegistry;
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,12 @@ import android.view.View;
|
||||
|
||||
import androidx.annotation.IdRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class MappingViewHolder<Model> extends LifecycleViewHolder implements LifecycleOwner {
|
||||
public abstract class MappingViewHolder<Model> extends RecyclerView.ViewHolder {
|
||||
|
||||
protected final Context context;
|
||||
protected final List<Object> payload;
|
||||
@@ -29,6 +29,12 @@ public abstract class MappingViewHolder<Model> extends LifecycleViewHolder imple
|
||||
return itemView.getContext();
|
||||
}
|
||||
|
||||
public void onAttachedToWindow() {
|
||||
}
|
||||
|
||||
public void onDetachedFromWindow() {
|
||||
}
|
||||
|
||||
public abstract void bind(@NonNull Model model);
|
||||
|
||||
public void setPayload(@NonNull List<Object> payload) {
|
||||
|
||||
Reference in New Issue
Block a user