@Override protected void onPostExecute(Boolean result) { if (null != activity) { progress.dismiss(); if (result) { ActivityMixin.showToast( activity, getName() + ' ' + getString(R.string.export_exportedto) + ": " + exportFile.toString()); if (Settings.getShareAfterExport()) { Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(exportFile)); shareIntent.setType("application/xml"); activity.startActivity( Intent.createChooser(shareIntent, getString(R.string.export_gpx_to))); } } else { ActivityMixin.showToast(activity, getString(R.string.export_failed)); } } }
@Override protected void onPostExecuteInternal(Boolean result) { if (null != activity) { if (result) { // if (onlyNew) { // // update last export time in settings when doing it ourself // (currently we use the date check from gc.com) // } ActivityMixin.showToast( activity, getName() + ' ' + getString(R.string.export_exportedto) + ": " + exportFile.toString()); if (upload) { ActivityMixin.showToast(activity, getString(R.string.export_fieldnotes_upload_success)); } } else { ActivityMixin.showToast(activity, getString(R.string.export_failed)); } } }
@Override public boolean invoke( final cgGeo geo, final Activity activity, final Resources res, final cgCache cache, final Long searchId, final cgWaypoint waypoint, final Double latitude, final Double longitude) { if (activity == null) { return false; } boolean navigationResult = false; if (latitude != null && longitude != null) { navigationResult = navigateToCoordinates(geo, activity, latitude, longitude); } else if (waypoint != null) { navigationResult = navigateToCoordinates(geo, activity, waypoint.latitude, waypoint.longitude); } else if (cache != null) { navigationResult = navigateToCoordinates(geo, activity, cache.latitude, cache.longitude); } if (!navigationResult) { if (res != null) { ActivityMixin.showToast(activity, res.getString(R.string.err_navigation_no)); } return false; } return true; }
/** * Starts the default navigation tool if correctly set and installed or the compass app as default * fallback. */ public static void startDefaultNavigationApplication( final int defaultNavigation, final Activity activity, final Waypoint waypoint) { if (waypoint == null || waypoint.getCoords() == null) { ActivityMixin.showToast( activity, CgeoApplication.getInstance().getString(R.string.err_location_unknown)); return; } navigateWaypoint(activity, waypoint, getDefaultNavigationApplication(defaultNavigation)); }
/** * Starts the default navigation tool if correctly set and installed or the compass app as default * fallback. */ public static void startDefaultNavigationApplication( final int defaultNavigation, final Activity activity, final Geopoint destination) { if (destination == null) { ActivityMixin.showToast( activity, CgeoApplication.getInstance().getString(R.string.err_location_unknown)); return; } navigateGeopoint(activity, destination, getDefaultNavigationApplication(defaultNavigation)); }
/** * Starts the default navigation tool if correctly set and installed or the compass app as default * fallback. */ public static void startDefaultNavigationApplication( final int defaultNavigation, final Activity activity, final Geocache cache) { if (cache == null || cache.getCoords() == null) { ActivityMixin.showToast( activity, CgeoApplication.getInstance().getString(R.string.err_location_unknown)); return; } navigateCache(activity, cache, getDefaultNavigationApplication(defaultNavigation)); }
@Override public void onClick(final View view) { final Activity activity = AbstractCredentialsAuthorizationActivity.this; try { activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getCreateAccountUrl()))); } catch (final ActivityNotFoundException e) { Log.e("Cannot find suitable activity", e); ActivityMixin.showToast(activity, R.string.err_application_no); } }
private void checkCredentials(final String username, final String password) { final String nam = StringUtils.defaultString(username); final String pwd = StringUtils.defaultString(password); if (StringUtils.isBlank(username) || StringUtils.isBlank(password)) { ActivityMixin.showToast(this, R.string.err_missing_auth); return; } final Credentials credentials = new Credentials(nam, pwd); final AbstractCredentialsAuthorizationActivity authorizationActivity = this; final ProgressDialog loginDialog = ProgressDialog.show( authorizationActivity, res.getString(R.string.init_login_popup), getAuthDialogWait(), true); loginDialog.setCancelable(false); AppObservable.bindActivity( authorizationActivity, Observable.defer( new Func0<Observable<StatusCode>>() { @Override public Observable<StatusCode> call() { return Observable.just(checkCredentials(credentials)); } })) .subscribeOn(AndroidRxUtils.networkScheduler) .subscribe( new Action1<StatusCode>() { @Override public void call(StatusCode statusCode) { loginDialog.dismiss(); if (statusCode == StatusCode.NO_ERROR) { setCredentials(credentials); showToast(getAuthDialogCompleted()); setResult(RESULT_OK); finish(); } else { Dialogs.message( authorizationActivity, R.string.init_login_popup, res.getString( R.string.init_login_popup_failed_reason, statusCode.getErrorString(res))); checkButton.setText(getAuthCheckAgain()); checkButton.setOnClickListener(new CheckListener()); checkButton.setEnabled(true); } } }); }
@Override protected void onPostExecuteInternal(Boolean result) { if (null != activity) { if (result) { Settings.setFieldnoteExportDate(System.currentTimeMillis()); ActivityMixin.showToast( activity, getName() + ' ' + getString(R.string.export_exportedto) + ": " + exportFile.toString()); if (upload) { ActivityMixin.showToast(activity, getString(R.string.export_fieldnotes_upload_success)); } } else { ActivityMixin.showToast(activity, getString(R.string.export_failed)); } } }
public final void showToast(String text) { ActivityMixin.showToast(this, text); }
/** * Show a long toast message to the user. This can be called from any thread. * * @param activity the activity the user is facing * @param resId the message */ public static void showToast(final Activity activity, @StringRes final int resId) { showToast(activity, activity.getString(resId)); }