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 static ProgressDialog show(Context context, CharSequence title, CharSequence message,
        boolean indeterminate, boolean cancelable) 

Source Link

Document

Creates and shows a ProgressDialog.

Usage

From source file:com.lge.friendsCamera.RecordVideoActivity.java

/**
 * get captureMode option/*from   ww  w  .  ja  v a  2s  .  co  m*/
 * API: /osc/commands/execute (camera.getOptions)
 */
private void getOptionCaptureMode() {
    JSONObject parameters = new JSONObject();

    try {
        JSONArray optionParameter = new JSONArray();
        optionParameter.put(optionCaptureMode);

        parameters.put(OSCParameterNameMapper.Options.OPTIONNAMES, optionParameter);
        OSCCommandsExecute commandsExecute = new OSCCommandsExecute("camera.getOptions", parameters);

        commandsExecute.setListener(new HttpAsyncTask.OnHttpListener() {
            @Override
            public void onResponse(OSCReturnType type, Object response) {
                try {

                    if (type == OSCReturnType.SUCCESS) {
                        //If the getOption request get response successfully,
                        //check whether the mode is video or not
                        JSONObject jObject = new JSONObject((String) response);

                        JSONObject results = jObject.getJSONObject(OSCParameterNameMapper.RESULTS);
                        JSONObject options = results.getJSONObject(OSCParameterNameMapper.Options.OPTIONS);
                        String captureMode = options.getString(optionCaptureMode);

                        if (!captureMode.equals("video")) {
                            //Ask user whether change captureMode as 'video' or not
                            //  yes = Send request to captureMode as video(camera.setOption)
                            //  no = finish this activity
                            DialogInterface.OnClickListener okListener = new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    mProgressDialog = ProgressDialog.show(mContext, "", "Setting..", true,
                                            false);
                                    setCaptureModeVideo();
                                }
                            };
                            DialogInterface.OnClickListener cancelListener = new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    ((RecordVideoActivity) mContext).finish();
                                }
                            };

                            Utils.showSelectDialog(mContext, "Note: ",
                                    "Do you want to change captureMode to 'video'?", okListener,
                                    cancelListener);
                        }
                    } else {
                        Utils.showTextDialog(mContext, getString(R.string.response),
                                Utils.parseString(response));
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        });

        commandsExecute.execute();

    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:ansteph.com.beecab.view.profile.DriverProfileView.java

private void getImageData() {
    final ProgressDialog loading = ProgressDialog.show(this, "Please wait ", "Fetching data...", false, false);

    String url = String.format(Config.RETRIEVE_USER_IMAGE_URL, taxiID);

    //Creating a json array request to get the json from our api
    JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(url, new Response.Listener<JSONArray>() {
        @Override//from  www .ja  v  a2s .co m
        public void onResponse(JSONArray response) {
            //Dismissing the progressdialog on response
            loading.dismiss();

            //Displaying our grid
            loadImage(response);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {

        }
    });
    //Creating a request queue
    RequestQueue requestQueue = Volley.newRequestQueue(getApplicationContext());
    //Adding our request to the queue
    requestQueue.add(jsonArrayRequest);
}

From source file:com.example.research.whatis.MainActivity.java

public String invokeOCRAPI() throws IOException, JSONException {
    //        String license_code = "31CB2366-603F-4F19-BEFB-1C961348DBA0";
    //        String user_name = "VIVEKHARIKRISHNANR";
    //        String ocrURL = "http://www.ocrwebservice.com/restservices/processDocument?gettext=true";

    //        Toast.makeText(this, "Invoking OCR", Toast.LENGTH_LONG).show();
    Log.d("API", "Inokving OCR: ");

    final ProgressDialog dialog = ProgressDialog.show(MainActivity.this, "Loading ...", "Converting to text.",
            true, false);/*from  w  w  w .ja va2 s. co  m*/
    final Thread thread = new Thread(new Runnable() {
        @Override
        public void run() {
            String apiKey = "nh9tSJg3Mf";
            String langCode = "en";
            final OCRServiceAPI apiClient = new OCRServiceAPI(apiKey);
            apiClient.convertToText(langCode, sdImageMainDirectory.getPath());

            // Doing UI related code in UI thread
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    dialog.dismiss();

                    // Showing response dialog
                    //                        final AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this);
                    //                        alert.setMessage(apiClient.getResponseText());
                    OCRedText = apiClient.getResponseText();
                    OCRedText = OCRedText.replaceAll("\\W", "");
                    Log.e("OCRedText", OCRedText);

                    try {
                        invokeSynonymsAPI();
                    } catch (IOException e) {
                        e.printStackTrace();
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }

                    //                        alert.setPositiveButton(
                    //                                "OK",
                    //                                new DialogInterface.OnClickListener() {
                    //                                    public void onClick( DialogInterface dialog, int id) {
                    //                                    }
                    //                                });
                    //
                    ////                         Setting dialog title related from response code
                    //                        if (apiClient.getResponseCode() == 200) {
                    //                            alert.setTitle("Success");
                    //                        } else {
                    //                            alert.setTitle("Faild");
                    //                        }
                    //
                    //                        alert.show();
                }
            });
        }
    });
    thread.start();
    //
    //MediaStore.Files.getContentUri(Uri.fromFile(sdImageMainDirectory).toString());
    //        byte bytes[] = FileUtils.readFileToByteArray(sdImageMainDirectory);
    //
    //
    //        URL url = new URL(ocrURL);
    //        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    //        connection.setDoOutput(true);
    //        connection.setDoInput(true);
    //        connection.setRequestMethod("POST");
    //        connection.setRequestProperty("Authorization", "Basic " + Base64.encodeToString((user_name + ":" + license_code).getBytes(), Base64.DEFAULT));
    //        connection.setRequestProperty("Content-Type", "application/json");
    //        connection.setRequestProperty("Content-Length", Integer.toString(bytes.length));
    //
    //        Toast.makeText(this, "OCR Connection" + connection.toString(), Toast.LENGTH_LONG).show();
    //        Log.d("API", "OCR Connection: " + connection.toString());
    //
    //        OutputStream stream = connection.getOutputStream();
    //        stream.write(bytes);
    //        stream.close();
    //
    //        int httpCode = connection.getResponseCode();
    //        // Success request
    //        if (httpCode == HttpURLConnection.HTTP_OK) {
    //            Log.d("OCR API", "Success");
    //            // Get response stream
    //            String jsonResponse = GetResponseToString(connection.getInputStream());
    //            JSONObject reader = new JSONObject(jsonResponse);
    //            JSONArray text = reader.getJSONArray("OCRText");
    //            Log.d("OCR API", text.toString());
    //            if (text.length() > 0) {
    //                OCRedText = text.get(0).toString();
    //            } else {
    //                OCRedText = "";
    //            }
    //
    //            File root = new File(Environment
    //                    .getExternalStorageDirectory()
    //                    + File.separator + "WhatisCache" + File.separator);
    //            root.mkdirs();
    //            File f = new File(root, "OCRedText.txt");
    //
    //            FileWriter writer = new FileWriter(f);
    //            writer.append(OCRedText);
    //            writer.flush();
    //            writer.close();
    //        } else if (httpCode == HttpURLConnection.HTTP_UNAUTHORIZED) {
    //            Log.d("OCR API", "OCR Error Message: Unauthorizied request");
    //            System.out.println("OCR Error Message: Unauthorizied request");
    //        } else {
    //            // Error occurred
    //            String jsonResponse = GetResponseToString(connection.getErrorStream());
    //
    //            JSONObject reader = new JSONObject(jsonResponse);
    //            JSONArray text = reader.getJSONArray("ErrorMessage");
    //            Log.d("OCR API", "OCR Error");
    //            Log.d("OCR API", text.toString());
    //
    //            OCRedText = text.get(0).toString();
    //            // Error message
    //            Toast.makeText(MainActivity.this, "Error Message: " + OCRedText, Toast.LENGTH_LONG).show();
    //            System.out.println();
    //        }
    //
    //        connection.disconnect();
    //OCRedText = "happy";
    return OCRedText;
}

