Search in sources :

Example 1 with SlidingTabLayout

use of get.saga.ui.SlidingTabLayout in project saga-android by AnandChowdhary.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    if (!sp.getBoolean("tos_accepted", false)) {
        Intent intent = new Intent(this, WelcomeActivity.class);
        startActivity(intent);
        finish();
    }
    final ViewPager pager;
    final ViewPagerAdapter adapter;
    SlidingTabLayout tabs;
    File folder = new File(Utils.getStoragePath(this));
    if (!folder.exists()) {
        folder.mkdirs();
    }
    try {
        // Get tracker.
        Tracker t = ((ApplicationWrapper) getApplication()).getTracker(ApplicationWrapper.TrackerName.APP_TRACKER);
        // Set screen name.
        t.setScreenName("MainActivity");
        // Send a screen view.
        t.send(new HitBuilders.ScreenViewBuilder().build());
    } catch (Exception e) {
    //just as a protective measure
    }
    setContentView(R.layout.activity_main);
    String title = "";
    if (mToolbar == null) {
        mToolbar = (Toolbar) findViewById(R.id.toolbar);
        if (mToolbar != null) {
            setSupportActionBar(mToolbar);
            getSupportActionBar().setTitle(title);
        }
    }
    adapter = new ViewPagerAdapter(getSupportFragmentManager());
    pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(adapter);
    tabs = (SlidingTabLayout) findViewById(R.id.tabs);
    tabs.setDistributeEvenly(true);
    tabs.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() {

        @Override
        public int getIndicatorColor(int position) {
            return getResources().getColor(R.color.colorAccent);
        }
    });
    tabs.setViewPager(pager);
}
Also used : Tracker(com.google.android.gms.analytics.Tracker) SharedPreferences(android.content.SharedPreferences) SlidingTabLayout(get.saga.ui.SlidingTabLayout) Intent(android.content.Intent) ViewPager(android.support.v4.view.ViewPager) File(java.io.File)

Aggregations

Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 ViewPager (android.support.v4.view.ViewPager)1 Tracker (com.google.android.gms.analytics.Tracker)1 SlidingTabLayout (get.saga.ui.SlidingTabLayout)1 File (java.io.File)1