| | |
| | | package com.weikou.beibeivideo.ui.category; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | | |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.content.SharedPreferences; |
| | | import android.content.pm.ActivityInfo; |
| | | import android.graphics.Bitmap; |
| | | import android.graphics.drawable.Drawable; |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | | import android.support.annotation.NonNull; |
| | | import android.support.annotation.Nullable; |
| | | import android.support.v4.app.Fragment; |
| | | import android.support.v4.app.FragmentActivity; |
| | | import android.support.v4.app.FragmentManager; |
| | |
| | | import android.widget.TextView; |
| | | |
| | | import com.bumptech.glide.Glide; |
| | | import com.bumptech.glide.request.animation.GlideAnimation; |
| | | import com.bumptech.glide.request.target.SimpleTarget; |
| | | import com.bumptech.glide.request.transition.Transition; |
| | | import com.google.gson.FieldNamingPolicy; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | |
| | | import com.weikou.beibeivideo.ui.mine.BrowserActivity; |
| | | import com.weikou.beibeivideo.ui.mine.WatchHistoryActivity; |
| | | import com.weikou.beibeivideo.ui.recommend.SearchActivity; |
| | | import com.yeshi.buwanshequ.R; |
| | | import com.weikou.beibeivideo.R; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | public class MVideosActivity extends FragmentActivity implements |
| | | OnClickListener { |
| | |
| | | |
| | | private TextView tv_top_bar_left; |
| | | |
| | | private ImageView iv_taobao; |
| | | |
| | | private ImageView iv_red_dot; |
| | | |
| | | SharedPreferences preferences;// 广告商城,获取图标状态信息 |
| | | |
| | |
| | | findViewById(R.id.iv_activity_main_search).setOnClickListener(this); |
| | | findViewById(R.id.iv_recommend_watch_history).setOnClickListener(this); |
| | | |
| | | iv_taobao = (ImageView) findViewById(R.id.nat); |
| | | iv_taobao.setOnClickListener(this); |
| | | iv_red_dot = (ImageView) findViewById(R.id.iv_red_dot); |
| | | |
| | | preferences = getSharedPreferences("user", |
| | | Context.MODE_PRIVATE); |
| | | /* |
| | | * 计算状态栏高度并设置 |
| | | */ |
| | | */ |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { |
| | | Window window = getWindow(); |
| | | window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, |
| | |
| | | getVideoList(); |
| | | } |
| | | |
| | | private SimpleTarget<Bitmap> target = new SimpleTarget<Bitmap>() { |
| | | |
| | | @Override |
| | | public void onResourceReady(Bitmap bitmap, |
| | | GlideAnimation<? super Bitmap> arg1) { |
| | | iv_taobao.setImageBitmap(bitmap); |
| | | long time = preferences.getLong("latestAdtime_d", 0); |
| | | if (!getDay(time).equalsIgnoreCase( |
| | | getDay(System.currentTimeMillis()))) { |
| | | iv_red_dot.setVisibility(View.VISIBLE); |
| | | } else { |
| | | iv_red_dot.setVisibility(View.GONE); |
| | | } |
| | | |
| | | } |
| | | |
| | | }; |
| | | |
| | | private String getDay(long time) { |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String date = format.format(new Date(time)); |
| | |
| | | // if (position % mVideoInfos.size() == 0) |
| | | // return CategoryRecommendFragment.newInstance(mVideoInfos.get(position), mVideoType.getId()); |
| | | // else |
| | | return VideosFragment.newInstance(mVideoInfos.get(position)); |
| | | return VideosFragment.newInstance(mVideoInfos.get(position)); |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | protected void onResume() { |
| | | super.onResume(); |
| | | try { |
| | | Glide.with(getApplicationContext()).load(preferences.getString("top_icon", "")) |
| | | .asBitmap().into(target); |
| | | } catch (IllegalArgumentException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | MobclickAgent.onResume(this); |
| | | } |
| | | |
| | | @Override |
| | | protected void onPause() { |
| | | super.onPause(); |
| | | MobclickAgent.onPause(this); |
| | | } |
| | | |
| | | @Override |