| | |
| | | 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;// 广告商城,获取图标状态信息 |
| | | |
| | |
| | | |
| | | 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); |
| | | |
| | | |
| | |
| | | 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(); |
| | |
| | | .setChecked(true); |
| | | } |
| | | }); |
| | | setRightTopAD(); |
| | | preLoadCommonAD(); |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | 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 |
| | |
| | | } |
| | | |
| | | |
| | | //-------------------------视频广告结束----------------------------- |
| | | |
| | | 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"); |
| | |
| | | @Override |
| | | public void onResume() { |
| | | super.onResume(); |
| | | setRightTopAD(); |
| | | isLogin = StringUtils.isEmpty(preferences.getString("LoginUid", "")) ? false |
| | | : true; |
| | | |
| | |
| | | openMsg(); |
| | | break; |
| | | |
| | | case R.id.fl_category: |
| | | startActivity(new Intent(this, CategoryActivity.class)); |
| | | break; |
| | | |
| | | |
| | | } |
| | | } |