package com.zxhl.cms.utils;

import android.content.Intent;

import com.zxhl.cms.AppContext;
import com.zxhl.cms.common.C2CChatBean;
import com.zxhl.cms.router.RounterApi;
import com.zxhl.cms.router.RounterBus;

import org.greenrobot.eventbus.EventBus;

/**
 * Created by gaoleichao on 2019/3/12
 */
public class JumpUtils {

    public static void activityJump(Intent intent) {
        try {
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    public static void loginJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentLogin();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    public static void loginBeforeJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentLoginBefore();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    public static void videoClipsJump(int pos) {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityVideoClips(pos + "");
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    public static void memberJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityMembers();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    public static void payJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityPay();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    public static void starCoinpayJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityStarCoinPay();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    public static void memberRecordJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityMemberRecordPay();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    public static void coinPayRecordJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityCoinPayRecord();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    public static void UserDetailJump(String userId, String detailfree) {
        UserDetailsHwJump(userId, detailfree);
//        try {
//            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityUserDetail(userId, detailfree);
//            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//            AppContext.get().startActivity(intent);
//        } catch (Exception e) {
//            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
//        }
    }

    public static void UserDetailsHwJump(String userId, String detailfree) {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityUserDetailsHw(userId, detailfree);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    public static void SettingInfoJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivitySettingInfo();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    public static void MyFollowJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityMyFollow();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    public static void MyFansJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityMyFans();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    public static void MyLikesJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityMyLikes();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    public static void VisitorJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityVisitor();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    public static void SystemMsgJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivitySystemMsg();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    public static void VideoCallDemoJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityVideoCallDemo();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    public static void SettingJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivitySetting();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    public static void VoiceRoomJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityVoiceRoom();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    public static void AbuoutUsJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityAboutUs();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }
    public static void BlockListJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentBlockList();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "该版本暂不支持，请更新版本！");
        }
    }
    public static void UpdateNickNameJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentUpdateNickName();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "该版本暂不支持，请更新版本！");
        }
    }
    public static void UpdateIntrodutionJump(String description) {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentUpdateIntrodution(description);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "该版本暂不支持，请更新版本！");
        }
    }
    public static void ConstellResultJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentConstellReslut();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "该版本暂不支持，请更新版本！");
        }
    }

    public static void UserInfoJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityUserInfo();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    public static void VoiceJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityVoice();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    public static void ReportJump(String id) {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityReport(id);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    public static void FeedBackJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityFeedBack();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    public static void BannerDetailJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityBannerDetail();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    public static void CreateRoomJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityCreateRoom();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    public static void WinterBoxJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityWinterBox();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    public static void videoResultJump(String url) {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityVideoResult(url);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    public static void webJump(String title, String url) {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityWeb(title, url);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    /**
     * 跳转到聊天界面方法
     *
     * @param chatId   聊天id，即用户id
     * @param chatName 用户名称
     */
    /**
     * 跳转到聊天界面方法
     *
     * @param chatId   聊天id，即用户id
     * @param chatName 用户名称
     */
    public static void startC2CChatActivity(String chatId, String chatName) {
        startC2CChatActivity(1, chatId, chatName);
    }

    public static void startC2CChatActivity(int type, String chatId, String chatName) {
        EventBus.getDefault().post(new C2CChatBean(type, chatId, chatName));
    }

    //星币商店
    public static void coinStoreJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentCoinStore();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    //vip商店
    public static void becomeVipJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentBecomeVip();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

    //支付页
    public static void paymentPageJump(String type, String id, String name, String price) {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentPaymentPage(type, id, name, price);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "This version is not supported, please update the version!");
        }
    }

}
