admin
2021-04-20 e08fb55566539c5b0c489ab6f4b565454e2ae375
BuWanVideo/src/com/weikou/beibeivideo/ui/main/MainActivity.java
@@ -94,13 +94,10 @@
        LoaderManager.LoaderCallbacks<Cursor>, View.OnClickListener {
    private static final String TGA = "MainActivity";
    private ImageView iv_taobao;
    private ImageView iv_red_dot;
    private ProgressDialog pd = null;
    private FrameLayout fl_right_ad;
    private FrameLayout fl_category;
    SharedPreferences preferences;// 广告商城,获取图标状态信息
@@ -139,6 +136,8 @@
        tv_search = findViewById(R.id.tv_activity_main_search);
        fl_category = findViewById(R.id.fl_category);
        iv_msg_dot = findViewById(R.id.iv_msg_dot);
@@ -154,11 +153,8 @@
        findViewById(R.id.ll_activity_main_search).setOnClickListener(this);
        findViewById(R.id.iv_recommend_watch_history).setOnClickListener(this);
        findViewById(R.id.ll_activity_login).setOnClickListener(this);
        // 淘宝联盟
        iv_taobao = findViewById(R.id.nat);
        iv_taobao.setOnClickListener(this);
        iv_red_dot = findViewById(R.id.iv_red_dot);
        fl_right_ad = findViewById(R.id.fl_right_ad);
        findViewById(R.id.fl_category).setOnClickListener(this);
        TopStatusSettings.setStatusViewAndDeepColor(this);
        initialer.run();
@@ -208,7 +204,6 @@
                        .setChecked(true);
            }
        });
        setRightTopAD();
        preLoadCommonAD();
@@ -240,31 +235,6 @@
    }
    private void setRightTopAD() {
        if (preferences == null)
            preferences = getSharedPreferences("user",
                    Context.MODE_PRIVATE);
        String topIcon = preferences.getString("top_icon", "");
        if (!StringUtils.isBlank(topIcon)) {
            fl_right_ad.setVisibility(View.VISIBLE);
            try {
                Glide.with(getApplicationContext()).load(topIcon).into(iv_taobao);
                long time = preferences.getLong("latestAdtime", 0);
                if (!getDay(time).equalsIgnoreCase(
                        getDay(System.currentTimeMillis()))) {
                    iv_red_dot.setVisibility(View.VISIBLE);
                } else {
                    iv_red_dot.setVisibility(View.GONE);
                }
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            }
        } else {
            fl_right_ad.setVisibility(View.GONE);
        }
    }
    //-------------------------视频广告-----------------------------
    @Nullable
@@ -276,28 +246,6 @@
    }
    //-------------------------视频广告结束-----------------------------
    private SimpleTarget<Drawable> target = new SimpleTarget<Drawable>() {
        @Override
        public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
            iv_taobao.setImageDrawable(resource);
            long time = preferences.getLong("latestAdtime", 0);
            if (!getDay(time).equalsIgnoreCase(
                    getDay(System.currentTimeMillis()))) {
                iv_red_dot.setVisibility(View.VISIBLE);
            } else {
                iv_red_dot.setVisibility(View.GONE);
            }
        }
        @Override
        public void onLoadCleared(@Nullable Drawable placeholder) {
        }
    };
    private String getDay(long time) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
@@ -332,7 +280,6 @@
    @Override
    public void onResume() {
        super.onResume();
        setRightTopAD();
        isLogin = StringUtils.isEmpty(preferences.getString("LoginUid", "")) ? false
                : true;
@@ -512,6 +459,10 @@
                openMsg();
                break;
            case R.id.fl_category:
                startActivity(new Intent(this, CategoryActivity.class));
                break;
        }
    }