Example usage for android.app ProgressDialog show

List of usage examples for android.app ProgressDialog show

Introduction

In this page you can find the example usage for android.app ProgressDialog show.

Prototype

public void show() 

Source Link

Document

Start the dialog and display it on screen.

Usage

From source file:com.uraroji.garage.android.arrraycopybench.MainActivity.java

private void startBench() {
    mResultTextView.setText("");

    final String arrayTypeStr = mArrayTypeSpinner.getSelectedItem().toString();
    final int arrayLength = Integer.parseInt(mArrayLengthSpinner.getSelectedItem().toString());
    final int benchTimes = Integer.parseInt(mBenchTimesSpinner.getSelectedItem().toString());

    final ProgressDialog dialog = new ProgressDialog(this);
    dialog.setMessage(getString(R.string.benchmarking));
    dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    dialog.setCancelable(false);//from  ww w  . j a  va 2 s  . c om
    dialog.show();

    final Handler handler = new Handler();

    if (arrayTypeStr.equals("byte")) {
        final byte[] src = new byte[arrayLength];
        for (int i = 0; i < src.length; ++i) {
            src[i] = (byte) i;
        }

        new Thread(new Runnable() {
            @Override
            public void run() {
                BenchResult benchResult = null;

                benchResult = copyClone(src, benchTimes);
                showResult("clone", benchResult, handler);

                benchResult = copyArraycopy(src, benchTimes);
                showResult("System.arraycopy", benchResult, handler);

                benchResult = copyArraysCopyOf(src, benchTimes);
                showResult("Arrays.copyOf", benchResult, handler);

                benchResult = copyForLoop(src, benchTimes);
                showResult("for loop", benchResult, handler);

                benchResult = copyNative(src, benchTimes);
                showResult("native", benchResult, handler);

                dialog.dismiss();
            }
        }).start();
    } else if (arrayTypeStr.equals("short")) {
        final short[] src = new short[arrayLength];
        for (int i = 0; i < src.length; ++i) {
            src[i] = (short) i;
        }

        new Thread(new Runnable() {
            @Override
            public void run() {
                BenchResult benchResult = null;

                benchResult = copyClone(src, benchTimes);
                showResult("clone", benchResult, handler);

                benchResult = copyArraycopy(src, benchTimes);
                showResult("System.arraycopy", benchResult, handler);

                benchResult = copyArraysCopyOf(src, benchTimes);
                showResult("Arrays.copyOf", benchResult, handler);

                benchResult = copyForLoop(src, benchTimes);
                showResult("for loop", benchResult, handler);

                benchResult = copyNative(src, benchTimes);
                showResult("native", benchResult, handler);

                dialog.dismiss();
            }
        }).start();
    } else if (arrayTypeStr.equals("int")) {
        final int[] src = new int[arrayLength];
        for (int i = 0; i < src.length; ++i) {
            src[i] = (int) i;
        }

        new Thread(new Runnable() {
            @Override
            public void run() {
                BenchResult benchResult = null;

                benchResult = copyClone(src, benchTimes);
                showResult("clone", benchResult, handler);

                benchResult = copyArraycopy(src, benchTimes);
                showResult("System.arraycopy", benchResult, handler);

                benchResult = copyArraysCopyOf(src, benchTimes);
                showResult("Arrays.copyOf", benchResult, handler);

                benchResult = copyForLoop(src, benchTimes);
                showResult("for loop", benchResult, handler);

                benchResult = copyNative(src, benchTimes);
                showResult("native", benchResult, handler);

                dialog.dismiss();
            }
        }).start();
    } else if (arrayTypeStr.equals("long")) {
        final long[] src = new long[arrayLength];
        for (int i = 0; i < src.length; ++i) {
            src[i] = (long) i;
        }

        new Thread(new Runnable() {
            @Override
            public void run() {
                BenchResult benchResult = null;

                benchResult = copyClone(src, benchTimes);
                showResult("clone", benchResult, handler);

                benchResult = copyArraycopy(src, benchTimes);
                showResult("System.arraycopy", benchResult, handler);

                benchResult = copyArraysCopyOf(src, benchTimes);
                showResult("Arrays.copyOf", benchResult, handler);

                benchResult = copyForLoop(src, benchTimes);
                showResult("for loop", benchResult, handler);

                benchResult = copyNative(src, benchTimes);
                showResult("native", benchResult, handler);

                dialog.dismiss();
            }
        }).start();
    } else if (arrayTypeStr.equals("double")) {
        final double[] src = new double[arrayLength];
        for (int i = 0; i < src.length; ++i) {
            src[i] = (double) i;
        }

        new Thread(new Runnable() {
            @Override
            public void run() {
                BenchResult benchResult = null;

                benchResult = copyClone(src, benchTimes);
                showResult("clone", benchResult, handler);

                benchResult = copyArraycopy(src, benchTimes);
                showResult("System.arraycopy", benchResult, handler);

                benchResult = copyArraysCopyOf(src, benchTimes);
                showResult("Arrays.copyOf", benchResult, handler);

                benchResult = copyForLoop(src, benchTimes);
                showResult("for loop", benchResult, handler);

                benchResult = copyNative(src, benchTimes);
                showResult("native", benchResult, handler);

                dialog.dismiss();
            }
        }).start();
    } else if (arrayTypeStr.equals("Object")) {
        final Object[] src = new Object[arrayLength];
        for (int i = 0; i < src.length; ++i) {
            src[i] = new Object();
        }

        new Thread(new Runnable() {
            @Override
            public void run() {
                BenchResult benchResult = null;

                benchResult = copyClone(src, benchTimes);
                showResult("clone", benchResult, handler);

                benchResult = copyArraycopy(src, benchTimes);
                showResult("System.arraycopy", benchResult, handler);

                benchResult = copyArraysCopyOf(src, benchTimes);
                showResult("Arrays.copyOf", benchResult, handler);

                benchResult = copyForLoop(src, benchTimes);
                showResult("for loop", benchResult, handler);

                dialog.dismiss();
            }
        }).start();
    } else if (arrayTypeStr.equals("Byte")) {
        final Byte[] src = new Byte[arrayLength];
        for (int i = 0; i < src.length; ++i) {
            src[i] = new Byte((byte) i);
        }

        new Thread(new Runnable() {
            @Override
            public void run() {
                BenchResult benchResult = null;

                benchResult = copyClone(src, benchTimes);
                showResult("clone", benchResult, handler);

                benchResult = copyArraycopy(src, benchTimes);
                showResult("System.arraycopy", benchResult, handler);

                benchResult = copyArraysCopyOf(src, benchTimes);
                showResult("Arrays.copyOf", benchResult, handler);

                benchResult = copyForLoop(src, benchTimes);
                showResult("for loop", benchResult, handler);

                dialog.dismiss();
            }
        }).start();
    } else if (arrayTypeStr.equals("Integer")) {
        final Integer[] src = new Integer[arrayLength];
        for (int i = 0; i < src.length; ++i) {
            src[i] = new Integer((int) i);
        }

        new Thread(new Runnable() {
            @Override
            public void run() {
                BenchResult benchResult = null;

                benchResult = copyClone(src, benchTimes);
                showResult("clone", benchResult, handler);

                benchResult = copyArraycopy(src, benchTimes);
                showResult("System.arraycopy", benchResult, handler);

                benchResult = copyArraysCopyOf(src, benchTimes);
                showResult("Arrays.copyOf", benchResult, handler);

                benchResult = copyForLoop(src, benchTimes);
                showResult("for loop", benchResult, handler);

                dialog.dismiss();
            }
        }).start();
    } else if (arrayTypeStr.equals("Long")) {
        final Long[] src = new Long[arrayLength];
        for (int i = 0; i < src.length; ++i) {
            src[i] = new Long((long) i);
        }

        new Thread(new Runnable() {
            @Override
            public void run() {
                BenchResult benchResult = null;

                benchResult = copyClone(src, benchTimes);
                showResult("clone", benchResult, handler);

                benchResult = copyArraycopy(src, benchTimes);
                showResult("System.arraycopy", benchResult, handler);

                benchResult = copyArraysCopyOf(src, benchTimes);
                showResult("Arrays.copyOf", benchResult, handler);

                benchResult = copyForLoop(src, benchTimes);
                showResult("for loop", benchResult, handler);

                dialog.dismiss();
            }
        }).start();
    } else if (arrayTypeStr.equals("Double")) {
        final Double[] src = new Double[arrayLength];
        for (int i = 0; i < src.length; ++i) {
            src[i] = new Double((double) i);
        }

        new Thread(new Runnable() {
            @Override
            public void run() {
                BenchResult benchResult = null;

                benchResult = copyClone(src, benchTimes);
                showResult("clone", benchResult, handler);

                benchResult = copyArraycopy(src, benchTimes);
                showResult("System.arraycopy", benchResult, handler);

                benchResult = copyArraysCopyOf(src, benchTimes);
                showResult("Arrays.copyOf", benchResult, handler);

                benchResult = copyForLoop(src, benchTimes);
                showResult("for loop", benchResult, handler);

                dialog.dismiss();
            }
        }).start();
    } else {
        dialog.dismiss();
    }
}

