コード例 #1
0
 public static void showProgressDialog(Context context) {
   dialog = new ProgressDialog(context);
   dialog.setIcon(R.drawable.app_icon);
   dialog.setTitle(R.string.app_name);
   dialog.setMessage("请等候,数据加载中……");
   dialog.show();
 }
コード例 #2
0
ファイル: myUIWarn.java プロジェクト: RunCross/APPAIAI
 public static ProgressDialog wait(Context context, String msg) {
   ProgressDialog dialog = new ProgressDialog(context);
   // 设置进度条风格,风格为圆形,旋转�?
   dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
   // 设置ProgressDialog 标题
   dialog.setTitle(msg);
   // 设置ProgressDialog 提示信息
   // dialog.setMessage("圆形进度�?);
   // 设置ProgressDialog 标题图标
   dialog.setIcon(android.R.drawable.ic_dialog_map);
   // 设置ProgressDialog 的一个Button
   /*
    * dialog.setButton("确定", new ProgressDialog.OnClickListener(){
    *
    * @Override public void onClick(DialogInterface dialog, int which) {
    *
    * } });
    */
   // 设置ProgressDialog 的进度条是否不明�?
   dialog.setIndeterminate(false);
   // 设置ProgressDialog 是否可以按�?回按键取�?
   dialog.setCancelable(true);
   // 显示
   dialog.show();
   return dialog;
 }
コード例 #3
0
ファイル: DialogShowActivity.java プロジェクト: ykzyj/mycode
 private void click08() {
   m_count = 0;
   // 创建ProgressDialog对象
   m_pDialog = new ProgressDialog(DialogShowActivity.this);
   // 设置标题
   m_pDialog.setTitle("圆形进度条信息");
   // 设置进度条风格
   m_pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
   // 设置提示信息
   m_pDialog.setMessage("这是一个圆形进度条");
   // 设置标题图标
   m_pDialog.setIcon(R.drawable.info32);
   // 设置进度条是否不明确
   m_pDialog.setIndeterminate(false);
   // 是否可以按下退回键取消
   m_pDialog.setCancelable(true);
   // 展示ProgressDialog 对象
   new Thread() {
     public void run() {
       try {
         while (m_count <= 100) {
           // 由线程来控制进度
           m_pDialog.setProgress(m_count++);
           Thread.sleep(100);
         }
         m_pDialog.cancel();
       } catch (Exception e) {
         m_pDialog.cancel();
       }
     }
   }.start();
   m_pDialog.show();
 }
コード例 #4
0
ファイル: DialogShowActivity.java プロジェクト: ykzyj/mycode
 private void click07() {
   // TODO Auto-generated method stub
   m_count = 0;
   // 创建ProgressDialog对象
   m_pDialog = new ProgressDialog(DialogShowActivity.this);
   // 设置标题
   m_pDialog.setTitle("长进度条信息");
   // 设置进度条风格
   m_pDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
   // 设置提示信息
   // m_pDialog.setMessage("这是一个长进度条");
   // 设置标题图标
   m_pDialog.setIcon(R.drawable.info32);
   // 设置进度条是否不明确
   m_pDialog.setIndeterminate(false);
   // 是否可以按下退回键取消
   m_pDialog.setCancelable(true);
   // 开启线程,显示进度
   new Thread() {
     public void run() {
       try {
         while (m_count <= 100) {
           // 由线程来控制进度
           m_pDialog.setProgress(m_count++);
           Thread.sleep(100);
         }
         m_pDialog.cancel();
       } catch (Exception e) {
         m_pDialog.cancel();
       }
     }
   }.start();
   // 展示ProgressDialog 对象
   m_pDialog.show();
 }