From source file:com.facebook.android.Hackbook.java

@Override
public void onItemClick(AdapterView<?> arg0, View v, int position, long arg3) {
    switch (position) {
    /*/*from  ww w.  j a v a 2  s . c  o  m*/
     * Source Tag: update_status_tag Update user's status by invoking the
     * feed dialog To post to a friend's wall, provide his uid in the 'to'
     * parameter Refer to
     * https://developers.facebook.com/docs/reference/dialogs/feed/ for more
     * info.
     */
    case 0: {
        Bundle params = new Bundle();
        params.putString("caption", getString(R.string.app_name));
        params.putString("description", getString(R.string.app_desc));
        params.putString("picture", Utility.HACK_ICON_URL);
        params.putString("name", getString(R.string.app_action));

        Utility.mFacebook.dialog(Hackbook.this, "feed", params, new UpdateStatusListener());
        String access_token = Utility.mFacebook.getAccessToken();
        System.out.println(access_token);
        break;
    }

    /*
     * Source Tag: app_requests Send an app request to friends. If no
     * friend is specified, the user will see a friend selector and will
     * be able to select a maximum of 50 recipients. To send request to
     * specific friend, provide the uid in the 'to' parameter Refer to
     * https://developers.facebook.com/docs/reference/dialogs/requests/
     * for more info.
     */
    case 1: {
        Bundle params = new Bundle();
        params.putString("message", getString(R.string.request_message));
        Utility.mFacebook.dialog(Hackbook.this, "apprequests", params, new AppRequestsListener());
        break;
    }

    /*
     * Source Tag: friends_tag You can get friends using
     * graph.facebook.com/me/friends, this returns the list sorted by
     * UID OR using the friend table. With this you can sort the way you
     * want it.
     * Friend table - https://developers.facebook.com/docs/reference/fql/friend/
     * User table - https://developers.facebook.com/docs/reference/fql/user/
     */
    case 2: {
        if (!Utility.mFacebook.isSessionValid()) {
            Util.showAlert(this, "Warning", "You must first log in.");
        } else {
            dialog = ProgressDialog.show(Hackbook.this, "", getString(R.string.please_wait), true, true);
            new AlertDialog.Builder(this).setTitle(R.string.Graph_FQL_title).setMessage(R.string.Graph_FQL_msg)
                    .setPositiveButton(R.string.graph_button, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            graph_or_fql = "graph";
                            Bundle params = new Bundle();
                            params.putString("fields", "name, picture, location");
                            Utility.mAsyncRunner.request("me/friends", params, new FriendsRequestListener());
                        }

                    }).setNegativeButton(R.string.fql_button, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            graph_or_fql = "fql";
                            String query = "select name, current_location, uid, pic_square from user where uid in (select uid2 from friend where uid1=me()) order by name";
                            Bundle params = new Bundle();
                            params.putString("method", "fql.query");
                            params.putString("query", query);
                            Utility.mAsyncRunner.request(null, params, new FriendsRequestListener());
                        }

                    }).setOnCancelListener(new DialogInterface.OnCancelListener() {
                        @Override
                        public void onCancel(DialogInterface d) {
                            dialog.dismiss();
                        }
                    }).show();
        }
        break;
    }

    /*
     * Source Tag: upload_photo You can upload a photo from the media
     * gallery or from a remote server How to upload photo:
     * https://developers.facebook.com/blog/post/498/
     */
    case 3: {
        if (!Utility.mFacebook.isSessionValid()) {
            Util.showAlert(this, "Warning", "You must first log in.");
        } else {
            dialog = ProgressDialog.show(Hackbook.this, "", getString(R.string.please_wait), true, true);
            new AlertDialog.Builder(this).setTitle(R.string.gallery_remote_title)
                    .setMessage(R.string.gallery_remote_msg)
                    .setPositiveButton(R.string.gallery_button, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            Intent intent = new Intent(Intent.ACTION_PICK,
                                    (MediaStore.Images.Media.EXTERNAL_CONTENT_URI));
                            startActivityForResult(intent, PICK_EXISTING_PHOTO_RESULT_CODE);
                        }

                    }).setNegativeButton(R.string.remote_button, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            /*
                             * Source tag: upload_photo_tag
                             */
                            Bundle params = new Bundle();
                            params.putString("url",
                                    "http://www.facebook.com/images/devsite/iphone_connect_btn.jpg");
                            params.putString("caption", "FbAPIs Sample App photo upload");
                            Utility.mAsyncRunner.request("me/photos", params, "POST", new PhotoUploadListener(),
                                    null);
                        }

                    }).setOnCancelListener(new DialogInterface.OnCancelListener() {
                        @Override
                        public void onCancel(DialogInterface d) {
                            dialog.dismiss();
                        }
                    }).show();
        }
        break;
    }

    /*
     * User can check-in to a place, you require publish_checkins
     * permission for that. You can use the default Times Square
     * location or fetch user's current location. Get user's checkins:
     * https://developers.facebook.com/docs/reference/api/checkin/
     */
    case 4: {
        final Intent myIntent = new Intent(getApplicationContext(), Places.class);

        new AlertDialog.Builder(this).setTitle(R.string.get_location)
                .setMessage(R.string.get_default_or_new_location)
                .setPositiveButton(R.string.current_location_button, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        myIntent.putExtra("LOCATION", "current");
                        startActivity(myIntent);
                    }
                }).setNegativeButton(R.string.times_square_button, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        myIntent.putExtra("LOCATION", "times_square");
                        startActivity(myIntent);
                    }

                }).show();
        break;
    }

    case 5: {
        if (!Utility.mFacebook.isSessionValid()) {
            Util.showAlert(this, "Warning", "You must first log in.");
        } else {
            new FQLQuery(Hackbook.this).show();
        }
        break;
    }
    /*
     * This is advanced feature where you can request new permissions
     * Browser user's graph, his fields and connections. This is similar
     * to the www version:
     * http://developers.facebook.com/tools/explorer/
     */
    case 6: {
        Intent myIntent = new Intent(getApplicationContext(), GraphExplorer.class);
        if (Utility.mFacebook.isSessionValid()) {
            Utility.objectID = "me";
        }
        startActivity(myIntent);
        break;
    }

    case 7: {
        if (!Utility.mFacebook.isSessionValid()) {
            Util.showAlert(this, "Warning", "You must first log in.");
        } else {
            new TokenRefreshDialog(Hackbook.this).show();
        }
    }
    }
}

