Skip to content

Commit d6ab20c

Browse files
committed
Make sure to recreate dev actions for dev menu if front activity changes
1 parent af527c9 commit d6ab20c

File tree

3 files changed

+7
-78
lines changed

3 files changed

+7
-78
lines changed

native/NativeSampleApps/RestExplorer/src/com/salesforce/samples/restexplorer/ExplorerActivity.java

-12
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ public class ExplorerActivity extends SalesforceActivity {
8585
private RestClient client;
8686
private TextView resultText;
8787
private TabHost tabHost;
88-
private LogoutDialogFragment logoutConfirmationDialog;
8988

9089
// Use for objectId fields auto-complete.
9190
private TreeSet<String> knownIds = new TreeSet<String>();
@@ -129,8 +128,6 @@ protected void onCreate(Bundle savedInstanceState) {
129128
// Makes the result area scrollable.
130129
resultText = (TextView) findViewById(R.id.result_text);
131130
resultText.setMovementMethod(new ScrollingMovementMethod());
132-
logoutConfirmationDialog = new LogoutDialogFragment();
133-
134131
((RestExplorerApp.RestExplorerSDKManager) RestExplorerApp.RestExplorerSDKManager.getInstance())
135132
.addDevAction(this, "Export Credentials to Clipboard", this::exportCredentials);
136133
}
@@ -140,15 +137,6 @@ public void onResume(RestClient client) {
140137
this.client = client;
141138
}
142139

143-
/**
144-
* Returns the logout dialog fragment (used mainly by tests).
145-
*
146-
* @return Logout dialog fragment.
147-
*/
148-
public LogoutDialogFragment getLogoutConfirmationDialog() {
149-
return logoutConfirmationDialog;
150-
}
151-
152140
private void addTab(String tag, int titleId, int tabId) {
153141
tabHost.addTab(tabHost.newTabSpec(tag).setIndicator(getString(titleId))
154142
.setContent(tabId));

native/NativeSampleApps/RestExplorer/src/com/salesforce/samples/restexplorer/LogoutDialogFragment.java

-61
This file was deleted.

native/NativeSampleApps/RestExplorer/src/com/salesforce/samples/restexplorer/RestExplorerApp.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public void onCreate() {
7474
}
7575

7676
static class RestExplorerSDKManager extends SalesforceSDKManager {
77+
Activity frontActivityForDevActions;
7778
Map<String, DevActionHandler> devActions;
7879

7980
/**
@@ -109,6 +110,11 @@ public static void initNative(
109110
public Map<String, DevActionHandler> getDevActions(
110111
@NonNull Activity frontActivity
111112
) {
113+
if (frontActivityForDevActions != frontActivity) {
114+
devActions = null;
115+
frontActivityForDevActions = frontActivity;
116+
}
117+
112118
if (devActions == null) {
113119
devActions = super.getDevActions(frontActivity);
114120
}
@@ -117,11 +123,7 @@ public Map<String, DevActionHandler> getDevActions(
117123
}
118124

119125
public void addDevAction(Activity frontActivity, String name, DevActionHandler handler) {
120-
if (devActions == null) {
121-
devActions = super.getDevActions(frontActivity);
122-
}
123-
124-
devActions.put(name, handler);
126+
getDevActions(frontActivity).put(name, handler);
125127
}
126128
}
127129
}

0 commit comments

Comments
 (0)