package com.sheep.gamegroup.util;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;

import com.kfzs.duanduan.ActMain;
import com.kfzs.duanduan.bean.KFIntentKeys;
import com.sheep.gamegroup.absBase.BaseActivity;
import com.sheep.gamegroup.model.entity.Advertising;
import com.sheep.gamegroup.model.entity.Agreement;
import com.sheep.gamegroup.model.entity.BaseMessage;
import com.sheep.gamegroup.model.entity.CheckUserLabel;
import com.sheep.gamegroup.model.entity.Container;
import com.sheep.gamegroup.model.entity.CreditCard;
import com.sheep.gamegroup.model.entity.DialogConfig;
import com.sheep.gamegroup.model.entity.DialogEntity;
import com.sheep.gamegroup.model.entity.FindApp;
import com.sheep.gamegroup.model.entity.FindItem;
import com.sheep.gamegroup.model.entity.LoginEntity;
import com.sheep.gamegroup.model.entity.NewbieTask;
import com.sheep.gamegroup.model.entity.NewbieTaskRecord;
import com.sheep.gamegroup.model.entity.TaskAcceptedEty;
import com.sheep.gamegroup.model.entity.TaskEty;
import com.sheep.gamegroup.model.entity.UserEntity;
import com.sheep.gamegroup.model.entity.VersionInfo;
import com.sheep.gamegroup.model.entity.WebviewEntity;
import com.sheep.gamegroup.model.entity.XianWanEntity;
import com.sheep.gamegroup.model.util.SheepSubscriber;
import com.sheep.gamegroup.view.activity.ActAudit;
import com.sheep.gamegroup.view.activity.ActBindMobileRegister;
import com.sheep.gamegroup.view.activity.ActCreditCardTaskList;
import com.sheep.gamegroup.view.activity.ActCreditCardWeb;
import com.sheep.gamegroup.view.activity.ActDownloadWelfareList;
import com.sheep.gamegroup.view.activity.ActFindGame;
import com.sheep.gamegroup.view.activity.ActFindInformation;
import com.sheep.gamegroup.view.activity.ActGameAccount;
import com.sheep.gamegroup.view.activity.ActGameAgencyRecharge;
import com.sheep.gamegroup.view.activity.ActGiftCenter;
import com.sheep.gamegroup.view.activity.ActGuide;
import com.sheep.gamegroup.view.activity.ActGuideDeblocked;
import com.sheep.gamegroup.view.activity.ActGuideOnHook;
import com.sheep.gamegroup.view.activity.ActLoadH5;
import com.sheep.gamegroup.view.activity.ActMainGame;
import com.sheep.gamegroup.view.activity.ActMiDong;
import com.sheep.gamegroup.view.activity.ActMyMoney;
import com.sheep.gamegroup.view.activity.ActMyWelfare;
import com.sheep.gamegroup.view.activity.ActNewAboutUs;
import com.sheep.gamegroup.view.activity.ActNewbieTaskList;
import com.sheep.gamegroup.view.activity.ActNotice;
import com.sheep.gamegroup.view.activity.ActReservation;
import com.sheep.gamegroup.view.activity.ActSearchGame;
import com.sheep.gamegroup.view.activity.ActSetting;
import com.sheep.gamegroup.view.activity.ActUnderstandSheep;
import com.sheep.gamegroup.view.activity.ActUserLabelList;
import com.sheep.gamegroup.view.activity.ActWeb;
import com.sheep.gamegroup.view.activity.ActXiaomiGame;
import com.sheep.gamegroup.view.activity.ActXinwanWeb;
import com.sheep.gamegroup.view.activity.AskGetMoneyAct;
import com.sheep.gamegroup.view.activity.BindOrChangeWeixinAct;
import com.sheep.gamegroup.view.activity.ChangeTelAct;
import com.sheep.gamegroup.view.activity.ChangeWxOrTelAct;
import com.sheep.gamegroup.view.activity.CommitWxAct;
import com.sheep.gamegroup.view.activity.CommitWxCodeAct;
import com.sheep.gamegroup.view.activity.DialogToastAct;
import com.sheep.gamegroup.view.activity.FeedbackAct;
import com.sheep.gamegroup.view.activity.GameTaskOrderListAct;
import com.sheep.gamegroup.view.activity.GamemakeMoneyAct;
import com.sheep.gamegroup.view.activity.LieMakeMoneyAct;
import com.sheep.gamegroup.view.activity.LoginAct;
import com.sheep.gamegroup.view.activity.PersonalCenterAct;
import com.sheep.gamegroup.view.activity.PersonalInfoAct;
import com.sheep.gamegroup.view.activity.RealNameAuthenAct;
import com.sheep.gamegroup.view.activity.RechargeAct;
import com.sheep.gamegroup.view.activity.RechargeQAct;
import com.sheep.gamegroup.view.activity.RechargeResultAct;
import com.sheep.gamegroup.view.activity.SignCardAct;
import com.sheep.gamegroup.view.activity.SignRankingsAct;
import com.sheep.gamegroup.view.activity.SignRechargeAct;
import com.sheep.gamegroup.view.activity.SignRecordAct;
import com.sheep.gamegroup.view.activity.TaskDetailAct;
import com.sheep.gamegroup.view.activity.TaskDetailAddQQAct;
import com.sheep.gamegroup.view.activity.TaskDetailCreditCardAct;
import com.sheep.gamegroup.view.activity.TaskListAct;
import com.sheep.gamegroup.view.activity.TryMakeMoneyact;
import com.sheep.gamegroup.view.activity.WebviewAct;
import com.sheep.gamegroup.view.activity.WithdrawalAct;
import com.sheep.gamegroup.view.activity.WithdrawalListAct;
import com.sheep.gamegroup.view.activity.WithdrawalResultAct;
import com.sheep.gamegroup.view.dialog.DialogNewbieTask1;
import com.sheep.gamegroup.view.dialog.DialogNewbieTaskRegistSuccess;
import com.sheep.gamegroup.view.dialog.DialogShare;
import com.sheep.jiuyan.samllsheep.BuildConfig;
import com.sheep.jiuyan.samllsheep.R;
import com.sheep.jiuyan.samllsheep.SheepApp;
import com.sheep.jiuyan.samllsheep.service.FloatService;
import com.sheep.jiuyan.samllsheep.service.FloatShotScreenService;
import com.sheep.jiuyan.samllsheep.utils.G;
import com.sheep.jiuyan.samllsheep.utils.SpUtils;

import org.xutils.ex.DbException;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

import me.iwf.photopicker.PhotoPicker;
import me.iwf.photopicker.PhotoPreview;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action1;
import rx.schedulers.Schedulers;

