Example usage for android.widget SimpleAdapter SimpleAdapter

List of usage examples for android.widget SimpleAdapter SimpleAdapter

Introduction

In this page you can find the example usage for android.widget SimpleAdapter SimpleAdapter.

Prototype

public SimpleAdapter(Context context, List<? extends Map<String, ?>> data, @LayoutRes int resource,
        String[] from, @IdRes int[] to) 

Source Link

Document

Constructor

Usage

From source file:com.abeo.tia.noordin.ProcessCasePurchaser.java

public void dropdownstatus() throws JSONException {
    RequestParams params = null;//from  ww w . j  a v a  2s .  co m
    params = new RequestParams();

    JSONObject jsonObject = new JSONObject();
    jsonObject.put("TableName", "OCRD");
    jsonObject.put("FieldName", "CASESTATUS");
    params.put("sJsonInput", jsonObject.toString());

    RestService.post(GET_SPINNER_VALUES, params, new BaseJsonHttpResponseHandler<String>() {

        @Override
        public void onFailure(int arg0, Header[] arg1, Throwable arg2, String arg3, String arg4) {
            // TODO Auto-generated method stub
            System.out.println(arg3);
            System.out.println("Failed");

        }

        @Override
        protected String parseResponse(String s, boolean b) throws Throwable {
            return null;
        }

        @Override
        public void onSuccess(int arg0, Header[] arg1, String arg2, String arg3) {
            // TODO Auto-generated method stub
            System.out.println("Title Dropdown Success Details ");
            System.out.println(arg2);

            try {

                arrayResponse = new JSONArray(arg2);
                // Create new list
                jsonArraylist = new ArrayList<HashMap<String, String>>();

                for (int i = 0; i < arrayResponse.length(); i++) {

                    jsonResponse = arrayResponse.getJSONObject(i);

                    id = jsonResponse.getString("Id").toString();
                    name = jsonResponse.getString("Name").toString();

                    // SEND JSON DATA INTO SPINNER TITLE LIST
                    HashMap<String, String> proList = new HashMap<String, String>();

                    // Send JSON Data to list activity
                    System.out.println("SEND JSON  LIST");
                    proList.put("Id_T", id);
                    System.out.println(name);
                    proList.put("Name_T", name);
                    System.out.println(name);
                    System.out.println(" END SEND JSON PROPERTY LIST");

                    jsonArraylist.add(proList);
                    System.out.println("JSON PROPERTY LIST");
                    System.out.println(jsonArraylist);
                }
                // Spinner set Array Data in Drop down

                sAdapPROJ = new SimpleAdapter(ProcessCasePurchaser.this, jsonArraylist, R.layout.spinner_item,
                        new String[] { "Id_T", "Name_T" }, new int[] { R.id.Id, R.id.Name });

                spinner_case_status.setAdapter(sAdapPROJ);

                for (int j = 0; j < jsonArraylist.size(); j++) {
                    if (jsonArraylist.get(j).get("Id_T").equals(Scase_status)) {
                        spinner_case_status.setSelection(j);
                        break;
                    }
                }

            } catch (JSONException e) {

                e.printStackTrace();
            }
        }
    });
}

From source file:smart.services.adapter.ManageCarsAdapter.java

