Example usage for android.app ProgressDialog dismiss

List of usage examples for android.app ProgressDialog dismiss

Introduction

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

Prototype

@Override
public void dismiss() 

Source Link

Document

Dismiss this dialog, removing it from the screen.

Usage

From source file:cn.ucai.fulicenter.fragment.ContactlistFragment.java

/**
 * ?/*from   w  w w .  j a  v a 2s  .  c  o m*/
 * 
 * @param tobeDeleteUser
 */
public void deleteContact(final Contact tobeDeleteUser) {
    String st1 = getResources().getString(R.string.deleting);
    final String st2 = getResources().getString(R.string.Delete_failed);
    final ProgressDialog pd = new ProgressDialog(getActivity());
    pd.setMessage(st1);
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    try {
    } catch (Exception e) {
        e.printStackTrace();
    }
    new Thread(new Runnable() {
        public void run() {
            try {
                EMContactManager.getInstance().deleteContact(tobeDeleteUser.getMContactCname());
                // db?
                EMUserDao dao = new EMUserDao(getActivity());
                dao.deleteContact(tobeDeleteUser.getMContactCname());
                ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList()
                        .remove(tobeDeleteUser.getMContactCname());
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        adapter.remove(tobeDeleteUser);
                        adapter.notifyDataSetChanged();

                    }
                });
            } catch (final Exception e) {
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st2 + e.getMessage(), Toast.LENGTH_LONG).show();
                    }
                });

            }

        }
    }).start();

}

From source file:com.example.hana.rentcostumes.RegisterActivity.java

public void signup() {
    Log.d(TAG, "Signup");

    if (!validate()) {
        onSignupFailed();//w w w.  j a v a2 s  .c om
        return;
    }

    //btnRegister.setEnabled(false);

    final ProgressDialog progressDialog = new ProgressDialog(RegisterActivity.this,
            R.style.MyTheme_ProgressDialog_);
    progressDialog.setIndeterminate(true);
    progressDialog.setMessage("Creating Account...");
    progressDialog.show();

    String fname = inputFirstName.getText().toString();
    String lname = inputLastName.getText().toString();
    String email = inputEmail.getText().toString();
    String uname = inputUsername.getText().toString();
    String password = inputPassword.getText().toString();

    // TODO: Implement your own signup logic here.
    firebaseAuth.createUserWithEmailAndPassword(email, password).addOnCompleteListener(this,
            new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "createUserWithEmail:onComplete:" + task.isSuccessful());
                    if (task.isSuccessful()) {
                        Toast.makeText(RegisterActivity.this, R.string.auth_success, Toast.LENGTH_SHORT).show();
                        startActivity(new Intent(getApplicationContext(), MainActivity.class));
                    }
                    progressDialog.dismiss();
                }
            });
}

From source file:org.telegram.ui.ChangeUsernameActivity.java

private void saveName() {
    if (!checkUserName(firstNameField.getText().toString(), true)) {
        return;/* w  w  w  . java  2  s  .  c  o  m*/
    }
    TLRPC.User user = UserConfig.getCurrentUser();
    if (getParentActivity() == null || user == null) {
        return;
    }
    String currentName = user.username;
    if (currentName == null) {
        currentName = "";
    }
    String newName = firstNameField.getText().toString();
    if (currentName.equals(newName)) {
        finishFragment();
        return;
    }

    final ProgressDialog progressDialog = new ProgressDialog(getParentActivity());
    progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.setCancelable(false);

    TLRPC.TL_account_updateUsername req = new TLRPC.TL_account_updateUsername();
    req.username = newName;

    NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces,
            MessagesController.UPDATE_MASK_NAME);
    final int reqId = ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
        @Override
        public void run(TLObject response, final TLRPC.TL_error error) {
            if (error == null) {
                final TLRPC.User user = (TLRPC.User) response;
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            progressDialog.dismiss();
                        } catch (Exception e) {
                            FileLog.e("tmessages", e);
                        }
                        ArrayList<TLRPC.User> users = new ArrayList<>();
                        users.add(user);
                        MessagesController.getInstance().putUsers(users, false);
                        MessagesStorage.getInstance().putUsersAndChats(users, null, false, true);
                        UserConfig.saveConfig(true);
                        finishFragment();
                    }
                });
            } else {
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            progressDialog.dismiss();
                        } catch (Exception e) {
                            FileLog.e("tmessages", e);
                        }
                        showErrorAlert(error.text);
                    }
                });
            }
        }
    }, ConnectionsManager.RequestFlagFailOnServerErrors);
    ConnectionsManager.getInstance().bindRequestToGuid(reqId, classGuid);

    progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE,
            LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    ConnectionsManager.getInstance().cancelRequest(reqId, true);
                    try {
                        dialog.dismiss();
                    } catch (Exception e) {
                        FileLog.e("tmessages", e);
                    }
                }
            });
    progressDialog.show();
}

