// Path: 2014Spring/src/main/java/org/techbooster/app/abc/controllers/ActionBarController.java
// public interface ActionBarController {
// 
//     public void setTitle(String title);
//     public void setTitle(int titleResId);
// 
// }
// 
// Path: 2014Spring/src/main/java/org/techbooster/app/abc/controllers/FragmentTransitionController.java
// public interface FragmentTransitionController {
// 
//     public void addFragment(Fragment fragment);
//     public void replaceFragment(Fragment fragment);
// 
// }
// 
// Path: 2014Spring/src/main/java/org/techbooster/app/abc/tools/DrawerLayoutManager.java
// public class DrawerLayoutManager {
// 
//     private DrawerLayout mDrawerLayout;
// 
//     public static DrawerLayoutManager newInstance(DrawerLayout drawerLayout) {
//         DrawerLayoutManager manager = new DrawerLayoutManager();
//         manager.mDrawerLayout = drawerLayout;
//         return manager;
//     }
// 
//     public void toggle() {
//         if (mDrawerLayout.isDrawerOpen(Gravity.START)) {
//             mDrawerLayout.closeDrawer(Gravity.START);
//         } else {
//             mDrawerLayout.openDrawer(Gravity.START);
//         }
//     }
// 
// }
// 
// Path: 2014Spring/src/main/java/org/techbooster/app/abc/tools/FragmentHelper.java
// public class FragmentHelper {
// 
// 
//     public static boolean isCurrentFragment(FragmentManager fragmentManager,
//                                             Class<? extends Fragment> clazz) {
//         Fragment fragment = null;
//         List<Fragment> fragments = fragmentManager.getFragments();
//         int index = fragments.size();
//         while (fragment == null && index >= 0) {
//             index--;
//             fragment = fragments.get(index);
//         }
//         return fragment != null && fragment.getClass().equals(clazz);
//     }
// }


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarActivity;
import android.view.KeyEvent;
import android.widget.FrameLayout;
import com.sys1yagi.indirectinjector.IndirectInjector;
import org.techbooster.app.abc.controllers.ActionBarController;
import org.techbooster.app.abc.controllers.FragmentTransitionController;
import org.techbooster.app.abc.tools.DrawerLayoutManager;
import org.techbooster.app.abc.tools.FragmentHelper;
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_MENU) {
            mDrawerLayoutManager.toggle();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

    @Override
    public void addFragment(Fragment fragment) {

    }

    @Override
    public void replaceFragment(Fragment fragment) {
        FragmentManager fragmentManager = getSupportFragmentManager();
        if (!FragmentHelper.isCurrentFragment(fragmentManager, fragment.getClass())) {
            FragmentTransaction transaction = fragmentManager.beginTransaction();

            if (fragmentManager.getFragments().size() > 1) {
                transaction.addToBackStack(null);
            }
            transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
                    .replace(R.id.container, fragment)
                    .commit();
        }
    }

    @Override
    public void setTitle(String title) {
// Path: 2014Spring/src/main/java/org/techbooster/app/abc/controllers/ActionBarController.java
// public interface ActionBarController {
// 
//     public void setTitle(String title);
//     public void setTitle(int titleResId);
// 
// }
// 
// Path: 2014Spring/src/main/java/org/techbooster/app/abc/controllers/FragmentTransitionController.java
// public interface FragmentTransitionController {
// 
//     public void addFragment(Fragment fragment);
//     public void replaceFragment(Fragment fragment);
// 
// }
// 
// Path: 2014Spring/src/main/java/org/techbooster/app/abc/tools/DrawerLayoutManager.java
// public class DrawerLayoutManager {
// 
//     private DrawerLayout mDrawerLayout;
// 
//     public static DrawerLayoutManager newInstance(DrawerLayout drawerLayout) {
//         DrawerLayoutManager manager = new DrawerLayoutManager();
//         manager.mDrawerLayout = drawerLayout;
//         return manager;
//     }
// 
//     public void toggle() {
//         if (mDrawerLayout.isDrawerOpen(Gravity.START)) {
//             mDrawerLayout.closeDrawer(Gravity.START);
//         } else {
//             mDrawerLayout.openDrawer(Gravity.START);
//         }
//     }
// 
// }
// 
// Path: 2014Spring/src/main/java/org/techbooster/app/abc/tools/FragmentHelper.java
// public class FragmentHelper {
// 
// 
//     public static boolean isCurrentFragment(FragmentManager fragmentManager,
//                                             Class<? extends Fragment> clazz) {
//         Fragment fragment = null;
//         List<Fragment> fragments = fragmentManager.getFragments();
//         int index = fragments.size();
//         while (fragment == null && index >= 0) {
//             index--;
//             fragment = fragments.get(index);
//         }
//         return fragment != null && fragment.getClass().equals(clazz);
//     }
// }


// Path: 2014Spring/src/main/java/org/techbooster/app/abc/MainActivity.java
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarActivity;
import android.view.KeyEvent;
import android.widget.FrameLayout;
import com.sys1yagi.indirectinjector.IndirectInjector;
import org.techbooster.app.abc.controllers.ActionBarController;
import org.techbooster.app.abc.controllers.FragmentTransitionController;
import org.techbooster.app.abc.tools.DrawerLayoutManager;
import org.techbooster.app.abc.tools.FragmentHelper;

    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_MENU) {
            mDrawerLayoutManager.toggle();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

    @Override
    public void addFragment(Fragment fragment) {

    }

    @Override
    public void replaceFragment(Fragment fragment) {
        FragmentManager fragmentManager = getSupportFragmentManager();
        if (!FragmentHelper.isCurrentFragment(fragmentManager, fragment.getClass())) {
            FragmentTransaction transaction = fragmentManager.beginTransaction();

            if (fragmentManager.getFragments().size() > 1) {
                transaction.addToBackStack(null);
            }
            transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
                    .replace(R.id.container, fragment)
                    .commit();
        }
    }

    @Override
    public void setTitle(String title) {
        getSupportActionBar().setTitle(title);