public void showModelDialog() {
    dialog.setContentView(R.layout.add_car_dialog);
    dialog.setCancelable(true);//from  ww  w  .  j  ava 2s . com
    dialog.setTitle("Choose a Model");
    Booking.changeWidthHeight(context, dialog);
    // dialog.setP
    lv = (ListView) dialog.findViewById(R.id.addLV);

    if (dataBaseHandler.getModelsCount() == 0) {
        if (isConnectingToInternet()) {
            new CarModel().execute();
        } else {
            Toast.makeText(context, "Check your internet connection", Toast.LENGTH_LONG).show();
        }
    } else {
        List<Model> modelList = dataBaseHandler.getAllModels();
        carsModelList.clear();
        for (int i = 0; i < modelList.size(); i++) {
            if (modelList.get(i).getParentBrand().equals(brandTV.getText().toString())) {
                HashMap<String, String> model = new HashMap<String, String>();

                model.put("modelId", modelList.get(i).getTypeId());
                model.put("modelNameAr", modelList.get(i).getTypeNameAr());
                model.put("modelNameEn", modelList.get(i).getTypeNameEn());

                carsModelList.add(model);
            }
        }

        if (carsModelList.size() == 0) {
            if (isConnectingToInternet()) {
                for (int i = 0; i < modelList.size(); i++) {
                    if (modelList.get(i).getParentBrand().equals(brandTV.getText().toString())) {
                        dataBaseHandler.deleteSingleBrand(modelList.get(i).getId());
                    }
                }
                new CarModel().execute();
            } else {
                Toast.makeText(context, "Check your internet connection", Toast.LENGTH_LONG).show();
            }
        } else {
            ListAdapter adapter = new SimpleAdapter(context, carsModelList, R.layout.single_model_item,
                    new String[] { "modelId", "modelNameEn" }, new int[] { R.id.modelId, R.id.modelNameEn });

            lv.setAdapter(adapter);
            lv.setOnItemClickListener(new OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    finalModelId = carsModelList.get(position).get("modelId");
                    String s = ((TextView) view.findViewById(R.id.modelNameEn)).getText().toString();
                    modelTV.setText(s);
                    String sId = ((TextView) view.findViewById(R.id.modelId)).getText().toString();
                    // modelTV.setText(s);
                    modelIdTV.setText(sId);
                    dialog.dismiss();
                }
            });

            dialog.show();
        }
    }
}

From source file:com.app.uafeed.activity.EditFeedActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        finish();/*from   w w  w  .j av  a2  s .  c  om*/
        return true;
    case R.id.menu_add_filter: {
        final View dialogView = getLayoutInflater().inflate(R.layout.dialog_filter_edit, null);

        new AlertDialog.Builder(this) //
                .setTitle(R.string.filter_add_title) //
                .setView(dialogView) //
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        String filterText = ((EditText) dialogView.findViewById(R.id.filterText)).getText()
                                .toString();
                        if (filterText.length() != 0) {
                            String feedId = getIntent().getData().getLastPathSegment();

                            ContentValues values = new ContentValues();
                            values.put(FilterColumns.FILTER_TEXT, filterText);
                            values.put(FilterColumns.IS_REGEX,
                                    ((CheckBox) dialogView.findViewById(R.id.regexCheckBox)).isChecked());
                            values.put(FilterColumns.IS_APPLIED_TO_TITLE,
                                    ((RadioButton) dialogView.findViewById(R.id.applyTitleRadio)).isChecked());

                            ContentResolver cr = getContentResolver();
                            cr.insert(FilterColumns.FILTERS_FOR_FEED_CONTENT_URI(feedId), values);
                        }
                    }
                }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                    }
                }).show();
        return true;
    }
    case R.id.menu_search_feed: {
        final View dialogView = getLayoutInflater().inflate(R.layout.dialog_search_feed, null);
        final EditText searchText = (EditText) dialogView.findViewById(R.id.searchText);
        if (!mUrlEditText.getText().toString().startsWith(Constants.HTTP_SCHEME)
                && !mUrlEditText.getText().toString().startsWith(Constants.HTTPS_SCHEME)) {
            searchText.setText(mUrlEditText.getText());
        }
        final RadioGroup radioGroup = (RadioGroup) dialogView.findViewById(R.id.radioGroup);

        new AlertDialog.Builder(EditFeedActivity.this) //
                .setIcon(R.drawable.action_search) //
                .setTitle(R.string.feed_search) //
                .setView(dialogView) //
                .setPositiveButton(android.R.string.search_go, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                        if (searchText.getText().length() > 0) {
                            String tmp = searchText.getText().toString();
                            try {
                                tmp = URLEncoder.encode(searchText.getText().toString(), Constants.UTF8);
                            } catch (UnsupportedEncodingException ignored) {
                            }
                            final String text = tmp;

                            switch (radioGroup.getCheckedRadioButtonId()) {
                            case R.id.byWebSearch:
                                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) {
                                                return new GetFeedSearchResultsLoader(EditFeedActivity.this,
                                                        text);
                                            }

                                            @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) {
                                                                    mNameEditText.setText(data.get(which)
                                                                            .get(FEED_SEARCH_TITLE));
                                                                    mUrlEditText.setText(data.get(which)
                                                                            .get(FEED_SEARCH_URL));
                                                                }
                                                            });
                                                    builder.show();
                                                }
                                            }

                                            @Override
                                            public void onLoaderReset(
                                                    Loader<ArrayList<HashMap<String, String>>> loader) {
                                            }
                                        });
                                break;

                            case R.id.byTopic:
                                mUrlEditText.setText("http://www.faroo.com/api?q=" + text
                                        + "&start=1&length=10&l=en&src=news&f=rss");
                                break;

                            case R.id.byYoutube:
                                mUrlEditText.setText("http://www.youtube.com/rss/user/"
                                        + text.replaceAll("\\+", "") + "/videos.rss");
                                break;
                            }
                        }
                    }
                }).setNegativeButton(android.R.string.cancel, null).show();
        return true;
    }
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:cn.edu.nju.dapenti.activity.EditFeedActivity.java

