ItemHighQualityCommentsLayoutManager.java 2.43 KB
package com.wd.display.comp.page;

import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.people.common.statusbar.StatusBarCompat;
import com.people.component.R;
import com.people.component.comp.layoutmanager.ItemContainerManager;
import com.people.component.ui.fragment.TemplateFragment;
import com.people.entity.custom.MenuBean;
import com.people.toolset.ScreenUtils;
import com.wondertek.wheat.ability.tools.ResUtils;
import com.wondertek.wheat.ability.tools.ViewUtils;

/**
 * @Description: 优质评论顶部
 * @Author: wd
 * @Version: 1.0
 */
public class ItemHighQualityCommentsLayoutManager extends ItemContainerManager<MenuBean> {

    private TemplateFragment mColumnFragment;
    private ImageView ivtopbg,ivback;

    @Override
    public int getItemViewType() {
        return R.layout.page_item_layout_high_quality_comments;
    }

    @Override
    public void prepareItem(View itemView, int position) {
        ivtopbg = ViewUtils.findViewById(itemView, R.id.ivtopbg);
        ivback = ViewUtils.findViewById(itemView, R.id.title_bar_left_img);
    }

    @Override
    public int bindItem(View itemView, int position, MenuBean data) {
        if (data == null) {
            return position;
        }
        //图片高度根据屏幕宽度适配
        RelativeLayout.LayoutParams topbgParams = (RelativeLayout.LayoutParams) ivtopbg.getLayoutParams();
        topbgParams.height = ScreenUtils.getScreenSize(getFragmentActivity(), true) * 250 / 375;
        ivtopbg.setLayoutParams(topbgParams);

        //设置返回按钮距离顶部距离
        RelativeLayout.LayoutParams backParams = (RelativeLayout.LayoutParams) ivback.getLayoutParams();
        //状态栏高度+10
        backParams.setMargins(0, (int) (StatusBarCompat.getStatusBarHeight(getFragmentActivity())+ ResUtils.getDimension(R.dimen.rmrb_dp10)),0,0);
        ivback.setLayoutParams(backParams);

        //点击返回监听
        ivback.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getFragmentActivity().finish();
            }
        });

        //添加内容
        if (getFragmentActivity() != null) {
            mColumnFragment = TemplateFragment.newInstance(data);
            getFragmentActivity().getSupportFragmentManager().beginTransaction().add(R.id.rv_content, mColumnFragment).commit();

        }

        return position;
    }



}