admin
2021-12-21 fd0097a37e24c771d5ad271135e48e8f52e325e0
BuWanVideo/src/com/weikou/beibeivideo/util/VideoUtil.java
@@ -4,6 +4,7 @@
import android.content.SharedPreferences;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.lcjian.library.util.common.StringUtils;
import com.weikou.beibeivideo.entity.VideoDetailInfo;
@@ -56,7 +57,10 @@
    private static void saveTempVideoDetailList(Context context, List<VideoDetailInfo> detailInfos) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("videoTempInfo", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putString("videoDetailInfoList", new Gson().toJson(detailInfos));
      Gson gson=  new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
        editor.putString("videoDetailInfoList", gson.toJson(detailInfos));
        editor.commit();
    }
@@ -68,10 +72,11 @@
     * @return
     */
    private static List<VideoDetailInfo> getTempVideoDetailList(Context context) {
        Gson gson=  new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
        SharedPreferences sharedPreferences = context.getSharedPreferences("videoTempInfo", Context.MODE_PRIVATE);
        String content = sharedPreferences.getString("videoDetailInfoList", "");
        if (!StringUtils.isEmpty(content)) {
            return new Gson().fromJson(content, new TypeToken<List<VideoDetailInfo>>() {
            return gson.fromJson(content, new TypeToken<List<VideoDetailInfo>>() {
            }.getType());
        }
        return new ArrayList<>();