Search in sources :

Example 6 with UIHandler

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

the class TBAEventSelector method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_apievent_select);
    teamNumber = new IO(getApplicationContext()).loadSettings().getTeamNumber();
    /*
         * Setup UI
         */
    // Setup
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle("Select an event");
    }
    // Progress bar
    bar = findViewById(R.id.progress_bar);
    bar.setVisibility(View.GONE);
    // Recycler view
    rv = findViewById(R.id.events_recycler);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    rv.setLayoutManager(linearLayoutManager);
    ((SimpleItemAnimator) rv.getItemAnimator()).setSupportsChangeAnimations(false);
    // Setup the tbaEventAdapter
    tbaEventAdapter = new TBAEventAdapter(this, this);
    rv.setAdapter(tbaEventAdapter);
    // Setup the gesture listener
    ItemTouchHelper.Callback callback = new TutorialsRecyclerTouchHelper();
    ItemTouchHelper helper = new ItemTouchHelper(callback);
    helper.attachToRecyclerView(rv);
    /*
         * Create the "My Events / All Events" chooser
         */
    Spinner showTeam = findViewById(R.id.show_team);
    ArrayAdapter<String> sAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, new String[] { "My events", "All events" });
    sAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    showTeam.setAdapter(sAdapter);
    showTeam.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long l) {
            onlyShowMyEvents = parent.getItemAtPosition(position).toString().equals("My events");
            rv.setVisibility(View.INVISIBLE);
            bar.setVisibility(View.VISIBLE);
            if (tbaEventAdapter.getEvents() != null)
                tbaEventAdapter.getEvents().clear();
            tbaEventAdapter.notifyDataSetChanged();
            TBALoadEventsTask task = new TBALoadEventsTask(bar, rv, tbaEventAdapter, TBAEventSelector.this, teamNumber, selectedYear, onlyShowMyEvents);
            task.execute();
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    });
    // If no team number is found, default to "All events"
    if (new IO(getApplicationContext()).loadSettings().getTeamNumber() == 0)
        showTeam.setSelection(1);
    /*
         * Setup the years spinner
         */
    Spinner yearsSpinner = findViewById(R.id.spinner);
    selectedYear = Calendar.getInstance().get(Calendar.YEAR);
    String[] years = new String[selectedYear - 1991];
    for (int i = years.length - 1; i >= 0; i--) years[Math.abs(i - years.length + 1)] = String.valueOf(1992 + i);
    final ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, years);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    yearsSpinner.setAdapter(adapter);
    yearsSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            selectedYear = Integer.parseInt(adapterView.getItemAtPosition(i).toString());
            rv.setVisibility(View.INVISIBLE);
            bar.setVisibility(View.VISIBLE);
            if (tbaEventAdapter.getEvents() != null)
                tbaEventAdapter.getEvents().clear();
            tbaEventAdapter.notifyDataSetChanged();
            TBALoadEventsTask task = new TBALoadEventsTask(bar, rv, tbaEventAdapter, TBAEventSelector.this, teamNumber, selectedYear, onlyShowMyEvents);
            task.execute();
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    });
    /*
         * Setup the search view
         */
    searchView = findViewById(R.id.search_view);
    searchView.setHintTextColor(Color.BLACK);
    searchView.setHint("Search events");
    searchView.setOnSearchViewListener(new MaterialSearchView.SearchViewListener() {

        @Override
        public void onSearchViewShown() {
        }

        @Override
        public void onSearchViewClosed() {
            TBALoadEventsTask task = new TBALoadEventsTask(bar, rv, tbaEventAdapter, TBAEventSelector.this, teamNumber, selectedYear, onlyShowMyEvents);
            task.setEvents(events);
            task.execute();
        }
    });
    searchView.setOnQueryTextListener(new MaterialSearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            searchView.closeSearch();
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            TBALoadEventsTask task = new TBALoadEventsTask(bar, rv, tbaEventAdapter, TBAEventSelector.this, teamNumber, selectedYear, onlyShowMyEvents);
            task.setEvents(events);
            task.setQuery(newText);
            task.execute();
            return true;
        }
    });
    // Sync UI with user preferences
    new UIHandler(this, toolbar).update();
}
Also used : TutorialsRecyclerTouchHelper(com.cpjd.roblu.ui.tutorials.TutorialsRecyclerTouchHelper) Spinner(android.widget.Spinner) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) TBALoadEventsTask(com.cpjd.roblu.tba.TBALoadEventsTask) Toolbar(android.support.v7.widget.Toolbar) SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) UIHandler(com.cpjd.roblu.ui.UIHandler) IO(com.cpjd.roblu.io.IO) MaterialSearchView(com.miguelcatalan.materialsearchview.MaterialSearchView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) MaterialSearchView(com.miguelcatalan.materialsearchview.MaterialSearchView) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter)

