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.Build;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;

import com.danikula.videocache.HttpProxyCacheServer;
import com.sheep.gamegroup.absBase.BaseActivity;
import com.sheep.gamegroup.absBase.IHomePageSearch;
import com.sheep.gamegroup.absBase.IJumpWeb;
import com.sheep.gamegroup.module.find.activity.ActMediaChoose;
import com.sheep.gamegroup.greendao.download.DownLoadInfo;
import com.sheep.gamegroup.model.entity.Advertising;
import com.sheep.gamegroup.model.entity.Agreement;
import com.sheep.gamegroup.model.entity.Applications;
import com.sheep.gamegroup.model.entity.Article;
import com.sheep.gamegroup.model.entity.BaseMessage;
import com.sheep.gamegroup.model.entity.CheckUserLabel;
import com.sheep.gamegroup.model.entity.CommendApp;
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.GameListTag;
import com.sheep.gamegroup.model.entity.GameListType;
import com.sheep.gamegroup.model.entity.HomeListEntity;
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.RouserArticlesEntity;
import com.sheep.gamegroup.model.entity.SystemNotification;
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.Video;
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.module.login.ChangePasswordAct;
import com.sheep.gamegroup.util.share.ShareLinkConfig;
import com.sheep.gamegroup.view.activity.ActApprenticeRedPacket;
import com.sheep.gamegroup.view.activity.ActArticleComment;
import com.sheep.gamegroup.view.activity.ActAudit;
import com.sheep.gamegroup.view.activity.ActBindMobileRegister;
import com.sheep.gamegroup.view.activity.ActCoinCenter;
import com.sheep.gamegroup.view.activity.ActCommentGameApp;
import com.sheep.gamegroup.view.activity.ActCreditCardTaskList;
import com.sheep.gamegroup.view.activity.ActCreditCardWeb;
import com.sheep.gamegroup.view.activity.ActCutVideo;
import com.sheep.gamegroup.view.activity.ActDownloadWelfareList;
import com.sheep.gamegroup.module.find.activity.ActEditVideo;
import com.sheep.gamegroup.view.activity.ActEntertainmentLuckDraw;
import com.sheep.gamegroup.view.activity.ActEveryDayShare;
import com.sheep.gamegroup.view.activity.ActExchangeCMCC;
import com.sheep.gamegroup.view.activity.ActExchangeMall;
import com.sheep.gamegroup.view.activity.ActFootprint;
import com.sheep.gamegroup.view.activity.ActGameAccount;
import com.sheep.gamegroup.view.activity.ActGameAgencyRecharge;
import com.sheep.gamegroup.view.activity.ActGameCenter;
import com.sheep.gamegroup.view.activity.ActGcGameAppDetail;
import com.sheep.gamegroup.view.activity.ActGiftCenter;
import com.sheep.gamegroup.view.activity.ActGiftDetail;
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.ActInputAndPickerImg;
import com.sheep.gamegroup.view.activity.ActInvitation;
import com.sheep.gamegroup.view.activity.ActLoadH5;
import com.sheep.gamegroup.view.activity.ActMain;
import com.sheep.gamegroup.view.activity.ActMiDong;
import com.sheep.gamegroup.view.activity.ActModifyThird;
import com.sheep.gamegroup.view.activity.ActMyFocus;
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.ActPay;
import com.sheep.gamegroup.view.activity.ActPlayGameList;
import com.sheep.gamegroup.view.activity.ActPlayGameRecommendList;
import com.sheep.gamegroup.view.activity.ActPlayGameUserLikeList;
import com.sheep.gamegroup.view.activity.ActPlayVideo;
import com.sheep.gamegroup.view.activity.ActVideoDetail;
import com.sheep.gamegroup.view.activity.ActPublishArticle;
import com.sheep.gamegroup.view.activity.ActReservation;
import com.sheep.gamegroup.view.activity.ActSearchApp;
import com.sheep.gamegroup.view.activity.ActSearchAppOrTask;
import com.sheep.gamegroup.view.activity.ActSearchGame;
import com.sheep.gamegroup.view.activity.ActSetting;
import com.sheep.gamegroup.view.activity.ActSignCard;
import com.sheep.gamegroup.view.activity.ActSignCardRecord;
import com.sheep.gamegroup.view.activity.ActSysNfDetail;
import com.sheep.gamegroup.view.activity.ActUnderstandSheep;
import com.sheep.gamegroup.view.activity.ActUserAppHome;
import com.sheep.gamegroup.view.activity.ActUserCommentDetail;
import com.sheep.gamegroup.view.activity.ActUserLabelList;
import com.sheep.gamegroup.view.activity.ActUserNoviceGuidance;
import com.sheep.gamegroup.view.activity.ActVideoComment;
import com.sheep.gamegroup.view.activity.ActWebX5;
import com.sheep.gamegroup.view.activity.ActXianWanWeb;
import com.sheep.gamegroup.view.activity.ActXiaomiGame;
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.module.login.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.SignRankingsAct;
import com.sheep.gamegroup.view.activity.SignRechargeAct;
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.DialogNewbieTaskRegisterSuccess;
import com.sheep.jiuyan.samllsheep.BuildConfig;
import com.sheep.jiuyan.samllsheep.R;
import com.sheep.jiuyan.samllsheep.SheepApp;
import com.sheep.jiuyan.samllsheep.service.AutoCheckService;
import com.sheep.jiuyan.samllsheep.service.DownloadService;
import com.sheep.jiuyan.samllsheep.service.FloatShotScreenService;
import com.sheep.jiuyan.samllsheep.service.ListenerShotNewService;
import com.sheep.jiuyan.samllsheep.service.ListenerShotService;
import com.sheep.jiuyan.samllsheep.ui.activity.SignActivity;
import com.sheep.jiuyan.samllsheep.utils.G;
import com.sheep.jiuyan.samllsheep.utils.SpUtils;
import com.youmi.android.offer.BaseActYmPermissionCheck;
import com.youmi.android.offer.YmConfig;