import static com.sheep.gamegroup.util.UMConfigUtils.Event.GAME_DOWNLOAD_WELFARE_LIST;
import static com.sheep.gamegroup.util.UMConfigUtils.Event.GAME_GIFT_CENTER;
import static com.sheep.gamegroup.util.UMConfigUtils.Event.GAME_INSTEAD_OF_RECHARGE;
import static com.sheep.gamegroup.util.UMConfigUtils.Event.GAME_MY_WELFARE;
import static com.sheep.gamegroup.util.UMConfigUtils.Event.MI_DONG_VIEW;
import static com.sheep.gamegroup.util.UMConfigUtils.Event.RECHARGE;
import static com.sheep.gamegroup.util.UMConfigUtils.Event.RECHARGE_QQ;
import static com.sheep.gamegroup.util.UMConfigUtils.Event.SEARCH_GAME;
import static com.sheep.gamegroup.util.UMConfigUtils.Event.SETTING;
import static com.sheep.gamegroup.util.UMConfigUtils.Event.USER_ABOUT_US;
import static com.sheep.gamegroup.util.UMConfigUtils.Event.USER_FEEDBACK;
import static com.sheep.gamegroup.util.UMConfigUtils.Event.USER_FIND_APP_ORDER;
import static com.sheep.gamegroup.util.UMConfigUtils.Event.USER_GAME_ACCOUNT;
import static com.sheep.gamegroup.util.UMConfigUtils.Event.USER_INFO;
import static com.sheep.gamegroup.util.UMConfigUtils.Event.USER_MY_MONEY;
import static com.sheep.gamegroup.util.UMConfigUtils.Event.USER_NEW_VERSION;
import static com.sheep.gamegroup.util.UMConfigUtils.Event.USER_TASK_RECORD;
import static com.sheep.gamegroup.util.UMConfigUtils.Event.XIAOMI_GAME_LIST;
import static com.sheep.jiuyan.samllsheep.service.FloatShotScreenService.SET_SHOW_OR_HIDE;

/**
 * Created by ljy on 2018/3/18.
 */

public class Jump2View {

    private static Jump2View jump2View;

    public static Jump2View getInstance(){
        if (jump2View == null){
            jump2View = new Jump2View();
        }
        return jump2View;
    }

    /**
     * 跳转到提现页面
     * @param context
     */
    public void goWithdrawal(Context context){
        Intent intent = new Intent(context, WithdrawalAct.class);
        context.startActivity(intent);
        UMConfigUtils.onEvent(UMConfigUtils.Event.SHEEP_TIXIAN);
    }

    /**
     * 跳转到提现页面
     * @param context
     * @param userEntity
     */
    public void tryGoWithdrawal(Context context, UserEntity userEntity){
        if(userEntity == null) {
            userEntity = DataUtil.getInstance().getUserEntity();
        }
        if(userEntity == null){
            G.showToast(R.string.loading_data);
            return;
        }
        if(
                TestUtil.isTestRecharge() ||
                TextUtils.isEmpty(DataUtil.getInstance().getUserWxOpenId())){//这里认定没有微信id  为   没有绑定微信号
            goNoBindWx(context, ChangeWxOrTelAct.TYPE_RECHARGE);
            return;
        }
        if(userEntity.notCertification()){//没有实名认证
            goRealNameAuther(context, userEntity, 1);
            return;
        }
        goWithdrawal(context);
    }


//    /**
//     * 跳到安全中心
//     * @param context
//     * @param o
//     */
//    public void goAccountAndSecurit(Context context, Object o){
//        Intent intent = new Intent(context, AccountAndSecurityAct.class);
//        context.startActivity(intent);
//        USER_ACCOUNT_SAFE.onEvent();
//    }

    /**
     * 跳到登录页面
     * @param context
     * @param o
     */
    public synchronized void goLoginView(Context context, Object o){
        Intent intent = new Intent(context, LoginAct.class);
        if(!(context instanceof Activity))
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
    }


    /**
     * 跳到邀请赚钱页面
     * @param context
     * @param o
     */
    public void goAskGetMoney(Context context, Object o){
        Intent intent = new Intent(context, AskGetMoneyAct.class);
        context.startActivity(intent);
        UMConfigUtils.onEvent(UMConfigUtils.Event.SHEEP_TASK_INVITE);
    }



    /**
     * 跳到首页面
     * @param context
     * @param o
     */
    public void goHomePageView(final Context context, Object o){
        final Intent intent = new Intent(context, ActMain.class);
        if(o instanceof Integer){
            intent.putExtra(ActMain.INTENT_GAME_ID, (Integer) o);
            context.startActivity(intent);
        } else if(o instanceof String){
            //统计用户登录信息
            UMConfigUtils.onProfileSignIn();
            //从登录界面过来//新注册用户才添加到数据库,并设置可以显示
            NewbieTaskRecord newbie_task_record = new NewbieTaskRecord();
            newbie_task_record.setUser_id((String)o);
            newbie_task_record.setDontShowNewbieTaskDialog(false);
            MyDbManager.getInstance().saveOrUpdate(newbie_task_record);
            checkOrGoHomePage((Activity) context);
        } else {
            context.startActivity(intent);
        }
    }

    /**
     * 正常进入
     * 进入主页前需要检查是否需要绑定手机号
     * @param activity
     */
    public void checkPhoneOrGoHomePage(final Activity activity) {
        CommonUtil.getInstance().updateUserInfo(new Action1<UserEntity>() {
            @Override
            public void call(UserEntity userEntity) {
                if(userEntity != null && !TextUtils.isEmpty(userEntity.getShare_link())) {
                    //PersionInfoAct.java与AskGetMoneyAct.java中分享二维码时的图片预下载
                    GlideImageLoader.saveAndSetRqImage(null, userEntity.getShareLink(DialogShare.FACE_TO_FACE), 800);
                }

                if(userEntity != null && userEntity.canBindMobile()
                    && !BuildConfig.DEBUG
                        ){//老用户没有绑定手机号
                    Jump2View.getInstance().goBindPhone(activity, 2);
                    return;
                }
                Intent intent = new Intent(activity, ActMain.class);
                activity.startActivity(intent);
                activity.finish();
            }
        });
    }
    /**
     * 通过引导页面或者登录成功后进入
     * 进入主页前需要检查是否需要绑定手机号、用户标签是否设置
     * @param activity
     */
    private void checkOrGoHomePage(final Activity activity) {
        CommonUtil.getInstance().updateUserInfo(new Action1<UserEntity>() {
            @Override
            public void call(UserEntity userEntity) {
                if(userEntity != null && !TextUtils.isEmpty(userEntity.getShare_link())) {
                    //PersionInfoAct.java与AskGetMoneyAct.java中分享二维码时的图片预下载
                    GlideImageLoader.saveAndSetRqImage(null, userEntity.getShareLink(DialogShare.FACE_TO_FACE), 800);
                }

                if(userEntity != null && userEntity.canBindMobile()
                        && !BuildConfig.DEBUG
                        ){//老用户没有绑定手机号
                    Jump2View.getInstance().goBindPhone(activity, 1);
                    return;
                }
                checkLabel(activity, new Action1<BaseMessage>() {
                    @Override
                    public void call(BaseMessage baseMessage) {
                        goHomePageView(activity, null);
                        activity.finish();
                    }
                });
            }
        });
    }