From source file:org.ueu.uninet.it.IragarkiOholaKontaktua.java

@Override
protected void onResume() {
    super.onResume();
    // hasieratu hariak sinkronizatzeko kontagailua, irudia eta testuaren
    // karga sinkronizatzeko
    latch = new CountDownLatch(1);
    StringBuilder validationText = new StringBuilder();
    // Egiaztatu sareko konekzioa dagoela bestela ohartarazi eta leihoa itxi
    if (!NetworkConnectivity.sharedNetworkConnectivity().isConnected()) {
        validationText.append("Sareko konexioa beharrezkoa da");
        balidatuDialogoa = new AlertDialog.Builder(this).setTitle("Errorea")
                .setMessage(validationText.toString())
                .setPositiveButton("Segi", new android.content.DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int arg1) {
                        IragarkiOholaKontaktua.this.finish();
                    }//from  w  w w.  ja v  a  2  s.  c  o  m
                }).show();
        validationText = null;
    } else { // Sare konexioa badago
        this.progressDialog = ProgressDialog.show(this, " Lanean...", " Iragarkia eskuratzen", true, false);
        // ezarri iragarkiaren url-a unibertsitatea.net webgunean
        this.url = getIntent().getStringExtra("url");

        // TODO egiaztatu irudia duela getIrudi-ra deitu aurretik sare
        // atzipen bat
        // aurrezteko

        // irudia-ren url-a ezarri: formatua-> iragarkiaren_url +
        // /image_mini
        this.image_src = this.url + "/image_mini";

        // Testua eta irudia txertatzeko layout-a prestatu

        // Izenburua ezarri (parametro modua dator)
        TextView izenburua = (TextView) findViewById(R.id.izenburuaIragarkia);
        izenburua.setText(getIntent().getStringExtra("izenburua"));

        // Deskribapen laburra ezarri (parametro modua dator)
        TextView laburpena = (TextView) findViewById(R.id.laburpenaIragarkia);
        laburpena.setText(getIntent().getStringExtra("eduki_laburpen"));

        // Deskribapen luzea lortu hari berri batean
        getTestua();

        // Iragarkiak irudirik balu
        if (irudirik) {
            // eskuratu irudia saretik beste hari batean eta layout-ean
            // jarri
            // irudiaren kargak testuaren kargari itxaroten dio, hari biak
            // sinkronizatu gero testu inguratua egin ahal izateko
            irudiaDeskargatu task = new irudiaDeskargatu();
            task.execute(new String[] { this.image_src });
        }

        //Fokoa deskribaoen luzean jarri
        laburpen_luzea.setFocusable(true);
        laburpen_luzea.requestFocus();

    }
}