Example 7 with UIHandler

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

the class TeamViewer method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.team_viewer_actionbar, menu);
    new UIHandler(this, menu).updateMenu();
    if (getIntent().getBooleanExtra("readOnly", false)) {
        menu.findItem(R.id.match_settings).setVisible(false);
        menu.findItem(R.id.add_match).setVisible(false);
        menu.findItem(R.id.add_match).setEnabled(false);
        menu.findItem(R.id.match_settings).setEnabled(false);
    }
    return true;
}
Also used : UIHandler(com.cpjd.roblu.ui.UIHandler)

Example 8 with UIHandler

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

the class EventEditor method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    /*
		 * Load dependencies
		 */
    editing = getIntent().getBooleanExtra("editing", false);
    RUI rui = new IO(getApplicationContext()).loadSettings().getRui();
    // decide whether to use create event or edit event UI scheme
    if (editing)
        setContentView(R.layout.activity_edit_event);
    else
        setContentView(R.layout.activity_create_event);
    /*
         * Setup UI
         */
    // Toolbar
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setHomeAsUpIndicator(R.drawable.clear);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        if (editing)
            getSupportActionBar().setTitle("Edit event");
        else
            getSupportActionBar().setTitle("Create event");
    }
    // event name
    eventName = findViewById(R.id.event_create_name_edit);
    /*
         * Bind user color preferences to the UI elements
         */
    Utils.setInputTextLayoutColor(rui.getAccent(), (TextInputLayout) findViewById(R.id.name_wrapper), (AppCompatEditText) findViewById(R.id.event_create_name_edit));
    /*
         * Setup editing/non-editing UI specifics
         */
    if (!editing) {
        TextView t = findViewById(R.id.event_create_form_label);
        t.setTextColor(rui.getAccent());
        if (getIntent().getSerializableExtra("tbaEvent") != null) {
            /*
                 * This item will be set if this activity is called form the TBAEventSelector activity, all it's saying is that
                 * all the data within this Event model should be included when creating the REvent
                 */
            Event event = (Event) getIntent().getSerializableExtra("tbaEvent");
            eventName.setText(event.name);
            findViewById(R.id.switch1).setVisibility(View.VISIBLE);
        }
    } else {
        RelativeLayout layout = findViewById(R.id.create_layout);
        for (int i = 0; i < layout.getChildCount(); i++) {
            if (layout.getChildAt(i).getId() == R.id.form_type || layout.getChildAt(i).getId() == R.id.event_create_form_label) {
                layout.removeViewAt(i);
                i = 0;
            }
        }
        tbaKeyText = findViewById(R.id.key_edit);
        tbaKeyText.setText(getIntent().getStringExtra("key"));
        eventName.setText(getIntent().getStringExtra("name"));
    }
    // General UI syncing
    new UIHandler(this, toolbar).update();
}
Also used : UIHandler(com.cpjd.roblu.ui.UIHandler) IO(com.cpjd.roblu.io.IO) RUI(com.cpjd.roblu.models.RUI) RelativeLayout(android.widget.RelativeLayout) UnpackTBAEvent(com.cpjd.roblu.tba.UnpackTBAEvent) REvent(com.cpjd.roblu.models.REvent) Event(com.cpjd.models.Event) TextView(android.widget.TextView) Toolbar(android.support.v7.widget.Toolbar)

Example 9 with UIHandler

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

