Search in sources :

Example 1 with ImportEvent

use of com.cpjd.roblu.tba.ImportEvent in project Roblu by wdavies973.

the class TBAEventSelector method manualAdd.

/**
 * This is a dark ages method, it's for users who want to type in the event code manually
 */
private void manualAdd() {
    AlertDialog.Builder builder = new AlertDialog.Builder(TBAEventSelector.this);
    builder.setTitle("Add event manually");
    LinearLayout layout = new LinearLayout(TBAEventSelector.this);
    layout.setOrientation(LinearLayout.VERTICAL);
    final EditText input = new EditText(TBAEventSelector.this);
    input.setInputType(InputType.TYPE_CLASS_TEXT);
    input.setHint("year,event code");
    layout.addView(input);
    builder.setView(layout);
    builder.setPositiveButton("Create", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            try {
                Utils.showSnackbar(findViewById(R.id.activity_apievent_select), getApplicationContext(), "Downloading event...", false, new IO(getApplicationContext()).loadSettings().getRui().getPrimaryColor());
                new ImportEvent(TBAEventSelector.this, input.getText().toString().replaceFirst(",", "")).start();
            } catch (Exception e) {
                e.printStackTrace();
                Utils.showSnackbar(findViewById(R.id.activity_apievent_select), getApplicationContext(), "Invalid key: " + input.getText().toString() + ".", true, 0);
            }
        }
    });
    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    AlertDialog dialog = builder.create();
    dialog.show();
}
Also used : AlertDialog(android.app.AlertDialog) EditText(android.widget.EditText) DialogInterface(android.content.DialogInterface) IO(com.cpjd.roblu.io.IO) LinearLayout(android.widget.LinearLayout) ImportEvent(com.cpjd.roblu.tba.ImportEvent)

Example 2 with ImportEvent

use of com.cpjd.roblu.tba.ImportEvent in project Roblu by wdavies973.

the class TBAEventSelector method tbaEventSelected.

/**
 * The user selected an event from the downloaded events, what happens next is we need to create a sort of
 * "partial REvent" and pass it to the EventEditor class so the user can decide which form they want, etc.
 * @param v the view that was tapped
 */
@Override
public void tbaEventSelected(View v) {
    /*
         * Force close the keyboard, Android doesn't always automatically do this
         */
    View view = this.getCurrentFocus();
    if (view != null) {
        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }
    // Get the event reference from the UI
    Event event = tbaEventAdapter.getEvents().get(rv.getChildLayoutPosition(v));
    Utils.showSnackbar(findViewById(R.id.activity_apievent_select), getApplicationContext(), "Downloading event...", false, new IO(getApplicationContext()).loadSettings().getRui().getPrimaryColor());
    Log.d("RBS", "Importing event with key: " + event.key);
    /*
         * Import the event specifically, eventDownloaded(Event event) will receive the result of this
         * task execution
         */
    new ImportEvent(this, event.key).start();
}
Also used : IO(com.cpjd.roblu.io.IO) ImportEvent(com.cpjd.roblu.tba.ImportEvent) Event(com.cpjd.models.Event) InputMethodManager(android.view.inputmethod.InputMethodManager) MaterialSearchView(com.miguelcatalan.materialsearchview.MaterialSearchView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) ImportEvent(com.cpjd.roblu.tba.ImportEvent)

Aggregations

IO (com.cpjd.roblu.io.IO)2 ImportEvent (com.cpjd.roblu.tba.ImportEvent)2 AlertDialog (android.app.AlertDialog)1 DialogInterface (android.content.DialogInterface)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 InputMethodManager (android.view.inputmethod.InputMethodManager)1 AdapterView (android.widget.AdapterView)1 EditText (android.widget.EditText)1 LinearLayout (android.widget.LinearLayout)1 Event (com.cpjd.models.Event)1 MaterialSearchView (com.miguelcatalan.materialsearchview.MaterialSearchView)1