public void onClickSearch(View view) {
    final View dialogView = getLayoutInflater().inflate(R.layout.dialog_search_feed, null);
    final EditText searchText = (EditText) dialogView.findViewById(R.id.searchText);
    final RadioGroup radioGroup = (RadioGroup) dialogView.findViewById(R.id.radioGroup);

    new AlertDialog.Builder(EditFeedActivity.this) //
            .setIcon(R.drawable.action_search) //
            .setTitle(R.string.feed_search) //
            .setView(dialogView) //
            .setPositiveButton(android.R.string.search_go, new DialogInterface.OnClickListener() {
                @Override/*from   w w w .  j  ava 2 s .  c o  m*/
                public void onClick(DialogInterface dialog, int which) {

                    if (searchText.getText().length() > 0) {
                        String tmp = searchText.getText().toString();
                        try {
                            tmp = URLEncoder.encode(searchText.getText().toString(), Constants.UTF8);
                        } catch (UnsupportedEncodingException ignored) {
                        }
                        final String text = tmp;

                        switch (radioGroup.getCheckedRadioButtonId()) {
                        case R.id.byWebSearch:
                            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 LoaderCallbacks<ArrayList<HashMap<String, String>>>() {

                                        @Override
                                        public Loader<ArrayList<HashMap<String, String>>> onCreateLoader(int id,
                                                Bundle args) {
                                            return new GetFeedSearchResultsLoader(EditFeedActivity.this, text);
                                        }

                                        @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) {
                                                                mNameEditText.setText(
                                                                        data.get(which).get(FEED_SEARCH_TITLE));
                                                                mUrlEditText.setText(
                                                                        data.get(which).get(FEED_SEARCH_URL));
                                                            }
                                                        });
                                                builder.show();
                                            }
                                        }

                                        @Override
                                        public void onLoaderReset(
                                                Loader<ArrayList<HashMap<String, String>>> loader) {
                                        }
                                    }).forceLoad();
                            break;

                        case R.id.byTopic:
                            mUrlEditText.setText("http://www.faroo.com/api?q=" + text
                                    + "&start=1&length=10&l=en&src=news&f=rss");
                            break;

                        case R.id.byYoutube:
                            mUrlEditText.setText("http://www.youtube.com/rss/user/" + text.replaceAll("\\+", "")
                                    + "/videos.rss");
                            break;
                        }
                    }
                }
            }).setNegativeButton(android.R.string.cancel, null).show();
}

From source file:co.nerdart.ourss.activity.EditFeedActivity.java

