Exemplo n.º 1
0
        @Override
        public void handleMessage(Message msg) {
          switch (msg.what) {
            case IMPORT_STEP_READ_FILE:
            case IMPORT_STEP_READ_WPT_FILE:
            case IMPORT_STEP_STORE_CACHES:
              parseDialog.setMessage(res.getString(msg.arg1));
              parseDialog.setMax(msg.arg2);
              parseDialog.setProgress(0);
              break;

            case IMPORT_STEP_FINISHED:
              parseDialog.dismiss();
              fromActivity.helpDialog(
                  res.getString(R.string.gpx_import_title_caches_imported),
                  msg.arg1 + " " + res.getString(R.string.gpx_import_caches_imported));
              closeActivity();
              break;

            case IMPORT_STEP_FINISHED_WITH_ERROR:
              parseDialog.dismiss();
              fromActivity.helpDialog(
                  res.getString(R.string.gpx_import_title_caches_import_failed),
                  res.getString(msg.arg1) + "\n\n" + msg.obj);
              closeActivity();
              break;
          }
        }
Exemplo n.º 2
0
        @Override
        public void handleMessage(Message msg) {
          switch (msg.what) {
            case IMPORT_STEP_READ_FILE:
              Message cancelMessage = importStepHandler.obtainMessage(IMPORT_STEP_CANCEL);
              progress.show(
                  (Context) fromActivity,
                  res.getString(R.string.gpx_import_title_reading_file),
                  res.getString(msg.arg1),
                  ProgressDialog.STYLE_HORIZONTAL,
                  cancelMessage);
              progress.setMaxProgressAndReset(msg.arg2);
              break;

            case IMPORT_STEP_READ_WPT_FILE:
            case IMPORT_STEP_STORE_CACHES:
              progress.setMessage(res.getString(msg.arg1));
              progress.setMaxProgressAndReset(msg.arg2);
              break;

            case IMPORT_STEP_FINISHED:
              progress.dismiss();
              fromActivity.helpDialog(
                  res.getString(R.string.gpx_import_title_caches_imported),
                  msg.arg1 + " " + res.getString(R.string.gpx_import_caches_imported));
              closeActivity();
              break;

            case IMPORT_STEP_FINISHED_WITH_ERROR:
              progress.dismiss();
              fromActivity.helpDialog(
                  res.getString(R.string.gpx_import_title_caches_import_failed),
                  res.getString(msg.arg1) + "\n\n" + msg.obj);
              closeActivity();
              break;

            case IMPORT_STEP_CANCEL:
              progress.dismiss();
              progressHandler.cancel();
              break;

            case IMPORT_STEP_CANCELED:
              fromActivity.showShortToast(res.getString(R.string.gpx_import_canceled));
              closeActivity();
              break;
          }
        }
Exemplo n.º 3
0
  void logOffline(
      final IAbstractActivity fromActivity,
      final String log,
      Calendar date,
      final LogType logType) {
    if (logType == LogType.LOG_UNKNOWN) {
      return;
    }
    cgeoapplication app = (cgeoapplication) ((Activity) fromActivity).getApplication();
    final boolean status = app.saveLogOffline(geocode, date.getTime(), logType, log);

    Resources res = ((Activity) fromActivity).getResources();
    if (status) {
      fromActivity.showToast(res.getString(R.string.info_log_saved));
      app.saveVisitDate(geocode);
    } else {
      fromActivity.showToast(res.getString(R.string.err_log_post_failed));
    }
  }
Exemplo n.º 4
0
  public boolean logVisit(IAbstractActivity fromActivity) {
    if (StringUtils.isBlank(cacheId)) {
      fromActivity.showToast(
          ((Activity) fromActivity).getResources().getString(R.string.err_cannot_log_visit));
      return true;
    }
    Intent logVisitIntent = new Intent((Activity) fromActivity, VisitCacheActivity.class);
    logVisitIntent.putExtra(VisitCacheActivity.EXTRAS_ID, cacheId);
    logVisitIntent.putExtra(VisitCacheActivity.EXTRAS_GEOCODE, geocode.toUpperCase());
    logVisitIntent.putExtra(VisitCacheActivity.EXTRAS_FOUND, found);

    ((Activity) fromActivity).startActivity(logVisitIntent);

    return true;
  }
 public static boolean onMenuItemSelected(
     final MenuItem item,
     final cgGeo geo,
     final List<cgCache> caches,
     final IAbstractActivity activity,
     final SearchResult search) {
   CacheListApp app = (CacheListApp) getAppFromMenuItem(item, apps);
   if (app != null) {
     try {
       boolean result = app.invoke(geo, caches, (Activity) activity, search);
       activity.invalidateOptionsMenuCompatible();
       return result;
     } catch (Exception e) {
       Log.e("CacheListAppFactory.onMenuItemSelected: " + e.toString());
     }
   }
   return false;
 }