Search in sources :

Example 1 with RoleAdapter

use of fr.neamar.lolgamedata.adapter.RoleAdapter in project teamward-client by Neamar.

the class CounterChampionsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_counter_champions);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    assert getSupportActionBar() != null;
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    // Setup spinner
    Spinner spinner = (Spinner) findViewById(R.id.spinner);
    spinner.setAdapter(new RoleAdapter(toolbar.getContext(), ROLES));
    final Account account = (Account) getIntent().getSerializableExtra("account");
    final SharedPreferences prefs = getPreferences(MODE_PRIVATE);
    spinner.setSelection(prefs.getInt("lastUsedPosition", 2));
    spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            currentFragment = CounterChampionsFragment.newInstance(ROLES[position], account);
            getSupportFragmentManager().beginTransaction().replace(R.id.container, currentFragment).commitAllowingStateLoss();
            prefs.edit().putInt("lastUsedPosition", position).apply();
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
}
Also used : Account(fr.neamar.lolgamedata.pojo.Account) SharedPreferences(android.content.SharedPreferences) Spinner(android.widget.Spinner) OnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener) RoleAdapter(fr.neamar.lolgamedata.adapter.RoleAdapter) SearchView(android.support.v7.widget.SearchView) View(android.view.View) AdapterView(android.widget.AdapterView) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

SharedPreferences (android.content.SharedPreferences)1 SearchView (android.support.v7.widget.SearchView)1 Toolbar (android.support.v7.widget.Toolbar)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 OnItemSelectedListener (android.widget.AdapterView.OnItemSelectedListener)1 Spinner (android.widget.Spinner)1 RoleAdapter (fr.neamar.lolgamedata.adapter.RoleAdapter)1 Account (fr.neamar.lolgamedata.pojo.Account)1