// Path: app/src/main/java/cn/ytxu/androidbackflow/BaseBackFlowActivity.java
// public class BaseBackFlowActivity extends AppCompatActivity {
//     private final String TAG = this.getClass().getSimpleName();
// 
// 
//     @Override
//     protected void onCreate(@Nullable Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
// 
//         BackFlow.Logger.log(TAG, "taskId:" + getTaskId()
//                 + ", obj:" + Integer.toHexString(hashCode())
//                 + ", myPid:" + android.os.Process.myPid()  //获取当前进程的id
//                 + ", process:" + BackFlow.getCurProcessName(this));
//     }
// 
//     public <T extends View> T $(@IdRes int id) {
//         return (T) findViewById(id);
//     }
// 
// 
//     //******************** start activity replace method ********************
//     public void startActivity4NonBackFlow(Intent intent) {
//         startActivityForResult(intent, BackFlow.REQUEST_CODE_4_NON_BACK_FLOW);
//     }
// 
//     @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
//     public void startActivity4NonBackFlow(Intent intent, @Nullable Bundle options) {
//         startActivityForResult(intent, BackFlow.REQUEST_CODE_4_NON_BACK_FLOW, options);
//     }
// 
// 
//     //******************** back flow ********************
//     @Override
//     public void startActivity(Intent intent) {
//         startActivityForResult(intent, BackFlow.REQUEST_CODE);
//     }
// 
//     @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
//     @Override
//     public void startActivity(Intent intent, @Nullable Bundle options) {
//         startActivityForResult(intent, BackFlow.REQUEST_CODE, options);
//     }
// 
//     @Override
//     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//         if (BackFlow.handle(this, getSupportFragmentManager().getFragments(), requestCode, resultCode, data)) {
//             return;
//         }
//         super.onActivityResult(requestCode, resultCode, data);
//     }
// 
//     @Override
//     protected void onDestroy() {
//         BackFlow.Logger.log("onDestroy", this.getClass().getSimpleName());
//         super.onDestroy();
//     }
// }
// 
// Path: app/src/main/java/cn/ytxu/androidbackflow/sample/fragments/multi_fragment/letter/MFLetterAFragment.java
// public class MFLetterAFragment extends MFBaseLetterFragment {
// }
// 
// Path: app/src/main/java/cn/ytxu/androidbackflow/sample/fragments/multi_fragment/letter/MFLetterBFragment.java
// public class MFLetterBFragment extends MFBaseLetterFragment {
// }
// 
// Path: app/src/main/java/cn/ytxu/androidbackflow/sample/fragments/multi_fragment/letter/MFLetterCFragment.java
// public class MFLetterCFragment extends MFBaseLetterFragment {
// }
// 
// Path: app/src/main/java/cn/ytxu/androidbackflow/sample/fragments/multi_fragment/letter/MFLetterDFragment.java
// public class MFLetterDFragment extends MFBaseLetterFragment {
// }


import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import cn.ytxu.androidbackflow.BaseBackFlowActivity;
import cn.ytxu.androidbackflow.R;
import cn.ytxu.androidbackflow.sample.fragments.multi_fragment.letter.MFLetterAFragment;
import cn.ytxu.androidbackflow.sample.fragments.multi_fragment.letter.MFLetterBFragment;
import cn.ytxu.androidbackflow.sample.fragments.multi_fragment.letter.MFLetterCFragment;
import cn.ytxu.androidbackflow.sample.fragments.multi_fragment.letter.MFLetterDFragment;
package cn.ytxu.androidbackflow.sample.fragments.multi_fragment;



public class MultiFragmentActivity extends BaseBackFlowActivity {
    private String[] mTitles = new String[]{"唐僧", "大师兄", "二师兄", "沙师弟"};

