// 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/BaseBackFlowFragment.java
// public class BaseBackFlowFragment extends Fragment {
// 
//     protected View root;
// 
//     public void setRoot(View root) {
//         this.root = root;
//     }
// 
//     public <T extends View> T $(@IdRes int id) {
//         return (T) root.findViewById(id);
//     }
// 
// 
//     //******************** start activity replace method ********************
//     public void startActivity4NonBackFlow(Intent intent) {
//         startActivityForResult(intent, BackFlow.REQUEST_CODE_4_NON_BACK_FLOW);
//     }
// 
//     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);
//     }
// 
//     @Override
//     public void startActivity(Intent intent, @Nullable Bundle options) {
//         startActivityForResult(intent, BackFlow.REQUEST_CODE, options);
//     }
// 
//     @Override
//     public void onActivityResult(int requestCode, int resultCode, Intent data) {
//         BackFlow.Logger.logIntent(this, data);
//         super.onActivityResult(requestCode, resultCode, data);
//     }
// 
// }


import android.os.Bundle;
import cn.ytxu.androidbackflow.BaseBackFlowActivity;
import cn.ytxu.androidbackflow.BaseBackFlowFragment;
import cn.ytxu.androidbackflow.R;
package cn.ytxu.androidbackflow.sample.normal.request_activity_and_fragment;



/**
 * Created by ytxu on 16/12/31.
 */
public class ContainerAF2Activity extends BaseBackFlowActivity {

    /**
     * sample: XXXFragment.class.getName()
     */
    public final static String PARAM_CLASSNAME = "className";

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

        BaseBackFlowFragment fragment = getFragment();
        if (fragment == null) {
//            finish();
            return;
        }

        getSupportFragmentManager().beginTransaction()
                .replace(R.id.fragment_container, fragment)
                .commitAllowingStateLoss();
    }

    private BaseBackFlowFragment getFragment() {
        String className = getIntent().getStringExtra(PARAM_CLASSNAME);
        BaseBackFlowFragment fragment = null;
        if (className != null && !className.isEmpty()) {
            try {
// 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/BaseBackFlowFragment.java
// public class BaseBackFlowFragment extends Fragment {
// 
//     protected View root;
// 
//     public void setRoot(View root) {
//         this.root = root;
//     }
// 
//     public <T extends View> T $(@IdRes int id) {
//         return (T) root.findViewById(id);
//     }
// 
// 
//     //******************** start activity replace method ********************
//     public void startActivity4NonBackFlow(Intent intent) {
//         startActivityForResult(intent, BackFlow.REQUEST_CODE_4_NON_BACK_FLOW);
//     }
// 
//     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);
//     }
// 
//     @Override
//     public void startActivity(Intent intent, @Nullable Bundle options) {
//         startActivityForResult(intent, BackFlow.REQUEST_CODE, options);
//     }
// 
//     @Override
//     public void onActivityResult(int requestCode, int resultCode, Intent data) {
//         BackFlow.Logger.logIntent(this, data);
//         super.onActivityResult(requestCode, resultCode, data);
//     }
// 
// }


// Path: app/src/main/java/cn/ytxu/androidbackflow/sample/normal/request_activity_and_fragment/ContainerAF2Activity.java
import android.os.Bundle;
import cn.ytxu.androidbackflow.BaseBackFlowActivity;
import cn.ytxu.androidbackflow.BaseBackFlowFragment;
import cn.ytxu.androidbackflow.R;

package cn.ytxu.androidbackflow.sample.normal.request_activity_and_fragment;



/**
 * Created by ytxu on 16/12/31.
 */
public class ContainerAF2Activity extends BaseBackFlowActivity {

    /**
     * sample: XXXFragment.class.getName()
     */
    public final static String PARAM_CLASSNAME = "className";

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

        BaseBackFlowFragment fragment = getFragment();
        if (fragment == null) {
//            finish();
            return;
        }

        getSupportFragmentManager().beginTransaction()
                .replace(R.id.fragment_container, fragment)
                .commitAllowingStateLoss();
    }

    private BaseBackFlowFragment getFragment() {
        String className = getIntent().getStringExtra(PARAM_CLASSNAME);
        BaseBackFlowFragment fragment = null;
        if (className != null && !className.isEmpty()) {
            try {
                fragment = (BaseBackFlowFragment) getClassLoader().loadClass(className).newInstance();