From source file:com.microsoft.onedrive.apiexplorer.ItemFragment.java

@Override
public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    final BaseApplication application = (BaseApplication) getActivity().getApplication();
    final IOneDriveClient oneDriveClient = application.getOneDriveClient();

    if (requestCode == REQUEST_CODE_SIMPLE_UPLOAD && data != null && data.getData() != null
            && data.getData().getScheme().equalsIgnoreCase(SCHEME_CONTENT)) {

        final ProgressDialog dialog = new ProgressDialog(getActivity());
        dialog.setTitle(R.string.upload_in_progress_title);
        dialog.setMessage(getString(R.string.upload_in_progress_message));
        dialog.setIndeterminate(false);/*  ww  w.  j  a  v a 2s .c o  m*/
        dialog.setCancelable(false);
        dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        dialog.setProgressNumberFormat(getString(R.string.upload_in_progress_number_format));
        dialog.show();
        final AsyncTask<Void, Void, Void> uploadFile = new AsyncTask<Void, Void, Void>() {
            @Override
            protected Void doInBackground(final Void... params) {
                try {
                    final ContentResolver contentResolver = getActivity().getContentResolver();
                    final ContentProviderClient contentProvider = contentResolver
                            .acquireContentProviderClient(data.getData());
                    final byte[] fileInMemory = FileContent.getFileBytes(contentProvider, data.getData());
                    contentProvider.release();

                    // Fix up the file name (needed for camera roll photos, etc)
                    final String filename = FileContent.getValidFileName(contentResolver, data.getData());
                    final Option option = new QueryOption("@name.conflictBehavior", "fail");
                    oneDriveClient.getDrive().getItems(mItemId).getChildren().byId(filename).getContent()
                            .buildRequest(Collections.singletonList(option))
                            .put(fileInMemory, new IProgressCallback<Item>() {
                                @Override
                                public void success(final Item item) {
                                    dialog.dismiss();
                                    Toast.makeText(getActivity(),
                                            application.getString(R.string.upload_complete, item.name),
                                            Toast.LENGTH_LONG).show();
                                    refresh();
                                }

                                @Override
                                public void failure(final ClientException error) {
                                    dialog.dismiss();
                                    if (error.isError(OneDriveErrorCodes.NameAlreadyExists)) {
                                        Toast.makeText(getActivity(), R.string.upload_failed_name_conflict,
                                                Toast.LENGTH_LONG).show();
                                    } else {
                                        Toast.makeText(getActivity(),
                                                application.getString(R.string.upload_failed, filename),
                                                Toast.LENGTH_LONG).show();
                                    }
                                }

                                @Override
                                public void progress(final long current, final long max) {
                                    dialog.setProgress((int) current);
                                    dialog.setMax((int) max);
                                }
                            });
                } catch (final Exception e) {
                    Log.e(getClass().getSimpleName(), e.getMessage());
                    Log.e(getClass().getSimpleName(), e.toString());
                }
                return null;
            }
        };
        uploadFile.execute();
    }
}

