Skip to content

Commit

Permalink
move getLocalIpAddress off UI Thread
Browse files Browse the repository at this point in the history
  • Loading branch information
TuxPaper committed Sep 12, 2023
1 parent b37f0a3 commit 148e4f2
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ public class PrefFragmentHandlerCore

private static final String TAG = "PrefFragHandlerCore";

private String localIpAddress;

public PrefFragmentHandlerCore(SessionActivity activity, Fragment fragment) {
super(activity, fragment);
}
Expand Down Expand Up @@ -218,8 +220,7 @@ public boolean onPreferenceTreeClick(@NonNull final Preference preference) {
case KEY_RACCESS_SHOWQR: {
OffThread.runOffUIThread(this::saveRemoteAccessPrefs);
try {
String url = "biglybt://remote/profile?h="
+ NetworkState.getLocalIpAddress() + "&p="
String url = "biglybt://remote/profile?h=" + localIpAddress + "&p="
+ RPC.LOCAL_BIGLYBT_PORT;
boolean reqPW = ds.getBoolean(KEY_RACCESS_REQPW, false);
if (reqPW) {
Expand All @@ -229,7 +230,7 @@ public boolean onPreferenceTreeClick(@NonNull final Preference preference) {
url += "&reqPW=1";
}
}
String urlWebUI = "http://" + NetworkState.getLocalIpAddress() + ":"
String urlWebUI = "http://" + localIpAddress + ":"
+ RPC.LOCAL_BIGLYBT_PORT;
DialogFragmentRemoteAccessQR.open(
activity.getSupportFragmentManager(), url, urlWebUI);
Expand Down Expand Up @@ -343,6 +344,11 @@ public void updateWidgetsOffUI() {
// listener stuff
BiglyCoreUtils.waitForCore();

final String screenKey = preferenceScreen.getKey();
if (KEY_RACCESS_SCREEN.equals(screenKey)) {
localIpAddress = NetworkState.getLocalIpAddress();
}

final Preference prefSavePath = findPreference(KEY_SAVE_PATH);
if (prefSavePath != null) {
String sDir = ds.getString(KEY_SESSION_DOWNLOAD_PATH);
Expand Down Expand Up @@ -375,7 +381,7 @@ public void updateWidgetsOffUI() {
}
Bundle extras = prefRemAccessScreen.getExtras();

extras.putCharSequence("summary", s);
extras.putCharSequence("summary", s);
}
}

Expand Down Expand Up @@ -603,7 +609,7 @@ private void updateRemoteAccessWidgets() {
if (prefAllowLANAccess != null) {
prefAllowLANAccess.setChecked(allowLANAccess);
prefAllowLANAccess.setSummaryOn(
NetworkState.getLocalIpAddress() + ":" + RPC.LOCAL_BIGLYBT_PORT);
localIpAddress + ":" + RPC.LOCAL_BIGLYBT_PORT);
}

TwoStatePreference prefReqPW = (TwoStatePreference) findPreference(
Expand Down

0 comments on commit 148e4f2

Please sign in to comment.