public void onClickSearch(View view) {
    final View dialogView = getLayoutInflater().inflate(R.layout.search_feed, null);
    final EditText searchText = (EditText) dialogView.findViewById(R.id.searchText);
    final RadioGroup radioGroup = (RadioGroup) dialogView.findViewById(R.id.radioGroup);

    new AlertDialog.Builder(EditFeedActivity.this) //
            .setIcon(R.drawable.action_search) //
            .setTitle(R.string.feed_search) //
            .setView(dialogView) //
            .setPositiveButton(android.R.string.search_go, new DialogInterface.OnClickListener() {
                @Override//from w w w.j  a va 2  s.c o  m
                public void onClick(DialogInterface dialog, int which) {

                    if (searchText.getText().length() > 0) {
                        String tmp = searchText.getText().toString();
                        try {
                            tmp = URLEncoder.encode(searchText.getText().toString(), Constants.UTF8);
                        } catch (UnsupportedEncodingException ignored) {
                        }
                        final String text = tmp;

                        switch (radioGroup.getCheckedRadioButtonId()) {
                        case R.id.byWebSearch:
                            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 LoaderCallbacks<ArrayList<HashMap<String, String>>>() {

                                        @Override
                                        public Loader<ArrayList<HashMap<String, String>>> onCreateLoader(int id,
                                                Bundle args) {
                                            return new GetFeedSearchResultsLoader(EditFeedActivity.this, text);
                                        }

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

                                            if (data == null) {
                                                Crouton.makeText(EditFeedActivity.this, R.string.error,
                                                        Style.INFO);
                                            } else if (data.isEmpty()) {
                                                Crouton.makeText(EditFeedActivity.this, R.string.no_result,
                                                        Style.INFO);
                                            } 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.search_result_item, from, to);
                                                builder.setAdapter(adapter,
                                                        new DialogInterface.OnClickListener() {
                                                            @Override
                                                            public void onClick(DialogInterface dialog,
                                                                    int which) {
                                                                mNameEditText.setText(
                                                                        data.get(which).get(FEED_SEARCH_TITLE));
                                                                mUrlEditText.setText(
                                                                        data.get(which).get(FEED_SEARCH_URL));
                                                            }
                                                        });
                                                builder.show();
                                            }
                                        }

                                        @Override
                                        public void onLoaderReset(
                                                Loader<ArrayList<HashMap<String, String>>> loader) {
                                        }
                                    }).forceLoad();
                            break;

                        case R.id.byTopic:
                            mUrlEditText.setText("http://www.faroo.com/api?q=" + text
                                    + "&start=1&length=10&l=en&src=news&f=rss");
                            break;

                        case R.id.byYoutube:
                            mUrlEditText.setText("http://www.youtube.com/rss/user/" + text.replaceAll("\\+", "")
                                    + "/videos.rss");
                            break;
                        }
                    }
                }
            }).setNegativeButton(android.R.string.cancel, null).show();
}