From source file:tm.veriloft.mapsplayground.MapsActivity.java

private void fetchAndDrawRoute(final LatLng... latLngs) {
    final AsyncHttpClient asyncHttpClient = new AsyncHttpClient(SERVER_PORT);

    final ProgressDialog progressDialog = new ProgressDialog(this);
    progressDialog.setMessage("Loading..");
    progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() {
        @Override//from  w w  w.ja  va2  s . com
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });

    progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            asyncHttpClient.cancelRequests(MapsActivity.this, true);
            showCenteredToast("Drawing route got cancelled");
        }
    });

    final RequestParams requestParams = new RequestParams();

    for (LatLng latLng : latLngs) {
        requestParams.add("loc", latLng.latitude + "," + latLng.longitude);
        l("Added latLng to request, " + latLng);
    }

    asyncHttpClient.get(this, SERVER, requestParams, new JsonHttpResponseHandler() {
        @Override
        public void onStart() {
            progressDialog.show();
        }

        @Override
        public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
            try {
                ArrayList<LatLng> route = MapUtils.decodePoly(response.getString("route_geometry"));
                PolylineOptions routeOptions = new PolylineOptions();

                for (int i = 0; i < route.size(); i++) {
                    routeOptions.add(route.get(i));
                    l("Returned point " + route.get(i));
                    if (returnedPointsMarkers)
                        addedMarkers.add(mMap.addMarker(new MarkerOptions().position(route.get(i))
                                .title("#" + i + " point of #" + drawnRoutes.size())));
                }

                routeOptions.width(ROUTE_WIDTH).color(ROUTE_COLOR);
                drawnRoutes.add(mMap.addPolyline(routeOptions));

                List<LatLng> points = routeOptions.getPoints();

                if (focusAfterRouteDraw)
                    focusTo(points.get(0), 13);

                if (endMarkerRouteDraw) {
                    LatLng trueEndPoint = MapUtils.findTrueEndPoint(latLngs[latLngs.length - 1], route.get(0),
                            route.get(route.size() - 1));
                    addedMarkers.add(mMap.addMarker(
                            new MarkerOptions().position(trueEndPoint).title("End of #" + drawnRoutes.size())));
                }

                if (requestedPointMarkerRouteDraw)
                    addedMarkers.add(mMap.addMarker(new MarkerOptions().position(latLngs[latLngs.length - 1])
                            .title("Requested point of #" + drawnRoutes.size())));

            } catch (JSONException exception) {
                exception.printStackTrace();
                showCenteredToast("Exception while parsing! Error: " + exception.getLocalizedMessage());
            }
        }

        @Override
        public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONArray errorResponse) {
            showCenteredToast("Network error! Error: " + throwable.getLocalizedMessage());
        }

        @Override
        public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
            showCenteredToast("Network error! Server returned non-json response, response: " + responseString
                    + ", Error: " + throwable.getLocalizedMessage());
        }

        @Override
        public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) {
            showCenteredToast("Network error! Error: " + throwable.getLocalizedMessage());
        }

        @Override
        public void onFinish() {
            progressDialog.dismiss();
        }
    });
}

