Android Open Source - Gazetti_Newspaper_Reader Add Cell Dialog Fragment






From Project

Back to project page Gazetti_Newspaper_Reader.

License

The source code is released under:

MIT License

If you think the Android project Gazetti_Newspaper_Reader listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package in.sahildave.gazetti.homescreen.adapter;
/* ww  w  .  j ava  2  s. co m*/
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import in.sahildave.gazetti.R;

public class AddCellDialogFragment extends DialogFragment implements OnItemSelectedListener {

    private Spinner spinner_newspaper;
    private Spinner spinner_category;

    public interface AddCellDialogListener {
        void onFinishAddingListener(String np, String cat);
    }

    public AddCellDialogFragment() {
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {

        LayoutInflater inflater = LayoutInflater.from(getActivity());
        final View v = inflater.inflate(R.layout.add_new_cell_dialog, null);

        spinner_newspaper = (Spinner) v.findViewById(R.id.add_cell_newpaper_spinner);
        spinner_category = (Spinner) v.findViewById(R.id.add_cell_category_spinner);

        spinner_newspaper.setOnItemSelectedListener(this);

        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setTitle("Add New Shortcut");
        builder.setView(v);
        builder.setPositiveButton(R.string.add_cell_dialog_add, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {

                String np = spinner_newspaper.getSelectedItem().toString();
                String cat = spinner_category.getSelectedItem().toString();

                AddCellDialogListener activity = (AddCellDialogListener) getActivity();
                activity.onFinishAddingListener(np, cat);
            }
        });
        builder.setNegativeButton(R.string.add_cell_dialog_cancel, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
            }
        });

        return builder.create();
    }

    @Override
    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

        if (position == 0) {
            ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.hindu_cat,
                    android.R.layout.simple_spinner_item);
            adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            spinner_category.setAdapter(adapter);
        } else if (position == 1) {
            ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.toi_cat,
                    android.R.layout.simple_spinner_item);
            adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            spinner_category.setAdapter(adapter);
        } else if (position == 2) {
            ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.fp_cat,
                    android.R.layout.simple_spinner_item);
            adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            spinner_category.setAdapter(adapter);
        } else if (position == 3) {
            ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.tie_cat,
                    android.R.layout.simple_spinner_item);
            adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            spinner_category.setAdapter(adapter);
        }

    }

    @Override
    public void onNothingSelected(AdapterView<?> parent) {}

}




Java Source Code List

in.sahildave.gazetti.StarterApplication.java
in.sahildave.gazetti.bookmarks.BookmarkAdapter.java
in.sahildave.gazetti.bookmarks.BookmarkDetailActivity.java
in.sahildave.gazetti.bookmarks.BookmarkDetailFragment.java
in.sahildave.gazetti.bookmarks.BookmarkListActivity.java
in.sahildave.gazetti.bookmarks.BookmarkListFragment.java
in.sahildave.gazetti.bookmarks.BookmarkLoadingCallback.java
in.sahildave.gazetti.bookmarks.sqlite.BookmarkDataSource.java
in.sahildave.gazetti.bookmarks.sqlite.BookmarkModel.java
in.sahildave.gazetti.bookmarks.sqlite.SQLiteHelper.java
in.sahildave.gazetti.homescreen.HomeScreenActivity.java
in.sahildave.gazetti.homescreen.HomeScreenFragment.java
in.sahildave.gazetti.homescreen.adapter.AddCellDialogFragment.java
in.sahildave.gazetti.homescreen.adapter.CellModel.java
in.sahildave.gazetti.homescreen.adapter.EditCellDialogFragment.java
in.sahildave.gazetti.homescreen.adapter.GridAdapter.java
in.sahildave.gazetti.homescreen.adapter.NewsCatModel.java
in.sahildave.gazetti.homescreen.newcontent.DialogNewContentExpListAdaper.java
in.sahildave.gazetti.homescreen.newcontent.DialogNewContent.java
in.sahildave.gazetti.news_activities.ArticleLoadingCallback.java
in.sahildave.gazetti.news_activities.WebViewFragment.java
in.sahildave.gazetti.news_activities.WebsiteDetailActivity.java
in.sahildave.gazetti.news_activities.WebsiteDetailFragment.java
in.sahildave.gazetti.news_activities.WebsiteListActivity.java
in.sahildave.gazetti.news_activities.WebsiteListFragment.java
in.sahildave.gazetti.news_activities.adapter.NavDrawerListAdapter.java
in.sahildave.gazetti.news_activities.adapter.NewsAdapter.java
in.sahildave.gazetti.news_activities.adapter.RobotoLight.java
in.sahildave.gazetti.news_activities.fetch.firstPost.java
in.sahildave.gazetti.news_activities.fetch.hindu.java
in.sahildave.gazetti.news_activities.fetch.indianExpressBusiness.java
in.sahildave.gazetti.news_activities.fetch.indianExpress.java
in.sahildave.gazetti.news_activities.fetch.toi.java
in.sahildave.gazetti.preference.FeedSelectFragment.java
in.sahildave.gazetti.preference.FeedSelectSettingsActivity.java
in.sahildave.gazetti.preference.LicensesActivity.java
in.sahildave.gazetti.preference.PreferenceExpListAdapter.java
in.sahildave.gazetti.preference.SettingsActivity.java
in.sahildave.gazetti.util.BitmapTransform.java
in.sahildave.gazetti.util.ConfigService.java
in.sahildave.gazetti.util.Constants.java
in.sahildave.gazetti.util.GazettiEnums.java
in.sahildave.gazetti.util.JsonHelper.java
in.sahildave.gazetti.util.NewsCatFileUtil.java
in.sahildave.gazetti.util.ShareButtonListener.java
in.sahildave.gazetti.util.UserPrefUtil.java
in.sahildave.gazetti.welcomescreen.WelcomeScreenExpListAdapter.java
in.sahildave.gazetti.welcomescreen.WelcomeScreenFragmentExpList.java
in.sahildave.gazetti.welcomescreen.WelcomeScreenFragmentFirst.java
in.sahildave.gazetti.welcomescreen.WelcomeScreenViewPagerActivity.java