package com.letv.android.client.commonlib.activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout.LayoutParams;
import cn.com.iresearch.mapptracker.IRMonitor;
import com.flurry.android.FlurryAgent;
import com.letv.android.client.commonlib.R;
import com.letv.android.client.commonlib.bean.RedPacketFrom;
import com.letv.android.client.commonlib.broadcast.HomeKeyEventReceiver;
import com.letv.android.client.commonlib.fragement.LetvBaseFragment;
import com.letv.android.client.commonlib.fragement.LetvFragmentListener;
import com.letv.android.client.commonlib.messagemodel.RedPackageConfig.RedPackageShareGift;
import com.letv.core.BaseApplication;
import com.letv.core.config.LetvConfig;
import com.letv.core.db.PreferencesManager;
import com.letv.core.download.image.ImageDownloader;
import com.letv.core.messagebus.config.LeMessageIds;
import com.letv.core.messagebus.manager.LeMessageManager;
import com.letv.core.messagebus.message.LeMessage;
import com.letv.core.messagebus.message.LeResponseMessage;
import com.letv.core.network.volley.Volley;
import com.letv.core.utils.ActivityUtils;
import com.letv.core.utils.BaseTypeUtils;
import com.letv.core.utils.LetvUtils;
import com.letv.core.utils.LogInfo;
import com.letv.core.utils.RxBus;
import com.letv.core.utils.StatisticsUtils;
import com.letv.core.utils.StringUtils;
import com.letv.core.utils.UIsUtils;
import com.letv.datastatistics.constant.PageIdConstant;
import com.letv.datastatistics.util.DataUtils;
import com.letv.plugin.pluginloader.util.JarUtil;
import com.letv.pp.utils.NetworkUtils;
import com.letv.redpacketsdk.RedPacketSdk;
import com.letv.redpacketsdk.RedPacketSdkManager;
import com.letv.redpacketsdk.bean.RedPacketBean;
import com.letv.redpacketsdk.callback.ClickCallBack;
import com.letv.redpacketsdk.callback.RedPacketViewListener;
import com.letv.redpacketsdk.ui.RedPacketForecastView;
import com.letv.redpacketsdk.ui.RedPacketUI;
import com.letv.redpacketsdk.utils.DensityUtil;
import com.umeng.analytics.AnalyticsConfig;
import com.umeng.analytics.MobclickAgent;
import java.util.List;
import pub.devrel.easypermissions.AfterPermissionGranted;
import pub.devrel.easypermissions.EasyPermissions;
import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks;

public abstract class LetvBaseActivity extends FragmentActivity implements PermissionCallbacks {
    private static final int PEM_INIT_APP = 101;
    private static boolean isLoginStatatistics = false;
    protected static HomeKeyEventReceiver mHomeKeyEventReceiver;
    private ActivityUtils mActivityUtils = ActivityUtils.getInstance();
    protected Context mContext;
    private boolean mHasDoInit = false;
    protected boolean mKeepSingle = true;
    protected boolean mNeedApplyPermissions = false;
    private RedPacketUI mRedPacketEntry;
    private RedPacketForecastView mRedPacketForecastView;
    private RedPacketFrom mRedPacketFrom;
    protected boolean mSaveFragmentWhenKilled = false;

    public static class BaseActivityOnActivityResult {
        public Intent data;
        public int requestCode;
        public int resultCode;

        public BaseActivityOnActivityResult(int requestCode, int resultCode, Intent data) {
            this.requestCode = requestCode;
            this.resultCode = resultCode;
            this.data = data;
        }
    }

    public abstract Activity getActivity();

    public abstract String getActivityName();

    public abstract String[] getAllFragmentTags();

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(1);
        if (this.mNeedApplyPermissions && LetvUtils.is60()) {
            doApplyPermissions();
        } else {
            onApplyPermissionsSuccess();
        }
    }

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        RxBus.getInstance().send(new BaseActivityOnActivityResult(requestCode, resultCode, data));
    }

    protected void _setContentView() {
    }

    @AfterPermissionGranted(101)
    private void doApplyPermissions() {
        if (EasyPermissions