package com.gh.gamecenter.libao;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.NonNull;

import com.therouter.router.Route;
import com.gh.gamecenter.common.base.activity.ToolBarActivity;
import com.gh.gamecenter.common.constant.EntranceConsts;
import com.gh.gamecenter.common.constant.RouteConsts;
import com.gh.gamecenter.common.utils.ExtensionsKt;
import com.gh.gamecenter.feature.entity.LibaoEntity;
import com.halo.assistant.HaloApp;

import kotlin.Pair;

/**
 * Created by khy on 2016/12/13.
 * 礼包详情
 */
@Route(path = RouteConsts.activity.libaoDetailActivity)
public class LibaoDetailActivity extends ToolBarActivity {
    @Override
    protected Intent provideNormalIntent() {
        return getTargetIntent(this, LibaoDetailActivity.class, LibaoDetailFragment.class, getIntent().getExtras());
    }

    public static Intent getIntent(Context context, LibaoEntity libaoEntity, boolean isClickReceiveBtnIn, String entrance) {
        Bundle bundle = new Bundle();
        HaloApp.put(LibaoEntity.TAG, libaoEntity);
        bundle.putString(EntranceConsts.KEY_ENTRANCE, entrance);
        bundle.putBoolean(EntranceConsts.KEY_IS_CLICK_RECEIVE_BTN, isClickReceiveBtnIn);
        return getTargetIntent(context, LibaoDetailActivity.class, LibaoDetailFragment.class, bundle);
    }

    @NonNull
    public static Intent getIntent(Context context, LibaoEntity libaoEntity, String entrance) {
        return getIntent(context, libaoEntity, false, entrance);
    }

    @NonNull
    public static Intent getIntentById(Context context, String id, String entrance) {
        Bundle bundle = new Bundle();
        bundle.putString(EntranceConsts.KEY_ENTRANCE, entrance);
        bundle.putString(EntranceConsts.KEY_ID, id);
        return getTargetIntent(context, LibaoDetailActivity.class, LibaoDetailFragment.class, bundle);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ExtensionsKt.updateStatusBarColor(this, com.gh.gamecenter.common.R.color.ui_surface, com.gh.gamecenter.common.R.color.ui_surface);
    }

    @Override
    protected void onDarkModeChanged() {
        super.onDarkModeChanged();
        ExtensionsKt.updateStatusBarColor(this, com.gh.gamecenter.common.R.color.ui_surface, com.gh.gamecenter.common.R.color.ui_surface);
    }

    @Override
    public Pair<String, String> getBusinessId() {
        LibaoEntity libaoEntity = null;
        if (getTargetFragment() != null) {
            libaoEntity = ((LibaoDetailFragment) getTargetFragment()).getLibaoEntity();
        }
        if (libaoEntity != null) {
            return new Pair(libaoEntity.getId(), "");
        } else if (getIntent().getStringExtra(EntranceConsts.KEY_ID) != null) {
            return new Pair(getIntent().getStringExtra(EntranceConsts.KEY_ID), "");
        } else {
            return super.getBusinessId();
        }
    }
}