From source file:com.carlrice.reader.activity.EditFeedActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        finish();//from ww w  .  ja va2s . c o m
        return true;
    case R.id.menu_add_filter: {
        final View dialogView = getLayoutInflater().inflate(R.layout.dialog_filter_edit, null);

        new AlertDialog.Builder(this) //
                .setTitle(R.string.filter_add_title) //
                .setView(dialogView) //
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        String filterText = ((EditText) dialogView.findViewById(R.id.filterText)).getText()
                                .toString();
                        if (filterText.length() != 0) {
                            String feedId = getIntent().getData().getLastPathSegment();

                            ContentValues values = new ContentValues();
                            values.put(FilterColumns.FILTER_TEXT, filterText);
                            values.put(FilterColumns.IS_REGEX,
                                    ((CheckBox) dialogView.findViewById(R.id.regexCheckBox)).isChecked());
                            values.put(FilterColumns.IS_APPLIED_TO_TITLE,
                                    ((RadioButton) dialogView.findViewById(R.id.applyTitleRadio)).isChecked());
                            values.put(FilterColumns.IS_ACCEPT_RULE,
                                    ((RadioButton) dialogView.findViewById(R.id.acceptRadio)).isChecked());

                            ContentResolver cr = getContentResolver();
                            cr.insert(FilterColumns.FILTERS_FOR_FEED_CONTENT_URI(feedId), values);
                        }
                    }
                }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                    }
                }).show();
        return true;
    }
    case R.id.menu_search_feed: {
        final View dialogView = getLayoutInflater().inflate(R.layout.dialog_search_feed, null);
        final EditText searchText = (EditText) dialogView.findViewById(R.id.searchText);
        if (!mUrlEditText.getText().toString().startsWith(Constants.HTTP_SCHEME)
                && !mUrlEditText.getText().toString().startsWith(Constants.HTTPS_SCHEME)) {
            searchText.setText(mUrlEditText.getText());
        }
        final RadioGroup radioGroup = (RadioGroup) dialogView.findViewById(R.id.radioGroup);

        new AlertDialog.Builder(EditFeedActivity.this) //
                .setIcon(R.drawable.action_search) //
                .setTitle(R.string.feed_search) //
                .setView(dialogView) //
                .setPositiveButton(android.R.string.search_go, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                        if (searchText.getText().length() > 0) {
                            String tmp = searchText.getText().toString();
                            try {
                                tmp = URLEncoder.encode(searchText.getText().toString(), Constants.UTF8);
                            } catch (UnsupportedEncodingException ignored) {
                            }
                            final String text = tmp;

                            switch (radioGroup.getCheckedRadioButtonId()) {
                            case R.id.byWebSearch:
                                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) {
                                                return new GetFeedSearchResultsLoader(EditFeedActivity.this,
                                                        text);
                                            }

                                            @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) {
                                                                    mNameEditText.setText(data.get(which)
                                                                            .get(FEED_SEARCH_TITLE));
                                                                    mUrlEditText.setText(data.get(which)
                                                                            .get(FEED_SEARCH_URL));
                                                                }
                                                            });
                                                    builder.show();
                                                }
                                            }

                                            @Override
                                            public void onLoaderReset(
                                                    Loader<ArrayList<HashMap<String, String>>> loader) {
                                            }
                                        });
                                break;

                            case R.id.byTopic:
                                mUrlEditText.setText("http://www.faroo.com/api?q=" + text
                                        + "&start=1&length=10&l=en&src=news&f=rss");
                                break;

                            case R.id.byYoutube:
                                mUrlEditText.setText("http://www.youtube.com/rss/user/"
                                        + text.replaceAll("\\+", "") + "/videos.rss");
                                break;
                            }
                        }
                    }
                }).setNegativeButton(android.R.string.cancel, null).show();
        return true;
    }
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:nl.privacybarometer.privacyvandaag.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();
    final String cookieName = mCookieNameEditText.getText().toString();
    final String cookieValue = mCookieValueEditText.getText().toString();
    final TypedArray selectedValues = getResources().obtainTypedArray(R.array.settings_keep_time_values);
    final Integer keepTime = selectedValues.getInt(mKeepTime.getSelectedItemPosition(), 0);
    final String iconDrawable = "";

    if (urlOrSearch.isEmpty()) {
        Toast.makeText(this, R.string.error_feed_error, Toast.LENGTH_SHORT).show();
    }/*from  www.  ja  va  2s  .c  om*/

    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(), cookieName, cookieValue, keepTime,
                                            iconDrawable);

                                    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(), cookieName, cookieValue, keepTime, iconDrawable);

        setResult(RESULT_OK);
        finish();
    }
}

From source file:com.abeo.tia.noordin.ProcessCaseProperty.java