From source file:org.alfresco.mobile.android.ui.operation.OperationWaitingDialogFragment.java

public Dialog onCreateDialog(final Bundle savedInstanceState) {
    if (getArguments() != null) {
        operationType = getArguments().getInt(ARGUMENT_TYPEID);
        intentId = getArguments().getString(ARGUMENT_INTENTID);
        iconId = getArguments().getInt(ARGUMENT_ICONID);
        title = getArguments().getString(ARGUMENT_TITLEID);
        message = getArguments().getString(ARGUMENT_MESSAGEID);
        parent = getArguments().getParcelable(ARGUMENT_NODEID);
        nbItems = getArguments().getInt(ARGUMENT_SIZE);
        operationId = getArguments().getString(ARGUMENT_OPERATIONID);
    }/*from   w ww.j  a  v a  2  s.  c  o  m*/

    ProgressDialog dialog = new ProgressDialog(getActivity());
    if (iconId == 0) {
        iconId = R.drawable.ic_application_logo;
    }
    dialog.setIcon(iconId);
    dialog.setTitle(title);
    if (message == null) {
        message = getString(R.string.waiting_operations);
    }
    dialog.setMessage(message);
    boolean indeterminate = true;
    if (nbItems > 0) {
        dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        dialog.setProgress(0);
        dialog.setMax(nbItems);
        indeterminate = false;
    } else {
        dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    }
    dialog.setIndeterminate(indeterminate);
    dialog.setCancelable(false);
    dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (operationId != null) {
                        Operator.with(getActivity()).cancel(operationId);
                    }
                    dialog.dismiss();
                }
            });

    getActivity().getLoaderManager().restartLoader(this.hashCode(), null, this);

    return dialog;
}

From source file:com.example.sujit.customerapp.Get_Taxi.java