コード例 #5
0
  /**
   * Attaches the activity to the ASync task.
   *
   * @param activity The activity to which results will be sent on completion of this task.
   */
  public void attachToActivity(PuzzleFragmentActivity activity) {
    if (activity.equals(this.mActivity) && mProgressDialog != null && mProgressDialog.isShowing()) {
      // The activity is already attached to this task.
      return;
    }

    if (DEBUG_GRID_GAME_FILE_CONVERTER) {
      Log.i(TAG, "Attach to activity");
    }

    // Remember the activity that started this task.
    this.mActivity = activity;

    int maxProgressCounter = 0;

    // Determine how much (old) game files and preview files have to be
    // deleted.
    mGameFilesToBeDeleted = getGameFilesToBeDeleted();
    maxProgressCounter += (mGameFilesToBeDeleted == null ? 0 : mGameFilesToBeDeleted.length);

    // Determine how much usage log files have to be deleted.
    mUsageLogFilesToBeDeleted = getUsageLogFilesToBeDeleted();
    maxProgressCounter +=
        (mUsageLogFilesToBeDeleted == null ? 0 : mUsageLogFilesToBeDeleted.length);

    // Determine how many solving attempts in the database have to be
    // converted.
    if ((solvingAttemptIds = new SolvingAttemptDatabaseAdapter().getAllToBeConverted()) != null) {
      maxProgressCounter += solvingAttemptIds.size();
    }

    if (maxProgressCounter > 0) {
      // Build the dialog
      mProgressDialog = new ProgressDialog(mActivity);
      mProgressDialog.setTitle(R.string.dialog_converting_saved_games_title);
      mProgressDialog.setMessage(
          mActivity
              .getResources()
              .getString(
                  (mCurrentVersion < 369
                      ? R.string.dialog_converting_cleanup_v1_message
                      : R.string.dialog_converting_saved_games_message)));
      mProgressDialog.setIcon(android.R.drawable.ic_dialog_info);
      mProgressDialog.setIndeterminate(false);
      mProgressDialog.setCancelable(false);
      mProgressDialog.setMax(maxProgressCounter);

      // Set style of dialog.
      mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);

      // Show the dialog
      mProgressDialog.show();
    }

    // Initialize conversion results.
    mGridDefinitions = new ArrayList<String>();
  }
コード例 #6
0
  /**
   * create dialog for progress bar
   *
   * @param drawable
   */
  @Deprecated
  public Dialog onCreateDialog(int drawable, String title, String message, boolean cancel) {
    progressDialog.setIcon(drawable);
    progressDialog.setTitle(title);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    progressDialog.setMessage(message);
    progressDialog.setCancelable(cancel);

    return progressDialog;
  }
コード例 #7
0
 /**
  * @param msg 提示信息
  * @return
  */
 public ProgressDialog initProgressDialog(String msg) {
   pd_waiting = new ProgressDialog(this);
   pd_waiting.setProgressStyle(ProgressDialog.STYLE_SPINNER);
   pd_waiting.setTitle("提示");
   pd_waiting.setMessage(msg);
   pd_waiting.setIcon(R.drawable.icon_workdemo);
   pd_waiting.setIndeterminate(false);
   pd_waiting.setCancelable(false);
   pd_waiting.setCanceledOnTouchOutside(false);
   return pd_waiting;
 }
コード例 #8
0
  private TasksXmlExporter(
      final Context context,
      final boolean isService,
      final Runnable runAfterExport,
      File backupDirectoryOverride) {
    this.context = context;
    this.exportCount = 0;
    this.backupDirectory =
        backupDirectoryOverride == null
            ? BackupConstants.defaultExportDirectory()
            : backupDirectoryOverride;

    handler = new Handler();
    progressDialog = new ProgressDialog(context);
    if (!isService) {
      progressDialog.setIcon(android.R.drawable.ic_dialog_info);
      progressDialog.setTitle(R.string.export_progress_title);
      progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
      progressDialog.setProgress(0);
      progressDialog.setCancelable(false);
      progressDialog.setIndeterminate(false);
      progressDialog.show();
      if (context instanceof Activity) progressDialog.setOwnerActivity((Activity) context);
    }

    new Thread(
            new Runnable() {
              @Override
              public void run() {
                try {
                  String output = setupFile(backupDirectory, isService);
                  int tasks = taskService.countTasks();

                  if (tasks > 0) doTasksExport(output);

                  Preferences.setLong(BackupPreferences.PREF_BACKUP_LAST_DATE, DateUtilities.now());
                  Preferences.setString(BackupPreferences.PREF_BACKUP_LAST_ERROR, null);

                  if (!isService) onFinishExport(output);
                } catch (IOException e) {
                  if (!isService)
                    exceptionService.displayAndReportError(
                        context, context.getString(R.string.backup_TXI_error), e);
                  else {
                    exceptionService.reportError("background-backup", e); // $NON-NLS-1$
                    Preferences.setString(BackupPreferences.PREF_BACKUP_LAST_ERROR, e.toString());
                  }
                } finally {
                  if (runAfterExport != null) runAfterExport.run();
                }
              }
            })
        .start();
  }
