admin
2021-10-22 92d61ef2698d3822b63e5c921c26e1331380573e
BuWanVideo/src/com/weikou/beibeivideo/ui/main/MineFragment.java
@@ -13,10 +13,14 @@
import androidx.loader.content.CursorLoader;
import androidx.loader.content.Loader;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.webkit.WebChromeClient;
import android.webkit.WebViewClient;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
@@ -43,6 +47,8 @@
import com.umeng.socialize.UMShareAPI;
import com.umeng.socialize.UMShareListener;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.video.youth.ui.YouthActivity;
import com.video.youth.util.YouthUtil;
import com.weikou.beibeivideo.R;
import com.weikou.beibeivideo.db.MessageTable;
import com.weikou.beibeivideo.entity.NewComment;
@@ -70,7 +76,10 @@
import org.greenrobot.eventbus.EventBus;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
 * 原主页--我的-----3.2.4版本后已经放弃此页面
@@ -105,6 +114,8 @@
    private RatioLayout rl_banner;
    private ImageView iv_banner;
    private GridView gv_content;
    /**
     * 用于表示登录状态
     */
@@ -112,7 +123,6 @@
    private LinearLayout ll_mine_favourite, ll_mine_follow, ll_mine_watch_history;
    private RelativeLayout rl_mine_message, rl_mine_share, rl_mine_help, rl_mine_buy_record, rl_mine_about_us, rl_mine_settings;
    private boolean isHaveNewCom;// 是否存在新的评论消息
@@ -162,13 +172,6 @@
        ll_mine_follow = contentView.findViewById(R.id.ll_mine_follow);
        ll_mine_watch_history = contentView.findViewById(R.id.ll_mine_watch_history);
        rl_mine_message = contentView.findViewById(R.id.rl_mine_message);
        rl_mine_share = contentView.findViewById(R.id.rl_mine_share);
        rl_mine_help = contentView.findViewById(R.id.rl_mine_help);
        rl_mine_about_us = contentView.findViewById(R.id.rl_mine_about_us);
        rl_mine_buy_record = contentView.findViewById(R.id.rl_mine_buy_record);
        rl_mine_settings = contentView.findViewById(R.id.rl_mine_settings);
        tv_login = contentView.findViewById(R.id.mine_tv_login);
        tv_name = contentView.findViewById(R.id.mine_tv_name);
@@ -180,20 +183,8 @@
        rl_banner = contentView.findViewById(R.id.rl_banner);
        iv_banner = contentView.findViewById(R.id.iv_banner);
        gv_content = contentView.findViewById(R.id.gv_content);
        mBadgeView = new BadgeView(iv_user_logo.getContext(), rl_mine_message);
        mBadgeView.setBackgroundResource(R.drawable.ic_red_dot);
        mBadgeView.setTextSize(1);
        mBadgeView.setText("");
        mBadgeView.setBadgeMargin(DimenUtils.dipToPixels(20, tv_no_network.getContext()));
        mUpdateBadgeView = new BadgeView(getContext(), rl_mine_settings);
        mUpdateBadgeView.setBackgroundResource(R.drawable.ic_red_dot);
        mUpdateBadgeView.setTextSize(1);
        mUpdateBadgeView.setText("");
        mUpdateBadgeView.setBadgeMargin(DimenUtils.dipToPixels(20,
                tv_no_network.getContext()));
        contentView.findViewById(R.id.mine_rl_head).setOnClickListener(this);
        ll_mine_favourite.setOnClickListener(this);
@@ -201,13 +192,8 @@
        ll_mine_watch_history.setOnClickListener(this);
        mAquery.id(R.id.ll_mine_novel).clicked(this);
        rl_mine_about_us.setOnClickListener(this);
        rl_mine_message.setOnClickListener(this);
        rl_mine_help.setOnClickListener(this);
        rl_mine_settings.setOnClickListener(this);
        rl_mine_share.setOnClickListener(this);
        tv_vip_open.setOnClickListener(this);
        rl_mine_buy_record.setOnClickListener(this);
        getLoaderManager().initLoader(0, null, this);
    }