private void getDrivers() {
    final ProgressDialog loading = ProgressDialog.show(this, "Getting Drivers", "Please wait...", false, false);
    loading.show();//from  w  w w  . j a  v a 2s.c  om

    //   RequestQueue requestQueue = Volley.newRequestQueue(Get_Taxi.this);
    String driversUrl = "http://6e1e7877.ngrok.io/willselectataxi";

    StringRequest jsonObjectRequest = new StringRequest(Request.Method.POST, driversUrl,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {

                    mGoogleMap.clear();
                    LatLng latLng1 = new LatLng(currentLatitude, currentLongitude);
                    mGoogleMap.addMarker(new MarkerOptions().position(latLng1).title("Your Location"));
                    loading.dismiss();
                    Log.d("Response", response);
                    try {
                        JSONObject jsonObject = new JSONObject(response);
                        JSONArray jsonArray = jsonObject.getJSONArray("markers");

                        for (int i = 0; i < jsonArray.length(); i++) {
                            JSONObject jsonObj = jsonArray.getJSONObject(i);

                            double lang = jsonObj.getDouble("longitude");
                            double lat = jsonObj.getDouble("latitude");

                            LatLng latLng = new LatLng(lat, lang);
                            //move CameraPosition on first result
                            if (i == 0) {
                                CameraPosition cameraPosition = new CameraPosition.Builder().target(latLng)
                                        .zoom(15).build();
                                mGoogleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
                            }
                            // Create a marker for each lat, lng the JSON data.
                            myMarker = mGoogleMap.addMarker(new MarkerOptions()
                                    .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_directions_car))
                                    .title(jsonObj.getString("username")).position(latLng));

                            mGoogleMap.setOnInfoWindowClickListener(Get_Taxi.this);
                            mGoogleMap.setOnMarkerClickListener(Get_Taxi.this);

                        }
                        loading.dismiss();
                    } catch (JSONException e) {
                        e.printStackTrace();
                        Log.d("Error processing JSON", e.toString());
                    }
                }
            }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    loading.dismiss();
                    Toast.makeText(Get_Taxi.this, error.toString(), Toast.LENGTH_LONG).show();
                    Log.d("abd", "Error: " + error + ">>" + error.networkResponse.statusCode + ">>"
                            + error.getCause() + ">>" + error.getMessage());
                }
            }) {
        @Override
        protected Map<String, String> getParams() {

            SharedPreferences sharedPreferences = getSharedPreferences("LoggedInUser", MODE_PRIVATE);
            String phnNo = sharedPreferences.getString("phoneNo", "");

            Map<String, String> params = new HashMap<>();

            params.put("latitude", String.valueOf(currentLatitude));
            params.put("longitude", String.valueOf(currentLongitude));
            params.put("mobile_number", phnNo);
            return params;
        }
    };
    MySingleton.getInstance(getApplicationContext()).addToRequestQueue(jsonObjectRequest);

}

From source file:org.sickstache.fragments.ShowsFragment.java

@Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
    if (actionMode == null) {
        actionMode = getSherlockActivity().startActionMode(new ActionMode.Callback() {

            @Override//  ww w .ja  v a 2 s  . c o  m
            public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
                return false;
            }

            @Override
            public void onDestroyActionMode(ActionMode mode) {
                showAdapter.notifyDataSetChanged();
                selected.clear();
                actionMode = null;
            }

            @Override
            public boolean onCreateActionMode(ActionMode mode, Menu menu) {
                MenuInflater inflate = getSherlockActivity().getSupportMenuInflater();
                inflate.inflate(R.menu.shows_cab_menu, menu);
                return true;
            }

            @Override
            public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
                switch (item.getItemId()) {
                case R.id.pauseMenuItem:
                    final PauseDialog pDialog = new PauseDialog();
                    pDialog.setTitle("Set Pause");
                    pDialog.setOnOkClick(new OnClickListener() {
                        @Override
                        public void onClick(DialogInterface arg0, int arg1) {
                            final ProgressDialog dialog = ProgressDialog.show(
                                    ShowsFragment.this.getSherlockActivity(), "",
                                    "Pausing Shows. Please wait...", true);
                            dialog.setCancelable(true);
                            dialog.show();
                            String[] tvdbids = new String[selected.size()];
                            for (int i = 0; i < selected.size(); i++) {
                                tvdbids[i] = showAdapter.getItem(selected.get(i)).id;
                            }
                            Preferences pref = Preferences
                                    .getSingleton(ShowsFragment.this.getSherlockActivity());
                            PauseTask pause = new PauseTask(pref, tvdbids, pDialog.getPause()) {
                                @Override
                                protected void onPostExecute(Boolean result) {
                                    if (dialog != null && dialog.isShowing())
                                        dialog.dismiss();
                                    if (error != null && getFragmentManager() != null) {
                                        ErrorDialog dialog = new ErrorDialog();
                                        dialog.setMessage("Error pausing show.\nERROR: " + error.getMessage());
                                        dialog.show(getFragmentManager(), "pauseError");
                                    }
                                }
                            };
                            pause.execute();
                        }
                    });
                    pDialog.show(getFragmentManager(), "update");
                    return true;
                case R.id.refreshMenuItem: {
                    final ProgressDialog dialog = ProgressDialog.show(ShowsFragment.this.getSherlockActivity(),
                            "", "Refreshing Shows. Please wait...", true);
                    dialog.setCancelable(true);
                    dialog.show();
                    String[] tvdbids = new String[selected.size()];
                    for (int i = 0; i < selected.size(); i++) {
                        tvdbids[i] = showAdapter.getItem(selected.get(i)).id;
                    }
                    Preferences pref = Preferences.getSingleton(ShowsFragment.this.getSherlockActivity());
                    RefreshTask refresh = new RefreshTask(pref, tvdbids) {
                        @Override
                        protected void onPostExecute(Boolean result) {
                            if (dialog != null && dialog.isShowing())
                                dialog.dismiss();
                            if (error != null && getFragmentManager() != null) {
                                ErrorDialog dialog = new ErrorDialog();
                                dialog.setMessage("Error refreshing show.\nERROR: " + error.getMessage());
                                dialog.show(getFragmentManager(), "refreshError");
                            }
                        }
                    };
                    refresh.execute();
                }
                    return true;
                case R.id.updateMenuItem: {
                    final ProgressDialog dialog = ProgressDialog.show(ShowsFragment.this.getSherlockActivity(),
                            "", "Updating Shows. Please wait...", true);
                    dialog.setCancelable(true);
                    dialog.show();
                    String[] tvdbids = new String[selected.size()];
                    for (int i = 0; i < selected.size(); i++) {
                        tvdbids[i] = showAdapter.getItem(selected.get(i)).id;
                    }
                    Preferences pref = Preferences.getSingleton(ShowsFragment.this.getSherlockActivity());
                    UpdateTask update = new UpdateTask(pref, tvdbids) {
                        @Override
                        protected void onPostExecute(Boolean result) {
                            if (dialog != null && dialog.isShowing())
                                dialog.dismiss();
                            if (error != null && getFragmentManager() != null) {
                                ErrorDialog dialog = new ErrorDialog();
                                dialog.setMessage("Error updating show.\nERROR: " + error.getMessage());
                                dialog.show(getFragmentManager(), "updateError");
                            }
                        }
                    };
                    update.execute();
                }
                    return true;
                //               case R.id.editMenuItem:
                //                  // get all selected items and create the edit show activity passing all of them
                //                  actionMode.finish();
                //                  return true;
                }
                return false;
            }
        });
    }
    ImageView overlay = (ImageView) arg1.findViewById(R.id.showSelectedOverlay);
    int i = selected.indexOf(arg2);
    if (i >= 0) {
        selected.remove(i);
        overlay.setVisibility(View.INVISIBLE);
    } else {
        selected.add(arg2);
        overlay.setVisibility(View.VISIBLE);
    }
    actionMode.setTitle(selected.size() + " Items Selected");
    if (selected.size() == 0) {
        actionMode.finish();
    }
    return true;
}

From source file:au.com.wallaceit.reddinator.ViewRedditActivity.java

private void showLoginDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(ViewRedditActivity.this);
    // Get the layout inflater
    LayoutInflater inflater = getLayoutInflater();
    final View v = inflater.inflate(R.layout.logindialog, null);

    builder.setView(v)//from w w  w  .j ava 2  s  . c o  m
            // Add action buttons
            .setPositiveButton("Login", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    final String username = ((EditText) v.findViewById(R.id.username)).getText().toString();
                    final String password = ((EditText) v.findViewById(R.id.password)).getText().toString();
                    final boolean rememberaccn = ((CheckBox) v.findViewById(R.id.rememberaccn)).isChecked();
                    dialog.cancel();
                    // run login procedure
                    final ProgressDialog logindialog = android.app.ProgressDialog.show(ViewRedditActivity.this,
                            "", ("Logging in..."), true);
                    Thread t = new Thread() {
                        public void run() {
                            // login
                            final String result = global.mRedditData.checkLogin(prefs, username, password,
                                    rememberaccn); // request "remember" cookie if account is being saved
                            // Set thread network policy to prevent network on main thread exceptions.
                            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll()
                                    .build();
                            StrictMode.setThreadPolicy(policy);
                            runOnUiThread(new Runnable() {
                                public void run() {
                                    logindialog.dismiss();
                                    if (result.equals("1")) {
                                        if (rememberaccn) { // store account if requested & login result is OK
                                            global.setAccount(prefs, username, password, true);
                                        }
                                    } else {
                                        // show error
                                        Toast.makeText(ViewRedditActivity.this, "Login error: " + result,
                                                Toast.LENGTH_LONG).show();
                                    }
                                }
                            });
                        }
                    };
                    t.start();
                }
            }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            }).setTitle("Login to Reddit");
    builder.create().show();
}