public void dropdownState() throws JSONException {

    RequestParams params = null;/*w w w . j a  v a  2s.c o  m*/
    params = new RequestParams();

    JSONObject jsonObject = new JSONObject();
    jsonObject.put("TableName", "OCRD");
    jsonObject.put("FieldName", "STATE");
    params.put("sJsonInput", jsonObject.toString());

    RestService.post(GET_SPINNER_VALUES, params, new BaseJsonHttpResponseHandler<String>() {

        @Override
        public void onFailure(int arg0, Header[] arg1, Throwable arg2, String arg3, String arg4) {
            // TODO Auto-generated method stub
            System.out.println(arg3);

        }

        @Override
        public void onSuccess(int arg0, Header[] arg1, String arg2, String arg3) {
            // TODO Auto-generated method stub
            System.out.println("State Dropdown Success Details ");
            System.out.println(arg2);

            try {

                arrayResponse = new JSONArray(arg2);
                // Create new list
                jsonliststate = new ArrayList<HashMap<String, String>>();

                for (int i = 0; i < arrayResponse.length(); i++) {

                    jsonResponse = arrayResponse.getJSONObject(i);

                    id = jsonResponse.getString("Id").toString();
                    name = jsonResponse.getString("Name").toString();

                    // SEND JSON DATA INTO SPINNER TITLE LIST
                    HashMap<String, String> proList = new HashMap<String, String>();

                    // Send JSON Data to list activity
                    System.out.println("SEND JSON  LIST");
                    proList.put("Id_T", id);
                    System.out.println(name);
                    proList.put("Name_T", name);
                    System.out.println(name);
                    System.out.println(" END SEND JSON PROPERTY LIST");

                    jsonliststate.add(proList);
                    System.out.println("JSON STATE LIST");
                    System.out.println(jsonliststate);
                }
                // Spinner set Array Data in Drop down

                sAdaparea = new SimpleAdapter(ProcessCaseProperty.this, jsonliststate, R.layout.spinner_item,
                        new String[] { "Id_T", "Name_T" }, new int[] { R.id.Id, R.id.Name });

                spinnerpropertySTATE.setAdapter(sAdaparea);

                for (int j = 0; j < jsonliststate.size(); j++) {
                    if (jsonliststate.get(j).get("Id_T").equals(statevalue)) {
                        spinnerpropertySTATE.setSelection(j);
                        break;
                    }
                }

            } catch (JSONException e) { // TODO Auto-generated
                // catc
                // block
                e.printStackTrace();
            }

        }

        @Override
        protected String parseResponse(String arg0, boolean arg1) throws Throwable {

            // Get Json response
            arrayResponse = new JSONArray(arg0);
            jsonResponse = arrayResponse.getJSONObject(0);

            System.out.println("State Dropdown Details parse Response");
            System.out.println(arg0);
            return null;
        }
    });

}

From source file:de.baumann.quitsmoking.fragments.FragmentNotes.java