@@ -224,10 +210,12 @@
        // Swap the new cursor in. (The framework will take care of closing the
        // old cursor once we return.)
        if (data != null && data.getCount() != 0 || (isLogin && isHaveNewCom)) {
            mBadgeView.show();
        } else {
            mBadgeView.hide();
        if (mBadgeView != null) {
            if (data != null && data.getCount() != 0 || (isLogin && isHaveNewCom)) {
                mBadgeView.show();
            } else {
                mBadgeView.hide();
            }
        }
    }
@@ -283,38 +271,6 @@
            //书架
            case R.id.ll_mine_novel:
                break;
            case R.id.rl_mine_message:
                openMsg();
                break;
            case R.id.rl_mine_share:
                new ShareAPPDialog.Builder(getActivity()).create().show();
                break;
            case R.id.rl_mine_help:
                startActivity(new Intent(tv_no_network.getContext(),
                        HelpAndTicklingActivity.class));
                break;
            case R.id.rl_mine_about_us:
                Intent intent1 = new Intent(getContext(), BrowserActivity.class);
                intent1.putExtra("url", BeibeiConstant.ABOUT_US);
                startActivity(intent1);
            break;
            case R.id.rl_mine_buy_record: {
                String url = ConfigUtil.getBuyRecordUrl(getContext());
                if (StringUtils.isEmpty(url))
                    return;
                Intent intent11 = new Intent(getContext(), BrowserActivity.class);
                intent11.putExtra("url", url);
                startActivity(intent11);
            }
            break;
            case R.id.rl_mine_settings:
                startActivity(new Intent(tv_no_network.getContext(), SettingsActivity.class));
                break;
            case R.id.tv_vip_open:
@@ -447,10 +403,12 @@
        mChangeHelper.registerReceiver();
        SharedPreferences preferences2 = tv_no_network.getContext().getSharedPreferences(
                "update", Context.MODE_PRIVATE);
        if (preferences2.getBoolean("status", false)) {
            mUpdateBadgeView.show();
        } else {
            mUpdateBadgeView.hide();
        if (mUpdateBadgeView != null) {
            if (preferences2.getBoolean("status", false)) {
                mUpdateBadgeView.show();
            } else {
                mUpdateBadgeView.hide();
            }
        }
        //填充
        BannerVO bannerVO = ConfigUtil.getMinePageBanner(getContext());
@@ -470,6 +428,18 @@
        getPersonInfo();
        if (YouthUtil.isOpenYouthMode(getContext())) {
            gv_content.setAdapter(new MyAdapter(getYouthFunctions()));
            mAquery.id(R.id.ll_videos).visibility(View.GONE);
            mAquery.id(R.id.ll_vip).visibility(View.GONE);
        } else {
            gv_content.setAdapter(new MyAdapter(getNotYouthFunctions()));
            mAquery.id(R.id.ll_videos).visibility(View.VISIBLE);
            mAquery.id(R.id.ll_vip).visibility(View.VISIBLE);
        }
    }
    @Override
