Keep popup menu on update

pull/187/head
M66B 4 years ago
parent f6ce93d564
commit c4d85ab121

@ -557,16 +557,11 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
holder.unwire();
TupleAccountEx account = items.get(position);
holder.bindTo(account);
holder.powner.recreate(account == null ? null : account.id);
holder.unwire();
holder.bindTo(account);
holder.wire();
}
@Override
public void onViewDetachedFromWindow(@NonNull ViewHolder holder) {
holder.powner.recreate();
}
}

@ -320,14 +320,10 @@ public class AdapterAnswer extends RecyclerView.Adapter<AdapterAnswer.ViewHolder
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
EntityAnswer answer = items.get(position);
holder.powner.recreate(answer == null ? null : answer.id);
holder.unwire();
holder.bindTo(answer);
holder.wire();
}
@Override
public void onViewDetachedFromWindow(@NonNull ViewHolder holder) {
holder.powner.recreate();
}
}

@ -247,16 +247,11 @@ public class AdapterCertificate extends RecyclerView.Adapter<AdapterCertificate.
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
holder.unwire();
EntityCertificate certificate = items.get(position);
holder.bindTo(certificate);
holder.powner.recreate(certificate == null ? null : certificate.id);
holder.unwire();
holder.bindTo(certificate);
holder.wire();
}
@Override
public void onViewDetachedFromWindow(@NonNull ViewHolder holder) {
holder.powner.recreate();
}
}

@ -466,17 +466,14 @@ public class AdapterContact extends RecyclerView.Adapter<AdapterContact.ViewHold
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
holder.unwire();
TupleContactEx contact = selected.get(position);
holder.powner.recreate(contact == null ? null : contact.id);
holder.unwire();
holder.bindTo(contact);
holder.wire();
}
@Override
public void onViewDetachedFromWindow(@NonNull ViewHolder holder) {
holder.powner.recreate();
}
public static class FragmentEditName extends FragmentDialogBase {
@NonNull
@Override

@ -1146,19 +1146,14 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
holder.unwire();
TupleFolderEx folder = items.get(position);
holder.bindTo(folder);
holder.powner.recreate(folder == null ? null : folder.id);
holder.unwire();
holder.bindTo(folder);
holder.wire();
}
@Override
public void onViewDetachedFromWindow(@NonNull ViewHolder holder) {
holder.powner.recreate();
}
interface IFolderSelectedListener {
void onFolderSelected(TupleFolderEx folder);
}

@ -467,16 +467,11 @@ public class AdapterIdentity extends RecyclerView.Adapter<AdapterIdentity.ViewHo
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
holder.unwire();
TupleIdentityEx identity = items.get(position);
holder.bindTo(identity);
holder.powner.recreate(identity == null ? null : identity.id);
holder.unwire();
holder.bindTo(identity);
holder.wire();
}
@Override
public void onViewDetachedFromWindow(@NonNull ViewHolder holder) {
holder.powner.recreate();
}
}

@ -5779,6 +5779,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private void _onBindViewHolder(@NonNull ViewHolder holder, int position) {
TupleMessageEx message = differ.getItem(position);
holder.powner.recreate(message == null ? null : message.id);
if (message == null || context == null)
return;
@ -5837,7 +5838,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
@Override
public void onViewDetachedFromWindow(@NonNull ViewHolder holder) {
holder.cowner.stop();
holder.powner.recreate();
}
@Override

@ -349,16 +349,11 @@ public class AdapterOperation extends RecyclerView.Adapter<AdapterOperation.View
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
holder.unwire();
TupleOperationEx operation = items.get(position);
holder.bindTo(operation);
holder.powner.recreate(operation == null ? null : operation.id);
holder.unwire();
holder.bindTo(operation);
holder.wire();
}
@Override
public void onViewDetachedFromWindow(@NonNull ViewHolder holder) {
holder.powner.recreate();
}
}

@ -533,14 +533,11 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
holder.unwire();
TupleRuleEx rule = selected.get(position);
holder.powner.recreate(rule == null ? null : rule.id);
holder.unwire();
holder.bindTo(rule);
holder.wire();
}
@Override
public void onViewDetachedFromWindow(@NonNull ViewHolder holder) {
holder.powner.recreate();
}
}

@ -26,10 +26,13 @@ import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LifecycleRegistry;
import androidx.lifecycle.OnLifecycleEvent;
import java.util.Objects;
// This class can be used as an externally controlled standalone or child life cycle owner
public class TwoStateOwner implements LifecycleOwner {
private String name;
private Object condition;
private LifecycleRegistry registry;
// https://developer.android.com/topic/libraries/architecture/lifecycle#lc
@ -87,6 +90,13 @@ public class TwoStateOwner implements LifecycleOwner {
create();
}
void recreate(Object condition) {
if (!Objects.equals(this.condition, condition)) {
this.condition = condition;
recreate();
}
}
void destroy() {
Lifecycle.State state = registry.getCurrentState();
if (!state.equals(Lifecycle.State.DESTROYED)) {

Loading…
Cancel
Save