From source file:org.ros.android.app_chooser.ExchangeActivity.java

public void uninstallApp(View view) {
    final ExchangeActivity activity = this;
    final ProgressDialog progress = ProgressDialog.show(activity, "Uninstalling App",
            "Uninstalling " + appSelectedDisplay + "...", true, false);
    progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    appManager.uninstallApp(appSelected, new ServiceResponseListener<UninstallApp.Response>() {
        @Override/*  w  w  w .  j  a  v  a 2  s  .c  om*/
        public void onSuccess(UninstallApp.Response message) {
            if (!message.uninstalled) {
                final String errorMessage = message.message;
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        new AlertDialog.Builder(activity).setTitle("Error on Uninstallation!")
                                .setCancelable(false).setMessage("ERROR: " + errorMessage)
                                .setNeutralButton("Ok", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {
                                    }
                                }).create().show();
                    }
                });
            }
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    progress.dismiss();
                }
            });
        }

        @Override
        public void onFailure(final RemoteException e) {
            e.printStackTrace();
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    new AlertDialog.Builder(activity).setTitle("Error on Uninstallation").setCancelable(false)
                            .setMessage("Failed: cannot contact robot: " + e.toString())
                            .setNeutralButton("Ok", new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                }
                            }).create().show();
                    progress.dismiss();
                }
            });
        }
    });
}

