Last active
October 9, 2018 10:18
-
-
Save DVegasa/4274d58b96260ac3c5fabebcbc5f9a66 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.github.dvegasa.civisz.screens.main; | |
import android.os.Bundle; | |
import android.support.v7.app.AppCompatActivity; | |
import com.aurelhubert.ahbottomnavigation.AHBottomNavigation; | |
import com.aurelhubert.ahbottomnavigation.AHBottomNavigationItem; | |
import butterknife.BindView; | |
import butterknife.ButterKnife; | |
import io.github.dvegasa.civisz.R; | |
import io.github.dvegasa.civisz.helpers.NonSwipeableViewPager; | |
public class MainActivity extends AppCompatActivity implements MainContract.View { | |
@BindView(R.id.bottomNav) | |
AHBottomNavigation bottomNav; | |
@BindView(R.id.nsvp) | |
NonSwipeableViewPager nsvp; | |
private MainContract.Presenter presenter; | |
private NsvpAdapter nsvpAdater; | |
@Override | |
protected void onCreate(final Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
ButterKnife.bind(this); | |
presenter = new MainPresenter(); | |
presenter.attachView(this); | |
nsvpAdater = new NsvpAdapter(getSupportFragmentManager()); | |
nsvp.setAdapter(nsvpAdater); | |
presenter.viewIsReady(); | |
bottomNav.setOnTabSelectedListener(presenter.getBottomNavListener()); | |
} | |
@Override | |
protected void onDestroy() { | |
super.onDestroy(); | |
presenter.onDestroyView(); | |
} | |
@Override | |
public void initBottomNav() { | |
AHBottomNavigationItem item1 = new AHBottomNavigationItem("Главная", R.drawable.ic_home_white_24dp); | |
AHBottomNavigationItem item2 = new AHBottomNavigationItem("Мои рапорты", R.drawable.ic_format_list_bulleted_white_24dp); | |
AHBottomNavigationItem item3 = new AHBottomNavigationItem("Создать рапорт", R.drawable.ic_add_box_white_24dp); | |
AHBottomNavigationItem item4 = new AHBottomNavigationItem("Бонусы", R.drawable.ic_card_giftcard_white_24dp); | |
AHBottomNavigationItem item5 = new AHBottomNavigationItem("Настройки", R.drawable.ic_settings_white_24dp); | |
bottomNav.addItem(item1); | |
bottomNav.addItem(item2); | |
bottomNav.addItem(item3); | |
bottomNav.addItem(item4); | |
bottomNav.addItem(item5); | |
bottomNav.setCurrentItem(0); | |
bottomNav.setTitleState(AHBottomNavigation.TitleState.ALWAYS_SHOW); | |
bottomNav.setAccentColor(getApplicationContext().getResources().getColor(R.color.colorPrimary)); | |
} | |
@Override | |
public NsvpAdapter getNsvpAdapter() { | |
return nsvpAdater; | |
} | |
@Override | |
public void setPage(int n, boolean smoothScroll) { | |
nsvp.setCurrentItem(n, smoothScroll); | |
} | |
@Override | |
public int getCurrentPage() { | |
return nsvp.getCurrentItem(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment