Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #2818 Make sure only one instance on the send tab dialog is alive #2823

Merged
merged 1 commit into from
Feb 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1028,11 +1028,10 @@ private void hideMenu() {
}

public void showSendTabDialog() {
if (mSendTabDialog == null) {
mSendTabDialog = new SendTabDialogWidget(getContext());
}
mSendTabDialog = SendTabDialogWidget.getInstance(getContext());
mSendTabDialog.mWidgetPlacement.parentHandle = mWidgetManager.getFocusedWindow().getHandle();
mSendTabDialog.setSessionId(mAttachedWindow.getSession().getId());
mSendTabDialog.setDelegate(null);
mSendTabDialog.show(UIWidget.REQUEST_FOCUS);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,10 @@ public void onAdd(TabView aSender) {

@Override
public void onSend(TabView aSender) {
if (mSendTabDialog == null) {
mSendTabDialog = new SendTabDialogWidget(getContext());
}
mSendTabDialog = SendTabDialogWidget.getInstance(getContext());
mSendTabDialog.setSessionId(aSender.getSession().getId());
mSendTabDialog.mWidgetPlacement.parentHandle = mWidgetManager.getFocusedWindow().getHandle();
mSendTabDialog.setDelegate(() -> show(REQUEST_FOCUS));
mSendTabDialog.show(UIWidget.REQUEST_FOCUS);

holder.tabView.reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,23 @@ public class SendTabDialogWidget extends SettingDialogWidget implements
DeviceConstellationObserver,
AccountObserver {

private static SendTabDialogWidget mSendTabDialog;

private SendTabsDisplayBinding mSendTabsDialogBinding;
private Accounts mAccounts;
private List<Device> mDevicesList = new ArrayList<>();
private WhatsNewWidget mWhatsNew;
private String mSessionId;

public SendTabDialogWidget(@NonNull Context aContext) {
public static SendTabDialogWidget getInstance(@NonNull Context context) {
if (mSendTabDialog == null) {
mSendTabDialog = new SendTabDialogWidget(context);
}

return mSendTabDialog;
}

private SendTabDialogWidget(@NonNull Context aContext) {
super(aContext);
}

Expand All @@ -58,6 +68,13 @@ protected void initialize(@NonNull Context aContext) {
mAccounts = ((VRBrowserApplication)getContext().getApplicationContext()).getAccounts();
}

@Override
public void releaseWidget() {
super.releaseWidget();

mSendTabDialog = null;
}

bluemarvin marked this conversation as resolved.
Show resolved Hide resolved
@Override
public void updateUI() {
super.updateUI();
Expand Down