@@ -514,4 +484,153 @@
        });
    }
    class MyAdapter extends BaseAdapter {
        private List<Function> functionList;
        private LayoutInflater inflater;
        public MyAdapter(List<Function> functionList) {
            this.functionList = functionList;
            inflater = LayoutInflater.from(getContext());
        }
        @Override
        public int getCount() {
            return functionList == null ? 0 : functionList.size();
        }
        @Override
        public Object getItem(int i) {
            return functionList.get(i);
        }
        @Override
        public long getItemId(int i) {
            return i;
        }
        @Override
        public View getView(int i, View view, ViewGroup viewGroup) {
            View root = inflater.inflate(R.layout.mine_function, null);
            TextView tv_name = root.findViewById(R.id.tv_name);
            ImageView iv_icon = root.findViewById(R.id.iv_icon);
            RelativeLayout rl_container = root.findViewById(R.id.rl_content);
            final Function function = functionList.get(i);
            if (function.getType() == Function.Type.msg) {
                mBadgeView = new BadgeView(iv_user_logo.getContext(), rl_container);
                mBadgeView.setBackgroundResource(R.drawable.ic_red_dot);
                mBadgeView.setTextSize(1);
                mBadgeView.setText("");
                mBadgeView.setBadgeMargin(DimenUtils.dipToPixels(20, tv_no_network.getContext()));
                mUpdateBadgeView = new BadgeView(getContext(), rl_container);
                mUpdateBadgeView.setBackgroundResource(R.drawable.ic_red_dot);
                mUpdateBadgeView.setTextSize(1);
                mUpdateBadgeView.setText("");
                mUpdateBadgeView.setBadgeMargin(DimenUtils.dipToPixels(20,
                        tv_no_network.getContext()));
            }
            tv_name.setText(function.getName());
            iv_icon.setImageResource(function.getResourceId());
            root.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (function.getType() == Function.Type.msg) {
                        openMsg();
                    } else if (function.getType() == Function.Type.share) {
                        new ShareAPPDialog.Builder(getActivity()).create().show();
                    } else if (function.getType() == Function.Type.help) {
                        startActivity(new Intent(tv_no_network.getContext(),
                                HelpAndTicklingActivity.class));
                    } else if (function.getType() == Function.Type.buy) {
                        String url = ConfigUtil.getBuyRecordUrl(getContext());
                        if (StringUtils.isEmpty(url))
                            return;
                        Intent intent11 = new Intent(getContext(), BrowserActivity.class);
                        intent11.putExtra("url", url);
                        startActivity(intent11);
                    } else if (function.getType() == Function.Type.youth) {
                        Intent intent11 = new Intent(getContext(), YouthActivity.class);
                        startActivity(intent11);
                    } else if (function.getType() == Function.Type.about) {
                        Intent intent1 = new Intent(getContext(), BrowserActivity.class);
                        intent1.putExtra("url", BeibeiConstant.ABOUT_US);
                        startActivity(intent1);
                    } else if (function.getType() == Function.Type.setting) {
                        startActivity(new Intent(tv_no_network.getContext(), SettingsActivity.class));
                    }
                }
            });
            return root;
        }
    }
    private List<Function> getNotYouthFunctions() {
        List<Function> list = new ArrayList<>();
        list.add(new Function(R.drawable.ic_mine_message_w, "站内消息", Function.Type.msg));
        list.add(new Function(R.drawable.ic_mine_share_w, "分享软件", Function.Type.share));
        list.add(new Function(R.drawable.ic_mine_help_w, "帮助中心", Function.Type.help));
        list.add(new Function(R.drawable.icon_mine_buy_record, "购买记录", Function.Type.buy));
        list.add(new Function(R.drawable.icon_mine_youth, "青少年模式", Function.Type.youth));
        list.add(new Function(R.drawable.ic_mine_about_us_w, "关于我们", Function.Type.about));
        list.add(new Function(R.drawable.ic_mine_settings_w, "设置", Function.Type.setting));
        return list;
    }
    private List<Function> getYouthFunctions() {
        List<Function> list = new ArrayList<>();
        list.add(new Function(R.drawable.ic_mine_share_w, "分享软件", Function.Type.share));
        list.add(new Function(R.drawable.ic_mine_help_w, "帮助中心", Function.Type.help));
        list.add(new Function(R.drawable.icon_mine_youth, "青少年模式", Function.Type.youth));
        list.add(new Function(R.drawable.ic_mine_about_us_w, "关于我们", Function.Type.about));
        list.add(new Function(R.drawable.ic_mine_settings_w, "设置", Function.Type.setting));
        return list;
    }
    static class Function {
        enum Type {
            msg, share, help, buy, youth, about, setting
        }
        private int resourceId;
        private String name;
        private Type type;
        public Function(int resourceId, String name, Type type) {
            this.resourceId = resourceId;
            this.name = name;
            this.type = type;
        }
        public int getResourceId() {
            return resourceId;
        }
        public void setResourceId(int resourceId) {
            this.resourceId = resourceId;
        }
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
        public Type getType() {
            return type;
        }
        public void setType(Type type) {
            this.type = type;
        }
    }
}