Search in sources :

Example 6 with FastDialogBuilder

use of com.cpjd.roblu.ui.dialogs.FastDialogBuilder in project Roblu by wdavies973.

the class EventCreateMethodPicker method onItemClick.

/**
 * This method is called when an item from the list is selected
 * @param parent the parent adapter
 * @param view the view that was selected
 * @param position the vertical position of the selected view
 * @param id the ID of the view
 */
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    /*
         * User selected manual event creation
         */
    if (position == 4) {
        startActivityForResult(new Intent(this, EventEditor.class), Constants.GENERAL);
    } else /*
         * User selected TBA event import
         */
    if (position == 0) {
        Intent intent = new Intent(this, TBAEventSelector.class);
        startActivityForResult(intent, Constants.GENERAL);
    } else /*
         * User selected Roblu Cloud event import
         */
    if (position == 1) {
        /*
             * First, check if an active cloud event already exists and warn the user
             * that they will be disabling that
             */
        if (doesActiveEventExist()) {
            new FastDialogBuilder().setTitle("Warning").setMessage("It looks like an active cloud event already exists on your device. Importing a new event from Roblu Cloud will disable the local" + " event from cloud syncing. Do you want to proceed?").setPositiveButtonText("Yes").setNegativeButtonText("No").setFastDialogListener(new FastDialogBuilder.FastDialogListener() {

                @Override
                public void accepted() {
                    importRobluCloudEvent(-1);
                }

                @Override
                public void denied() {
                }

                @Override
                public void neutral() {
                }
            }).build(EventCreateMethodPicker.this);
        } else
            importRobluCloudEvent(-1);
    } else /*
         * User selected the read only event option, first get their username
         */
    if (position == 2) {
        importPublicRobluCloudEvent();
    } else /*
         * User selected import from backup file
         */
    if (position == 3) {
        /*
             * Open a file chooser where the user can select a backup file to use.
             * We'll listen to a result in onActivityResult() and import the backup file there
             */
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setType("*/*");
        intent.addCategory(Intent.CATEGORY_OPENABLE);
        try {
            startActivityForResult(Intent.createChooser(intent, "Select a .roblubackup file"), Constants.FILE_CHOOSER);
        } catch (android.content.ActivityNotFoundException ex) {
            Utils.showSnackbar(findViewById(R.id.activity_create_event_picker), getApplicationContext(), "No file manager found", true, rui.getPrimaryColor());
        }
    }
}
Also used : FastDialogBuilder(com.cpjd.roblu.ui.dialogs.FastDialogBuilder) Intent(android.content.Intent) TBAEventSelector(com.cpjd.roblu.ui.tba.TBAEventSelector)

Aggregations

FastDialogBuilder (com.cpjd.roblu.ui.dialogs.FastDialogBuilder)6 Intent (android.content.Intent)2 View (android.view.View)2 Button (android.widget.Button)2 TextView (android.widget.TextView)2 Dialog (android.app.Dialog)1 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 AppCompatEditText (android.support.v7.widget.AppCompatEditText)1 AppCompatRadioButton (android.support.v7.widget.AppCompatRadioButton)1 CardView (android.support.v7.widget.CardView)1 AdapterView (android.widget.AdapterView)1 ArrayAdapter (android.widget.ArrayAdapter)1 CompoundButton (android.widget.CompoundButton)1 ImageView (android.widget.ImageView)1 RadioButton (android.widget.RadioButton)1 RelativeLayout (android.widget.RelativeLayout)1 Spinner (android.widget.Spinner)1 RTeam (com.cpjd.roblu.models.RTeam)1 RGallery (com.cpjd.roblu.models.metrics.RGallery)1