From source file:com.arantius.tivocommander.SeasonPass.java

public void reorderApply(View unusedView) {
    Utils.log("SeasonPass::reorderApply() " + Boolean.toString(mInReorderMode));

    boolean noChange = true;
    ArrayList<String> subIds = new ArrayList<String>();
    for (int i = 0; i < mSubscriptionIds.size(); i++) {
        if (mSubscriptionIds.get(i) != mSubscriptionIdsBeforeReorder.get(i)) {
            noChange = false;//from w  ww.j  av a 2  s . com
        }
        subIds.add(mSubscriptionData.get(i).path("subscriptionId").asText());
    }

    final ProgressDialog d = new ProgressDialog(this);
    final MindRpcResponseListener onReorderComplete = new MindRpcResponseListener() {
        public void onResponse(MindRpcResponse response) {
            if (d.isShowing()) {
                d.dismiss();
            }

            // Flip the buttons.
            findViewById(R.id.reorder_enable).setVisibility(View.VISIBLE);
            findViewById(R.id.reorder_apply).setVisibility(View.GONE);
            // Turn off the drag handles.
            mInReorderMode = false;
            mListAdapter.notifyDataSetChanged();
        }
    };

    if (noChange) {
        // If there was no change, switch the UI back immediately.
        onReorderComplete.onResponse(null);
    } else {
        // Otherwise show a dialog while we do the RPC.
        d.setIndeterminate(true);
        d.setTitle("Saving ...");
        d.setMessage("Saving new season pass order.  " + "Patience please, this takes a while.");
        d.setCancelable(false);
        d.show();

        SubscriptionsReprioritize req = new SubscriptionsReprioritize(subIds);
        MindRpc.addRequest(req, onReorderComplete);
    }
}