コード例 #9
0
  /** Sets up the look and actions for the progress dialog while the GPS is searching. */
  private void setupLocationDialog() {
    Collect.getInstance()
        .getActivityLogger()
        .logInstanceAction(this, "setupLocationDialog", "show");
    // dialog displayed while fetching gps location
    mLocationDialog = new ProgressDialog(this);
    DialogInterface.OnClickListener geopointButtonListener =
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            switch (which) {
              case DialogInterface.BUTTON_POSITIVE:
                Collect.getInstance()
                    .getActivityLogger()
                    .logInstanceAction(this, "acceptLocation", "OK");
                returnLocation();
                break;
              case DialogInterface.BUTTON_NEGATIVE:
                Collect.getInstance()
                    .getActivityLogger()
                    .logInstanceAction(this, "cancelLocation", "cancel");
                mLocation = null;
                finish();
                break;
            }
          }
        };

    // back button doesn't cancel
    mLocationDialog.setCancelable(false);
    mLocationDialog.setIndeterminate(true);
    mLocationDialog.setIcon(android.R.drawable.ic_dialog_info);
    mLocationDialog.setTitle(getString(R.string.getting_location));
    mLocationDialog.setMessage(getString(R.string.please_wait_long));
    mLocationDialog.setButton(
        DialogInterface.BUTTON_POSITIVE,
        getString(R.string.accept_location),
        geopointButtonListener);
    mLocationDialog.setButton(
        DialogInterface.BUTTON_NEGATIVE,
        getString(R.string.cancel_location),
        geopointButtonListener);
  }
コード例 #10
0
ファイル: TabSearch.java プロジェクト: karlzheng/testapps
  // 获取网络单词数据
  private void getWord(final String thisWord) {
    final ProgressDialog pd = new ProgressDialog(this);
    pd.setIcon(android.R.drawable.ic_dialog_info);
    pd.setTitle(R.string.dialog_title_loding_data);
    pd.setMessage(getString(R.string.dialog_msg_wait));
    pd.setOnDismissListener(
        new OnDismissListener() {
          @Override
          public void onDismiss(DialogInterface arg0) {
            if (word == null) {
              Toast.makeText(TabSearch.this, "没有数据!", Toast.LENGTH_SHORT).show();
            } else {
              nameTv.setText(thisWord);
              phoneticsTv.setText(word.get("音标"));
              sentsTv.setText(word.get("解释"));
            }
          }
        });
    pd.show();
    new Thread() {
      @Override
      public void run() {
        word = new HashMap<String, String>();
        word.put("单词", thisWord);
        String result = seek.getTrans(thisWord);

        Pattern p = Pattern.compile("/(.*?)/");
        Matcher m = p.matcher(result);

        if (m.find()) {
          String phonetic = m.group();
          word.put("音标", phonetic.replace("/", ""));

          word.put("解释", result.replace(phonetic, "").replaceAll("\\*", "\n\\*"));
        } else {
          word.put("解释", result);
        }

        pd.dismiss();
      }
    }.start();
  }
