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();
}
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();
}
Aggregations