From source file:org.zeroxlab.zeroxbenchmark.Benchmark.java

public void runCase(LinkedList<Case> list) {
        Case pointer = null;/*from  w  w w .j a v  a  2  s  .  co  m*/
        boolean finish = true;
        for (int i = 0; i < list.size(); i++) {
            pointer = list.get(i);
            if (!pointer.isFinish()) {
                finish = false;
                break;
            }
        }

        if (finish) {
            //            mBannerInfo.setText("Benchmarking complete.\nClick Show to upload.\nUploaded results:\nhttp://0xbenchmark.appspot.com");
            String result = getResult();
            writeResult(mOutputFile, result);

            final ProgressDialog dialogGetXml = new ProgressDialog(this).show(this, "Generating XML Report",
                    "Please wait...", true, false);
            new Thread() {
                public void run() {
                    mJSONResult = getJSONResult();
                    mXMLResult = getXMLResult();
                    Log.d(TAG, "XML: " + mXMLResult);
                    writeResult(mOutputXMLFile, mXMLResult);
                    Log.d(TAG, "JSON: " + mJSONResult);
                    writeResult(mOutputJSONFile, mJSONResult);
                    mShow.setClickable(true);
                    onClick(mShow);
                    mTouchable = true;
                    dialogGetXml.dismiss();
                }
            }.start();
        } else {
            Intent intent = pointer.generateIntent();
            if (intent != null) {
                startActivityForResult(intent, 0);
            }
        }
    }

From source file:me.albertonicoletti.latex.activities.EditorActivity.java

/**
 * Routine that searches for the images used in the current document, zips them with the file
 * and sends it to the server.//w w w  . j  a  v a 2 s  .  c  o  m
 * It will show the response pdf or log.
 */
private void generatePDF() {
    boolean fileNeedsToBeSaved = !saveFile();
    if (!fileNeedsToBeSaved) {
        if (!editor.getTextString().equals("")) {
            final String imagesFolderPath = PreferenceHelper.getImageFolder(getApplicationContext());
            final String outputFolderPath = PreferenceHelper.getOutputFolder(getApplicationContext());
            final File imagesFolder = new File(imagesFolderPath);
            final File outputFolder = new File(outputFolderPath);
            final ProgressDialog asyncDialog = new ProgressDialog(EditorActivity.this);
            asyncDialog.setMessage("Compressing and sending files...");
            asyncDialog.show();
            latexCompiler.generatePDF(editor, imagesFolder, outputFolder, document,
                    new FileAsyncHttpResponseHandler(this) {
                        @Override
                        public void onFailure(int statusCode, cz.msebera.android.httpclient.Header[] headers,
                                Throwable throwable, File file) {
                            asyncDialog.dismiss();
                            // On failure shows an error toast
                            Toast.makeText(getApplicationContext(), "Server Error.", Toast.LENGTH_LONG).show();
                            Log.e("LATEX_NET", throwable.getMessage() + "");
                        }

                        @Override
                        public void onSuccess(int statusCode, cz.msebera.android.httpclient.Header[] headers,
                                File file) {
                            asyncDialog.dismiss();
                            Header header = null;
                            // Retrieves the content-type header
                            for (Header h : headers) {
                                if (h.getName().equals("Content-Type")) {
                                    header = h;
                                    break;
                                }
                            }
                            openResultingFile(header, file);
                        }
                    });
            asyncDialog.setMessage("Waiting for the server to compile...");
        } else {
            // Empty file
            Toast.makeText(getApplicationContext(), "Can't compile an empty file!", Toast.LENGTH_LONG).show();
        }
    }
}

