Java Code Examples for android.app.Activity#setProgressBarIndeterminateVisibility()

The following examples show how to use android.app.Activity#setProgressBarIndeterminateVisibility() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DemoBaseActivity.java    From java-unified-sdk with Apache License 2.0 6 votes vote down vote up
public void runMethod(final Activity demoRunActivity, final String methodName) {
  demoRunActivity.setProgressBarIndeterminateVisibility(true);
  new BackgroundTask() {
    @Override
    protected void doInBack() throws Exception {
      Method method = DemoUtils.getMethodSafely(DemoBaseActivity.this.getClass(), methodName);
      DemoUtils.invokeMethod(DemoBaseActivity.this, method);
    }

    @Override
    protected void onPost(Exception e) {
      demoRunActivity.setProgressBarIndeterminateVisibility(false);
      if (e != null) {
        if (e instanceof InvocationTargetException) {
          // 打印原方法抛出的异常
          log("Error : %s", e.getCause().getMessage());
        } else {
          log("Error : %s", e.getMessage());
        }
      } else {
        log("%s Finished.", methodName);
      }
    }
  }.execute();
}
 
Example 2
Source File: ActivityHelper.java    From android-atleap with Apache License 2.0 6 votes vote down vote up
/**
 * Change specified Progress Bar Visibility or Indeterminate Progress Bar
 * @param progressBar progress bar, could be <code>null</code>
 * @param show <code>true</code> if we would like to show
 */
public static void changeProgressBarVisibility(ProgressBar progressBar, Activity activity, boolean show) {
    if (progressBar != null) {
        if (show)
            progressBar.setVisibility(View.VISIBLE);
        else
            progressBar.setVisibility(View.GONE);
    } else {
        if (activity != null) {
            if (activity instanceof ActionBarActivity) {
                ActionBarActivity actionBarActivity = (ActionBarActivity) activity;
                actionBarActivity.setSupportProgressBarIndeterminateVisibility(show);
            } else {
                activity.setProgressBarIndeterminateVisibility(show);
            }
        }
    }
}
 
Example 3
Source File: ImportTask.java    From TextFiction with Apache License 2.0 6 votes vote down vote up
@Override
public void onPostExecute(Exception result) {
	Activity context = master.getActivity();
	if (result != null) {
		Toast.makeText(context, R.string.msg_failure_import, Toast.LENGTH_SHORT)
				.show();
	}
	if (context != null) {
		context.setProgressBarIndeterminate(false);
		context.setProgressBarIndeterminateVisibility(false);
		context.setProgressBarVisibility(false);
	}
	if (result==null && context!=null && didImport) {
		Toast.makeText(context,R.string.msg_file_copied_you_may_delete_the_original_now,Toast.LENGTH_LONG).show();
	}
	master.reScan();
}
 
Example 4
Source File: ImportTask.java    From TextFiction with Apache License 2.0 5 votes vote down vote up
@Override
public void onPreExecute() {
	Activity context = master.getActivity();
	if (context != null) {
		context.setProgressBarIndeterminate(false);
		context.setProgressBarIndeterminateVisibility(false);
		context.setProgressBarVisibility(false);
	}
}
 
Example 5
Source File: DelayedIndeterminateProgressBarRunnable.java    From clusterkraf with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
	Activity activity = activityRef.get();
	if (activity != null) {
		activity.setProgressBarIndeterminateVisibility(true);
	}
}
 
Example 6
Source File: UserFragment.java    From android-discourse with Apache License 2.0 4 votes vote down vote up
private void showActonBarProgress() {
    Activity a = getActivity();
    if (a != null) {
        a.setProgressBarIndeterminateVisibility(Boolean.TRUE);
    }
}
 
Example 7
Source File: UserFragment.java    From android-discourse with Apache License 2.0 4 votes vote down vote up
private void hideActonBarProgress() {
    Activity a = getActivity();
    if (a != null) {
        a.setProgressBarIndeterminateVisibility(Boolean.FALSE);
    }
}
 
Example 8
Source File: EditorFragment.java    From android-discourse with Apache License 2.0 4 votes vote down vote up
private void showActonBarProgress() {
    Activity a = getActivity();
    if (a != null) {
        a.setProgressBarIndeterminateVisibility(Boolean.TRUE);
    }
}
 
Example 9
Source File: EditorFragment.java    From android-discourse with Apache License 2.0 4 votes vote down vote up
private void hideActonBarProgress() {
    Activity a = getActivity();
    if (a != null) {
        a.setProgressBarIndeterminateVisibility(Boolean.FALSE);
    }
}