    private ViewPager viewPager;
    private TabLayout tabLayout;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.multi_fragment_activity);

        $(R.id.multi_fragment_4_requedst_activity).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(MultiFragmentActivity.this, MFSecondActivity.class));
            }
        });

        tabLayout = $(R.id.multi_fragment_tab);
        viewPager = $(R.id.multi_fragment_viewPager);
        // TODO init all fragment or init only two
        viewPager.setOffscreenPageLimit(mTitles.length);
        setPagerAdapter();
    }

    private void setPagerAdapter() {
        viewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {

            @Override
            public int getCount() {
                return mTitles.length;
            }

// Path: app/src/main/java/cn/ytxu/androidbackflow/BaseBackFlowActivity.java
// public class BaseBackFlowActivity extends AppCompatActivity {
//     private final String TAG = this.getClass().getSimpleName();
// 
// 
//     @Override
//     protected void onCreate(@Nullable Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
// 
//         BackFlow.Logger.log(TAG, "taskId:" + getTaskId()
//                 + ", obj:" + Integer.toHexString(hashCode())
//                 + ", myPid:" + android.os.Process.myPid()  //获取当前进程的id
//                 + ", process:" + BackFlow.getCurProcessName(this));
//     }
// 
//     public <T extends View> T $(@IdRes int id) {
//         return (T) findViewById(id);
//     }
// 
// 
//     //******************** start activity replace method ********************
//     public void startActivity4NonBackFlow(Intent intent) {
//         startActivityForResult(intent, BackFlow.REQUEST_CODE_4_NON_BACK_FLOW);
//     }
// 
//     @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
//     public void startActivity4NonBackFlow(Intent intent, @Nullable Bundle options) {
//         startActivityForResult(intent, BackFlow.REQUEST_CODE_4_NON_BACK_FLOW, options);
//     }
// 
// 
//     //******************** back flow ********************
//     @Override
//     public void startActivity(Intent intent) {
//         startActivityForResult(intent, BackFlow.REQUEST_CODE);
//     }
// 
//     @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
//     @Override
//     public void startActivity(Intent intent, @Nullable Bundle options) {
//         startActivityForResult(intent, BackFlow.REQUEST_CODE, options);
//     }
// 
//     @Override
//     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//         if (BackFlow.handle(this, getSupportFragmentManager().getFragments(), requestCode, resultCode, data)) {
//             return;
//         }
//         super.onActivityResult(requestCode, resultCode, data);
//     }
// 
//     @Override
//     protected void onDestroy() {
//         BackFlow.Logger.log("onDestroy", this.getClass().getSimpleName());
//         super.onDestroy();
//     }
// }
// 
// Path: app/src/main/java/cn/ytxu/androidbackflow/sample/fragments/multi_fragment/letter/MFLetterAFragment.java
// public class MFLetterAFragment extends MFBaseLetterFragment {
// }
// 
// Path: app/src/main/java/cn/ytxu/androidbackflow/sample/fragments/multi_fragment/letter/MFLetterBFragment.java
// public class MFLetterBFragment extends MFBaseLetterFragment {
// }
// 
// Path: app/src/main/java/cn/ytxu/androidbackflow/sample/fragments/multi_fragment/letter/MFLetterCFragment.java
// public class MFLetterCFragment extends MFBaseLetterFragment {
// }
// 
// Path: app/src/main/java/cn/ytxu/androidbackflow/sample/fragments/multi_fragment/letter/MFLetterDFragment.java
// public class MFLetterDFragment extends MFBaseLetterFragment {
// }


// Path: app/src/main/java/cn/ytxu/androidbackflow/sample/fragments/multi_fragment/MultiFragmentActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import cn.ytxu.androidbackflow.BaseBackFlowActivity;
import cn.ytxu.androidbackflow.R;
import cn.ytxu.androidbackflow.sample.fragments.multi_fragment.letter.MFLetterAFragment;
import cn.ytxu.androidbackflow.sample.fragments.multi_fragment.letter.MFLetterBFragment;
import cn.ytxu.androidbackflow.sample.fragments.multi_fragment.letter.MFLetterCFragment;
import cn.ytxu.androidbackflow.sample.fragments.multi_fragment.letter.MFLetterDFragment;

package cn.ytxu.androidbackflow.sample.fragments.multi_fragment;



public class MultiFragmentActivity extends BaseBackFlowActivity {
    private String[] mTitles = new String[]{"唐僧", "大师兄", "二师兄", "沙师弟"};

    private ViewPager viewPager;
    private TabLayout tabLayout;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.multi_fragment_activity);

        $(R.id.multi_fragment_4_requedst_activity).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(MultiFragmentActivity.this, MFSecondActivity.class));
            }
        });

        tabLayout = $(R.id.multi_fragment_tab);
        viewPager = $(R.id.multi_fragment_viewPager);
        // TODO init all fragment or init only two
        viewPager.setOffscreenPageLimit(mTitles.length);
        setPagerAdapter();
    }

    private void setPagerAdapter() {
        viewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {

            @Override
            public int getCount() {
                return mTitles.length;
            }

            @Override