From source file:ansteph.com.beecabfordrivers.view.registration.RegistrationFragment.java

private void registerClient() throws JSONException {

    //Displaying a progress dialog
    final ProgressDialog loading = ProgressDialog.show(getActivity(), "Registering",
            "Please wait... you will soon be in our awesome network", false, false);

    //Getting user data
    fullName = txtFullName.getText().toString().trim();
    email = txtEmail.getText().toString().trim();
    mobile = txtMobile.getText().toString().trim();
    pwd = txtPassword.getText().toString().trim();
    companyname = txtCompanyName.getText().toString().trim();
    carmodel = txtCarModel.getText().toString().trim();
    numPlate = txtNumPlate.getText().toString().trim();
    licence = txtLicence.getText().toString().trim();
    year = txtYear.getText().toString().trim();

    //create the string request
    StringRequest stringRequest = new StringRequest(Request.Method.POST, Config.REGISTER_URL,
            new Response.Listener<String>() {
                @Override//  www. j  a  v a  2  s.co  m
                public void onResponse(String response) {
                    loading.dismiss();

                    try {
                        //creating the Json object from the response
                        JSONObject jsonResponse = new JSONObject(response);
                        boolean error = jsonResponse.getBoolean(Config.ERROR_RESPONSE);
                        String serverMsg = jsonResponse.getString("message");
                        //if it is success
                        if (!error) {
                            //asking user to confirm OTP
                            confirmOtp();
                        } else {
                            Toast.makeText(getActivity(), serverMsg, Toast.LENGTH_LONG).show();

                        }
                        /* if(jsonResponse.getString(Config.TAG_RESPONSE).equalsIgnoreCase("success")){
                             //asking user to confirm OTP
                             confirmOtp();
                         }else{
                             //if not succcess
                             Toast.makeText(getActivity(), "Welcome back to our network, we happy to have you back", Toast.LENGTH_LONG).show();
                         }*/

                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    loading.dismiss();
                    Toast.makeText(getActivity(), error.getMessage(), Toast.LENGTH_LONG).show();
                }
            }) {

        @Override
        protected Map<String, String> getParams() throws AuthFailureError {
            Map<String, String> params = new HashMap<>();
            //Adding the parameters to the request name','email','mobile','password', 'company_name',  'carmodel', 'numplate', 'license', 'year
            params.put(Config.KEY_NAME, fullName);
            params.put(Config.KEY_EMAIL, email);
            params.put(Config.KEY_MOBILE, mobile);
            params.put(Config.KEY_COMNAME, companyname);
            params.put(Config.KEY_CARMODEL, carmodel);
            params.put(Config.KEY_NUMPLATE, numPlate);
            params.put(Config.KEY_LICENSE, licence);
            params.put(Config.KEY_YEAR, year);

            params.put(Config.KEY_PWD, pwd);

            return params;
        }
    };
    //Adding request the queue
    requestQueue.add(stringRequest);
}

From source file:com.yi4all.rupics.ImageDetailActivity.java

private void initBtn() {
    topBarPanel = findViewById(R.id.image_top_bar);
    topBarPanel.setVisibility(View.GONE);

    popMenuPanel = findViewById(R.id.image_pop_menu);

    TextView tv = (TextView) findViewById(R.id.image_title_txt);
    tv.setText(issue.getCategory().getName() + "-" + issue.getName());

    ImageView back = (ImageView) findViewById(R.id.image_back_btn);
    back.setOnClickListener(new OnClickListener() {

        @Override//from   w  w w. j a  v  a  2s .  c o m
        public void onClick(View v) {
            finish();
        }
    });

    ImageView pop = (ImageView) findViewById(R.id.image_pop_btn);
    pop.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (popMenuPanel.getVisibility() == View.VISIBLE) {
                popMenuPanel.setVisibility(View.GONE);
            } else {
                popMenuPanel.setVisibility(View.VISIBLE);
            }
        }
    });

    //      final TextView wallpaperBtn = (TextView) findViewById(R.id.wallpaperBtn);

    final TextView slideshowBtn = (TextView) findViewById(R.id.slideshowBtn);

    final TextView shareBtn = (TextView) findViewById(R.id.shareBtn);

    final TextView downloadBtn = (TextView) findViewById(R.id.downloadBtn);

    //      wallpaperBtn.setOnClickListener(new OnClickListener() {
    //         public void onClick(View v) {
    //            String img = imgList.get(imageSequence).getUrl();
    //            String path = Utils.convertUrl2Path(ImageDetailActivity.this, img);
    //            if (path != null && new File(path).exists()) {
    //               try {
    //                  ImageDetailActivity.this.setWallpaper(BitmapFactory.decodeFile(path));
    //               } catch (IOException e) {
    //                  e.printStackTrace();
    //               }
    //            } else {
    //               // give a tip to user
    //               Utils.toastMsg(ImageDetailActivity.this, R.string.noImageWallpaper);
    //            }
    //            Utils.toastMsg(ImageDetailActivity.this, R.string.setWallpaperSuccess);
    //         }
    //      });

    slideshowBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            isSlideshow = !isSlideshow;
            if (isSlideshow) {

                startSlideShow();
                topBarPanel.setVisibility(View.GONE);
                popMenuPanel.setVisibility(View.GONE);

                slideshowBtn.setText(R.string.slideshow_pause);
            } else {
                topBarPanel.setVisibility(View.VISIBLE);

                slideshowBtn.setText(R.string.slideshow);
            }

        }
    });

    shareBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            //            Intent intent = createShareIntent();
            byte[] bytes = getCurrentImage();
            if (bytes == null) {
                Utils.toastMsg(ImageDetailActivity.this, R.string.noImageShare);
            } else {
                //             ImageDetailActivity.this.startActivity(intent);
                popMenuPanel.setVisibility(View.GONE);
                UMServiceFactory.shareTo(ImageDetailActivity.this, getString(R.string.shareImageMmsBody),
                        bytes);
            }

        }
    });

    downloadBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            if (getService().sureLimitation()) {
                popMenuPanel.setVisibility(View.GONE);

                final ProgressDialog pd = ProgressDialog.show(ImageDetailActivity.this,
                        getString(R.string.waitTitle), getString(R.string.downloadAllImage), false, false);
                final Handler handler = new Handler() {
                    int current = 0;
                    int total = imgList.size();
                    int size = 0;

                    @Override
                    public void handleMessage(Message msg) {
                        current++;

                        pd.setMessage(getString(R.string.downloadAllImage) + current + "/" + total);

                        if (msg.arg2 > 0) {
                            size += msg.arg2;
                        }

                        if (current >= total) {
                            if (size > 0) {
                                getService().addUserConsumedKbytes(size);
                            }
                            pd.dismiss();
                        }
                    }
                };
                new Thread(new Runnable() {

                    @Override
                    public void run() {
                        for (ImageModel im : imgList) {
                            String imgUrl = im.getUrl();
                            String path = Utils.convertUrl2Path(ImageDetailActivity.this, imgUrl);
                            util.runSaveUrl(path, imgUrl, handler);
                        }

                    }
                }).start();
            }
        }
    });

}