From source file:fm.smart.r1.activity.CreateItemActivity.java

public void onClick(View v) {
    EditText cueInput = (EditText) findViewById(R.id.cue);
    EditText responseInput = (EditText) findViewById(R.id.response);
    Spinner posInput = (Spinner) findViewById(R.id.pos);
    EditText characterResponseInput = (EditText) findViewById(R.id.response_character);
    EditText characterCueInput = (EditText) findViewById(R.id.cue_character);
    final String cue = cueInput.getText().toString();
    final String response = responseInput.getText().toString();
    final String pos = posInput.getSelectedItem().toString();
    final String character_cue = characterCueInput.getText().toString();
    final String character_response = characterResponseInput.getText().toString();
    String pos_code = Utils.POS_MAP.get(pos);
    if (TextUtils.isEmpty(pos_code)) {
        pos_code = "NONE";
    }/*w ww . j  a  v  a  2  s .co  m*/
    final String final_pos_code = pos_code;

    if (Main.isNotLoggedIn(this)) {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setClassName(this, LoginActivity.class.getName());
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); // avoid
        // navigation
        // back to this?
        LoginActivity.return_to = CreateItemActivity.class.getName();
        LoginActivity.params = new HashMap<String, String>();
        LoginActivity.params.put("list_id", list_id);
        LoginActivity.params.put("cue", cue);
        LoginActivity.params.put("response", response);
        LoginActivity.params.put("cue_language", cue_language);
        LoginActivity.params.put("response_language", response_language);
        LoginActivity.params.put("pos", pos);
        LoginActivity.params.put("character_cue", character_cue);
        LoginActivity.params.put("character_response", character_response);
        startActivity(intent);
    } else {
        // TODO cue and response languages need to be inferred from list we are
        // adding to ... Might want to fix those, i.e. not allow variation
        // on
        // search ...
        // TODO wondering whether there is some way to edit existing items
        // ...

        final ProgressDialog myOtherProgressDialog = new ProgressDialog(this);
        myOtherProgressDialog.setTitle("Please Wait ...");
        myOtherProgressDialog.setMessage("Creating Item ...");
        myOtherProgressDialog.setIndeterminate(true);
        myOtherProgressDialog.setCancelable(true);

        final Thread create_item = new Thread() {
            public void run() {
                // TODO make this interruptable .../*if
                // (!this.isInterrupted())*/
                CreateItemActivity.create_item_result = createItem(cue, cue_language, character_cue,
                        final_pos_code, response, response_language, character_response, list_id);

                myOtherProgressDialog.dismiss();

            }
        };
        myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                create_item.interrupt();
            }
        });
        OnCancelListener ocl = new OnCancelListener() {
            public void onCancel(DialogInterface arg0) {
                create_item.interrupt();
            }
        };
        myOtherProgressDialog.setOnCancelListener(ocl);
        myOtherProgressDialog.show();
        create_item.start();
    }
}

From source file:activities.PaintActivity.java

public void saveImage() {
    //save changes
    Bitmap image = painter.getImageBitmap();

    //        String description = null;
    //        PaintColor currentColor = PaintUtility.getCurrentPaintColor();

    //        if (null != currentColor) {
    //            ColorCategory category = currentColor.getColorCategory();
    //            description = category.getBrand().getName() + ", " + category.getName() + " - " + currentColor.getName();
    //        }/*from  w w  w  . j  av a 2s  .c  o  m*/
    String saveText = getResources().getString(save_image_text);
    final ProgressDialog dialog = PaintUtility.showProgressDialog(PaintActivity.this, saveText);
    dialog.show();

    //add branding
    //        Bitmap mutableBitmap = image.copy(Bitmap.Config.ARGB_8888, true);
    //        Canvas canvas = new Canvas(mutableBitmap);
    //        addBranding(canvas, description);

    //        PaintUtility.savePhoto(PaintActivity.this, mutableBitmap);
    PaintUtility.savePhoto(PaintActivity.this, image);
    PaintUtility.hideDialogAfterDelay(dialog, 1200);

}

From source file:br.com.indigo.android.facebook.SocialFacebook.java

public void commentPost(final Activity activity, final String postId, final NewObjectListener listener) {

    if (!mFacebook.isSessionValid()) {
        login(activity, new SimpleRequestListener() {

            public void onComplete() {
                commentPost(activity, postId, listener);
            }/*  w w w . j  a  v  a  2 s  .  c  o m*/

            public void onFail(Throwable thr) {
                listener.onFail(thr);
            }

            public void onCancel() {
                listener.onCancel();
            }
        });
    } else {

        final FbTextDialog dialog = new FbTextDialog(activity);
        dialog.setDialogListener(new DialogListener() {

            public void onComplete(Bundle values) {

                final ProgressDialog spinner = new ProgressDialog(activity);
                spinner.setMessage(spinner.getContext().getString(R.string.loading));
                spinner.setCancelable(false);
                spinner.show();

                facebookRequest(activity, postId + "/comments", values, "POST", true, new RequestAdapter() {

                    public void onFail(Throwable thr, Object state) {
                        listener.onFail(thr);
                        spinner.dismiss();
                        dialog.dismiss();
                    }

                    public void onComplete(JSONObject jsonResponse, Object state) {
                        listener.onComplete(jsonResponse.optString("id"));
                        spinner.dismiss();
                        dialog.dismiss();
                    }

                    public void onCancel() {
                        listener.onCancel();
                        spinner.dismiss();
                        dialog.dismiss();
                    }
                });
            }

            public void onFacebookError(FacebookError e) {
                listener.onFail(e);
            }

            public void onError(DialogError e) {
                listener.onFail(e);
            }

            public void onCancel() {
                listener.onCancel();
            }
        });

        dialog.show();
    }
}

From source file:com.arantius.tivocommander.SeasonPass.java

