admin
2021-12-22 0a1336cd2b95126d66d6f3126cb48a446cdbfad1
app/src/com/hanju/video/app/ui/main/MineFragment.java
@@ -15,11 +15,13 @@
import android.widget.TextView;
import android.widget.Toast;
import com.androidquery.AQuery;
import com.bumptech.glide.Glide;
import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.hanju.video.app.util.JsonUtil;
import com.hanju.video.app.util.http.BasicTextHttpResponseHandler;
import com.hanju.video.app.util.http.HttpApiUtil;
import com.hanju.video.app.database.HanJuSQLiteOpenHelper;
@@ -50,6 +52,8 @@
import com.hanju.video.app.ui.mine.WatchHistoryActivity;
import com.hanju.video.app.ui.recommend.SearchActivity;
import com.hanju.video.app.util.ui.GlideCircleTransform;
import com.video.youth.ui.YouthActivity;
import com.video.youth.util.YouthUtil;
import org.apache.http.Header;
import org.json.JSONObject;
@@ -91,6 +95,8 @@
    private RecyclerView rv_watch_history;
    private AQuery mAquery;
    List<WatchHistoryMineAdapter.MineWatchHistoryVideoInfo> historyList = new ArrayList<>();
    public static MineFragment newInstance() {
@@ -111,7 +117,7 @@
    @Override
    public void onCreateView(View contentView, Bundle savedInstanceState) {
        mAquery = new AQuery(contentView);
        tv_no_network = contentView.findViewById(R.id.tv_no_network);
        rv_watch_history = contentView.findViewById(R.id.rv_watch_history);
        tv_no_network.setOnClickListener(this);
@@ -145,6 +151,8 @@
        contentView.findViewById(R.id.ll_mine_follow).setOnClickListener(this);
        contentView.findViewById(R.id.ll_mine_save).setOnClickListener(this);
        contentView.findViewById(R.id.tv_mine_watch_history).setOnClickListener(this);
        contentView.findViewById(R.id.ll_youth).setOnClickListener(this);
        tv_mine_favourite = contentView.findViewById(R.id.tv_mine_favourite);
        tv_mine_follow = contentView.findViewById(R.id.tv_mine_follow);
@@ -209,6 +217,10 @@
                break;
            case R.id.ll_mine_advice://建议
                startActivity(new Intent(getContext(), BrowserActivity.class).putExtra("title", "意见反馈").putExtra("url", "https://support.qq.com/embed/phone/343178/new-post/"));
                break;
            case R.id.ll_youth://青少年模式
                startActivity(new Intent(getContext(), YouthActivity.class));
                break;
        }
    }
@@ -313,7 +325,6 @@
            initLoginInfo();
        }
        mChangeHelper.registerReceiver();
        MobclickAgent.onPageStart("主页面—我的");
        historyList.clear();
        List<WatchHistoryMineAdapter.MineWatchHistoryVideoInfo> list = new ArrayList<>();
@@ -363,6 +374,17 @@
            });
        }
        if (YouthUtil.isOpenYouthMode(getContext())) {
            mAquery.id(R.id.ll_video_mine).visibility(View.GONE);
            mAquery.id(R.id.fl_history).visibility(View.GONE);
            mAquery.id(R.id.rv_watch_history).visibility(View.GONE);
        } else {
            mAquery.id(R.id.ll_video_mine).visibility(View.VISIBLE);
            mAquery.id(R.id.fl_history).visibility(View.VISIBLE);
            mAquery.id(R.id.rv_watch_history).visibility(View.VISIBLE);
        }
    }
    private void getUserVideoDataCount() {
@@ -385,7 +407,6 @@
    public void onPause() {
        super.onPause();
        mChangeHelper.unregisterReceiver();
        MobclickAgent.onPageEnd("主页面—我的");
    }
    @Override
@@ -407,8 +428,7 @@
    private List<WatchHistoryMineAdapter.MineWatchHistoryVideoInfo> getWatchHistory() throws Exception {
        List<WatchHistoryMineAdapter.MineWatchHistoryVideoInfo> videoInfoList = new ArrayList<>();
        Gson gson = new GsonBuilder().setFieldNamingPolicy(
                FieldNamingPolicy.UPPER_CAMEL_CASE).create();
        SQLiteDatabase database = new HanJuSQLiteOpenHelper(getContext()).getReadableDatabase();
        Cursor cursor = database.query(WatchHistoryTable.TABLE_NAME, new String[]{WatchHistoryTable._ID, WatchHistoryTable.VIDEO_ID, WatchHistoryTable.VIDEO_DETAIL_ID, WatchHistoryTable.VIDEO_DETAIL}, null, null, null, null, WatchHistoryTable.UPDATE_TIME + " DESC");
        cursor.moveToFirst();
@@ -421,7 +441,7 @@
                    .getColumnIndex(WatchHistoryTable.VIDEO_DETAIL_ID));
            String videoInfoStr = cursor.getString(cursor
                    .getColumnIndexOrThrow(WatchHistoryTable.VIDEO_DETAIL));
            VideoInfo videoInfo = gson.fromJson(videoInfoStr, new TypeToken<VideoInfo>() {
            VideoInfo videoInfo =  JsonUtil.videoGson.fromJson(videoInfoStr, new TypeToken<VideoInfo>() {
            }.getType());
            String[] types = new String[]{"150", "151", "152", "153"};
            if (videoInfo.getVideoType() != null && Arrays.asList(types).contains(videoInfo.getVideoType().getId())) {