Search in sources :

Example 1 with RFieldDiagram

use of com.cpjd.roblu.models.metrics.RFieldDiagram in project Roblu by wdavies973.

the class MetricEditor method onItemSelected.

/**
 * Called when the user selects a metric type
 * @param adapterView the adapter containing all the choices
 * @param view the view that was tapped
 * @param i the position of the view
 * @param l id of the view
 */
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
    ((TextView) adapterView.getChildAt(0)).setTextColor(rui.getText());
    /*
         * User selected a new metric, let's create it
         */
    String stringOfSelected = METRIC_TYPES[i];
    if (stringOfSelected.equals(METRIC_TYPES[0])) {
        metric = new RBoolean(0, "Boolean", false);
    } else if (stringOfSelected.equals(METRIC_TYPES[1])) {
        metric = new RCounter(0, "Counter", 1, 0);
    } else if (stringOfSelected.equals(METRIC_TYPES[2])) {
        metric = new RSlider(0, "Slider", 0, 100, 0);
    } else if (stringOfSelected.equals(METRIC_TYPES[3])) {
        metric = new RChooser(0, "Chooser", null, 0);
    } else if (stringOfSelected.equals(METRIC_TYPES[4])) {
        metric = new RCheckbox(0, "Checkbox", null);
    } else if (stringOfSelected.equals(METRIC_TYPES[5])) {
        metric = new RStopwatch(0, "Stopwatch", 0);
    } else if (stringOfSelected.equals(METRIC_TYPES[6])) {
        metric = new RTextfield(0, "Text field", "");
    } else if (stringOfSelected.equals(METRIC_TYPES[7])) {
        metric = new RGallery(0, "Gallery");
    } else if (stringOfSelected.equalsIgnoreCase(METRIC_TYPES[8])) {
        metric = new RDivider(0, "Divider");
    } else if (stringOfSelected.equals(METRIC_TYPES[9])) {
        metric = new RFieldDiagram(0, R.drawable.field2018, null);
    } else if (stringOfSelected.equals(METRIC_TYPES[10])) {
        metric = new RCalculation(0, "Custom calculation");
    } else if (stringOfSelected.equals(METRIC_TYPES[11])) {
        metric = new RFieldData(0, "Match data");
    }
    metric.setModified(true);
    addMetricPreviewToToolbar();
    buildConfigLayout();
}
Also used : RBoolean(com.cpjd.roblu.models.metrics.RBoolean) RDivider(com.cpjd.roblu.models.metrics.RDivider) RChooser(com.cpjd.roblu.models.metrics.RChooser) RGallery(com.cpjd.roblu.models.metrics.RGallery) RTextfield(com.cpjd.roblu.models.metrics.RTextfield) RFieldData(com.cpjd.roblu.models.metrics.RFieldData) RFieldDiagram(com.cpjd.roblu.models.metrics.RFieldDiagram) RCalculation(com.cpjd.roblu.models.metrics.RCalculation) RStopwatch(com.cpjd.roblu.models.metrics.RStopwatch) RCheckbox(com.cpjd.roblu.models.metrics.RCheckbox) RSlider(com.cpjd.roblu.models.metrics.RSlider) TextView(android.widget.TextView) RCounter(com.cpjd.roblu.models.metrics.RCounter)

Example 2 with RFieldDiagram

use of com.cpjd.roblu.models.metrics.RFieldDiagram in project Roblu by wdavies973.

the class MetricEditor method addMetricPreviewToToolbar.

/**
 * Adds the metric preview to the Toolbar
 */
private void addMetricPreviewToToolbar() {
    Toolbar toolbar = findViewById(R.id.toolbar);
    toolbar.setBackgroundColor(rui.getPrimaryColor());
    toolbar.removeAllViews();
    if (metric instanceof RBoolean)
        toolbar.addView(rMetricToUI.getBoolean((RBoolean) metric));
    else if (metric instanceof RCounter)
        toolbar.addView(rMetricToUI.getCounter((RCounter) metric));
    else if (metric instanceof RSlider)
        toolbar.addView(rMetricToUI.getSlider((RSlider) metric));
    else if (metric instanceof RChooser)
        toolbar.addView(rMetricToUI.getChooser((RChooser) metric));
    else if (metric instanceof RCheckbox)
        toolbar.addView(rMetricToUI.getCheckbox((RCheckbox) metric));
    else if (metric instanceof RStopwatch)
        toolbar.addView(rMetricToUI.getStopwatch((RStopwatch) metric, true));
    else if (metric instanceof RTextfield)
        toolbar.addView(rMetricToUI.getTextfield((RTextfield) metric));
    else if (metric instanceof RGallery)
        toolbar.addView(rMetricToUI.getGallery(true, 0, 0, ((RGallery) metric)));
    else if (metric instanceof RDivider)
        toolbar.addView(rMetricToUI.getDivider((RDivider) metric));
    else if (metric instanceof RFieldDiagram)
        toolbar.addView(rMetricToUI.getFieldDiagram(-1, (RFieldDiagram) metric));
    else if (metric instanceof RCalculation)
        toolbar.addView(rMetricToUI.getCalculationMetric(null, ((RCalculation) metric)));
    else if (metric instanceof RFieldData)
        toolbar.addView(rMetricToUI.getFieldData((RFieldData) metric));
}
Also used : RBoolean(com.cpjd.roblu.models.metrics.RBoolean) RDivider(com.cpjd.roblu.models.metrics.RDivider) RChooser(com.cpjd.roblu.models.metrics.RChooser) RGallery(com.cpjd.roblu.models.metrics.RGallery) RTextfield(com.cpjd.roblu.models.metrics.RTextfield) RFieldData(com.cpjd.roblu.models.metrics.RFieldData) RFieldDiagram(com.cpjd.roblu.models.metrics.RFieldDiagram) RCalculation(com.cpjd.roblu.models.metrics.RCalculation) RStopwatch(com.cpjd.roblu.models.metrics.RStopwatch) RCheckbox(com.cpjd.roblu.models.metrics.RCheckbox) RSlider(com.cpjd.roblu.models.metrics.RSlider) RCounter(com.cpjd.roblu.models.metrics.RCounter) Toolbar(android.support.v7.widget.Toolbar)

