use of com.cpjd.roblu.ui.dialogs.FastDialogBuilder in project Roblu by wdavies973.
the class RMetricToUI method addStopwatchLapButton.
private void addStopwatchLapButton(final RStopwatch stopwatch, final RelativeLayout layout, final ImageView playButton, final ArrayList<Button> buttons, double time) {
final Button b = new Button(activity);
b.setText("Lap " + (buttons.size() + 1) + ": " + time + " seconds");
b.setId(Utils.generateViewId());
final RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
if (buttons.size() != 0)
params.addRule(RelativeLayout.BELOW, buttons.get(buttons.size() - 1).getId());
else
params.addRule(RelativeLayout.BELOW, playButton.getId());
b.setTextColor(rui.getText());
b.setLayoutParams(params);
b.getBackground().mutate().setColorFilter(new PorterDuffColorFilter(RUI.darker(rui.getCardColor(), 0.75f), PorterDuff.Mode.SRC));
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new FastDialogBuilder().setTitle("Are you sure?").setMessage("Are you sure you want to delete this lap time?").setPositiveButtonText("Yes").setNegativeButtonText("No").setFastDialogListener(new FastDialogBuilder.FastDialogListener() {
@Override
public void accepted() {
// Remove the time
stopwatch.getTimes().remove(buttons.indexOf(b));
layout.removeView(b);
buttons.remove(b);
// Redo positions
for (int i = 0; i < buttons.size(); i++) {
final RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
if (i == 0)
params.addRule(RelativeLayout.BELOW, playButton.getId());
else
params.addRule(RelativeLayout.BELOW, buttons.get(i - 1).getId());
buttons.get(i).setLayoutParams(params);
}
listener.changeMade(stopwatch);
}
@Override
public void denied() {
}
@Override
public void neutral() {
}
}).build(activity);
}
});
buttons.add(b);
layout.addView(b);
}
use of com.cpjd.roblu.ui.dialogs.FastDialogBuilder in project Roblu by wdavies973.
the class TeamViewer method showMatchCreator.
/**
* Opens the manual match creator
*/
private void showMatchCreator() {
if (!editable) {
Toast.makeText(getApplicationContext(), "Can't create match in read only mode.", Toast.LENGTH_LONG).show();
return;
}
final Dialog d = new Dialog(this);
d.setTitle("Create match");
d.setContentView(R.layout.match_create_dialog);
final AppCompatEditText number = d.findViewById(R.id.editText);
Utils.setInputTextLayoutColor(rui.getAccent(), null, number);
TextView spinnerTip = d.findViewById(R.id.spinner_tip);
spinnerTip.setTextColor(rui.getText());
TextView numberTip = d.findViewById(R.id.number_tip);
numberTip.setTextColor(rui.getText());
TextView colorTip = d.findViewById(R.id.color_tip);
colorTip.setTextColor(rui.getText());
Button button = d.findViewById(R.id.button7);
button.setTextColor(rui.getText());
button.setBackgroundColor(rui.getBackground());
String[] values = { "Quals", "Quarters 1", "Quarters 2", "Quarters 3", "Quarters 4", "Semis 1", "Semis 2", "Finals" };
final Spinner spinner = d.findViewById(R.id.type);
spinner.getBackground().setColorFilter(rui.getText(), PorterDuff.Mode.SRC_ATOP);
ArrayAdapter<String> adp = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, values);
adp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adp);
final Spinner spinner2 = d.findViewById(R.id.spinner2);
spinner2.getBackground().setColorFilter(rui.getText(), PorterDuff.Mode.SRC_ATOP);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Check for duplicates!!
final String processedName = processName(spinner, number);
if (doesExist(processedName)) {
new FastDialogBuilder().setTitle("Match already exists").setMessage("Would you like to go to its tab?").setPositiveButtonText("Yes").setNegativeButtonText("No").setFastDialogListener(new FastDialogBuilder.FastDialogListener() {
@Override
public void accepted() {
d.dismiss();
pager.setCurrentItem(getPosition(processedName));
}
@Override
public void denied() {
}
@Override
public void neutral() {
}
}).build(TeamViewer.this);
} else {
boolean isRed = spinner2.getSelectedItemPosition() == 0;
pager.setCurrentItem(tabAdapter.createMatch(processedName, isRed));
d.dismiss();
}
}
});
if (d.getWindow() != null) {
d.getWindow().getAttributes().windowAnimations = rui.getDialogDirection();
d.getWindow().setBackgroundDrawable(new ColorDrawable(rui.getBackground()));
}
d.getWindow().getAttributes().windowAnimations = rui.getDialogDirection();
d.show();
}
use of com.cpjd.roblu.ui.dialogs.FastDialogBuilder in project Roblu by wdavies973.
the class FormRecyclerTouchHelper method onSwiped.
/**
* Called when a form card is swiped in a certain direction
* @param viewHolder the view holder containing the swiped card
* @param direction the direction the card was swiped in
*/
@Override
public void onSwiped(final RecyclerView.ViewHolder viewHolder, int direction) {
final RMetric metric = mMetricsAdapter.getMetrics().get(viewHolder.getAdapterPosition());
/*
* User wants to delete the RMetric
*/
if (direction == ItemTouchHelper.LEFT) {
/*
* Decide which delete message to display, if the user is deleting a form metric that contains scouting data somewhere else,
* we'll want to notify them a bit more
*/
if (metric.getID() <= mMetricsAdapter.getInitID()) {
new FastDialogBuilder().setTitle("Warning").setMessage("Deleting this metric will remove it and all its associated scouting data from ALL team profiles.").setPositiveButtonText("Delete").setNegativeButtonText("Cancel").setFastDialogListener(new FastDialogBuilder.FastDialogListener() {
@Override
public void accepted() {
mMetricsAdapter.getMetrics().remove(viewHolder.getAdapterPosition());
mMetricsAdapter.notifyItemRemoved(viewHolder.getAdapterPosition());
}
@Override
public void denied() {
mMetricsAdapter.reAdd(metric);
mMetricsAdapter.notifyDataSetChanged();
}
@Override
public void neutral() {
}
}).build(mMetricsAdapter.getContext());
} else {
mMetricsAdapter.getMetrics().remove(viewHolder.getAdapterPosition());
mMetricsAdapter.notifyItemRemoved(viewHolder.getAdapterPosition());
}
} else /*
* User wants to edit the RMetric, we can't actually handle that here, so pass it back tot he FormViewer activity
*/
if (direction == ItemTouchHelper.RIGHT) {
/*
* One quick thing - Intents have a payload maximum, galleries will trigger this easily
* because of their size, so if the user requested a RGallery edit, remove all picture information
* from the reference.
*/
if (metric instanceof RGallery)
((RGallery) metric).setImages(null);
mMetricsAdapter.getListener().metricEditRequested(metric);
}
}
use of com.cpjd.roblu.ui.dialogs.FastDialogBuilder in project Roblu by wdavies973.
the class FormViewer method launchParent.
private void launchParent() {
if (changesMade && !getIntent().getBooleanExtra("ignoreDiscard", false)) {
new FastDialogBuilder().setTitle("Discard changes?").setMessage("Really discard changes you've made to this form?").setPositiveButtonText("Discard").setNegativeButtonText("Cancel").setFastDialogListener(new FastDialogBuilder.FastDialogListener() {
@Override
public void accepted() {
setResult(Constants.CANCELLED);
finish();
}
@Override
public void denied() {
}
@Override
public void neutral() {
}
}).build(FormViewer.this);
} else {
// Make sure to include the form in the return transfer for EventEditor primarily, even on a form discard
if (getIntent().getBooleanExtra("ignoreDiscard", false)) {
/*
* Make sure to retrieve all metrics
*/
if (currentTab == 0)
form.setPit(metricsAdapter.getMetrics());
else if (currentTab == 1)
form.setMatch(metricsAdapter.getMetrics());
Intent intent = new Intent();
intent.putExtra("form", form);
setResult(Constants.CANCELLED, intent);
} else {
setResult(Constants.CANCELLED);
}
finish();
}
}
use of com.cpjd.roblu.ui.dialogs.FastDialogBuilder in project Roblu by wdavies973.
the class TeamsRecyclerTouchHelper method onSwiped.
/**
* This method is called when a card is swiped, in this case, the only swipe direction is for the team
* delete swipe
* @param viewHolder the viewHolder that was swiped
* @param direction the direction the card was swiped in
*/
@Override
public void onSwiped(final RecyclerView.ViewHolder viewHolder, int direction) {
/*
* User wants to delete a team, let's confirm it with them
*/
if (direction == ItemTouchHelper.LEFT) {
final RTeam team = teamsAdapter.getTeams().get(viewHolder.getAdapterPosition());
new FastDialogBuilder().setTitle("Are you sure?").setMessage("Are you sure you want to delete team " + team.getName() + "?").setPositiveButtonText("Delete").setNegativeButtonText("Cancel").setFastDialogListener(new FastDialogBuilder.FastDialogListener() {
@Override
public void accepted() {
teamsAdapter.remove(viewHolder.getAdapterPosition());
teamsAdapter.notifyDataSetChanged();
/*
* Also, we need to tell TeamsView that the LoadTeamsTask now contains an invalid internal teams array and must
* refresh it from the local disk
*/
teamsAdapter.getListener().teamDeleted(team);
}
@Override
public void denied() {
teamsAdapter.reAdd(team);
}
@Override
public void neutral() {
}
}).build(teamsAdapter.getContext());
}
}
Aggregations