PaperActivity.java 4.1 KB
package com.wd.module_home;

import android.os.Build;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.fastjson.JSONObject;
import com.wd.capability.layout.page.ItemElectronPapterLayoutManager;
import com.wd.capability.router.data.ActionBean;
import com.wd.common.base.BaseActivity;
import com.wd.common.constant.PageNameConstants;
import com.wd.common.constant.RegionNameConstants;
import com.wd.common.constant.RouterConstants;
import com.wd.common.utils.BarUtils;
import com.wd.foundation.bean.analytics.TrackContentBean;
import com.wd.foundation.bean.custom.MenuBean;
import com.wd.foundation.wdkit.constant.GlobalAppCacheData;
import com.wd.foundation.wdkit.constant.IntentConstants;
import com.wd.foundation.wdkit.statusbar.StatusBarStyleEnum;
import com.wd.foundation.wdkit.utils.ViewUtils;
import com.wd.foundation.wdkitcore.tools.JsonUtils;
import com.wd.foundation.wdkitcore.tools.ResUtils;

/**
 * @Description: 电子报
 * @Author: Li Yubing
 * @Email: liyubing@wondert.com.cn
 * @CreateDate: 2023/7/12 14:42
 * @Version: 1.0
 */
@Route(path = RouterConstants.PATH_MODULE_PAPER)
public class PaperActivity extends BaseActivity {


    private FrameLayout mRootView;

    private ItemElectronPapterLayoutManager mLayoutManager;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_common_subject;
    }


    @Override
    protected StatusBarStyleEnum getStatusBarStyle() {
        return StatusBarStyleEnum.FULLSCREEN_LIGHT_ENUM;
    }

    @Override
    public int getNavigationBarBgColor() {
        return ResUtils.getColor(R.color.res_color_common_C9);
    }

//    @Override
//    public boolean settingSwipeBack() {
//        return false;
//    }

    @Override
    protected String getTag() {
        return "PaperActivity";
    }

    @Override
    protected void initView() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            BarUtils.setNavBarColor(this.getWindow(), ResUtils.getColor(R.color.res_color_common_C9));
        }
//        setSwipeBackEnable(false);

        mRootView = ViewUtils.findViewById(this, R.id.container);

    }

    @Override
    protected void initData() {
        mLayoutManager = new ItemElectronPapterLayoutManager();
        mRootView.removeAllViews();
        View pageView = LayoutInflater.from(this).inflate(mLayoutManager.getItemViewType(), mRootView, false);
        mRootView.addView(pageView);

        MenuBean menuBean = new MenuBean();
        menuBean.setTopMargin(statusHeight);
        Object actionBeanObject = getExtrasSerializableObject();
        if (actionBeanObject != null && !TextUtils.isEmpty(((ActionBean) actionBeanObject).paramBean.params)) {
            JSONObject jsonObject = JsonUtils.convertJsonToObject(((ActionBean) actionBeanObject).paramBean.params, JSONObject.class);
            String elePageFirstPic = jsonObject.getString(IntentConstants.PAGE_BACKGROUND_URL);
            //最新电子报第一版的第一张图url
            menuBean.setBackgroundUrl(elePageFirstPic);
        }
        mLayoutManager.setFragmentActivity(this);
        mLayoutManager.prepareItem(mRootView, 0);
        mLayoutManager.bindItem(mRootView, 0, menuBean);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mLayoutManager != null) {
            mLayoutManager.onDestory();
            mLayoutManager = null;
        }

        GlobalAppCacheData.haveElDataMap.clear();

        // 埋点
        TrackContentBean bean = new TrackContentBean();
        bean.setPage_name(PageNameConstants.NEWS_PAPER_PAGE);
        bean.setPage_id(PageNameConstants.NEWS_PAPER_PAGE);
        bean.setExposure(duration);
        bean.setRegion_name(RegionNameConstants.NEWS_PAPER);
//        CommonTrack.getInstance().channelExposureTrack(bean);
    }

    @Override
    protected void initViewModel() {

    }

    @Override
    public void finish() {
        super.finish();
        overridePendingTransition(R.anim.exit_page_alpha_in, R.anim.exit_page_top_bottom_out);
    }


}