    /**
     * 跳到个人中心页面
     * @param context
     * @param o
     */
    public void goPersonnalCenterView(Context context, Object o){
        Intent intent = new Intent(context, PersonalCenterAct.class);
        context.startActivity(intent);
    }


    /**
     * 跳到提现结果页面
     * @param context
     * @param o
     */
    public void goWithdrawalResultview(Context context, float o){
        Intent intent = new Intent(context, WithdrawalResultAct.class);
        intent.putExtra(Float.class.getSimpleName(), o);
        context.startActivity(intent);
    }

    /**
     * 跳到绑定微信页面
     * @param context
     * @param o false:绑定   true：切换
     * @param from
     */
    public void goBindOrChangeWeixinView(Context context, boolean o, int from){
        Intent intent = new Intent(context, BindOrChangeWeixinAct.class);
        intent.putExtra("type",o);
        intent.putExtra("from",from);
        context.startActivity(intent);
    }

    /**
     * 跳到试玩界面
     * @param context
     * @param o
     */
    public void goTryplayView(Context context, Object o){
        Intent intent = new Intent(context, TryMakeMoneyact.class);
        intent.putExtra("is_succession", 0);
        context.startActivity(intent);
        UMConfigUtils.Event.SHEEP_TASK_TRY.onEvent();
    }
    /**
     * 跳到试玩界面
     * @param context
     */
    public void goSequentialTaskView(Context context){
        Intent intent = new Intent(context, TryMakeMoneyact.class);
        intent.putExtra("is_succession", 1);
        context.startActivity(intent);
        UMConfigUtils.Event.SHEEP_SEQUENTIAL_TASK.onEvent();
    }

    /**
     * 跳到分享界面
     * @param context
     * @param o
     */
    public void goInvitationView(Context context, Object o){
        Intent intent = new Intent(context, BindOrChangeWeixinAct.class);
        context.startActivity(intent);
    }

    /**
     * 跳到躺着界面
     * @param context
     * @param o
     */
    public void goLyingView(Context context, Object o){
        UMConfigUtils.onEvent(UMConfigUtils.Event.SHEEP_TASK_LIE);
        Intent intent = new Intent(context, LieMakeMoneyAct.class);
        context.startActivity(intent);
    }
    /**
     * 先判断服务器是否打开躺着赚钱功能，再跳到躺着界面
     * @param context
     * @param o
     */
    public void tryGoLyingView(final Context context, final Object o){
        if(context instanceof BaseActivity){
            ((BaseActivity) context).showProgress();
        }
        SheepApp.getInstance().getNetComponent().getApiService().getWebchatIsOpen()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new SheepSubscriber<BaseMessage>(context) {
                    @Override
                    public void onNext(BaseMessage baseMessage) {
                        if(context instanceof BaseActivity){
                            ((BaseActivity) context).hideProgress();
                        }
                        Boolean wechatIsOpen;
                        if (baseMessage.getData() instanceof Boolean)
                            wechatIsOpen = (Boolean) baseMessage.getData();
                        else
                            wechatIsOpen = false;
                        if(wechatIsOpen){
                            goLoginView(context, o);
                        } else {
                            G.showToast(R.string.coming_soon);
                        }
                    }

                    @Override
                    public void onError(BaseMessage baseMessage) {
                        if(context instanceof BaseActivity){
                            ((BaseActivity) context).hideProgress();
                        }
                        G.showToast(R.string.coming_soon);
                    }
                });
    }
    /**
     * 先获取服务器配置的微信辅助功能的地址，再跳到微信辅助功能界面
     * @param context
     * @param o
     */
    public void tryGoWxfz(final Context context, final Object o){
        if(context instanceof BaseActivity){
            ((BaseActivity) context).showProgress();
        }
        SheepApp.getInstance().getNetComponent().getApiService().wxfzGetUrl()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new SheepSubscriber<BaseMessage>(context) {
                    @Override
                    public void onNext(BaseMessage baseMessage) {
                        if(context instanceof BaseActivity){
                            ((BaseActivity) context).hideProgress();
                        }
                        Jump2View.getInstance().goWeb(context, baseMessage.getData().toString(), "微信二维码辅助好友注册任务");
                    }

                    @Override
                    public void onError(BaseMessage baseMessage) {
                        if(context instanceof BaseActivity){
                            ((BaseActivity) context).hideProgress();
                        }
                        G.showToast(baseMessage);
                    }
                });
    }
    /**
     * 跳到提交挂机微信验证码界面
     * @param context
     * @param id
     * @param account
     * @param type
     */
    public void goCommitWxCodeOnHookView(Context context, int id, String account, int type){
        Intent intent = new Intent(context, CommitWxCodeAct.class);
        intent.putExtra("type", type);
        intent.putExtra("id", id);
        intent.putExtra("account", account);
        context.startActivity(intent);
    }
    /**
     * 跳到引导用户  添加  微信小号H5界面
     * @param context
     * @param o
     */
    public void goGuideOnHook(Context context, Object o){
        Intent intent = new Intent(context, ActGuideOnHook.class);
//        extraUrl = getIntent().getStringExtra(KFIntentKeys.EXTRA_WEBVIEW_URL);
//        extraTitle = getIntent().getStringExtra(KFIntentKeys.EXTRA_WEBVIEW_TITLE);
        intent.putExtra(KFIntentKeys.EXTRA_WEBVIEW_URL, "https://qiniu.kuaifazs.com/weixinxiaohaoliuc.html");
        intent.putExtra(KFIntentKeys.EXTRA_WEBVIEW_TITLE, "挂机引导");
        context.startActivity(intent);
    }
    /**
     * 跳到引导用户   解封   微信小号H5界面
     * @param context
     * @param o
     */
    public void goGuideDeArchive(Context context, Object o){
        Intent intent = new Intent(context, ActGuideDeblocked.class);
//        extraUrl = getIntent().getStringExtra(KFIntentKeys.EXTRA_WEBVIEW_URL);
//        extraTitle = getIntent().getStringExtra(KFIntentKeys.EXTRA_WEBVIEW_TITLE);
        intent.putExtra(KFIntentKeys.EXTRA_WEBVIEW_URL, "https://qiniu.kuaifazs.com/jiefeng.html");
        intent.putExtra(KFIntentKeys.EXTRA_WEBVIEW_TITLE, "解封引导");
        context.startActivity(intent);
    }
    /**
     * 跳到提交微信号挂机赚钱界面
     * @param context
     * @param o
     */
    public void goCommitWxView(Context context, Object o){
        Intent intent = new Intent(context, CommitWxAct.class);
        context.startActivity(intent);
    }


    /**
     * 跳转到信用卡任务详情界面
     * @param context
     * @param id
     */
    public synchronized void goCreditCardTaskDetail(Context context, int id){
        Intent intent = new Intent(context, TaskDetailCreditCardAct.class);
        intent.putExtra("id", id);
        context.startActivity(intent);
        UMConfigUtils.onEvent(UMConfigUtils.Event.SHEEP_CREDIT_CARD_DETAIL);
    }
    /**
     * 跳转到新手加QQ群任务详情界面
     * @param context
     * @param task
     */
    public synchronized void goAddQQTaskDetail(Context context, NewbieTask task){
        Intent intent = new Intent(context, TaskDetailAddQQAct.class);
        intent.putExtra("task_entity", task);
        context.startActivity(intent);
        UMConfigUtils.onEvent(UMConfigUtils.Event.SHEEP_NEWBIE_TASK_ADD_QQ);
    }
    public synchronized void goTaskDetailView(Context context, Object o){
        Intent intent = new Intent(context, TaskDetailAct.class);
        if(o instanceof Integer){
            intent.putExtra("task_id", (Integer) o);
            context.startActivity(intent);
        } else if(context instanceof Activity && o instanceof TaskAcceptedEty){
            intent.putExtra("task_entity", (TaskAcceptedEty)o);
            ((Activity) context).startActivityForResult(intent, ViewUtil.REQUEST_CODE_TASK_LIST);
        }

    }
    public synchronized void goTaskDetailViewFromTaskList(Activity activity, int task_id){
        Intent intent = new Intent(activity, TaskDetailAct.class);
            intent.putExtra("task_id", task_id);
            intent.putExtra("is_from_task_list", true);
            activity.startActivityForResult(intent, ViewUtil.REQUEST_CODE_TASK_LIST);
    }

    public synchronized void goTaskDetailView(Context context, Object o, Object b){
        Intent intent = new Intent(context, TaskDetailAct.class);
        if(o instanceof Integer){
            intent.putExtra("task_id", (Integer) o);
        }
        if(b instanceof String){
            intent.putExtra("game_id", (String) b);
        }else
        if(b instanceof Boolean){
            intent.putExtra("btn_show", (Boolean) b);
        }

        context.startActivity(intent);

    }
    public synchronized void goGameTaskDetailView(Context context, Object o, Object b, int type){
        Intent intent = new Intent(context, TaskDetailAct.class);
        if(o instanceof Integer){
            intent.putExtra("task_id", (Integer) o);
        }
        if(b instanceof String){
            intent.putExtra("game_id", (String) b);
        }else
        if(b instanceof Boolean){
            intent.putExtra("btn_show", (Boolean) b);
        }
        intent.putExtra("game_type", type);
        context.startActivity(intent);

    }

    /**
     * 跳到已做过任务列表页面
     * @param context
     * @param o
     */
    public void goTaskList2View(Context context, TaskEty o){
        Intent intent = new Intent(context, TaskListAct.class);
        intent.putExtra("task_entity", o);
        context.startActivity(intent);
        USER_TASK_RECORD.onEvent();
    }

    /**
     * 跳到已提现的列表
     * @param context
     * @param o
     */
    public void goWithdrawallistView(Context context, TaskEty o){
        Intent intent = new Intent(context, WithdrawalListAct.class);
        intent.putExtra("task_entity", o);
        context.startActivity(intent);
    }


    /**
     * 跳转到个人中心界面
     * @param context
     * @param o
     */
    public void goPersionInfo(Context context, Object o){
        Intent i = new Intent(context, PersonalInfoAct.class);
        context.startActivity(i);
        USER_INFO.onEvent();
    }


    /**
     * 实名认证
     * @param context
     * @param o
     * @param whereFrom 0:不作处理 1：跳到充值页面
     */
    public void goRealNameAuther(Context context, UserEntity o, int whereFrom){
        Intent i = new Intent(context, RealNameAuthenAct.class);
        i.putExtra("info", o);
        i.putExtra("where_from", whereFrom);
        context.startActivity(i);
        UMConfigUtils.onEvent(UMConfigUtils.Event.USER_AUTHENTICATION_ENTER);
    }
    /**
     * 跳转到未绑定微信界面
     * @param context
     * @param from
     */
    public void goNoBindWx(Context context, int from){
        Intent i = new Intent(context, ChangeWxOrTelAct.class);
        i.putExtra("from", from);
        context.startActivity(i);
    }
    /**
     * 跳转到绑定手机页面
     * @param context
     * @param o
     */
    public void goBindPhone(Context context, Object o){
        Intent i = new Intent(context, ChangeTelAct.class);
        if(o instanceof Integer){
            i.putExtra("where_from", (Integer) o);
        }
        if(!(context instanceof Activity))
            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(i);
    }
    /**
     * 绑定手机页面并注册第三方账号
     * @param context
     * @param loginEntity
     */
    public void goBindPhoneRegister(Context context, LoginEntity loginEntity){
        Intent intent = new Intent(context, ActBindMobileRegister.class);
        intent.putExtra(LoginEntity.class.getSimpleName(), loginEntity);
        if(!(context instanceof Activity))
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
    }
    /**
     * 跳转到非wifi网络提示
     * @param context
     * @param o
     */
    public void goNoticeAct(Context context, DialogEntity o){
        Intent i = new Intent(context, DialogToastAct.class);
        i.putExtra("dialog_entity", o);
        if(context instanceof Activity){
            ((Activity)context).startActivityForResult(i,0);
        }else {
            i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(i);
        }

    }

    /**
     * 跳转到webview
     */
    public void goWebview(Context context, WebviewEntity webviewEntity){
        Intent intent = new Intent(context, WebviewAct.class);
        intent.putExtra("webview_entity", webviewEntity);
        context.startActivity(intent);
    }
    /**
     * 跳转到 一分钟快速了解小绵羊 界面
     */
    public void goUnderstandSheep(Context context, NewbieTaskRecord newbieTaskRecord){
        UMConfigUtils.onEvent(UMConfigUtils.Event.SHEEP_NEWBIE_TASK_UNDERSTAND_SHEEP);
        Intent intent = new Intent(context, ActUnderstandSheep.class);
        if(newbieTaskRecord != null)
            intent.putExtra(NewbieTaskRecord.class.getSimpleName(), newbieTaskRecord);
        context.startActivity(intent);
    }

    /**
     * 跳转到 一分钟快速了解小绵羊 界面
     */
    public void goNewbieTaskList(Context context, Object o){
        UMConfigUtils.onEvent(UMConfigUtils.Event.SHEEP_NEWBIE_TASK_LIST);
        Intent intent = new Intent(context, ActNewbieTaskList.class);
        context.startActivity(intent);
    }

    /**
     * 跳到信用卡任务界面界面
     * @param context
     * @param o
     */
    public void goCreditCardTaskList(Context context, Object o){
        Intent intent = new Intent(context, ActCreditCardTaskList.class);
        context.startActivity(intent);
        UMConfigUtils.onEvent(UMConfigUtils.Event.SHEEP_CREDIT_CARD);
    }

    /**
     * 跳到银行web页面
     * @param context
     * @param creditCard
     */
    public void goCreditCardWeb(Context context, CreditCard creditCard){
        Intent intent = new Intent(context, ActCreditCardWeb.class);
        intent.putExtra(CreditCard.class.getSimpleName(), creditCard);
        context.startActivity(intent);
        UMConfigUtils.onEvent(UMConfigUtils.Event.SHEEP_CREDIT_CARD_DETAIL_WEB);
    }
    /**
     * 尝试跳到银行web页面
     * @param context
     * @param id
     */
    public void tryGoCreditCardWeb(final Context context, final int release_id, int id, final Action1<String> action1){
        SheepApp.getInstance().getNetComponent().getApiService().getCredit(id)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new SheepSubscriber<BaseMessage>(context) {
                    @Override
                    public void onNext(BaseMessage baseMessage) {
                        final CreditCard creditCard = baseMessage.getData(CreditCard.class);
                        if(release_id > 0){
                            CommonUtil.getInstance().getTaskAllDetail(release_id, new Action1<BaseMessage>() {
                                @Override
                                public void call(BaseMessage baseMessages) {
                                    if(baseMessages != null && baseMessages.getCode() == 0){
                                        TaskAcceptedEty gettaskAcceptedEty = baseMessages.getData(TaskAcceptedEty.class);
                                        if(gettaskAcceptedEty != null && creditCard != null)
                                            creditCard.setRelease_id(gettaskAcceptedEty.getId());
                                    }
                                    Jump2View.getInstance().goCreditCardWeb(context, creditCard);
                                }
                            });
                        }else {
                            Jump2View.getInstance().goCreditCardWeb(context, creditCard);
                        }


                        if(action1 != null)
                            action1.call(null);
                    }

                    @Override
                    public void onError(BaseMessage baseMessage) {
                        if(action1 != null)
                            action1.call(baseMessage.getErrorMsg());
                    }
                });
    }
    /**
     * 浏览器打开web页面
     * @param context
     * @param url
     */
    public void goWeb(Context context, String url){
        if(TextUtils.isEmpty(url)){
            G.showToast(R.string.service_data_error);
            return;
        }
        try {
            Uri uri = Uri.parse(url);
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            context.startActivity(intent);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 跳到web页面
     * @param context
     * @param url
     * @param title
     */
    public void goWeb(Context context, String url, String title){
        if(TextUtils.isEmpty(url)){
            G.showToast(R.string.service_data_error);
            return;
        }
        Intent intent = new Intent(context, ActWeb.class);
        intent.putExtra("url", url);
        intent.putExtra("title", title);
        context.startActivity(intent);
    }
    /**
     * 跳到我的资产界面
     * @param context
     * @param o
     */
    public void goMyMoney(Context context, Object o){
        Intent intent = new Intent(context, ActMyMoney.class);
        context.startActivity(intent);
        USER_MY_MONEY.onEvent();
    }

    /**
     * 跳到充值结果页面
     * @param context
     * @param resultStatus 支付宝支付结果码
     */
    public void goRechargeResultAct(Context context, String resultStatus){
        Intent intent = new Intent(context, RechargeResultAct.class);
        intent.putExtra("payCode",resultStatus);
        context.startActivity(intent);
    }

    /**
     * 跳到充值页面
     * @param context
     * @param from
     */
    public void goRechargeAct(Context context, String from){
        Intent intent = new Intent(context, RechargeAct.class);
        context.startActivity(intent);
        RECHARGE.onEvent("from", from);
    }

    /**
     * 跳到绵羊币充值充值页面
     * @param context
     * @param from
     */
    public void goRechargeQAct(Context context, String from){
        if(!SheepApp.getInstance().isShowQB()){
            goRechargeAct(context, from);
        }else {
            Intent intent = new Intent(context, RechargeQAct.class);
            context.startActivity(intent);
            RECHARGE_QQ.onEvent("from", from);
        }

    }

    /**
     * 添加flags Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP启动一个Activity
     * @param context
     * @param actClass
     * @param bundle
     */
    public void newTaskTopStartAct(Context context, Class<? extends Activity> actClass, Bundle bundle) {
        Intent i = new Intent(context, actClass);
        if(bundle != null)
            i.putExtras(bundle);
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP );
        context.startActivity(i);
    }

    /**
     * 展示公告
     * @param context
     * @param title
     * @param content
     */
    public void goNotice(Context context, String title, String content, long time) {
        Intent intent = new Intent(context, ActNotice.class);
        intent.putExtra("title", title);
        intent.putExtra("content", content);
        if(time > 0)
            intent.putExtra("time", time);
        context.startActivity(intent);
    }
    /**
     * 展示h5内容
     * @param context
     * @param title
     * @param content
     */
    public void goLoadH5(Context context, String title, String content) {
        Intent intent = new Intent(context, ActLoadH5.class);
        intent.putExtra("title", title);
        intent.putExtra("content", content);
        context.startActivity(intent);
    }

    /**
     * 意见反馈
     * @param context
     */
    public void goFeedbackAct(Context context) {
        Intent intent = new Intent(context, FeedbackAct.class);
        context.startActivity(intent);
        USER_FEEDBACK.onEvent();
    }

    /**
     * 游戏列表界面
     * @param context
     */
    public void goMainGame(Context context) {
        Intent intent = new Intent(context, ActMainGame.class);
        context.startActivity(intent);
    }

    /**
     * 显示多张图片
     * @param context
     * @param position
     * @param imgs 多张图片地址，用;分隔
     */
    public void showImgs(Context context, int position, String imgs) {
        showImgList(context, position, ListUtil.asList(imgs.split(";")));
    }
    /**
     * 显示多张图片
     * @param context
     * @param position
     * @param imgList
     */
    public void showImgList(Context context, int position, ArrayList<String> imgList) {
        Activity activity = context instanceof Activity ? (Activity) context : ActivityManager.getInstance().currentActivity();
        if(activity != null) {
            PhotoPreview.builder()
                    .setPhotos(imgList)
                    .setCurrentItem(position)
                    .setShowDeleteButton(false)
                    .start(activity);
        }
    }
    /**
     * 显示多张图片
     * @param context
     * @param position
     * @param files
     */
    public void showImgFiles(Context context, int position, File...files) {
        showImgList(context, position, ListUtil.asList(new ListUtil.CallBack<File, String>() {
            @Override
            public String call(File file) {
                return file.getAbsolutePath();
            }
        }, files));
    }
    /**
     * 提供多张图片给用户选择
     * @param activity
     * @param photoCount
     * @param files
     */
    public void selectImgFiles(Activity activity, int photoCount, File...files) {
        PhotoPicker.builder()
                .setPhotoCount(photoCount)
                .setShowCamera(false)
                .setShowGif(false)
                .setPreviewEnabled(true)
                .setPicker(ListUtil.asList(new ListUtil.CallBack<File, String>() {
                    @Override
                    public String call(File file) {
                        return file.getAbsolutePath();
                    }
                }, files))
                .start(activity, PhotoPicker.REQUEST_CODE);
    }




    /**
     * 启动小绵羊悬浮窗
     * @param context
     */
    public void startFloat(Context context, boolean isShow) {
        Intent intent = new Intent(context, FloatService.class);
        intent.putExtra("isShow", isShow);
        context.startService(intent);
    }
    /**
     * 启动小绵羊悬浮窗
     * @param context
     */
    public void startShotScreenFloat(Context context, Object object) {
        if(DataUtil.IS_USE_SCREEN_SHOT) {
            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {//5.0才上系统才使用
                Intent intent = new Intent(context, FloatShotScreenService.class);
                if (object instanceof Boolean) {
                    intent.putExtra("isShow", (Boolean) object);
                    intent.putExtra("type", SET_SHOW_OR_HIDE);
                } else if (object instanceof Integer) {
                    intent.putExtra("type", (Integer) object);
                }
                context.startService(intent);
            }
        }
    }


    /**
     * 获取协议列表，如果没有协议，则直接通过，否则显示协议对话框
     * @param activity
     * @param action1
     */
    public void tryShowAgreement(final Activity activity, final Action1<String> action1) {
        SheepApp.getInstance().getNetComponent().getApiService().getAgreement()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new SheepSubscriber<BaseMessage>(activity) {
                    @Override
                    public void onNext(BaseMessage baseMessage) {
                        List<Agreement> agreementList = baseMessage.getDatas(Agreement.class);
                        if(agreementList.isEmpty()){
                            if(action1 != null)
                                action1.call(null);
                        } else {
//                            DialogAgreement.showDialog(activity, agreementList, action1);
                            Agreement item = ListUtil.getItem(agreementList, 0);
                            if(item != null)
                                goLoadH5(activity, item.getName(), item.getContent());
                        }
                    }

                    @Override
                    public void onError(BaseMessage baseMessage) {
                        if(action1 != null){
                            String msg = baseMessage.getCode() == 404 ? "404" : baseMessage.getErrorMsg();
                            action1.call(msg);
                        }
                    }
                });
    }

    /**
     * 先尝试显示用户协议与劳务协议等协议对话框，再尝试显示新手任务对话框，如果协议没有通过，直接退出，无论原因
     * @param activity
     * @param userEntity
     * @param newbie_task
     */
    public void tryShowAgreementOrNewbieTask(final Activity activity, final UserEntity userEntity, final View newbie_task) {
        tryShowAgreement(activity, new Action1<String>() {
            @Override
            public void call(String msg) {
                if(msg == null || TextUtils.equals(msg, "404")) {
                    tryShowNewbieTask(activity, userEntity, newbie_task);
                }else {
                    G.showToast(msg);
                    SheepApp.getInstance().quit();
                }
            }
        });
    }

    public void tryShowNewbieTask(final Activity activity, final UserEntity userEntity, final View newbie_task) {
        if(userEntity == null){
            return;
        }
        if (userEntity.getIs_new() == 2){ //1新用户 2老用户
            if(newbie_task != null)
                newbie_task.setVisibility(View.GONE);
        } else {
            NewbieTaskRecord newbie_task_record = null;
            try {
                newbie_task_record = MyDbManager.getInstance().dbFindNewbieTaskRecord(userEntity.getInvitation_code());
            } catch (DbException e) {
                e.printStackTrace();
            }
            boolean dontShowNewbieTaskDialog = newbie_task_record == null || newbie_task_record.isDontShowNewbieTaskDialog();//默认可以显示对话框
            if (
//                !BuildConfig.DEBUG &&
                    !userEntity.isNewRegistUser() || dontShowNewbieTaskDialog) {
                if(newbie_task != null)
                    newbie_task.setVisibility(View.VISIBLE);
                return;
            }
            final NewbieTaskRecord finalNewbie_task_record = newbie_task_record;
            SheepApp.getInstance().getNetComponent().getApiService().getNewbieTask()
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(new SheepSubscriber<BaseMessage>(activity) {
                        @Override
                        public void onNext(BaseMessage baseMessage) {
                            if(newbie_task != null)
                                newbie_task.setVisibility(View.VISIBLE);
                            List<NewbieTask> newbieTaskList = baseMessage.getDatas(NewbieTask.class);
                            if (newbieTaskList != null && !newbieTaskList.isEmpty() && newbieTaskList.size() > 1 && !newbieTaskList.get(1).getFinished()) {//了解小绵羊任务未完成时
                                DialogNewbieTaskRegistSuccess.showDialog(activity, finalNewbie_task_record, newbieTaskList.get(0));
                            } else if (newbieTaskList != null && !newbieTaskList.isEmpty()) {
                                finalNewbie_task_record.setDontShowNewbieTaskDialog(true);
                                MyDbManager.getInstance().saveOrUpdate(finalNewbie_task_record);//设置为不再显示新手对话框
                                List<NewbieTask> taskList = new ArrayList<>();
                                NewbieTask task = null;
                                for (NewbieTask newbieTask : newbieTaskList) {
                                    if (newbieTask.getFinished()) {//已经完成
                                        task = newbieTask;
                                    } else {
                                        taskList.add(newbieTask);
                                    }
                                }
                                DialogNewbieTask1.showDialog(activity, taskList, task);
                            } else {
                                if (BuildConfig.DEBUG)
                                    G.showToast("测试：服务器数据错误,新手任务数据为空");
                            }
                        }

                        @Override
                        public void onError(BaseMessage baseMessage) {
                            if(newbie_task != null)
                                newbie_task.setVisibility(View.GONE);
                        }
                    });
        }
    }



    /**
     * 跳到每日打卡页面
     * @param context
     * @param o
     */
    public void goSignCardAct(Context context, Object o){
        Intent intent = new Intent(context, SignCardAct.class);
        context.startActivity(intent);
        UMConfigUtils.Event.PUNCH.onEvent();
    }


    /**
     * 跳到本月排行榜页面
     * @param context
     * @param o
     */
    public void goSignRankingsAct(Context context, Object o){
        Intent intent = new Intent(context, SignRankingsAct.class);
        context.startActivity(intent);
        UMConfigUtils.Event.PUNCH_RANKING_LIST.onEvent();
    }


    /**
     * 跳到我的战绩页面
     * @param context
     * @param o
     */
    public void goSignRecordAct(Context context, Object o){
        Intent intent = new Intent(context, SignRecordAct.class);
        context.startActivity(intent);
        UMConfigUtils.Event.PUNCH_RECORD.onEvent();
    }

    /**
     * (一元报名充值界面)
     * @param context
     * @param o
     */
    public void goSignRechargeAct(Context context, Object o){
        Intent intent = new Intent(context, SignRechargeAct.class);
        context.startActivity(intent);
    }

    /**
     * 重新登录
     */
    public void gotoLoginAgain() {
        SpUtils.saveToken(SheepApp.mContext,"");
        DataUtil.getInstance().clearData();
        G.showToast("请重新登录");
        ActivityManager.getInstance().finishAllActivity();
        Jump2View.getInstance().goLoginView(SheepApp.mContext, "");
    }

    public void gotoGuide(final Activity activity) {
        if(SysAppUtil.isNewSmallSheep(false)){
            Intent intent = new Intent(activity, ActGuide.class);
            activity.startActivity(intent);
            activity.finish();
        } else {
            gotoMain(activity);
        }
    }
    public void gotoMain(Activity activity) {
        String openId = SpUtils.getToken(SheepApp.getInstance());
        LogUtil.logI("GOTOMIAN_____TOKEN----"+openId);
        if (!TextUtils.isEmpty(openId)) {
            checkOrGoHomePage(activity);
        } else {
            goLoginView(activity, null);
            activity.finish();
        }
    }

    public void tryShowHalfScreenAd(final Activity activity, final Container<Action1<Integer>> container) {
        if(SysAppUtil.isNewSmallSheep(true)){//新版本只显示引导页面，不展示弹窗和开屏广告
            return;
        }
        SheepApp.getInstance().getNetComponent().getApiService().getAdvertising(2)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new SheepSubscriber<BaseMessage>(activity) {
                    @Override
                    public void onNext(BaseMessage baseMessage) {
                        Advertising advertising = baseMessage.getData(Advertising.class);
                        ViewUtil.showHalfScreenAd(activity, advertising, container);
                    }

                    @Override
                    public void onError(BaseMessage baseMessage) {
                        tryShowReservation(activity);
                    }
                });
    }
    public void tryShowReservation(final Activity activity) {
        SheepApp.getInstance().getNetComponent().getApiService().getFindAppDownloadsStatus()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new SheepSubscriber<BaseMessage>(activity) {
                    @Override
                    public void onNext(BaseMessage baseMessage) {
                        if(baseMessage.getData() instanceof Integer && !BuildConfig.DEBUG){
                            if((int)baseMessage.getData() > 0){//该提示在弹窗广告后显示，且必须有可下载的游戏，弹出弹窗
                                ViewUtil.showMsgDialog(activity, new DialogConfig().setTitle("预约下载提示")
                                        .setMsg("你有可下载的预约游戏请及时下载，不要错过优先时机哦。").setMsgGravity(Gravity.START)
                                        .setBtnLeftText("去下载").setBtnLeftOnClickListener(new View.OnClickListener() {
                                            @Override
                                            public void onClick(View view) {
                                                goActReservation(activity);//点击去下载到游戏预约列表
                                            }
                                        }).setBtnRightText("我知道了"));
                            }
                        }
                    }

                    @Override
                    public void onError(BaseMessage baseMessage) {
                    }
                });
    }

    public void goVersionChange(final Activity activity, String currentPkgVersionName) {
        USER_NEW_VERSION.onEvent();
        SheepApp.getInstance().getNetComponent().getApiService().getVersionInfo(currentPkgVersionName)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new SheepSubscriber<BaseMessage>(activity) {
                    @Override
                    public void onNext(BaseMessage baseMessage) {
                        VersionInfo newVersionInfo = baseMessage.getData(VersionInfo.class);
                        if(newVersionInfo != null && !TextUtils.isEmpty(newVersionInfo.getVersion_content())) {
                            goLoadH5(activity, "新功能介绍", newVersionInfo.getVersion_content());
                        } else {
                            G.showToast(R.string.service_data_error);
                        }
                    }
                    @Override
                    public void onError(BaseMessage baseMessage) {
                        G.showToast(baseMessage);
                    }
                });
    }

    public void gotoUserLabelList(Activity activity, BaseMessage baseMessage) {
        Intent intent = new Intent(activity, ActUserLabelList.class);
        activity.startActivity(intent);
        activity.finish();
    }

    public void checkLabel(final Activity activity, final Action1<BaseMessage> action1) {
        SheepApp.getInstance().getNetComponent().getApiService().checkLabel()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
                    @Override
                    public void onNext(BaseMessage baseMessage) {
                        CheckUserLabel checkLabel = baseMessage.getData(CheckUserLabel.class);
                        if(
//                                BuildConfig.DEBUG ||
                                        checkLabel != null && checkLabel.isNeed_set_label()){//需要设置用户标签
                            Jump2View.getInstance().gotoUserLabelList(activity, baseMessage);
                        } else if(action1 != null) {
                            action1.call(baseMessage);
                        }
                    }

                    @Override
                    public void onError(BaseMessage baseMessage) {
                        if(action1 != null) {
                            action1.call(baseMessage);
                        }
                    }
                });
    }

    public void goNewAboutUs(Activity activity) {
        Intent intent = new Intent(activity, ActNewAboutUs.class);
        activity.startActivity(intent);
        USER_ABOUT_US.onEvent();
    }

    /**
     * 任务游戏列表
     */
    public void goGameMakeMoney(Context activity, int o){
        Intent intent = new Intent(activity, GamemakeMoneyAct.class);
        intent.putExtra("current_item", o);
        activity.startActivity(intent);
        UMConfigUtils.Event.SHEEP_GAME_TASK.onEvent();
    }
    /**
     * 订单管理
     */
    public void goGameTaskOrderList(Context activity){
        Intent intent = new Intent(activity, GameTaskOrderListAct.class);
        activity.startActivity(intent);
        UMConfigUtils.onEvent(UMConfigUtils.Event.ORDER_MANAGER);
    }
    public void testIntent(Context activity){
        PackageManager packageManager = activity.getPackageManager();

        activity.startActivity(packageManager.getLaunchIntentForPackage(activity.getPackageName()));
    }
    /**
     * 跳到闲玩web页面
     * @param context
     * @param
     */
    public void goXianwanWeb(final Context context, XianWanEntity xianWanEntity, final Action1<String> action1){

        SheepApp.getInstance().getNetComponent()
                .getApiService()
                .commonConfig("xianwan")
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new SheepSubscriber<BaseMessage>(context) {
                    @Override
                    public void onError(BaseMessage baseMessage) {
                        G.showToast(baseMessage.getMsg() + "");
                        if(action1 != null)
                            action1.call(baseMessage.getErrorMsg());
                    }

                    @Override
                    public void onNext(BaseMessage baseMessage) {
                        final XianWanEntity xianWanEntity = baseMessage.getData(XianWanEntity.class);
                        if(action1 != null)
                            action1.call(null);

                        Intent intent = new Intent(context, ActXinwanWeb.class);
                        intent.putExtra("xianwan_enty", xianWanEntity);
                        context.startActivity(intent);
                    }
                });
        UMConfigUtils.onEvent(UMConfigUtils.Event.XIANWAN_WEBVIEW);
    }

    /**
     * 发现模块--游戏详情界面
     * @param activity
     * @param item
     */
    public void goFindGame(Activity activity, Object item) {
        Intent intent = new Intent(activity, ActFindGame.class);
        int applicationId = 0;
        if(item instanceof FindItem){
            applicationId = ((FindItem) item).getApplication_id();
        } else if(item instanceof FindApp){
            applicationId = ((FindApp) item).getId();
        } else if(item instanceof Integer){
            applicationId = (int) item;
        }
        intent.putExtra("id", applicationId);
        activity.startActivity(intent);
    }
    /**
     * 发现模块--资讯详情界面
     * @param activity
     * @param item
     */
    public void goFindInformation(Activity activity, FindItem item) {
        Intent intent = new Intent(activity, ActFindInformation.class);
        intent.putExtra("id", item.getId());
        intent.putExtra("title", item.getTitle());
        activity.startActivity(intent);
        USER_FIND_APP_ORDER.onEvent();
    }

    /**
     * 进入游戏预约列表界面
     * @param activity
     */
    public void goActReservation(Activity activity) {
        Intent intent = new Intent(activity, ActReservation.class);
        activity.startActivity(intent);
    }

    public void tryShare(final Activity activity, String shareUrlKey, final String idName, final int id) {
        try{
            CommonUtil.getInstance().initUrlConfigByNet(shareUrlKey, new Action1<String>(){
                @Override
                public void call(String find_share_url) {
                    String url = String.format(Locale.CHINA, "%s?authorization=%s&%s=%d&invitation_code=%s", find_share_url, SpUtils.getToken(activity), idName, id, DataUtil.getInstance().getInvitationCode());
                    CommonUtil.getInstance().popShare(activity, url, DialogShare.ALL);
                }
            });
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    /**
     * 游戏帐号
     */
    public void goGameAccount(Activity activity, Object o){
        Intent intent = new Intent(activity, ActGameAccount.class);
        activity.startActivity(intent);
        USER_GAME_ACCOUNT.onEvent();
    }
    /**
     * 游戏代充
     */
    public void goGameRecharge(Activity activity, Object o){
        Intent intent = new Intent(activity, ActGameAgencyRecharge.class);
        activity.startActivity(intent);
        GAME_INSTEAD_OF_RECHARGE.onEvent();
    }
    /**
     * 游戏搜索
     */
    public void goGameSearch(Activity activity, Object o){
        Intent intent = new Intent(activity, ActSearchGame.class);
        if(o instanceof Integer)
            intent.putExtra("where_come", (Integer) o);
        activity.startActivity(intent);
        SEARCH_GAME.onEvent();
    }
    /**
     * 设置界面
     */
    public void goSetting(Activity activity, Object o){
        Intent intent = new Intent(activity, ActSetting.class);
        activity.startActivity(intent);
        SETTING.onEvent();
    }

    /**
     * 幂动科技
     */
    public void goMiDong(final Activity activity, Object o){
        if(!SheepApp.getInstance().isShowMidong()){
            G.showToast("敬请期待");
            return;
        }
        CommonUtil.getInstance().initMiDong(activity, DataUtil.getInstance().getUserId());
        long l ;
        if(SheepApp.getInstance().getMidongTimeCount() == 1){
            l = 1000;
        }else {
            l = 0;
        }
        SheepApp.getInstance().setMidongTimeCount(SheepApp.getInstance().getMidongTimeCount()+1);
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                if(SheepApp.getInstance().isInitMidong()){
                    Intent intent = new Intent(activity, ActMiDong.class);
                    activity.startActivity(intent);
                    MI_DONG_VIEW.onEvent();
                }

            }
        }, l);
    }
    /**
     * 小米游戏列表
     */
    public void goXiaomiGameList(Activity activity, Object o){
        Intent intent = new Intent(activity,ActXiaomiGame.class);
        activity.startActivity(intent);
        XIAOMI_GAME_LIST.onEvent();
    }
    /**
     * 审核列表
     */
    public void goAuditTastList(Activity activity, Object o){
        Intent intent = new Intent(activity,ActAudit.class);
        activity.startActivity(intent);
        XIAOMI_GAME_LIST.onEvent();
    }

    /**
     * 进入下载福利列表界面
     */
    public void goWelfareList(Activity activity) {
        Intent intent = new Intent(activity, ActDownloadWelfareList.class);
        activity.startActivity(intent);
        GAME_DOWNLOAD_WELFARE_LIST.onEvent();
    }
    /**
     * 进入礼包中心界面
     */
    public void goGiftCenter(Activity activity) {
        Intent intent = new Intent(activity, ActGiftCenter.class);
        activity.startActivity(intent);
        GAME_GIFT_CENTER.onEvent();
    }
    /**
     * 进入礼包中心界面
     */
    public void goMyWelfare(Activity activity) {
        Intent intent = new Intent(activity, ActMyWelfare.class);
        activity.startActivity(intent);
        GAME_MY_WELFARE.onEvent();
    }
}
