// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Contract.java
// public interface Business1Contract {
// 
//     interface View extends BaseView<Presenter> {
// 
//     }
// 
//     interface Presenter extends BasePresenter {
// 
//     }
// 
//     interface Model {
// 
//     }
// }
// 
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Model.java
// public class Business1Model implements Business1Contract.Model {
// 
// }
// 
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Presenter.java
// public class Business1Presenter implements Business1Contract.Presenter {
// 
//     public Business1Presenter(Business1Contract.View view, Business1Contract.Model model) {
// 
//     }
// 
//     @Override
//     public void onCreate() {
// 
//     }
// 
//     @Override
//     public void onResume() {
// 
//     }
// 
//     @Override
//     public void onPause() {
// 
//     }
// 
//     @Override
//     public void onDestroy() {
// 
//     }
// }
// 
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1View.java
// public class Business1View extends FrameLayout implements Business1Contract.View {
// 
//     public Business1View(@NonNull Context context) {
//         super(context);
//     }
// 
//     public Business1View(@NonNull Context context, @Nullable AttributeSet attrs) {
//         super(context, attrs);
//     }
// 
//     public Business1View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
//         super(context, attrs, defStyleAttr);
//     }
// 
//     @Override
//     public void setPresenter(Business1Contract.Presenter presenter) {
// 
//     }
// }
// 
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Contract.java
// public interface Business2Contract {
// 
//     interface View extends BaseView<Presenter> {
// 
//     }
// 
//     interface Presenter extends BasePresenter {
// 
//     }
// 
//     interface Model {
// 
//     }
// }
// 
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Model.java
// public class Business2Model implements Business2Contract.Model {
// 
// }
// 
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Presenter.java
// public class Business2Presenter implements Business2Contract.Presenter {
// 
//     public Business2Presenter(Business2Contract.View view, Business2Contract.Model model) {
// 
//     }
// 
//     @Override
//     public void onCreate() {
// 
//     }
// 
//     @Override
//     public void onResume() {
// 
//     }
// 
//     @Override
//     public void onPause() {
// 
//     }
// 
//     @Override
//     public void onDestroy() {
// 
//     }
// }
// 
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2View.java
// public class Business2View extends FrameLayout implements Business2Contract.View {
// 
//     public Business2View(@NonNull Context context) {
//         super(context);
//     }
// 
//     public Business2View(@NonNull Context context, @Nullable AttributeSet attrs) {
//         super(context, attrs);
//     }
// 
//     public Business2View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
//         super(context, attrs, defStyleAttr);
//     }
// 
//     @Override
//     public void setPresenter(Business2Contract.Presenter presenter) {
// 
//     }
// }


