Search in sources :

Example 1 with FeedsFragment

use of com.madonasyombua.growwithgoogleteamproject.ui.fragment.FeedsFragment in project Devsfolio by Madonahs.

the class MainActivity method onCreate.

/**
 * Theme can only be changed before setContentView is called.
 * Therefore, I am changing the theme on here.
 * store data
 * @param savedInstanceState
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    sharedPref = new SharedPref(this);
    if (sharedPref.loadNightModeState()) {
        setTheme(R.style.DarkTheme);
    } else {
        setTheme(R.style.AppTheme);
    }
    prev_State = sharedPref.loadNightModeState();
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    // This method will save the theme and initiates the preferenceChange listener
    setCorrectTheme();
    // Get all user information views from the drawer header view
    View drawerHeaderView = navView.getHeaderView(0);
    profilePicView = drawerHeaderView.findViewById(R.id.drawer_header_user_image);
    userName = drawerHeaderView.findViewById(R.id.drawer_header_user_name);
    userProfession = drawerHeaderView.findViewById(R.id.drawer_header_user_profession);
    // Set action bar, navigation drawer, navigation drawer header
    setSupportActionBar(toolbar);
    setupNavDrawer();
    setDrawerHeader();
    fragment = getSupportFragmentManager().findFragmentByTag(TAG);
    if (fragment == null) {
        fragment = new FeedsFragment();
    }
    BottomNavigationView navigation = findViewById(R.id.navigation);
    BottomNavigationViewHelper.disableShiftMode(navigation);
    navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.replace(R.id.content, fragment, TAG);
    transaction.commit();
    /*TODO: Get user data from intent or load from DB if intent is null*/
    Bundle data = getIntent().getBundleExtra(Constant.USER);
    if (data != null)
        user = User.build(data);
    else
        // TODO: load from DB
        user = new User("this guy", "thisguy@devs.com", "000000");
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) User(com.madonasyombua.growwithgoogleteamproject.models.User) BottomNavigationView(android.support.design.widget.BottomNavigationView) Bundle(android.os.Bundle) FeedsFragment(com.madonasyombua.growwithgoogleteamproject.ui.fragment.FeedsFragment) SharedPref(com.madonasyombua.growwithgoogleteamproject.ui.SharedPref) NavigationView(android.support.design.widget.NavigationView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) BindView(butterknife.BindView) View(android.view.View) AdapterView(android.widget.AdapterView) BottomNavigationView(android.support.design.widget.BottomNavigationView) TextView(android.widget.TextView)

Aggregations

Bundle (android.os.Bundle)1 BottomNavigationView (android.support.design.widget.BottomNavigationView)1 NavigationView (android.support.design.widget.NavigationView)1 FragmentTransaction (android.support.v4.app.FragmentTransaction)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1 User (com.madonasyombua.growwithgoogleteamproject.models.User)1 SharedPref (com.madonasyombua.growwithgoogleteamproject.ui.SharedPref)1 FeedsFragment (com.madonasyombua.growwithgoogleteamproject.ui.fragment.FeedsFragment)1 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)1