From source file:com.wishlist.Wishlist.java

public void addToTimeline() {
    dialog = ProgressDialog.show(Wishlist.this, "", getString(R.string.adding_to_timeline), true, true);
    /*// w  w w  . java2 s .  c  om
     * Create Product URL
     */
    String productURL = HOST_SERVER_URL + HOST_PRODUCT_URI;
    Bundle productParams = new Bundle();
    productParams.putString("name", mProductName);
    productParams.putString("image", mProductImageName);
    productURL = productURL + "?" + Util.encodeUrl(productParams);

    Bundle wishlistParams = new Bundle();

    if (mPlacesAvailable) {
        try {
            wishlistParams.putString("place", mPlacesJSONArray
                    .getJSONObject(mPlacesListSpinner.getSelectedItemPosition()).getString("id"));
        } catch (JSONException e) {
        }
    }
    wishlistParams.putString("wishlist", WISHLIST_OBJECTS_URL[mWishlistSpinner.getSelectedItemPosition()]);
    wishlistParams.putString("product", productURL);
    wishlistParams.putString("image", mProductImageURL);
    //TODO
    //put the app's namespace and 'add_to' action here
    Utility.mAsyncRunner.request("me/{namespace}:{add_to_action}", wishlistParams, "POST",
            new addToTimelineListener(), null);
}

From source file:com.lge.friendsCamera.CameraFileListViewActivity.java

/**
 * Initialize view based on media type (image or video)
 *//*w  w  w .j  av a2  s .  co  m*/
private void initialize() {
    mContext = this;
    FriendsCameraApplication.setContext(mContext);

    if (mediaType == null) {
        Log.v(TAG, "ERROR: Need to set media type");
        return;
    }

    //Set adapter type based on media type
    if (mediaType.equals(IMAGE)) {
        adapter.setType(CustomListAdapter.selectedGalleryType.CAMERA_IMAGE);
    } else if (mediaType.equals(VIDEO)) {
        adapter.setType(CustomListAdapter.selectedGalleryType.CAMERA_VIDEO);
    }

    //Set adapter for list view
    //  Multiple choice mode for deleting multiple items
    //  Single choice mode for selecting an item to show info, download, and delete
    mListView.setAdapter(adapter);
    mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    mListView.setItemsCanFocus(false);
    mListView.setMultiChoiceModeListener(multiChoiceModeListener);
    mListView.setOnItemClickListener(itemClickListener);

    mProgressDialog = ProgressDialog.show(mContext, "", "Loading...", true, false);

    //Get file list from camera
    getListFiles(null);
}