Example usage for android.app ProgressDialog setIndeterminate

List of usage examples for android.app ProgressDialog setIndeterminate

Introduction

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

Prototype

public void setIndeterminate(boolean indeterminate) 

Source Link

Document

Change the indeterminate mode for this ProgressDialog.

Usage

From source file:com.android.gallery3d.ingest.IngestActivity.java

private void updateProgressDialog() {
    ProgressDialog dialog = getProgressDialog();
    boolean indeterminate = (mProgressState.max == 0);
    dialog.setIndeterminate(indeterminate);
    dialog.setProgressStyle(indeterminate ? ProgressDialog.STYLE_SPINNER : ProgressDialog.STYLE_HORIZONTAL);
    if (mProgressState.title != null) {
        dialog.setTitle(mProgressState.title);
    }/*from w ww .j a  v a2s  .  c om*/
    if (mProgressState.message != null) {
        dialog.setMessage(mProgressState.message);
    }
    if (!indeterminate) {
        dialog.setProgress(mProgressState.current);
        dialog.setMax(mProgressState.max);
    }
    if (!dialog.isShowing()) {
        dialog.show();
    }
}

From source file:com.andrewshu.android.reddit.reddits.PickSubredditActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    Dialog dialog;//from   w  w w. j  a v a  2s  .  c o  m
    ProgressDialog pdialog;

    switch (id) {
    // "Please wait"
    case Constants.DIALOG_LOADING_REDDITS_LIST:
        pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        pdialog.setMessage("Loading your reddits...");
        pdialog.setIndeterminate(true);
        pdialog.setCancelable(true);
        dialog = pdialog;
        break;
    default:
        throw new IllegalArgumentException("Unexpected dialog id " + id);
    }
    return dialog;
}

From source file:edu.mit.mobile.android.locast.accounts.AbsLocastAuthenticatorActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DIALOG_PROGRESS:

        final ProgressDialog dialog = new ProgressDialog(this);
        dialog.setMessage(getText(R.string.login_message_authenticating));
        dialog.setIndeterminate(true);
        dialog.setCancelable(true);//from  w ww.ja v a2 s. c  o m
        dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
            public void onCancel(DialogInterface dialog) {
                if (BuildConfig.DEBUG) {
                    Log.i(TAG, "dialog cancel has been invoked");
                }
                if (mAuthenticationTask != null) {
                    mAuthenticationTask.cancel(true);
                    mAuthenticationTask = null;
                    finish();
                }
            }
        });
        return dialog;

    default:
        return null;
    }
}

From source file:com.chaturs.notepad.NoteEditor.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {

    case SELECT_STUDY_GROUP:

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(" Select Study Group(s)");
        final CharSequence[] charArray = new CharSequence[studyGroupNames.size()];

        for (int i = 0; i < studyGroupNames.size(); i++) {
            charArray[i] = studyGroupNames.get(i).substring(0);
        }//from ww w  .j  a va 2 s  .c o m

        builder.setMultiChoiceItems(charArray, null, new DialogInterface.OnMultiChoiceClickListener() {
            public void onClick(DialogInterface dialog, int which, boolean isChecked) {
                if (isChecked) {
                    selectedStudyGroupList.add(studyGroupList.get(which));
                } else {
                    if (!selectedStudyGroupList.isEmpty()) {
                        selectedStudyGroupList.remove(studyGroupList.get(which));
                    }
                }
            }
        });

        builder.setPositiveButton("Send", new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {

                if (selectedStudyGroupList.isEmpty()) {
                    Toast.makeText(getApplicationContext(), "No option selected to send", Toast.LENGTH_SHORT)
                            .show();
                    return;
                }

                if (title == null) {
                    title = "Sample Note";
                }

                DatabaseHandler databaseHandler = DatabaseHandler.getInstance();
                String text = mText.getText().toString();
                if (text == null || text.length() == 0) {
                    text = "empty Note";
                }

                StringBuffer Ids = new StringBuffer();
                for (int i = 0; i < selectedStudyGroupList.size(); i++) {
                    if (Ids.length() > 0) {
                        Ids.append("|");
                    }
                    long id = selectedStudyGroupList.get(i).getServerId();
                    Ids.append(id);
                }
                String user = preferences.getString(KEY_USERNAME, "android");
                note = new Note(Ids.toString(), title, text, user, "");
                selectedStudyGroupList.clear();

                dismissDialog(SELECT_STUDY_GROUP);
                showDialog(PROGRESS_DIALOG_KEY);

                new Thread(new Runnable() {
                    public void run() {
                        response = postData();
                        handler.sendEmptyMessage(0);
                    }
                }).start();
            }
        });

        builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {

            }
        });
        Dialog dialog = builder.create();
        return dialog;

    case PROGRESS_DIALOG_KEY:
        ProgressDialog progressDialog = new ProgressDialog(this);
        progressDialog.setMessage("sending....");
        progressDialog.setIndeterminate(true);
        return progressDialog;

    }
    return null;
}

