| | |
| | | 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; |
| | |
| | | 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(); |
| | | } |
| | | |
| | |
| | | * @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<>(); |