private void setNotesList() {

    ArrayList<HashMap<String, String>> mapList = new ArrayList<>();

    try {/*w  w w .j av  a 2s. c o m*/
        Database_Notes db = new Database_Notes(getActivity());
        ArrayList<String[]> bookmarkList = new ArrayList<>();
        db.getBookmarks(bookmarkList, getActivity());
        if (bookmarkList.size() == 0) {
            db.loadInitialData();
            db.getBookmarks(bookmarkList, getActivity());
        }
        db.close();

        for (String[] strAry : bookmarkList) {
            HashMap<String, String> map = new HashMap<>();
            map.put("seqno", strAry[0]);
            map.put("title", strAry[1]);
            map.put("cont", strAry[2]);
            map.put("icon", strAry[3]);
            map.put("attachment", strAry[4]);
            map.put("createDate", strAry[5]);
            mapList.add(map);
        }

        SimpleAdapter simpleAdapter = new SimpleAdapter(getActivity(), mapList, R.layout.list_item_notes,
                new String[] { "title", "cont", "createDate" },
                new int[] { R.id.textView_title_notes, R.id.textView_des_notes, R.id.textView_create_notes }) {
            @Override
            public View getView(final int position, View convertView, ViewGroup parent) {

                @SuppressWarnings("unchecked")
                HashMap<String, String> map = (HashMap<String, String>) listView.getItemAtPosition(position);
                final String title = map.get("title");
                final String cont = map.get("cont");
                final String seqnoStr = map.get("seqno");
                final String icon = map.get("icon");
                final String attachment = map.get("attachment");
                final String create = map.get("createDate");

                View v = super.getView(position, convertView, parent);
                ImageView i = (ImageView) v.findViewById(R.id.icon_notes);
                ImageView i2 = (ImageView) v.findViewById(R.id.att_notes);

                switch (icon) {
                case "1":
                    i.setImageResource(R.drawable.emoticon_neutral);
                    break;
                case "2":
                    i.setImageResource(R.drawable.emoticon_happy);
                    break;
                case "3":
                    i.setImageResource(R.drawable.emoticon_sad);
                    break;
                case "4":
                    i.setImageResource(R.drawable.emoticon);
                    break;
                case "5":
                    i.setImageResource(R.drawable.emoticon_cool);
                    break;
                case "6":
                    i.setImageResource(R.drawable.emoticon_dead);
                    break;
                case "7":
                    i.setImageResource(R.drawable.emoticon_excited);
                    break;
                case "8":
                    i.setImageResource(R.drawable.emoticon_tongue);
                    break;
                case "9":
                    i.setImageResource(R.drawable.emoticon_devil);
                    break;
                }
                switch (attachment) {
                case "":
                    i2.setVisibility(View.GONE);
                    break;
                default:
                    i2.setVisibility(View.VISIBLE);
                    break;
                }

                File file = new File(attachment);
                if (!file.exists()) {
                    i2.setVisibility(View.GONE);
                }

                i.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View arg0) {

                        final FragmentNotes.Item[] items = {
                                new FragmentNotes.Item(getString(R.string.text_tit_1),
                                        R.drawable.emoticon_neutral),
                                new FragmentNotes.Item(getString(R.string.text_tit_2),
                                        R.drawable.emoticon_happy),
                                new FragmentNotes.Item(getString(R.string.text_tit_3), R.drawable.emoticon_sad),
                                new FragmentNotes.Item(getString(R.string.text_tit_4), R.drawable.emoticon),
                                new FragmentNotes.Item(getString(R.string.text_tit_5),
                                        R.drawable.emoticon_cool),
                                new FragmentNotes.Item(getString(R.string.text_tit_6),
                                        R.drawable.emoticon_dead),
                                new FragmentNotes.Item(getString(R.string.text_tit_7),
                                        R.drawable.emoticon_excited),
                                new FragmentNotes.Item(getString(R.string.text_tit_8),
                                        R.drawable.emoticon_tongue),
                                new FragmentNotes.Item(getString(R.string.text_tit_9),
                                        R.drawable.emoticon_devil) };

                        ListAdapter adapter = new ArrayAdapter<FragmentNotes.Item>(getActivity(),
                                android.R.layout.select_dialog_item, android.R.id.text1, items) {
                            @NonNull
                            public View getView(int position, View convertView, @NonNull ViewGroup parent) {
                                //Use super class to create the View
                                View v = super.getView(position, convertView, parent);
                                TextView tv = (TextView) v.findViewById(android.R.id.text1);
                                tv.setTextSize(18);
                                tv.setCompoundDrawablesWithIntrinsicBounds(items[position].icon, 0, 0, 0);
                                //Add margin between image and text (support various screen densities)
                                int dp5 = (int) (24 * getResources().getDisplayMetrics().density + 0.5f);
                                tv.setCompoundDrawablePadding(dp5);

                                return v;
                            }
                        };

                        new AlertDialog.Builder(getActivity())
                                .setPositiveButton(R.string.goal_cancel, new DialogInterface.OnClickListener() {

                                    public void onClick(DialogInterface dialog, int whichButton) {
                                        dialog.dismiss();
                                    }
                                }).setAdapter(adapter, new DialogInterface.OnClickListener() {

                                    public void onClick(DialogInterface dialog, int item) {
                                        if (item == 0) {
                                            changeIcon(seqnoStr, title, cont, "1", attachment, create);
                                        } else if (item == 1) {
                                            changeIcon(seqnoStr, title, cont, "2", attachment, create);
                                        } else if (item == 2) {
                                            changeIcon(seqnoStr, title, cont, "3", attachment, create);
                                        } else if (item == 3) {
                                            changeIcon(seqnoStr, title, cont, "4", attachment, create);
                                        } else if (item == 4) {
                                            changeIcon(seqnoStr, title, cont, "5", attachment, create);
                                        } else if (item == 5) {
                                            changeIcon(seqnoStr, title, cont, "6", attachment, create);
                                        } else if (item == 6) {
                                            changeIcon(seqnoStr, title, cont, "7", attachment, create);
                                        } else if (item == 7) {
                                            changeIcon(seqnoStr, title, cont, "8", attachment, create);
                                        } else if (item == 8) {
                                            changeIcon(seqnoStr, title, cont, "9", attachment, create);
                                        } else if (item == 9) {
                                            changeIcon(seqnoStr, title, cont, "10", attachment, create);
                                        }
                                    }
                                }).show();
                    }
                });
                i2.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View arg0) {
                        openAtt(attachment);
                    }
                });

                return v;
            }
        };

        listView.setAdapter(simpleAdapter);

    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
}