From source file:com.slownet5.pgprootexplorer.filemanager.ui.FileManagerActivity.java

private void setupRoot() {
    if (alreadySetup()) {
        afterInitSetup(true);//ww w  .j  a va  2 s  . c  o  m
        return;
    }
    final ProgressDialog dialog = new ProgressDialog(this);
    dialog.setIndeterminate(true);
    dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    dialog.setTitle("Setting up root");
    dialog.setCancelable(false);
    ;
    dialog.setMax(100);
    final String os = SystemUtils.getSystemArchitecture();
    Log.d(TAG, "setupRoot: architecture is: " + os);
    class Setup extends AsyncTask<Void, Integer, Boolean> {

        @Override
        protected Boolean doInBackground(Void... params) {
            new File(SharedData.CRYPTO_FM_PATH).mkdirs();
            String filename = SharedData.CRYPTO_FM_PATH + "/toybox";
            AssetManager asset = getAssets();
            try {

                InputStream stream = asset.open("toybox");

                OutputStream out = new FileOutputStream(filename);
                byte[] buffer = new byte[4096];
                int read;
                int total = 0;
                while ((read = stream.read(buffer)) != -1) {
                    total += read;
                    out.write(buffer, 0, read);
                }
                Log.d(TAG, "doInBackground: total written bytes: " + total);
                stream.close();
                out.flush();
                out.close();
            } catch (IOException ex) {
                ex.printStackTrace();
                return false;
            }
            RootUtils.initRoot(filename);

            return true;
        }

        @Override
        protected void onPreExecute() {
            dialog.setMessage("Please wait....");
            dialog.show();
        }

        @Override
        protected void onPostExecute(Boolean aBoolean) {
            dialog.dismiss();
            if (aBoolean) {
                SharedPreferences.Editor prefs = getSharedPreferences(CommonConstants.COMMON_SHARED_PEREFS_NAME,
                        Context.MODE_PRIVATE).edit();
                prefs.putBoolean(CommonConstants.ROOT_TOYBOX, true);
                prefs.apply();
                prefs.commit();
                afterInitSetup(true);

            } else {
                afterInitSetup(aBoolean);
            }
        }
    }
    new Setup().execute();
}

From source file:net.mypapit.mobile.callsignview.MainActivity.java

public ProgressDialog progressDialog() {

    ProgressDialog dialog = new ProgressDialog(this);
    dialog.setMessage(getResources().getString(R.string.progress_dialog));
    dialog.setTitle(getResources().getString(R.string.progress_title));
    dialog.setCancelable(false);/*from  w  w w  . j a v a  2 s  .c  o m*/
    dialog.setIndeterminate(true);
    dialog.show();

    return dialog;

}

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

