Android Open Source - NerdZoo Base Normal Activity






From Project

Back to project page NerdZoo.

License

The source code is released under:

Apache License

If you think the Android project NerdZoo listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.bignerdranch.android.nerdzoo.base;
/*from   w ww  .  j a va2  s .  co m*/
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.MenuItem;

import com.bignerdranch.android.nerdzoo.BaseApplication;
import com.bignerdranch.android.nerdzoo.R;

import butterknife.ButterKnife;
import timber.log.Timber;

public abstract class BaseNormalActivity extends BaseActivity {

    protected abstract Fragment createFragment();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_base_normal);
        BaseApplication.get(BaseNormalActivity.this).inject(this);
        ButterKnife.inject(this);

        setupToolbar();
        setupOverflowButton();
        setupOverviewScreen();
        setupInitialFragment();
    }

    protected void setupInitialFragment() {
        Fragment fragment = createFragment();
        if (fragment != null) {
            FragmentManager fm = getSupportFragmentManager();
            FragmentTransaction ft = fm.beginTransaction();
            ft.replace(R.id.activity_base_normal_container, fragment);
            ft.commit();
        } else {
            Timber.e("Error in creating fragment.");
        }
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                super.onBackPressed();
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }

}




Java Source Code List

com.bignerdranch.android.nerdzoo.ApplicationTest.java
com.bignerdranch.android.nerdzoo.BaseApplication.java
com.bignerdranch.android.nerdzoo.BaseModule.java
com.bignerdranch.android.nerdzoo.anim.BaseItemAnimator.java
com.bignerdranch.android.nerdzoo.anim.PathAnimator.java
com.bignerdranch.android.nerdzoo.anim.RevealAnimator.java
com.bignerdranch.android.nerdzoo.anim.ZooItemAnimator.java
com.bignerdranch.android.nerdzoo.base.BaseActivity.java
com.bignerdranch.android.nerdzoo.base.BaseDrawerActivity.java
com.bignerdranch.android.nerdzoo.base.BaseNormalActivity.java
com.bignerdranch.android.nerdzoo.controller.AboutFragment.java
com.bignerdranch.android.nerdzoo.controller.AnimalActivity.java
com.bignerdranch.android.nerdzoo.controller.AnimalFragment.java
com.bignerdranch.android.nerdzoo.controller.MainActivity.java
com.bignerdranch.android.nerdzoo.controller.ZooFragment.java
com.bignerdranch.android.nerdzoo.drawer.DrawerAdapter.java
com.bignerdranch.android.nerdzoo.drawer.DrawerItem.java
com.bignerdranch.android.nerdzoo.model.Animal.java
com.bignerdranch.android.nerdzoo.model.Zoo.java
com.bignerdranch.android.nerdzoo.util.BuildUtils.java