From source file:com.abeo.tia.noordin.ProcesscaseLoanSubsidiary.java

public void dropdownf2() throws JSONException {
    RequestParams params = null;/*from  w ww .  ja  va  2  s  .c o  m*/
    params = new RequestParams();

    JSONObject jsonObject = new JSONObject();
    jsonObject.put("TableName", "OCRD");
    jsonObject.put("FieldName", "LOAN_PRNCP_TYPE");
    params.put("sJsonInput", jsonObject.toString());

    RestService.post(GET_SPINNER_VALUES, params, new BaseJsonHttpResponseHandler<String>() {

        @Override
        public void onFailure(int arg0, Header[] arg1, Throwable arg2, String arg3, String arg4) {
            // TODO Auto-generated method stub
            System.out.println(arg3);
            System.out.println("Failed");

        }

        @Override
        protected String parseResponse(String s, boolean b) throws Throwable {
            return null;
        }

        @Override
        public void onSuccess(int arg0, Header[] arg1, String arg2, String arg3) {
            // TODO Auto-generated method stub
            System.out.println("Title Dropdown Success Details ");
            System.out.println(arg2);

            try {

                arrayResponse = new JSONArray(arg2);
                // Create new list
                jsonArraylist = new ArrayList<HashMap<String, String>>();

                for (int i = 0; i < arrayResponse.length(); i++) {

                    jsonResponse = arrayResponse.getJSONObject(i);

                    id = jsonResponse.getString("Id").toString();
                    name = jsonResponse.getString("Name").toString();

                    // SEND JSON DATA INTO SPINNER TITLE LIST
                    HashMap<String, String> proList = new HashMap<String, String>();

                    // Send JSON Data to list activity
                    System.out.println("SEND JSON  LIST");
                    proList.put("Id_T", id);
                    System.out.println(name);
                    proList.put("Name_T", name);
                    System.out.println(name);
                    System.out.println(" END SEND JSON PROPERTY LIST");

                    jsonArraylist.add(proList);
                    System.out.println("JSON PROPERTY LIST");
                    System.out.println(jsonArraylist);
                }
                // Spinner set Array Data in Drop down

                sAdapPROJ = new SimpleAdapter(ProcesscaseLoanSubsidiary.this, jsonArraylist,
                        R.layout.spinner_item, new String[] { "Id_T", "Name_T" },
                        new int[] { R.id.Id, R.id.Name });

                sf2.setAdapter(sAdapPROJ);

                /*for (int j = 0; j < jsonlistProject.size(); j++) {
                        if (jsonlistProject.get(j).get("Id_T").equals(projectDetailResponse)) {
                      TitleType_DROPDOWN.setSelection(j);
                      break;
                   }
                }*/

            } catch (JSONException e) {

                e.printStackTrace();
            }
        }
    });
}