import org.afinal.simplecache.DataKey;
import org.xutils.ex.DbException;

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

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

import static com.sheep.gamegroup.util.UMConfigUtils.Event.ASK_MAKE_MONEY_INVITATION;
import static com.sheep.gamegroup.util.UMConfigUtils.Event.FIND_ITEM;
import static com.sheep.gamegroup.util.UMConfigUtils.Event.GAME_DOWNLOAD_WELFARE_LIST;
import static com.sheep.gamegroup.util.UMConfigUtils.Event.GAME_EVERY_DAY_MORE;
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.GAME_PLAY_GAME_DETAIL;
import static com.sheep.gamegroup.util.UMConfigUtils.Event.GIFT_DETAIL;
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_APP_OR_TASK;
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.SYSTEM_NOTIFICATION_DETAIL;
import static com.sheep.gamegroup.util.UMConfigUtils.Event.USER_ABOUT_US;
import static com.sheep.gamegroup.util.UMConfigUtils.Event.USER_CHANGE_PASSWORD;
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;
import static com.sheep.jiuyan.samllsheep.service.ListenerShotService.IS_RECORD_PATH;

/**
 * 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.isDev() ||
                        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, String o) {
        Intent intent = new Intent(context, LoginAct.class);
        intent.putExtra("where_from", o);
        if (!(context instanceof Activity)) {
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        } else if (!TextUtils.isEmpty(o)) {
            ((Activity) context).finish();
        }
        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 object
     */
    public void checkCommendApp(final Context context, final Object object) {
        checkCommendApp(context, object, true);
    }

    public void checkCommendApp(final Context context, final Object object, boolean jump) {
        if (DataUtil.getAsBoolean(ActMain.FIRST_SHOW_MAIN, true)) {
            String game_id = ChannelContent.getInstance().getGameId();
            SheepApp.getInstance().getNetComponent().getApiService().canGetCommendApp(game_id)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
                        @Override
                        public void onNext(BaseMessage baseMessage) {
                            CommendApp result = baseMessage.getData(CommendApp.class);
                            if (!result.getNeed()) {//不需要展示
                                DataUtil.putAsBoolean(ActMain.FIRST_SHOW_MAIN, false);
                            }
                            if (jump) goHomePageView(context, object);
                        }

                        @Override
                        public void onError(BaseMessage baseMessage) {
                            //默认不展示
                            DataUtil.putAsBoolean(ActMain.FIRST_SHOW_MAIN, false);
                            if (jump) goHomePageView(context, object);
                        }
                    });
            return;
        }
        if (jump) goHomePageView(context, object);
    }

    /**
     * 跳到首页面
     *
     * @param context
     * @param object
     */
    public void goHomePageView(final Context context, Object object) {
        final Intent intent = new Intent(context, ActMain.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        if (object instanceof String) {
            //统计用户登录信息
            UMConfigUtils.onProfileSignIn();
            //从登录界面过来//新注册用户才添加到数据库,并设置可以显示
            NewbieTaskRecord newbie_task_record = new NewbieTaskRecord();
            newbie_task_record.setUser_id((String) object);
            newbie_task_record.setDontShowNewbieTaskDialog(false);
            MyDbManager.getInstance().saveOrUpdate(newbie_task_record);
            checkOrGoHomePage((Activity) context);
        } else {
            context.startActivity(intent);
        }
        //登录后尝试启动监听截图后台
        Jump2View.getInstance().startListenerShotService(context);
    }

    /**
     * 正常进入
     * 进入主页前需要检查是否需要绑定手机号
     *
     * @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(ShareLinkConfig.FACE_TO_FACE), 800);
                }

                if (userEntity != null && userEntity.canBindMobile()
                        && !BuildConfig.DEBUG
                        ) {//老用户没有绑定手机号
                    Jump2View.getInstance().goBindPhone(activity, 2);
                    return;
                }
                Intent intent = new Intent(activity, ActMain.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                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(ShareLinkConfig.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) {
                        checkCommendApp(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 String 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);
    }

    public static final String EXTRA_WEBVIEW_NO_TITLE = "EXTRA_WEBVIEW_NO_TITLE";
    public static final String EXTRA_WEBVIEW_URL = "EXTRA_WEBVIEW_URL";
    public static final String EXTRA_WEBVIEW_TITLE = "EXTRA_WEBVIEW_TITLE";

    /**
     * 跳到引导用户  添加  微信小号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(EXTRA_WEBVIEW_URL, "https://qiniu.kuaifazs.com/weixinxiaohaoliuc.html");
        intent.putExtra(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(EXTRA_WEBVIEW_URL, "https://qiniu.kuaifazs.com/jiefeng.html");
        intent.putExtra(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, int task_id, Object b, int type) {
        Intent intent = new Intent(context, TaskDetailAct.class);
        intent.putExtra("task_id", task_id);
        UMConfigUtils.IdEvent.TASK.commit(task_id);
        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;
        }
        //检查url是否是http开头并添加
        if (!url.startsWith("http") && !url.contains("://")) {
            url = "http://" + url;
        }
        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;
        }
        //检查url是否是http开头并添加
        if (!url.startsWith("http") && !url.contains("://")) {
            url = "http://" + url;
        }
        Intent intent = new Intent(context, ActWebX5.class);
        intent.putExtra(IJumpWeb.KEY_URL, url);
        intent.putExtra(IJumpWeb.KEY_TITLE, TextUtils.isEmpty(title) ? "加载中..." : title);
        context.startActivity(intent);
    }

    /**
     * 跳到web页面
     *
     * @param context
     * @param jumpWeb
     */
    public void goWeb(Context context, IJumpWeb jumpWeb) {
        String url = jumpWeb.getUrl();
        String title = jumpWeb.getTitle();
        if (TextUtils.isEmpty(url)) {
            G.showToast(R.string.service_data_error);
            return;
        }
        //检查url是否是http开头并添加
        if (!url.startsWith("http") && !url.contains("://")) {
            url = "http://" + url;
        }
        Intent intent = new Intent(context, ActWebX5.class);
        intent.putExtra(IJumpWeb.KEY_URL, url);
        intent.putExtra(IJumpWeb.KEY_TITLE, TextUtils.isEmpty(title) ? "加载中..." : title);
        intent.putExtra(IJumpWeb.KEY_NEEDJSINTERACT, jumpWeb.needJsInteract());
        //判断是否注入js
        boolean hasJsUrl = !TextUtils.isEmpty(jumpWeb.getJsUrl());
        if (hasJsUrl) {
            intent.putExtra(IJumpWeb.KEY_JSURL, jumpWeb.getJsUrl());
        }
        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, ActGameCenter.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 startAutoCheckService(Context context, ArrayList<String> taskList) {
        String userId = DataUtil.getInstance().getUserId();
        if (TextUtils.isEmpty(userId)) {
            return;
        }
        if (AutoCheckService.IS_USE_THIS_SERVICE) {
            Intent intent = new Intent(context, AutoCheckService.class);
            intent.putStringArrayListExtra(AutoCheckService.EXTRA_KEY_TASK_LIST, taskList);
            intent.putExtra(AutoCheckService.EXTRA_KEY_USER_ID, userId);
            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 context
     */
    public void startListenerShotService(Context context) {
        if (DataUtil.IS_LISTEN_SCREEN_SHOT && (!IS_RECORD_PATH || !TextUtils.isEmpty(DataUtil.getInstance().getUserId()))) {
            if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                Intent intent = new Intent(context, ListenerShotNewService.class);
                intent.putExtra(AutoCheckService.EXTRA_KEY_USER_ID, DataUtil.getInstance().getUserId());//记录用户截图方案需要记录当前用户id
                context.startForegroundService(intent);
            } else {
                Intent intent = new Intent(context, ListenerShotService.class);
                intent.putExtra(AutoCheckService.EXTRA_KEY_USER_ID, DataUtil.getInstance().getUserId());//记录用户截图方案需要记录当前用户id
                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()) {//了解小绵羊任务未完成时
                                DialogNewbieTaskRegisterSuccess.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, ActSignCard.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, ActSignCardRecord.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() {
        gotoLoginAgain("");
    }

    public void gotoLoginAgain(String o) {
        SpUtils.saveToken(SheepApp.getInstance(), "");
        DataUtil.getInstance().clearData();
        G.showToast(TextUtils.isEmpty(o) ? "请重新登录" : o);
        ActivityManager.getInstance().finishAllActivity();
        Jump2View.getInstance().goLoginView(SheepApp.getInstance(), o);
    }

    public void gotoGuide(final Activity activity) {
        if (SysAppUtil.isNewSmallSheep()) {
            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());
        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()) {//新版本只显示引导页面，不展示弹窗和开屏广告
            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 goChangePassword(Activity activity) {
        ChangePasswordAct.changePassword(activity);
        USER_CHANGE_PASSWORD.onEvent();
    }

    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, 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, ActXianWanWeb.class);
                        intent.putExtra("xianwan_enty", xianWanEntity);
                        context.startActivity(intent);
                    }
                });
        UMConfigUtils.onEvent(UMConfigUtils.Event.XIANWAN_WEBVIEW);
    }

    /**
     * 发现模块--游戏详情界面
     *
     * @param activity
     * @param item
     */
    public void goFindGame(Activity activity, Article item) {
        Intent intent = new Intent(activity, ActGcGameAppDetail.class);
        intent.putExtra("id", item.getApplication_id());
        activity.startActivity(intent);
    }

    /**
     * 发现模块--游戏详情界面
     *
     * @param activity
     * @param findApp
     */
    public void goFindGame(Activity activity, Applications findApp) {
        Intent intent = new Intent(activity, ActGcGameAppDetail.class);
        intent.putExtra("id", findApp.getId());
        activity.startActivity(intent);
    }

    /**
     * 发现模块--游戏详情界面
     *
     * @param activity
     * @param applicationId
     */
    public void goFindGame(Activity activity, int applicationId) {
        Intent intent = new Intent(activity, ActGcGameAppDetail.class);
        intent.putExtra("id", applicationId);
        activity.startActivity(intent);
    }

    /**
     * 发现模块--资讯详情界面
     *
     * @param activity
     * @param item
     */
    public void goFindInformation(Activity activity, Article item) {
        goFindInformation(activity, item.getTitle(), item.getId());
    }

    /**
     * 发现模块--资讯详情界面
     *
     * @param activity
     * @param title
     * @param id
     */
    public void goFindInformation(Activity activity, String title, int id) {
        Intent intent = new Intent(activity, ActArticleComment.class);
        DataUtil.putObject(intent, id);
        intent.putExtra("title", title);
        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, final String description) {
        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());
                    new ShareLinkConfig().setLink(url).setDes(description).toShare(activity);
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //分享
    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());
                    new ShareLinkConfig().setLink(url).toShare(activity);
                }
            });
        } 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();
    }

    /**
     * 3.4 新的搜索(游戏与任务)
     */
    public void goAppTaskSearch(Activity activity, Object o) {
        Intent intent = new Intent(activity, ActSearchAppOrTask.class);
        activity.startActivity(intent);
        SEARCH_APP_OR_TASK.onEvent();
    }

    /**
     * 新的游戏搜索
     */
    public void goAppSearch(Activity activity, Object o) {
        Intent intent = new Intent(activity, ActSearchApp.class);
        activity.startActivity(intent);
        SEARCH_GAME.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 object) {
        Intent intent = new Intent(activity, ActAudit.class);
        if (object instanceof Integer) {
            DataUtil.putObject(intent, object);
        }
        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 goGiftDetail(Context context, Object object) {
        Intent intent = new Intent(context, ActGiftDetail.class);
        if (object instanceof Integer)//ActGiftDetail中暂未实现获取功能
            intent.putExtra("id", (Integer) object);
        else if (object != null)//ActGiftDetail中暂时只支持获取 GiftBagApp
            DataUtil.putObject(intent, object);
        context.startActivity(intent);
        GIFT_DETAIL.onEvent();
    }

    /**
     * 进入我的福利界面
     */
    public void goMyWelfare(Activity activity) {
        Intent intent = new Intent(activity, ActMyWelfare.class);
        activity.startActivity(intent);
        GAME_MY_WELFARE.onEvent();
    }

    /**
     * 进入验证手机号
     */
    public void goBindThird(final Activity activity, @ActModifyThird.THIRD_TYPE final String type) {
        Intent intent = new Intent(activity, ActModifyThird.class);
        intent.putExtra("type", type);
        activity.startActivity(intent);
    }

    /**
     * 每日必做、近期最热等
     */
    public void goActPlayGameList(Activity activity, GameListType gameListType) {
//        Intent intent = new Intent(activity, TextUtils.equals("猜你喜欢", gameListType.getTitle()) ? ActPlayGameUserLikeList.class : ActPlayGameList.class);
        Intent intent;
        switch (gameListType.getTitle()) {
            case "天天更新":
            case "重点推荐":
                intent = new Intent(activity, ActPlayGameRecommendList.class);
                break;
            case "猜你喜欢":
                intent = new Intent(activity, ActPlayGameUserLikeList.class);
                break;
            default:
                intent = new Intent(activity, ActPlayGameList.class);
                break;
        }
        DataUtil.putObject(intent, gameListType);
        activity.startActivity(intent);
        GAME_EVERY_DAY_MORE.onEvent("title", gameListType.getTitle());
    }

    /**
     * 点击游戏标签
     */
    public void goActPlayGameList(Activity activity, GameListTag item) {
        Intent intent = new Intent(activity, ActPlayGameList.class);
        DataUtil.putObject(intent, item.toGameListType());
        activity.startActivity(intent);
        GAME_EVERY_DAY_MORE.onEvent("title", item.getName());
    }

    /**
     * 游戏详情
     */
    public void goPlayGameDetail(Activity activity, int id) {
        if (activity == null) {
            activity = ActivityManager.getInstance().currentActivity();
        }
        if (activity == null) {
            G.showToast(R.string.coming_soon);
            return;
        }
        Intent intent = new Intent(activity, ActGcGameAppDetail.class);
        intent.putExtra("id", id);
        activity.startActivity(intent);
        GAME_PLAY_GAME_DETAIL.onEvent();
    }

    /**
     * 普通的消息详情
     */
    public void goActSysNfDetail(Activity activity, Object object) {
        SYSTEM_NOTIFICATION_DETAIL.onEvent();
        Intent intent = new Intent(activity, ActSysNfDetail.class);
        if (object instanceof Integer)
            intent.putExtra("id", (Integer) object);
        else if (object instanceof SystemNotification)
            intent.putExtra(SystemNotification.class.getSimpleName(), (SystemNotification) object);
        activity.startActivity(intent);
    }

    /**
     * 进入邀请赚钱分享界面
     *
     * @param activity
     */
    public void goActInvitation(Activity activity) {
        ASK_MAKE_MONEY_INVITATION.onEvent();
        activity.startActivity(new Intent(activity, ActInvitation.class));
    }

    /**
     * 跳到积分兑换界面
     *
     * @param context
     */
    public void goActExchangeCMCC(Context context) {
        Intent intent = new Intent(context, ActExchangeCMCC.class);
        context.startActivity(intent);
        UMConfigUtils.Event.EXCHANGE_CMCC.onEvent();
    }

    /**
     * 点击看点
     *
     * @param activity
     */
    public void goWatchFocus(Activity activity, RouserArticlesEntity entity) {
        try {
            String deepLink = entity.getDeeplink().trim();
            Intent intent = Intent.parseUri(deepLink, Intent.URI_INTENT_SCHEME);
            intent.setComponent(null);
            activity.startActivity(intent);
            CommonUtil.getInstance().awakenDetail(entity);
        } catch (Exception e) {
            e.printStackTrace();
            if (TestUtil.isTest())
                G.showToast(e.getMessage());
            else
                G.showToast(activity.getString(R.string.not_install, entity.getApp_name()));
        }
    }

    /**
     * 通过id尝试打开一个看点
     *
     * @param activity
     */
    public void goWatchFocus(final Activity activity, int id) {
        SheepApp.getInstance().getNetComponent().getApiService().awakenAppArticle(id)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
                    @Override
                    public void onNext(BaseMessage baseMessage) {
                        RouserArticlesEntity item = baseMessage.getData(RouserArticlesEntity.class);
                        if (item == null) {
                            G.showToast(R.string.error_data);
                            return;
                        }
                        goWatchFocus(activity, item);
                    }

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

    //通过查询发现打开一个发现
    public void goFindItem(final Activity activity, int findItemId) {
        SheepApp.getInstance().getNetComponent().getApiService().getFindDetail(findItemId)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
                    @Override
                    public void onNext(BaseMessage baseMessage) {
                        Article item = baseMessage.getData(Article.class);
                        if (item == null) {
                            G.showToast(R.string.error_data);
                            return;
                        }
                        goFindItem(activity, item);
                    }

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

    //打开一个发现
    public void goFindItem(Activity activity, Article item) {
        switch (item.getType()) {//类型 1：游戏 2：咨询 3：转跳 4：任务 5：栏目
            case 1:
                Jump2View.getInstance().goFindGame(activity, item);
                break;
            case 2:
                Jump2View.getInstance().goFindInformation(activity, item);
                break;
            case 3:
                openLink(activity, item);
                break;
            case 4:
                Jump2View.getInstance().goTaskDetailView(activity, item.getRelease_task_id());
                break;
            case 5:
                openHomeListItem(activity, item);
                break;
        }
        FIND_ITEM.onEvent("find_id", item.getId());
        SheepApp.getInstance().getNetComponent().getApiService().getFindItemAddClicks(item.getId())
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
                    @Override
                    public void onNext(BaseMessage baseMessage) {
                    }

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

    /**
     * 打开一个homelist项
     *
     * @param item
     */
    private void openHomeListItem(final Activity activity, Article item) {
        SheepApp.getInstance().getNetComponent().getApiService().getHomeListItem(item.getHome_list_id())
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
                    @Override
                    public void onNext(BaseMessage baseMessage) {
                        HomeListEntity homeListEntity = baseMessage.getData(HomeListEntity.class);
                        if (homeListEntity == null) {
                            G.showToast(R.string.error_data);
                            return;
                        }
                        CommonUtil.getInstance().goWhere(activity, homeListEntity, "发现");
                    }

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

    /**
     * 打开一个链接
     *
     * @param item
     */
    private void openLink(Activity activity, Article item) {
        if (TextUtils.isEmpty(item.getUrl())) {
            G.showToast(R.string.error_link);
            return;
        }
        switch (item.getIs_in_url()) {//是否外部链接 1：是 0：不是
            case 1:
                Jump2View.getInstance().goWeb(activity, item.getUrl());
                break;
            default:
                Jump2View.getInstance().goWeb(activity, item.getUrl(), item.getTitle());
                break;
        }
    }

    /**
     * 跳转支付界面
     *
     * @param activity
     * @param order_no 订单编号
     * @param token    登录token
     */
    public void goActPay(Activity activity, String order_no, String token) {
        activity.startActivityForResult(new Intent(activity, ActPay.class)
                        .putExtra("order_no", order_no)
                        .putExtra("token", token),
                ActPay.RESULT_CODE);
    }

    /**
     * 启动下载后台服务进行下载
     *
     * @param context
     * @param downLoadInfo
     */
    public void startDownloadService(Context context, DownLoadInfo downLoadInfo) {
        context.startService(new Intent(context, DownloadService.class).putExtra("download_url", downLoadInfo.getMDownloadUrl()).putExtra("file_path", downLoadInfo.getMApkPath()));
    }

    /**
     * 有米科技
     *
     * @param activity
     */
    public void goYm(final Activity activity) {
        if (activity instanceof BaseActYmPermissionCheck) {
            if (YmConfig.isToastTotalPrice()) {
                //获取总积分
                SheepApp.getInstance().getNetComponent().getApiService().getYmTotalPrice(DataUtil.getInstance().getUserId())
                        .subscribeOn(Schedulers.io())
                        .observeOn(AndroidSchedulers.mainThread())
                        .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
                            @Override
                            public void onNext(BaseMessage baseMessage) {
                                DataUtil.putAsInt(DataKey.YM_TOTAL_PRICE, baseMessage.getData(Integer.class));
                                ((BaseActYmPermissionCheck) activity).checkOrShowYmOffersAds();
                            }

                            @Override
                            public void onError(BaseMessage baseMessage) {
                                G.showToast(baseMessage);
                            }
                        });
            } else {
                ((BaseActYmPermissionCheck) activity).checkOrShowYmOffersAds();
            }
        }
    }

    /**
     * 跳转到游戏评论界面
     *
     * @param activity
     * @param game_id  游戏id
     */
    public void goActCommentGameApp(Activity activity, int game_id) {
        activity.startActivityForResult(new Intent(activity, ActCommentGameApp.class).putExtra("game_id", game_id), RequestCodeConstants.REQUEST_CODE_REFRESH);
    }

    /**
     * 跳转游戏评论详情界面
     *
     * @param activity
     * @param user_comment_id
     */
    public void goActAppCommentDetail(Activity activity, int user_comment_id) {
        activity.startActivity(DataUtil.putObject(new Intent(activity, ActUserCommentDetail.class), user_comment_id));
    }

    /**
     * 跳转个人游戏主页界面
     *
     * @param activity
     * @param user_id
     */
    public void goActUserAppHome(Activity activity, int user_id) {
        activity.startActivity(DataUtil.putObject(new Intent(activity, ActUserAppHome.class), user_id));
    }


    /**
     * 跳转游戏资讯评论界面
     *
     * @param activity
     * @param article_id
     */
    public void goActFindInformationComment(Activity activity, int article_id) {
        activity.startActivity(DataUtil.putObject(new Intent(activity, ActArticleComment.class), article_id));
    }

    /**
     * 签到 小绵羊
     *
     * @param activity
     */
    public void goActSignSheep(Activity activity) {
        activity.startActivity(new Intent(activity, SignActivity.class));
    }

    /**
     * 新手引导图文或视频
     *
     * @param activity
     */
    public void goActGuideNewUser(Activity activity) {
        activity.startActivity(new Intent(activity, ActUserNoviceGuidance.class));
    }

    /**
     * 跳转到游戏详情或者任务详情界面
     */
    public void goTaskOrAppDetail(IHomePageSearch item) {
        Activity activity = ActivityManager.getInstance().currentActivity();
        switch (item.getLink_type()) {
            case IHomePageSearch.LINK_TYPE_RELEASE_TASK:
                goTaskDetailView(activity, item.getLink_id());
                break;
            case IHomePageSearch.LINK_TYPE_APPLICATIONS:
                goPlayGameDetail(activity, item.getLink_id());
                break;
        }
    }

    /**
     * 播放视频
     *
     * @param url     播放地址
     * @param isCache 是否缓存，方便以后播放
     */
    public void goActPlayVideo(String url, boolean isCache) {
        Activity activity = ActivityManager.getInstance().currentActivity();
        if (isCache) {
            HttpProxyCacheServer proxy = SheepApp.getHttpProxyCacheServer();
            url = proxy.getProxyUrl(url);
        }
        activity.startActivity(DataUtil.putObject(new Intent(activity, ActPlayVideo.class), url));
    }

    /**
     * 播放视频
     *
     * @param item 视频对象
     */
    public void goActPlayVideoArticle(Serializable item) {
        Activity activity = ActivityManager.getInstance().currentActivity();
        activity.startActivity(DataUtil.putObject(new Intent(activity, ActVideoDetail.class), item));
    }

    /**
     * 剪切视频
     *
     * @param data 视频数据，包括地址与时长，宽高等
     */
    public void goActCutVideo(Video data) {
        Activity activity = ActivityManager.getInstance().currentActivity();
        Intent intent = new Intent(activity, ActCutVideo.class);
        DataUtil.putObject(intent, data);
        activity.startActivity(intent);
    }

    /**
     * 编辑视频
     *
     * @param data 视频数据，包括地址与时长，宽高等
     */
    public void goActEditVideo(Video data) {
        Activity activity = ActivityManager.getInstance().currentActivity();
        Intent intent = new Intent(activity, ActEditVideo.class);
        DataUtil.putObject(intent, data);
        activity.startActivity(intent);
    }

    /**
     * 提交自定义字段
     *
     * @param activity
     */
    public void goActInputAndPickerImg(Activity activity, String label) {
        activity.startActivityForResult(DataUtil.putObject(new Intent(activity, ActInputAndPickerImg.class), label), RequestCodeConstants.REQUEST_CODE_GE_DATA);
    }

    /**
     * 进入覆盖js的Web界面
     *
     * @param activity
     * @param title
     * @param url
     * @param jsUrl
     */
    public void goActOverrideJsWeb(Activity activity, String title, String url, String jsUrl) {
        Intent intent = new Intent(activity, ActWebX5.class);
        intent.putExtra(IJumpWeb.KEY_TITLE, title);
        intent.putExtra(IJumpWeb.KEY_URL, url);
        intent.putExtra(IJumpWeb.KEY_JSURL, jsUrl);
        intent.putExtra(IJumpWeb.KEY_NEEDJSINTERACT, true);
        activity.startActivity(intent);
    }

    /**
     * 小绵羊3.4.5新增--跳转到我的关注界面
     */
    public void goActMyFocus() {
        Activity activity = ActivityManager.getInstance().currentActivity();
        Intent intent = new Intent(activity, ActMyFocus.class);
        activity.startActivity(intent);
    }

    /**
     * 小绵羊3.4.5新增--跳转到足迹界面
     */
    public void goActFootPrint() {
        Activity activity = ActivityManager.getInstance().currentActivity();
        Intent intent = new Intent(activity, ActFootprint.class);
        activity.startActivity(intent);
    }

    /**
     * 小绵羊3.4.5新增--跳转到收徒红包界面
     */
    public void goActApprenticeRedPacket() {
        Activity activity = ActivityManager.getInstance().currentActivity();
        Intent intent = new Intent(activity, ActApprenticeRedPacket.class);
        activity.startActivity(intent);
    }

    /**
     * 小绵羊3.4.5新增--跳转到兑换商城界面
     */
    public void goActExchangeMall() {
        Activity activity = ActivityManager.getInstance().currentActivity();
        Intent intent = new Intent(activity, ActExchangeMall.class);
        activity.startActivity(intent);
    }

    /**
     * 小绵羊3.4.5新增--跳转到每日分享界面
     */
    public void goActEveryDayShare() {
        Activity activity = ActivityManager.getInstance().currentActivity();
        Intent intent = new Intent(activity, ActEveryDayShare.class);
        activity.startActivity(intent);
    }

    /**
     * 小绵羊3.4.5新增--跳转到娱乐抽奖界面
     */
    public void goActEntertainmentLuckDraw() {
        Activity activity = ActivityManager.getInstance().currentActivity();
        Intent intent = new Intent(activity, ActEntertainmentLuckDraw.class);
        activity.startActivity(intent);
    }

    /**
     * 小绵羊3.4.5新增--跳转到金币中心界面
     */
    public void goActCoinCenter() {
        Activity activity = ActivityManager.getInstance().currentActivity();
        Intent intent = new Intent(activity, ActCoinCenter.class);
        activity.startActivity(intent);
    }

    /**
     * 小绵羊3.4.5新增--跳转到发布发现内容的界面
     */
    public void gotoActPublishArticle(@ActPublishArticle.Type int type) {
        Activity activity = ActivityManager.getInstance().currentActivity();
        Intent intent = new Intent(activity, ActPublishArticle.class);
        activity.startActivity(DataUtil.putObject(intent, type));
    }

    /**
     * 小绵羊3.4.5新增--跳转到发布发现内容的界面
     */
    public void gotoActVideoComment(int video_id) {
        Activity activity = ActivityManager.getInstance().currentActivity();
        Intent intent = new Intent(activity, ActVideoComment.class);
        activity.startActivity(DataUtil.putObject(intent, video_id));
    }

    /**
     * 小绵羊3.4.5新增--跳转到选择视频与图片界面
     */
    public void gotoActMediaChoose(@ActPublishArticle.Type int type) {
        Activity activity = ActivityManager.getInstance().currentActivity();
        Intent intent = new Intent(activity, ActMediaChoose.class);
        activity.startActivity(DataUtil.putObject(intent, type));
    }
}