public void onClick(View v) {
    String threegpfile_name = "test.3gp_amr";
    String amrfile_name = "test.amr";
    File dir = this.getDir("sounds", MODE_WORLD_READABLE);
    final File threegpfile = new File(dir, threegpfile_name);
    File amrfile = new File(dir, amrfile_name);
    String path = threegpfile.getAbsolutePath();
    Log.d("CreateSoundActivity", path);
    Log.d("CreateSoundActivity", (String) button.getText());
    if (button.getText().equals("Start")) {
        try {// ww w.  j  a va2s. co  m
            recorder = new MediaRecorder();

            // ContentValues values = new ContentValues(3);
            //
            // values.put(MediaStore.MediaColumns.TITLE, "test");
            // values.put(MediaStore.MediaColumns.DATE_ADDED,
            // System.currentTimeMillis());
            // values.put(MediaStore.MediaColumns.MIME_TYPE,
            // MediaRecorder.OutputFormat.THREE_GPP);
            //             
            // ContentResolver contentResolver = new ContentResolver(this);
            //             
            // Uri base = MediaStore.Audio.INTERNAL_CONTENT_URI;
            // Uri newUri = contentResolver.insert(base, values);

            recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
            recorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR);
            recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
            recorder.setOutputFile(path);

            recorder.prepare();
            button.setText("Stop");
            recorder.start();
        } catch (Exception e) {
            Log.w(TAG, e);
        }
    } else {
        FileOutputStream os = null;
        FileInputStream is = null;
        try {
            recorder.stop();
            recorder.release(); // Now the object cannot be reused
            button.setEnabled(false);

            // ThreegpReader tr = new ThreegpReader(threegpfile);
            // os = new FileOutputStream(amrfile);
            // tr.extractAmr(os);
            is = new FileInputStream(threegpfile);
            playSound(is.getFD());

            final String media_entity = "http://test.com/test.mp3";
            final String author = "tansaku";
            final String author_url = "http://smart.fm/users/tansaku";

            if (Main.isNotLoggedIn(this)) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setClassName(this, LoginActivity.class.getName());
                intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                LoginActivity.return_to = CreateSoundActivity.class.getName();
                LoginActivity.params = new HashMap<String, String>();
                LoginActivity.params.put("item_id", item_id);
                LoginActivity.params.put("list_id", list_id);
                LoginActivity.params.put("id", id);
                LoginActivity.params.put("to_record", to_record);
                LoginActivity.params.put("sound_type", sound_type);
                startActivity(intent);
            } else {

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

                final Thread create_sound = new Thread() {
                    public void run() {
                        // TODO make this interruptable .../*if
                        // (!this.isInterrupted())*/
                        CreateSoundActivity.create_sound_result = createSound(threegpfile, media_entity, author,
                                author_url, "1", id);

                        myOtherProgressDialog.dismiss();

                    }
                };
                myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        create_sound.interrupt();
                    }
                });
                OnCancelListener ocl = new OnCancelListener() {
                    public void onCancel(DialogInterface arg0) {
                        create_sound.interrupt();
                    }
                };
                myOtherProgressDialog.setOnCancelListener(ocl);
                myOtherProgressDialog.show();
                create_sound.start();
            }
        } catch (Exception e) {
            Log.w(TAG, e);
        } finally {
            if (os != null) {
                try {
                    os.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            if (is != null) {
                try {
                    is.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    }

}

From source file:fm.smart.r1.CreateSoundActivity.java

public void onClick(View v) {
    String threegpfile_name = "test.3gp_amr";
    String amrfile_name = "test.amr";
    File dir = this.getDir("sounds", MODE_WORLD_READABLE);
    final File threegpfile = new File(dir, threegpfile_name);
    File amrfile = new File(dir, amrfile_name);
    String path = threegpfile.getAbsolutePath();
    Log.d("CreateSoundActivity", path);
    Log.d("CreateSoundActivity", (String) button.getText());
    if (button.getText().equals("Start")) {
        try {/*from w  ww  . j a  v a 2 s  .c  om*/
            recorder = new MediaRecorder();

            // ContentValues values = new ContentValues(3);
            //
            // values.put(MediaStore.MediaColumns.TITLE, "test");
            // values.put(MediaStore.MediaColumns.DATE_ADDED,
            // System.currentTimeMillis());
            // values.put(MediaStore.MediaColumns.MIME_TYPE,
            // MediaRecorder.OutputFormat.THREE_GPP);
            //
            // ContentResolver contentResolver = new ContentResolver(this);
            //
            // Uri base = MediaStore.Audio.INTERNAL_CONTENT_URI;
            // Uri newUri = contentResolver.insert(base, values);

            recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
            recorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR);
            recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
            recorder.setOutputFile(path);

            recorder.prepare();
            button.setText("Stop");
            recorder.start();
        } catch (Exception e) {
            Log.w(TAG, e);
        }
    } else {
        FileOutputStream os = null;
        FileInputStream is = null;
        try {
            recorder.stop();
            recorder.release(); // Now the object cannot be reused
            button.setEnabled(false);

            // ThreegpReader tr = new ThreegpReader(threegpfile);
            // os = new FileOutputStream(amrfile);
            // tr.extractAmr(os);
            is = new FileInputStream(threegpfile);
            playSound(is.getFD());

            final String media_entity = "http://test.com/test.mp3";
            final String author = "tansaku";
            final String author_url = "http://smart.fm/users/tansaku";

            if (LoginActivity.isNotLoggedIn(this)) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setClassName(this, LoginActivity.class.getName());
                intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                LoginActivity.return_to = CreateSoundActivity.class.getName();
                LoginActivity.params = new HashMap<String, String>();
                LoginActivity.params.put("item_id", item_id);
                LoginActivity.params.put("goal_id", goal_id);
                LoginActivity.params.put("id", id);
                LoginActivity.params.put("to_record", to_record);
                LoginActivity.params.put("sound_type", sound_type);
                startActivity(intent);
            } else {

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

                final Thread create_sound = new Thread() {
                    public void run() {
                        // TODO make this interruptable .../*if
                        // (!this.isInterrupted())*/
                        CreateSoundActivity.create_sound_result = createSound(threegpfile, media_entity, author,
                                author_url, "1", item_id, id, to_record);
                        // this will also ensure item is in goal, but this
                        // should be sentence
                        // submission if we are handling sentence sound.
                        if (sound_type.equals(Integer.toString(R.id.cue_sound))) {
                            CreateSoundActivity.add_item_result = new AddItemResult(
                                    Main.lookup.addItemToGoal(Main.transport, Main.default_study_goal_id,
                                            item_id, CreateSoundActivity.create_sound_result.sound_id));
                        } else {
                            // ensure item is in goal
                            CreateSoundActivity.add_item_result = new AddItemResult(Main.lookup
                                    .addItemToGoal(Main.transport, Main.default_study_goal_id, item_id, null));
                            CreateSoundActivity.add_sentence_result = new AddSentenceResult(
                                    Main.lookup.addSentenceToGoal(Main.transport, Main.default_study_goal_id,
                                            item_id, id, CreateSoundActivity.create_sound_result.sound_id));

                        }
                        myOtherProgressDialog.dismiss();

                    }
                };
                myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        create_sound.interrupt();
                    }
                });
                OnCancelListener ocl = new OnCancelListener() {
                    public void onCancel(DialogInterface arg0) {
                        create_sound.interrupt();
                    }
                };
                myOtherProgressDialog.setOnCancelListener(ocl);
                myOtherProgressDialog.show();
                create_sound.start();
            }
        } catch (Exception e) {
            Log.w(TAG, e);
        } finally {
            if (os != null) {
                try {
                    os.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            if (is != null) {
                try {
                    is.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    }

}

From source file:com.kkbox.toolkit.dialog.KKDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    DialogInterface.OnClickListener positiveListener = new DialogInterface.OnClickListener() {
        @Override//from   w  w  w.  jav a 2 s .  c o m
        public void onClick(DialogInterface dialog, int id) {
            if (!isDismissed) {
                if (listener != null) {
                    listener.onPositive();
                }
                onDialogFinishedByUser();
                isDismissed = true;
            }
        }
    };

    DialogInterface.OnClickListener neutralListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            if (!isDismissed) {
                if (listener != null) {
                    listener.onNeutral();
                }
                onDialogFinishedByUser();
                isDismissed = true;
            }
        }
    };

    DialogInterface.OnClickListener negativeListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            if (!isDismissed) {
                if (listener != null) {
                    listener.onNegative();
                }
                onDialogFinishedByUser();
                isDismissed = true;
            }
        }
    };

    switch (dialogType) {
    case Type.PROGRESSING_DIALOG:
        ProgressDialog progressDialog;
        if (theme != -1) {
            progressDialog = new ProgressDialog(getActivity(), theme);
        } else {
            progressDialog = new ProgressDialog(getActivity());
        }
        progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        progressDialog.setMessage(message);
        progressDialog.setIndeterminate(true);
        progressDialog.setCanceledOnTouchOutside(false);
        progressDialog.setCancelable(listener != null);
        return progressDialog;
    case Type.ALERT_DIALOG:
        AlertDialog.Builder builder;
        AlertDialog alertDialog;
        if (theme != -1) {
            builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), theme));
        } else {
            builder = new AlertDialog.Builder(getActivity());
        }
        builder.setMessage(message);
        builder.setTitle(title);
        builder.setPositiveButton(positiveButtonText, positiveListener);
        alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(isAlertDialogCanceledOnTouchOutside);
        return alertDialog;
    case Type.THREE_CHOICE_DIALOG:
        if (theme != -1) {
            builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), theme));
        } else {
            builder = new AlertDialog.Builder(getActivity());
        }
        builder.setMessage(message);
        builder.setTitle(title);
        builder.setPositiveButton(positiveButtonText, positiveListener);
        builder.setNeutralButton(neutralButtonText, neutralListener);
        builder.setNegativeButton(negativeButtonText, negativeListener);
        alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(isAlertDialogCanceledOnTouchOutside);
        return alertDialog;
    case Type.YES_OR_NO_DIALOG:
        if (theme != -1) {
            builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), theme));
        } else {
            builder = new AlertDialog.Builder(getActivity());
        }
        builder.setMessage(message);
        builder.setTitle(title);
        builder.setPositiveButton(positiveButtonText, positiveListener);
        builder.setNegativeButton(negativeButtonText, negativeListener);
        alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(isAlertDialogCanceledOnTouchOutside);
        return alertDialog;
    case Type.SELECT_DIALOG:
        if (theme != -1) {
            builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), theme));
        } else {
            builder = new AlertDialog.Builder(getActivity());
        }
        builder.setMessage(message);
        builder.setTitle(title);
        builder.setSingleChoiceItems(entries, selectedIndex, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                if (!isDismissed) {
                    if (listener != null) {
                        listener.onEvent(id);
                    }
                    dismiss();
                    onDialogFinishedByUser();
                    isDismissed = true;
                }
            }
        });
        builder.setNegativeButton(negativeButtonText, negativeListener);
        alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(isAlertDialogCanceledOnTouchOutside);
        return alertDialog;
    case Type.CUSTOMIZE_DIALOG:
        if (theme != -1) {
            builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), theme));
        } else {
            builder = new AlertDialog.Builder(getActivity());
        }
        if (customizeView != null && customizeView.getParent() != null) {
            ((ViewGroup) customizeView.getParent()).removeView(customizeView);
        }
        builder.setView(customizeView);

        if (!TextUtils.isEmpty(title)) {
            builder.setTitle(title);
        }
        if (!TextUtils.isEmpty(positiveButtonText)) {
            builder.setPositiveButton(positiveButtonText, positiveListener);
        }
        if (!TextUtils.isEmpty(neutralButtonText)) {
            builder.setNeutralButton(neutralButtonText, neutralListener);
        }
        if (!TextUtils.isEmpty(negativeButtonText)) {
            builder.setNegativeButton(negativeButtonText, negativeListener);
        }
        alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(isAlertDialogCanceledOnTouchOutside);
        return alertDialog;
    case Type.CUSTOMIZE_FULLSCREEN_DIALOG:
        Dialog dialog;
        if (theme != -1) {
            dialog = new Dialog(getActivity(), theme);
        } else {
            dialog = new Dialog(getActivity(), android.R.style.Theme_NoTitleBar);
        }
        if (customizeView != null && customizeView.getParent() != null) {
            ((ViewGroup) customizeView.getParent()).removeView(customizeView);
        }
        dialog.setContentView(customizeView);
        return dialog;
    }
    return null;
}

