package com.kfzs.duanduan.utils.dlg;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;

import com.kfzs.duanduan.ActGameDetails;
import com.kfzs.duanduan.ActGategoryRank;
import com.kfzs.duanduan.ActWeb;
import com.kfzs.duanduan.bean.KFIntentKeys;


/**
 * @ Created by Dlg
 * @ <p>TiTle:  SkipUtils</p>
 * @ <p>Description: 专门负责各类Activity的跳转</p>
 * @ date:  2017/6/15 13:55
 * @ QQ:    315096953
 */

public class SkipUtils {

    private static SkipUtils mSkipUtils;

    public synchronized static SkipUtils getInstance() {
        if (mSkipUtils == null) {
            mSkipUtils = new SkipUtils();
        }
        return mSkipUtils;
    }

    /**
     * 跳到详情页
     *
     * @param sGameId
     */
    public void goGameDetails(Context context, int sGameId) {
        Intent intent = new Intent(context, ActGameDetails.class);
        intent.putExtra(KFIntentKeys.EXTRA_GAME_ID, String.valueOf(sGameId));
        context.startActivity(intent);
    }

    /**
     * @param context
     * @param sGameId
     * @param whichpage 游戏里面有个多栏项目，默认跳到第几个项目
     */
    public void goGameDetails(Context context, int sGameId, int whichpage) {
        Intent intent = new Intent(context, ActGameDetails.class);
        intent.putExtra(KFIntentKeys.EXTRA_GAME_ID, String.valueOf(sGameId));
        intent.putExtra(KFIntentKeys.EXTRA_PAGE_NUM, whichpage);
        context.startActivity(intent);
    }

    /**
     * 跳游戏分类页
     *
     * @param context
     * @param gametypeid
     */
    public void goGameType(Context context, int gametypeid) {
        Intent intent = new Intent(context, ActGategoryRank.class);
        intent.putExtra(ActGategoryRank.INTENT_TYPE_ID, gametypeid);
        context.startActivity(intent);
    }

    /**
     * 跳到Web页
     *
     * @param strUrl
     * @param strTitle
     */
    public void goWebView(Context context, String strUrl, String strTitle, String packName, int gameid) {
        Intent intent = new Intent(context, ActWeb.class);
        intent.putExtra(KFIntentKeys.EXTRA_WEBVIEW_URL, strUrl);
        if (!TextUtils.isEmpty(strTitle)) {
            intent.putExtra(KFIntentKeys.EXTRA_WEBVIEW_TITLE, strTitle);
        }
        if (!TextUtils.isEmpty(packName)) {
            intent.putExtra(KFIntentKeys.EXTRA_WEBVIEW_PACKAGENAME, packName);
        }
        if (gameid > 0) {
            intent.putExtra(KFIntentKeys.EXTRA_GAME_ID, gameid + "");
        }
        context.startActivity(intent);
    }

    public void goWebView(Context context, String strUrl, String strTitle, Boolean isNotitle) {
        Intent intent = new Intent(context, ActWeb.class);
        intent.putExtra(KFIntentKeys.EXTRA_WEBVIEW_URL, strUrl);
        if (!TextUtils.isEmpty(strTitle)) {
            intent.putExtra(KFIntentKeys.EXTRA_WEBVIEW_TITLE, strTitle);
        }
        if (isNotitle) {
            intent.putExtra(KFIntentKeys.EXTRA_WEBVIEW_NO_TITLE, true);
        }
        context.startActivity(intent);
    }

}