public void reorderEnable(View unusedView) {
    Utils.log("SeasonPass::reorderEnable() " + Boolean.toString(mInReorderMode));

    final ArrayList<String> subscriptionIds = new ArrayList<String>();
    final ArrayList<Integer> slots = new ArrayList<Integer>();
    int i = 0;//from w  w  w  . j  a v a  2s . c o  m
    while (i < mSubscriptionData.size()) {
        if (mSubscriptionStatus.get(i) == SubscriptionStatus.MISSING) {
            String subscriptionId = mSubscriptionIds.get(i);
            subscriptionIds.add(subscriptionId);
            slots.add(i);
            mSubscriptionStatus.set(i, SubscriptionStatus.LOADING);
        }
        i++;
    }

    final ProgressDialog d = new ProgressDialog(this);
    final MindRpcResponseListener onAllPassesLoaded = new MindRpcResponseListener() {
        public void onResponse(MindRpcResponse response) {
            if (response != null) {
                mDetailCallback.onResponse(response);
            }
            d.dismiss();

            // Save the state before ordering.
            mSubscriptionIdsBeforeReorder.clear();
            mSubscriptionIdsBeforeReorder.addAll(mSubscriptionIds);
            // Flip the buttons.
            findViewById(R.id.reorder_enable).setVisibility(View.GONE);
            findViewById(R.id.reorder_apply).setVisibility(View.VISIBLE);
            // Show the drag handles.
            mInReorderMode = true;
            mListAdapter.notifyDataSetChanged();
        }
    };

    if (subscriptionIds.size() == 0) {
        // No subscriptions need loading? Proceed immediately.
        onAllPassesLoaded.onResponse(null);
    } else {
        // Otherwise, show dialog and start loading.
        d.setIndeterminate(true);
        d.setTitle("Preparing ...");
        d.setMessage("Loading all season pass data.");
        d.setCancelable(false);
        d.show();

        final SubscriptionSearch req = new SubscriptionSearch(subscriptionIds);
        mRequestSlotMap.put(req.getRpcId(), slots);
        MindRpc.addRequest(req, onAllPassesLoaded);
    }
}

From source file:br.com.indigo.android.facebook.SocialFacebook.java

public void publish(final Activity activity, final FbSimplePost post, final String pageId,
        final NewObjectListener listener) {

    if (!mFacebook.isSessionValid()) {

        login(activity, new SimpleRequestListener() {

            public void onFail(Throwable thr) {
                listener.onFail(thr);//from  w  w w.j  a v  a2  s.  c o m
            }

            public void onCancel() {
                listener.onCancel();
            }

            public void onComplete() {
                publish(activity, post, pageId, listener);
            }
        });
    } else {

        final FbTextDialog dialog = new FbTextDialog(activity);
        dialog.setTitle(R.string.dialog_post_to_wall_title);
        dialog.setPlaceHolder(R.string.dialog_post_to_wall_placeholder);

        dialog.setDialogListener(new DialogListener() {

            public void onComplete(Bundle values) {

                final ProgressDialog spinner = new ProgressDialog(activity);
                spinner.setMessage(spinner.getContext().getString(R.string.loading));
                spinner.setCancelable(false);
                spinner.show();

                Bundle params = paramsForPost(post);
                params.putAll(values);

                facebookRequest(activity, pageId + "/feed", params, "POST", true, new RequestAdapter() {

                    public void onFail(Throwable thr, Object state) {
                        listener.onFail(thr);
                        spinner.dismiss();
                        dialog.dismiss();
                    }

                    public void onComplete(JSONObject jsonResponse, Object state) {
                        listener.onComplete(jsonResponse.optString("id"));
                        spinner.dismiss();
                        dialog.dismiss();
                    }

                    public void onCancel() {
                        listener.onCancel();
                        spinner.dismiss();
                        dialog.dismiss();
                    }
                });
            }

            public void onFacebookError(FacebookError e) {
                listener.onFail(e);
            }

            public void onError(DialogError e) {
                listener.onFail(e);
            }

            public void onCancel() {
                listener.onCancel();
            }
        });

        dialog.show();
    }
}