package net.coding.program.compatible;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.Fragment;

import net.coding.program.EnterpriseMainActivity_;
import net.coding.program.EnterpriseMyPushReceiver;
import net.coding.program.common.StartActivity;
import net.coding.program.guide.EnterpriseGuideActivity_;
import net.coding.program.common.model.ProjectObject;
import net.coding.program.param.ProjectJumpParam;
import net.coding.program.project.EnterpriseProjectFragment_;
import net.coding.program.project.EnterpriseProjectHomeFragment_;
import net.coding.program.project.maopao.EnterpriseProjectMaopaoActivity_;
import net.coding.program.user.EnterpriseAddMemberActivity_;
import net.coding.program.user.EnterpriseLoginActivity_;
import net.coding.program.user.EnterpriseMyDetailActivity_;
import net.coding.program.user.EnterpriseUserDetailActivity_;
import net.coding.program.user.PickUserActivity_;
import net.coding.program.user.PickUserRelayMessageActivity_;

import java.util.ArrayList;

/**
 * Created by chenchao on 2016/12/28.
 */

public class EnterpriseCompatImp implements ClassCompatInterface {

    @Override
    public Class<?> getMainActivity() {
        return EnterpriseMainActivity_.class;
    }

    @Override
    public Class<?> getMainProjectFragment() {
        return EnterpriseProjectFragment_.FragmentBuilder_.class;
    }

    @Override
    public Fragment getProjectHome(ProjectObject projectObject, boolean needReload) {
        return EnterpriseProjectHomeFragment_.builder()
                .mProjectObject(projectObject)
                .needReload(needReload)
                .build();
    }

    @Override
    public Class getGuideActivity() {
        return EnterpriseGuideActivity_.class;
    }

    @Override
    public Class getLoginActivity() {
        return EnterpriseLoginActivity_.class;
    }

    @Override
    public void launchMyDetailActivity(Context context) {
        EnterpriseMyDetailActivity_.intent(context).start();
    }

    @Override
    public void launchUserDetailActivity(Context context, String globalKey) {
        EnterpriseUserDetailActivity_.intent(context).globalKey(globalKey).start();
    }

    @Override
    public void launchUserDetailActivity(Context context, String globalKey, int result) {
        EnterpriseUserDetailActivity_.intent(context).globalKey(globalKey).startForResult(result);
    }

    @Override
    public void launchUserDetailActivity(Fragment fragment, String globalKey, int result) {
        EnterpriseUserDetailActivity_.intent(fragment).globalKey(globalKey).startForResult(result);
    }

    @Override
    public void launchAddMemberActivity(Fragment fragment, ProjectObject projectObject, ArrayList<String> pickGlobalKeys, int result) {
        Intent intent = new Intent(fragment.getActivity(), EnterpriseAddMemberActivity_.class);
        intent.putExtra("projectObject", projectObject);
        intent.putExtra("pickedGlobalKeys", pickGlobalKeys);
        fragment.startActivityForResult(intent, result);
    }

    @Override
    public void launchPickUser(Context context, StartActivity startActivity, int result) {
        Intent intent = new Intent(context, PickUserActivity_.class);
        startActivity.startActivityForResult(intent, result);
    }

    @Override
    public void launchProjectMaopao(Fragment fragment, ProjectObject projectObject) {
        EnterpriseProjectMaopaoActivity_.intent(fragment)
                .projectObject(projectObject)
                .start();
    }

    @Override
    public void launchPickUser(Activity activity, String relayString) {
        PickUserRelayMessageActivity_.intent(activity)
                .relayString(relayString)
                .start();
    }

    @Override
    public void closeNotify(Context context, String url) {
        EnterpriseMyPushReceiver.closeNotify(context, url);
    }

    @Override
    public void closePushReceiverActivity(Activity context, String url) {
        Intent resultIntent = new Intent(EnterpriseMyPushReceiver.PushClickBroadcast);
        resultIntent.setPackage(context.getPackageName());
        resultIntent.putExtra("data", url);
        context.sendBroadcast(resultIntent);
        context.finish();
    }

    @Override
    public void launchProjectMaopoaList(Context context, ProjectJumpParam param) {
        EnterpriseProjectMaopaoActivity_.intent(context)
                .jumpParam(param)
                .start();
    }

    @Override
    public void launchSetGKActivity(Context context) {
        // todo 未完成
    }
}

@@ -1106,16 +1106,34 @@
 /12/28.%0A
+ * %E4%BC%81%E4%B8%9A%E7%89%88%E4%B8%8E%E5%B9%B3%E5%8F%B0%E6%9D%BF%E4%B8%8D%E5%90%8C%E7%9A%84%E8%B7%B3%E8%BD%AC%E9%A1%B5%E9%9D%A2%0A
  */%0A%0Apub
@@ -4598,16 +4598,29 @@
  // 
-todo %E6%9C%AA%E5%AE%8C%E6%88%90
+%E8%B7%B3%E8%BD%AC%E5%88%B0%E8%AE%BE%E7%BD%AE GK %E7%95%8C%E9%9D%A2%EF%BC%8C%E4%BC%81%E4%B8%9A%E7%89%88%E6%B2%A1%E6%9C%89%E8%BF%99%E4%B8%AA%E7%95%8C%E9%9D%A2
 %0A   

解决 todo