import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import java.lang.ref.WeakReference;
import tech.jackywang.intermediate.layer.business.business1.Business1Contract;
import tech.jackywang.intermediate.layer.business.business1.Business1Model;
import tech.jackywang.intermediate.layer.business.business1.Business1Presenter;
import tech.jackywang.intermediate.layer.business.business1.Business1View;
import tech.jackywang.intermediate.layer.business.business2.Business2Contract;
import tech.jackywang.intermediate.layer.business.business2.Business2Model;
import tech.jackywang.intermediate.layer.business.business2.Business2Presenter;
import tech.jackywang.intermediate.layer.business.business2.Business2View;

    public BusinessDelegate(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public BusinessDelegate(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public IBusinessDelegate setup() {
        mContextReference = new WeakReference<>(getContext());
        removeAllViews();
        return this;
    }

    // ---- 动态加载挂件 Start ----
    @Override
    public IBusinessDelegate setupBusiness1() {
        Business1View view = new Business1View(mContextReference.get());
        mBusiness1Presenter = new Business1Presenter(view, new Business1Model());
        view.setPresenter(mBusiness1Presenter);
        LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        addView(view, params);
        return this;
    }

    @Override
    public IBusinessDelegate setupBusiness2() {
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Contract.java
// public interface Business1Contract {
// 
//     interface View extends BaseView<Presenter> {
// 
//     }
// 
//     interface Presenter extends BasePresenter {
// 
//     }
// 
//     interface Model {
// 
//     }
// }
// 
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Model.java
// public class Business1Model implements Business1Contract.Model {
// 
// }
// 
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Presenter.java
// public class Business1Presenter implements Business1Contract.Presenter {
// 
//     public Business1Presenter(Business1Contract.View view, Business1Contract.Model model) {
// 
//     }
// 
//     @Override
//     public void onCreate() {
// 
//     }
// 
//     @Override
//     public void onResume() {
// 
//     }
// 
//     @Override
//     public void onPause() {
// 
//     }
// 
//     @Override
//     public void onDestroy() {
// 
//     }
// }
// 
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1View.java
// public class Business1View extends FrameLayout implements Business1Contract.View {
// 
//     public Business1View(@NonNull Context context) {
//         super(context);
//     }
// 
//     public Business1View(@NonNull Context context, @Nullable AttributeSet attrs) {
//         super(context, attrs);
//     }
// 
//     public Business1View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
//         super(context, attrs, defStyleAttr);
//     }
// 
//     @Override
//     public void setPresenter(Business1Contract.Presenter presenter) {
// 
//     }
// }
// 
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Contract.java
// public interface Business2Contract {
// 
//     interface View extends BaseView<Presenter> {
// 
//     }
// 
//     interface Presenter extends BasePresenter {
// 
//     }
// 
//     interface Model {
// 
//     }
// }
// 
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Model.java
// public class Business2Model implements Business2Contract.Model {
// 
// }
// 
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Presenter.java
// public class Business2Presenter implements Business2Contract.Presenter {
// 
//     public Business2Presenter(Business2Contract.View view, Business2Contract.Model model) {
// 
//     }
// 
//     @Override
//     public void onCreate() {
// 
//     }
// 
//     @Override
//     public void onResume() {
// 
//     }
// 
//     @Override
//     public void onPause() {
// 
//     }
// 
//     @Override
//     public void onDestroy() {
// 
//     }
// }
// 
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2View.java
// public class Business2View extends FrameLayout implements Business2Contract.View {
// 
//     public Business2View(@NonNull Context context) {
//         super(context);
//     }
// 
//     public Business2View(@NonNull Context context, @Nullable AttributeSet attrs) {
//         super(context, attrs);
//     }
// 
//     public Business2View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
//         super(context, attrs, defStyleAttr);
//     }
// 
//     @Override
//     public void setPresenter(Business2Contract.Presenter presenter) {
// 
//     }
// }


// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/BusinessDelegate.java
import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import java.lang.ref.WeakReference;
import tech.jackywang.intermediate.layer.business.business1.Business1Contract;
import tech.jackywang.intermediate.layer.business.business1.Business1Model;
import tech.jackywang.intermediate.layer.business.business1.Business1Presenter;
import tech.jackywang.intermediate.layer.business.business1.Business1View;
import tech.jackywang.intermediate.layer.business.business2.Business2Contract;
import tech.jackywang.intermediate.layer.business.business2.Business2Model;
import tech.jackywang.intermediate.layer.business.business2.Business2Presenter;
import tech.jackywang.intermediate.layer.business.business2.Business2View;


    public BusinessDelegate(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public BusinessDelegate(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public IBusinessDelegate setup() {
        mContextReference = new WeakReference<>(getContext());
        removeAllViews();
        return this;
    }

    // ---- 动态加载挂件 Start ----
    @Override
    public IBusinessDelegate setupBusiness1() {
        Business1View view = new Business1View(mContextReference.get());
        mBusiness1Presenter = new Business1Presenter(view, new Business1Model());
        view.setPresenter(mBusiness1Presenter);
        LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        addView(view, params);
        return this;
    }

    @Override
    public IBusinessDelegate setupBusiness2() {
        Business2View view = new Business2View(mContextReference.get());