the class EventEditor method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.event_create_actionbar, menu);
    new UIHandler(this, menu).updateMenu();
    return true;
}
Also used : UIHandler(com.cpjd.roblu.ui.UIHandler)

Example 10 with UIHandler

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

the class Tutorial method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tutorial);
    /*
         * Setup UI
         */
    // Toolbar
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setTitle("Tutorials");
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }
    // List of tutorials
    tutorials = new ArrayList<>();
    tutorials.add(new RTutorial("Text based", "View the Roblu text based tutorial", "https://docs.google.com/document/d/1DqpgKPdtfZDUc7Zu3MqdJHL59aB-ht8H1ZwllYlzMuc/edit?usp=sharing"));
    tutorials.add(new RTutorial("The basics", "Roblu's mission, description of platforms, terms, etc.", "9j6ysvJJyQg"));
    tutorials.add(new RTutorial("Events", "Learn how to create, manage, backup, organize, and export events", "6BLlLxltppk"));
    tutorials.add(new RTutorial("Forms", "Learn how to create, manage, edit, organize, master form", "xLLbPyhW9fg"));
    tutorials.add(new RTutorial("Roblu Cloud (Network syncing)", "Learn how to setup and sync scouting data across unlimited devices over a data connection.", "z9tIGaaV1jQ"));
    tutorials.add(new RTutorial("Bluetooth Syncing", "Learn how to setup and sync with Bluetooth syncing.", "Adjp3rjt2_4"));
    tutorials.add(new RTutorial("QR Codes", "Learn how to use QR code syncing", "pS_5bvp1D_c"));
    tutorials.add(new RTutorial("Manual Schedule Importer", "Learn how to use the manual schedule importer if the FIRST API is down.", "https://github.com/wdavies973/Roblu/wiki/Manually-Importing-a-Match-Schedule"));
    tutorials.add(new RTutorial("Scouting / Odds and Ends", "Learn about those features that weren't in any of the other tutorial videos", "JL_lSaB0gsk"));
    tutorials.add(new RTutorial("How to get Roblu Cloud for free", "Get Roblu Cloud for free", "dQw4w9WgXcQ"));
    tutorials.add(new RTutorial("Roblu Devlogs", "For those interested in watching the development process", ""));
    /*
         * Add the tutorials to the recycler view
         */
    rv = findViewById(R.id.teams_recycler);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    rv.setLayoutManager(linearLayoutManager);
    ((SimpleItemAnimator) rv.getItemAnimator()).setSupportsChangeAnimations(false);
    TutorialsRecyclerAdapter adapter = new TutorialsRecyclerAdapter(this, this, tutorials);
    rv.setAdapter(adapter);
    // Gesture listener
    ItemTouchHelper.Callback callback = new TutorialsRecyclerTouchHelper();
    ItemTouchHelper helper = new ItemTouchHelper(callback);
    helper.attachToRecyclerView(rv);
    // Sync UI with settings
    new UIHandler(this, toolbar).update();
}
Also used : ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) UIHandler(com.cpjd.roblu.ui.UIHandler) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

UIHandler (com.cpjd.roblu.ui.UIHandler)26 Toolbar (android.support.v7.widget.Toolbar)14 IO (com.cpjd.roblu.io.IO)10 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)5 SimpleItemAnimator (android.support.v7.widget.SimpleItemAnimator)5 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)4 MenuInflater (android.view.MenuInflater)4 RForm (com.cpjd.roblu.models.RForm)4 ArrayList (java.util.ArrayList)4 RecyclerView (android.support.v7.widget.RecyclerView)3 IntentFilter (android.content.IntentFilter)2 View (android.view.View)2 AdapterView (android.widget.AdapterView)2 ListView (android.widget.ListView)2 SimpleAdapter (android.widget.SimpleAdapter)2 TextView (android.widget.TextView)2 RUI (com.cpjd.roblu.models.RUI)2 MaterialSearchView (com.miguelcatalan.materialsearchview.MaterialSearchView)2 HashMap (java.util.HashMap)2 AlertDialog (android.app.AlertDialog)1