Example 3 with RFieldDiagram

use of com.cpjd.roblu.models.metrics.RFieldDiagram in project Roblu by wdavies973.

the class CustomSort method onCreate.

@Override
public void onCreate(Bundle saveInstanceState) {
    super.onCreate(saveInstanceState);
    setContentView(R.layout.activity_customsort);
    /*
         * Load the form and remove the team NAME and NUMBER metrics (since the user can sort by
         * this already without using CustomSort). Good news is that we know the form will ALWAYS
         * keep the team NAME and NUMBER as ID 0 and 1 respectively.
         */
    RForm form = new IO(getApplicationContext()).loadForm(getIntent().getIntExtra("eventID", 0));
    for (int i = 0; i < form.getPit().size(); i++) {
        if (form.getPit().get(i).getID() == 0 || form.getPit().get(i).getID() == 1 || form.getPit().get(i) instanceof RDivider || form.getPit().get(i) instanceof RFieldDiagram) {
            form.getPit().remove(i);
            i--;
        }
    }
    // Remove dividers - they are useless for sorting
    for (int i = 0; i < form.getMatch().size(); i++) {
        if (form.getMatch().get(i) instanceof RDivider || form.getMatch().get(i) instanceof RFieldDiagram) {
            form.getMatch().remove(i);
            i--;
        }
    }
    /*
         * Setup UI
         */
    // Toolbar
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setTitle("Custom sort");
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }
    // Setup tabs
    TabLayout tabLayout = findViewById(R.id.tab_layout);
    tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
    tabLayout.setBackgroundColor(new IO(getApplicationContext()).loadSettings().getRui().getPrimaryColor());
    // Setup the adapter - the back-end to the UI (manages all the MetricFragments)
    MetricSortAdapter adapter = new MetricSortAdapter(getSupportFragmentManager(), form, getIntent().getIntExtra("eventID", 0));
    ViewPager pager = findViewById(R.id.pager);
    pager.addOnPageChangeListener(this);
    pager.setAdapter(adapter);
    tabLayout.setupWithViewPager(pager);
    // Sync UI with user preferences
    new UIHandler(this, toolbar).update();
}
Also used : RDivider(com.cpjd.roblu.models.metrics.RDivider) RForm(com.cpjd.roblu.models.RForm) UIHandler(com.cpjd.roblu.ui.UIHandler) IO(com.cpjd.roblu.io.IO) TabLayout(android.support.design.widget.TabLayout) RFieldDiagram(com.cpjd.roblu.models.metrics.RFieldDiagram) ViewPager(android.support.v4.view.ViewPager) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

RDivider (com.cpjd.roblu.models.metrics.RDivider)3 RFieldDiagram (com.cpjd.roblu.models.metrics.RFieldDiagram)3 Toolbar (android.support.v7.widget.Toolbar)2 RBoolean (com.cpjd.roblu.models.metrics.RBoolean)2 RCalculation (com.cpjd.roblu.models.metrics.RCalculation)2 RCheckbox (com.cpjd.roblu.models.metrics.RCheckbox)2 RChooser (com.cpjd.roblu.models.metrics.RChooser)2 RCounter (com.cpjd.roblu.models.metrics.RCounter)2 RFieldData (com.cpjd.roblu.models.metrics.RFieldData)2 RGallery (com.cpjd.roblu.models.metrics.RGallery)2 RSlider (com.cpjd.roblu.models.metrics.RSlider)2 RStopwatch (com.cpjd.roblu.models.metrics.RStopwatch)2 RTextfield (com.cpjd.roblu.models.metrics.RTextfield)2 TabLayout (android.support.design.widget.TabLayout)1 ViewPager (android.support.v4.view.ViewPager)1 TextView (android.widget.TextView)1 IO (com.cpjd.roblu.io.IO)1 RForm (com.cpjd.roblu.models.RForm)1 UIHandler (com.cpjd.roblu.ui.UIHandler)1