Skip to content

Commit

Permalink
Don't show context menu in a destroyed activity
Browse files Browse the repository at this point in the history
  • Loading branch information
kaaholst committed Aug 9, 2023
1 parent 720f466 commit 51283a8
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.util.Pair;
import androidx.fragment.app.FragmentManager;
import androidx.recyclerview.widget.RecyclerView;

import org.greenrobot.eventbus.Subscribe;
Expand Down Expand Up @@ -106,14 +107,17 @@ public static void show(BaseActivity activity, JiveItem item) {
}

public static void show(BaseActivity activity, JiveItem item, Action action) {
ContextMenu contextMenu = new ContextMenu();
FragmentManager fragmentManager = activity.getSupportFragmentManager();
if (!fragmentManager.isDestroyed()) {
ContextMenu contextMenu = new ContextMenu();

Bundle args = new Bundle();
args.putParcelable(JiveItem.class.getName(), item);
args.putParcelable(Action.class.getName(), action);
contextMenu.setArguments(args);
Bundle args = new Bundle();
args.putParcelable(JiveItem.class.getName(), item);
args.putParcelable(Action.class.getName(), action);
contextMenu.setArguments(args);

contextMenu.show(activity.getSupportFragmentManager(), TAG);
contextMenu.show(fragmentManager, TAG);
}
}

private void doItemContext(JiveItem item) {
Expand Down

0 comments on commit 51283a8

Please sign in to comment.