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

[FIX] RankStatsFragment ISE fix candidate #679

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,11 @@ public void handleDialog(final int dialogId) {
BackupRunnable backupRunnable = new BackupRunnable(this.getActivity(), ListFragment.lameStatic.executorService, true);
Future<?> bFuture = ListFragment.lameStatic.executorService.submit(backupRunnable);
} catch (IllegalArgumentException e) {
WiGLEToast.showOverFragment(this.getActivity(), R.string.backup_in_progress, getString(R.string.duplicate_job));
final FragmentActivity a = getActivity();
if (null != a) {
WiGLEToast.showOverFragment(a, R.string.backup_in_progress,
a.getResources().getString(R.string.duplicate_job));
}
}
break;
}
Expand Down Expand Up @@ -526,15 +530,15 @@ public void handleDialog(final int dialogId) {
if (!exportM8bFile()) {
Logging.warn("Failed to export m8b.");
WiGLEToast.showOverFragment(getActivity(), R.string.error_general,
getString(R.string.m8b_failed));
getActivity().getResources().getString(R.string.m8b_failed));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason to be more confident about this getActivity not returning null (contra :466)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a good one.

}
break;
}
case EXPORT_GPX_DIALOG: {
if (!exportRouteGpxFile()) {
Logging.warn("Failed to export gpx.");
WiGLEToast.showOverFragment(getActivity(), R.string.error_general,
getString(R.string.gpx_failed));
getActivity().getResources().getString(R.string.gpx_failed));
}
break;
}
Expand Down Expand Up @@ -573,7 +577,11 @@ private boolean exportM8bFile() {
MagicEightBallRunnable m8bRunnable = new MagicEightBallRunnable(this.getActivity(), ListFragment.lameStatic.executorService, true, totalDbNets);
Future<?> mFuture = ListFragment.lameStatic.executorService.submit(m8bRunnable);
} catch (IllegalArgumentException e) {
WiGLEToast.showOverFragment(this.getActivity(), R.string.m8b_failed, getString(R.string.duplicate_job));
final FragmentActivity a = getActivity();
if (null != a) {
WiGLEToast.showOverFragment(a, R.string.m8b_failed,
a.getResources().getString(R.string.duplicate_job));
}
}
return true;
}
Expand All @@ -585,12 +593,18 @@ private boolean exportRouteGpxFile() {
GpxExportRunnable gpxRunnable = new GpxExportRunnable(this.getActivity(), ListFragment.lameStatic.executorService, true, totalRoutePoints);
Future<?> gFuture = ListFragment.lameStatic.executorService.submit(gpxRunnable);
} catch (IllegalArgumentException e) {
WiGLEToast.showOverFragment(this.getActivity(), R.string.gpx_failed, getString(R.string.duplicate_job));
final FragmentActivity a = getActivity();
if (null != a) {
WiGLEToast.showOverFragment(a, R.string.gpx_failed, a.getResources().getString(R.string.duplicate_job));
}
}
} else {
Logging.error("no points to create route");
WiGLEToast.showOverFragment(getActivity(), R.string.gpx_failed,
getString(R.string.gpx_no_points));
final FragmentActivity a = getActivity();
if (null != a) {
WiGLEToast.showOverFragment(a, R.string.gpx_failed,
a.getResources().getString(R.string.gpx_no_points));
}
//NO POINTS
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ private boolean exportRouteGpxFile(long runId) {
es.submit(new GpxExportRunnable(this, true, totalRoutePoints, runId));
} catch (IllegalArgumentException e) {
Logging.error("failed to submit job: ", e);
WiGLEToast.showOverFragment(this, R.string.export_gpx, getString(R.string.duplicate_job));
WiGLEToast.showOverFragment(this, R.string.export_gpx,
getResources().getString(R.string.duplicate_job));
return false;
}
} else {
Expand All @@ -205,7 +206,7 @@ private boolean exportRouteGpxFile(long runId) {
} else {
Logging.error("no points to create route");
WiGLEToast.showOverFragment(this, R.string.gpx_failed,
getString(R.string.gpx_no_points));
getResources().getString(R.string.gpx_no_points));
//NO POINTS
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.core.view.MenuItemCompat;
import androidx.fragment.app.FragmentActivity;

import android.util.Base64;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -220,7 +221,11 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Logging.error("security exception oncreateview map: " + ex, ex);
}
} else {
WiGLEToast.showOverFragment(getActivity(), R.string.fatal_pre_message, getString(R.string.map_needs_playservice));
final FragmentActivity fa = getActivity();
if (null != fa) {
WiGLEToast.showOverFragment(fa, R.string.fatal_pre_message,
fa.getResources().getString(R.string.map_needs_playservice));
}
}
MapsInitializer.initialize(a);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ public void onAuthenticationRequired() {
public void onTaskCompleted() {
stopAnimation();
if (userDownloadFailed) {
WiGLEToast.showOverFragment(a, R.string.upload_failed, getString(R.string.dl_failed));
if (null != a) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think a was already nullchecked at :113 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quite right - I was being cautious because it's in a callback, but the reference is final, it'll be fine.

WiGLEToast.showOverFragment(a, R.string.upload_failed,
a.getResources().getString(R.string.dl_failed));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void run() {
} else {
Logging.error("null or empty DB result in DB backup postExec");
WiGLEToast.showOverFragment(activity, R.string.error_general,
activity.getString(R.string.error_general));
activity.getResources().getString(R.string.error_general));
}
} else {
Logging.error("Null result in postExecute - unable to share sqlite backup.");
Expand Down