From source file:com.slp.rss_api.activity.EditFeedActivity.java

public void onClickOk(View view) {
    // only in insert mode

    final String name = mNameEditText.getText().toString().trim();
    final String urlOrSearch = mUrlEditText.getText().toString().trim();
    if (urlOrSearch.isEmpty()) {
        Toast.makeText(this, R.string.error_feed_error, Toast.LENGTH_SHORT).show();
    }//from  w  w w  .  j  a v a 2 s  .c o m

    if (!urlOrSearch.contains(".") || !urlOrSearch.contains("/") || urlOrSearch.contains(" ")) {
        final ProgressDialog pd = new ProgressDialog(EditFeedActivity.this);
        pd.setMessage(getString(R.string.loading));
        pd.setCancelable(true);
        pd.setIndeterminate(true);
        pd.show();

        getLoaderManager().restartLoader(1, null,
                new LoaderManager.LoaderCallbacks<ArrayList<HashMap<String, String>>>() {

                    @Override
                    public Loader<ArrayList<HashMap<String, String>>> onCreateLoader(int id, Bundle args) {
                        String encodedSearchText = urlOrSearch;
                        try {
                            encodedSearchText = URLEncoder.encode(urlOrSearch, Constants.UTF8);
                        } catch (UnsupportedEncodingException ignored) {
                        }

                        return new GetFeedSearchResultsLoader(EditFeedActivity.this, encodedSearchText);
                    }

                    @Override
                    public void onLoadFinished(Loader<ArrayList<HashMap<String, String>>> loader,
                            final ArrayList<HashMap<String, String>> data) {
                        pd.cancel();

                        if (data == null) {
                            Toast.makeText(EditFeedActivity.this, R.string.error, Toast.LENGTH_SHORT).show();
                        } else if (data.isEmpty()) {
                            Toast.makeText(EditFeedActivity.this, R.string.no_result, Toast.LENGTH_SHORT)
                                    .show();
                        } else {
                            AlertDialog.Builder builder = new AlertDialog.Builder(EditFeedActivity.this);
                            builder.setTitle(R.string.feed_search);

                            // create the grid item mapping
                            String[] from = new String[] { FEED_SEARCH_TITLE, FEED_SEARCH_DESC };
                            int[] to = new int[] { android.R.id.text1, android.R.id.text2 };

                            // fill in the grid_item layout
                            SimpleAdapter adapter = new SimpleAdapter(EditFeedActivity.this, data,
                                    R.layout.item_search_result, from, to);
                            builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    FeedDataContentProvider.addFeed(EditFeedActivity.this,
                                            data.get(which).get(FEED_SEARCH_URL),
                                            name.isEmpty() ? data.get(which).get(FEED_SEARCH_TITLE) : name,
                                            mRetrieveFulltextCb.isChecked());

                                    setResult(RESULT_OK);
                                    finish();
                                }
                            });
                            builder.show();
                        }
                    }

                    @Override
                    public void onLoaderReset(Loader<ArrayList<HashMap<String, String>>> loader) {
                    }
                });
    } else {
        FeedDataContentProvider.addFeed(EditFeedActivity.this, urlOrSearch, name,
                mRetrieveFulltextCb.isChecked());

        setResult(RESULT_OK);
        finish();
    }
}