Search in sources :

Example 1 with SectionsPagerAdapter

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

the class GameActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (!BuildConfig.DEBUG) {
        // Do not use NewRelic on DEBUG.
        NewRelic.withApplicationToken("AAcab2a6606aca33f2716f49d2c60e68234953a103").start(this.getApplication());
    }
    setContentView(R.layout.activity_game);
    // First run: open accounts activity, finish this activity
    AccountManager accountManager = new AccountManager(this);
    if (accountManager.getAccounts().isEmpty()) {
        Intent i = new Intent(this, AccountsActivity.class);
        startActivity(i);
        Tracker.trackFirstTimeAppOpen(GameActivity.this);
        finish();
        return;
    }
    // Get account
    if (getIntent() != null && getIntent().hasExtra("account")) {
        account = (Account) getIntent().getSerializableExtra("account");
    } else {
        account = accountManager.getAccounts().get(0);
        if (getIntent() != null && getIntent().getAction() != null && getIntent().getAction().equals(Intent.ACTION_MAIN)) {
            getIntent().putExtra("source", "app_open");
        }
    }
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    assert toolbar != null;
    setSupportActionBar(toolbar);
    ActionBar ab = getSupportActionBar();
    assert ab != null;
    ab.setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp);
    ab.setDisplayHomeAsUpEnabled(true);
    ab.setTitle(R.string.title_activity_game);
    mViewPager = (ViewPager) findViewById(R.id.container);
    mTabLayout = (TabLayout) findViewById(R.id.tabs);
    Button refreshButton = (Button) findViewById(R.id.refresh);
    mEmptyView = findViewById(android.R.id.empty);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager(), this);
    // Set up the ViewPager with the sections adapter.
    assert mViewPager != null;
    assert mTabLayout != null;
    mViewPager.setAdapter(sectionsPagerAdapter);
    mTabLayout.setupWithViewPager(mViewPager);
    assert refreshButton != null;
    refreshButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            setUiMode(UI_MODE_LOADING);
            loadCurrentGame(account.summonerName, account.region);
        }
    });
    TextView notInGame = ((TextView) findViewById(R.id.summoner_not_in_game_text));
    assert notInGame != null;
    notInGame.setText(String.format(getString(R.string.s_is_not_in_game_right_now), account.summonerName));
    setUiMode(UI_MODE_LOADING);
    if (savedInstanceState == null || !savedInstanceState.containsKey("game")) {
        loadCurrentGame(account.summonerName, account.region);
    }
    if (TokenRefreshedService.tokenUpdateRequired(this)) {
        Log.i(TAG, "Syncing FCM token with server");
        // Resync token with server
        Intent intent = new Intent(this, SyncTokenService.class);
        this.startService(intent);
    }
}
Also used : Button(android.widget.Button) Intent(android.content.Intent) TextView(android.widget.TextView) SectionsPagerAdapter(fr.neamar.lolgamedata.adapter.SectionsPagerAdapter) View(android.view.View) TextView(android.widget.TextView) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

Intent (android.content.Intent)1 ActionBar (android.support.v7.app.ActionBar)1 Toolbar (android.support.v7.widget.Toolbar)1 View (android.view.View)1 Button (android.widget.Button)1 TextView (android.widget.TextView)1 SectionsPagerAdapter (fr.neamar.lolgamedata.adapter.SectionsPagerAdapter)1