コード例 #11
0
ファイル: FINSplash.java プロジェクト: nahanson/finditnow
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fin_splash);
    manual = false;

    db = new FINDatabase(this).getReadableDatabase();

    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);

    rid = prefs.getInt("rid", 0);

    if (rid == 0) {
      // Acquire a reference to the system Location Manager
      final LocationManager locationManager =
          (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);

      // Define a listener that responds to location updates
      final LocationListener locationListener =
          new LocationListener() {
            public void onLocationChanged(Location location) {
              SharedPreferences.Editor editor = prefs.edit();

              editor.putInt("location_lat", (int) (location.getLatitude() * 1E6));
              editor.putInt("location_lon", (int) (location.getLatitude() * 1E6));
              editor.commit();

              handler4.sendEmptyMessage(0);

              locationManager.removeUpdates(this);
            }

            public void onStatusChanged(String provider, int status, Bundle extras) {}

            public void onProviderEnabled(String provider) {}

            public void onProviderDisabled(String provider) {}
          };

      // Register the listener with the Location Manager to receive location updates
      locationManager.requestLocationUpdates(
          LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
      locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);

      myDialog = new ProgressDialog(this);
      myDialog.setTitle("Welcome to FIN");
      myDialog.setMessage("Please wait while we detect the regions nearest you...");
      myDialog.setIcon(R.drawable.icon);
      myDialog.setCancelable(false);
      myDialog.setButton(
          "Manually Choose",
          new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
              locationManager.removeUpdates(locationListener);
              manual = true;
              myDialog.dismiss();
              handler4.sendEmptyMessage(0);
            }
          });
      myDialog.show();
    } else {
      handler3.sendEmptyMessage(0);
    }

    // thread for displaying the SplashScreen
    splashThread =
        new Thread() {

          @Override
          public void run() {

            Intent myIntent = null;

            // Set color theme (hardcoded for now).
            Cursor cursor =
                db.query(
                    "colors", null, "rid = " + prefs.getInt("rid", 0) + "", null, null, null, null);
            cursor.moveToFirst();
            String color = cursor.getString(cursor.getColumnIndex("color1"));

            cursor =
                db.query(
                    "regions",
                    null,
                    "rid = " + prefs.getInt("rid", 0) + "",
                    null,
                    null,
                    null,
                    null);
            cursor.moveToFirst();
            campus = cursor.getString(cursor.getColumnIndex("name"));

            // Set default location
            handler.sendEmptyMessage(0);

            myIntent = new Intent(getBaseContext(), FINHome.class);
            myIntent.addCategory("App Startup");

            // Check logged in status
            final String phone_id =
                Secure.getString(getBaseContext().getContentResolver(), Secure.ANDROID_ID);

            String loggedinstr = DBCommunicator.loggedIn(phone_id, getBaseContext());
            boolean loggedin = loggedinstr.contains(getString(R.string.login_already));

            campusJson =
                DBCommunicator.getRegions(
                    prefs.getInt("location_lat", 0) + "",
                    prefs.getInt("location_lon", 0) + "",
                    getBaseContext());
            if (!campusJson.equals(getString(R.string.timeout)))
              JsonParser.parseRegionJson(campusJson, getBaseContext());

            String categories = DBCommunicator.getCategories(getBaseContext());
            if (!categories.equals(getString(R.string.timeout)))
              JsonParser.parseCategoriesList(categories, getBaseContext());

            String buildings =
                DBCommunicator.getBuildings(prefs.getInt("rid", 0) + "", getBaseContext());
            if (!buildings.equals(getString(R.string.timeout)))
              JsonParser.parseBuildingJson(buildings, getBaseContext());

            String items = DBCommunicator.getItems(prefs.getInt("rid", 0) + "", getBaseContext());
            if (!items.equals(getString(R.string.timeout)))
              JsonParser.parseItemJson(items, getBaseContext());

            SharedPreferences.Editor editor = prefs.edit();
            editor.putBoolean("loggedin", loggedin);
            editor.putString("lastOpened", System.currentTimeMillis() / 1000 + "");
            editor.putString("color", color);
            editor.commit();

            if (loggedin) {
              myIntent.putExtra("username", loggedinstr.substring(21, loggedinstr.length()));
            }

            try {
              int waited = 0;

              while (active && (waited < splashTime)) {
                sleep(100);
                if (active) {
                  waited += 100;
                }
              }
            } catch (InterruptedException e) {
              // do nothing
            } finally {
              cursor.close();

              startActivity(myIntent);
              finish();
            }
          }
        };
  }