From source file:com.ubikod.urbantag.ContentViewerActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle extras = getIntent().getExtras();

    /* If we are coming from Notification delete notification */
    if (extras.getInt(NotificationHelper.FROM_NOTIFICATION, -1) == NotificationHelper.NEW_CONTENT_NOTIF) {
        NotificationHelper notificationHelper = new NotificationHelper(this);
        notificationHelper.closeContentNotif();
    } else if (extras.getInt(NotificationHelper.FROM_NOTIFICATION, -1) == NotificationHelper.NEW_PLACE_NOTIF) {
        NotificationHelper notificationHelper = new NotificationHelper(this);
        notificationHelper.closePlaceNotif();
    }//from w  ww  . j av a  2  s. co m

    /* Fetch content info */
    ContentManager contentManager = new ContentManager(new DatabaseHelper(this, null));
    Log.i(UrbanTag.TAG, "View content : " + extras.getInt(CONTENT_ID));
    this.content = contentManager.get(extras.getInt(CONTENT_ID));
    if (this.content == null) {
        Toast.makeText(this, R.string.error_occured, Toast.LENGTH_SHORT).show();
        finish();
        return;
    }
    setTitle(content.getName());
    com.actionbarsherlock.app.ActionBar actionBar = this.getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    setContentView(R.layout.content_viewer);

    /* Find webview and create url for content */
    final WebView webView = (WebView) findViewById(R.id.webview);
    final String URL = UrbanTag.API_URL + ACTION_GET_CONTENT.replaceAll("%", "" + this.content.getId());

    /* Display progress animation */
    final ProgressDialog progress = ProgressDialog.show(this, "",
            this.getResources().getString(R.string.loading_content), false, true,
            new DialogInterface.OnCancelListener() {

                @Override
                public void onCancel(DialogInterface dialog) {
                    timeOutHandler.interrupt();
                    webView.stopLoading();
                    ContentViewerActivity.this.finish();
                }

            });

    /* Go fetch content */
    contentFetcher = new Thread(new Runnable() {

        DefaultHttpClient httpClient;

        @Override
        public void run() {
            Looper.prepare();
            Log.i(UrbanTag.TAG, "Fetching content...");
            httpClient = new DefaultHttpClient();
            try {
                String responseBody = httpClient.execute(new HttpGet(URL), new BasicResponseHandler());
                webView.loadDataWithBaseURL("fake://url/for/encoding/hack...", responseBody, mimeType, encoding,
                        "");
                timeOutHandler.interrupt();
                if (progress.isShowing())
                    progress.dismiss();
            } catch (ClientProtocolException cpe) {
                new Handler().post(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(getApplicationContext(), R.string.error_loading_content,
                                Toast.LENGTH_SHORT).show();
                    }
                });
                timeOutHandler.interrupt();
                progress.cancel();
            } catch (IOException ioe) {
                new Handler().post(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(getApplicationContext(), R.string.error_loading_content,
                                Toast.LENGTH_SHORT).show();
                    }
                });
                timeOutHandler.interrupt();
                progress.cancel();
            }

            Looper.loop();
        }

    });
    contentFetcher.start();

    /* TimeOut Handler */
    timeOutHandler = new Thread(new Runnable() {
        private int INCREMENT = 1000;

        @Override
        public void run() {
            Looper.prepare();
            try {
                for (int time = 0; time < TIMEOUT; time += INCREMENT) {
                    Thread.sleep(INCREMENT);
                }

                Log.w(UrbanTag.TAG, "TimeOut !");
                new Handler().post(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(getApplicationContext(), R.string.error_loading_content,
                                Toast.LENGTH_SHORT).show();
                    }
                });

                contentFetcher.interrupt();
                progress.cancel();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            Looper.loop();

        }

    });
    timeOutHandler.start();

}