MovieMessageUtils.java
2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package com.gimi.common.cinema.utils;
import com.gimi.common.cinema.model.Constant;
import com.gimi.common.cinema.model.MovieMessage;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import java.io.File;
import java.io.IOException;
/**
* Created by wugian on 2016/4/27
*/
public class MovieMessageUtils {
public static final String TAG = MovieMessageUtils.class.getName();
public static MovieMessage getLocalMovieMessage(String localMoviePath) {
MovieMessage movieMessage = null;
File qntFile = new File(localMoviePath + Constant.MOVIE_MESSAGE_NAME_NEW);
File txtFile = new File(localMoviePath + Constant.MOVIE_MESSAGE_NAME_OLD);
if (qntFile.exists()) {
String mm = FileReadUtils.readDate(qntFile.getAbsolutePath());
try {
movieMessage = new Gson().fromJson(mm, MovieMessage.class);
} catch (JsonSyntaxException e) {
e.printStackTrace();
}
} else {
if (txtFile.exists()) {
String mm = FileReadUtils.readDate(txtFile.getAbsolutePath());
try {
movieMessage = new Gson().fromJson(mm, MovieMessage.class);
} catch (JsonSyntaxException e) {
e.printStackTrace();
}
}
}
return movieMessage;
}
public static String getLocalMoviePoster(String localMoviePath) {
// String gif = localMoviePath + Constant.MOVIE_POSTER_GIF;
String qnj = localMoviePath + Constant.MOVIE_POSTER_NEW;
String jpg = localMoviePath + Constant.MOVIE_POSTER_OLD;
/* if (SambaFileCharge.fileExist(gif)) {
return gif;
} else */if (SambaFileCharge.fileExist(qnj)) {
return qnj;
} else if (SambaFileCharge.fileExist(jpg)) {
return jpg;
} else {
return null;
}
}
public static int getPlayCount(String localMoviePath) {
int count = 0;
String path = localMoviePath + Constant.MOVIE_COUNT;
if (SambaFileCharge.fileExist(path)) {
count = FileReadUtils.readCount(path);
}
return count;
}
public static void writePlayCount(String localMoviePath, int count) {
String path = localMoviePath + Constant.MOVIE_COUNT;
if (SambaFileCharge.fileExist(path)) {
FileReadUtils.writeDate(path, "" + count);
} else {
try {
boolean newFile = new File(path).createNewFile();
if (newFile) {
FileReadUtils.writeDate(path, "" + count);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}