package im.actor.sdk.controllers.activity; import android.graphics.drawable.ColorDrawable; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentTransaction; import android.support.v7.app.ActionBar; import android.view.MenuItem; import android.view.ViewGroup; import android.widget.FrameLayout; import im.actor.sdk.R; public class BaseFragmentActivity extends BaseActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Configure ActionBar ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setElevation(0); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayShowCustomEnabled(false); if (STYLE.getToolBarColor() != 0) { actionBar.setBackgroundDrawable(new ColorDrawable(STYLE.getToolBarColor())); } } // Setting basic content FrameLayout rootLayout = new FrameLayout(this); rootLayout.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); rootLayout.setBackgroundColor(STYLE.getMainBackgroundColor()); rootLayout.setId(R.id.content_frame); setContentView(rootLayout); // Setting Background Color getWindow().setBackgroundDrawable(new ColorDrawable(STYLE.getMainBackgroundColor())); } public void showFragment(Fragment fragment, boolean addToBackStack) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.content_frame, fragment); if (addToBackStack) { transaction.addToBackStack(null); } transaction.commit(); } public void showNextFragment(Fragment fragment, boolean addToBackStack) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.content_frame, fragment); if (addToBackStack) { transaction.addToBackStack(null); } transaction.commit(); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: finish(); return true; } return false; } }