コード例 #12
0
  @Override
  protected Dialog onCreateDialog(int id) {
    switch (id) {
      case DIALOG_AUTHENTICATION_FAILED:
        return new AlertDialog.Builder(this)
            .setIcon(android.R.drawable.ic_dialog_alert)
            .setTitle(R.string.dialog_title_authentication_failed)
            .setMessage(R.string.dialog_summary_authentication_failed)
            .setPositiveButton(
                android.R.string.ok,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface Dialog, int whichButton) {
                    startActivity(new Intent(TimelineActivity.this, PreferencesActivity.class));
                  }
                })
            .create();

      case DIALOG_SERVICE_UNAVAILABLE:
        return new AlertDialog.Builder(this)
            .setIcon(android.R.drawable.ic_dialog_alert)
            .setTitle(R.string.dialog_title_service_unavailable)
            .setMessage(R.string.dialog_summary_service_unavailable)
            .setPositiveButton(
                android.R.string.ok,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface Dialog, int whichButton) {}
                })
            .create();

      case DIALOG_SENDING_MESSAGE:
        mProgressDialog = new ProgressDialog(this);
        mProgressDialog.setIcon(android.R.drawable.ic_dialog_info);
        mProgressDialog.setTitle(R.string.dialog_title_sending_message);
        mProgressDialog.setMessage(getText(R.string.dialog_summary_sending_message));
        return mProgressDialog;

      case DIALOG_TIMELINE_LOADING:
        mProgressDialog = new ProgressDialog(this);
        mProgressDialog.setIcon(android.R.drawable.ic_dialog_info);
        mProgressDialog.setTitle(R.string.dialog_title_timeline_loading);
        mProgressDialog.setMessage(getText(R.string.dialog_summary_timeline_loading));
        return mProgressDialog;

      case DIALOG_EXTERNAL_STORAGE:
        return new AlertDialog.Builder(this)
            .setIcon(android.R.drawable.ic_dialog_info)
            .setTitle(R.string.dialog_title_external_storage)
            .setMessage(R.string.dialog_summary_external_storage)
            .setPositiveButton(
                android.R.string.ok,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface Dialog, int whichButton) {
                    SharedPreferences.Editor editor = mSP.edit();
                    editor.putBoolean("confirmed_external_storage_use", true);
                    editor.putBoolean("storage_use_external", true);
                    editor.commit();
                    destroyService();
                    finish();
                    Intent intent = new Intent(TimelineActivity.this, TweetListActivity.class);
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);
                  }
                })
            .setNegativeButton(
                android.R.string.cancel,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface Dialog, int whichButton) {
                    SharedPreferences.Editor editor = mSP.edit();
                    editor.putBoolean("confirmed_external_storage_use", true);
                    editor.commit();
                  }
                })
            .create();

      case DIALOG_EXTERNAL_STORAGE_MISSING:
        return new AlertDialog.Builder(this)
            .setIcon(android.R.drawable.ic_dialog_alert)
            .setTitle(R.string.dialog_title_external_storage_missing)
            .setMessage(R.string.dialog_summary_external_storage_missing)
            .setPositiveButton(
                android.R.string.ok,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface Dialog, int whichButton) {
                    SharedPreferences.Editor editor = mSP.edit();
                    editor.putBoolean("confirmed_external_storage_use", true);
                    editor.putBoolean("storage_use_external", false);
                    editor.commit();
                    destroyService();
                    finish();
                    Intent intent = new Intent(TimelineActivity.this, TweetListActivity.class);
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);
                  }
                })
            .setNegativeButton(
                android.R.string.cancel,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface Dialog, int whichButton) {
                    destroyService();
                    finish();
                  }
                })
            .create();

      case DIALOG_CONNECTION_TIMEOUT:
        return new AlertDialog.Builder(this)
            .setIcon(android.R.drawable.ic_dialog_alert)
            .setTitle(R.string.dialog_title_connection_timeout)
            .setMessage(R.string.dialog_summary_connection_timeout)
            .setPositiveButton(
                android.R.string.ok,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface Dialog, int whichButton) {}
                })
            .create();

      case DIALOG_EXECUTING_COMMAND:
        mProgressDialog = new ProgressDialog(this);
        mProgressDialog.setIcon(android.R.drawable.ic_dialog_info);
        mProgressDialog.setTitle(R.string.dialog_title_executing_command);
        mProgressDialog.setMessage(getText(R.string.dialog_summary_executing_command));
        return mProgressDialog;

      default:
        return super.onCreateDialog(id);
    }
  }