Commit a99a436f969baa96143bed5bba5476d33e04dc9d

Authored by 李攀
1 parent 67ef630e

sync file

Showing 29 changed files with 361 additions and 137 deletions
... ... @@ -25,11 +25,11 @@
25 25 <meta name="viewport" content="width=device-width, initial-scale=1">
26 26 <link rel='shortcut icon' href='favicon.ico' type='image/x-icon'>
27 27 <link rel="stylesheet"
28   - href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
29   - <link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css">
30   - <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
31   - <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
32   - <script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
  28 + href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
  29 + <link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/jquery.dataTables.css">
  30 + <script src="https://code.jquery.com/jquery-3.1.1.js"></script>
  31 + <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.js"></script>
  32 + <script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.js"></script>
33 33
34 34 <link href="custom.css" rel="stylesheet">
35 35
... ...
... ... @@ -11,12 +11,14 @@ import com.gimi.common.cinema.model.QueryType;
11 11 import com.gimi.common.cinema.model.SourceType;
12 12 import com.gimi.common.cinema.utils.LogUtils;
13 13 import com.xgimi.gimicinema.activity.CinemaConfig;
  14 +import com.xgimi.gimicinema.application.FangTangApplication;
14 15
15 16 import java.io.File;
16 17 import java.util.ArrayList;
17 18 import java.util.List;
18 19
19 20 public class NewDBManager {
  21 + private static NewDBManager mNewDBManager;
20 22 private SQLiteDatabase db;
21 23
22 24 public NewDBManager(Context context) {
... ... @@ -26,6 +28,18 @@ public class NewDBManager {
26 28 db = helper.getWritableDatabase();
27 29 }
28 30
  31 + public static NewDBManager getInstance() {
  32 + if (mNewDBManager == null) {
  33 + synchronized (NewDBManager.class) {
  34 + if (mNewDBManager == null) {
  35 + mNewDBManager = new NewDBManager(FangTangApplication.getInstance().getApplicationContext());
  36 + }
  37 + }
  38 + }
  39 + return mNewDBManager;
  40 + }
  41 +
  42 +
29 43 /**
30 44 * 利用事务批量添加本地数据
31 45 *
... ... @@ -770,11 +784,93 @@ public class NewDBManager {
770 784 return persons;
771 785 }
772 786
  787 + /**
  788 + * 获取电影时长数据不正常的数据
  789 + *
  790 + * @return 电影时长数据不正常的数据
  791 + * SELECT path md5 FROM movie_message WHERE movie_length like '%000%' or movie_length = '0' or movie_length isnull
  792 + */
  793 + public ArrayList<LocalMovieMessage> checkWithoutDurationMovies() {
  794 + ArrayList<LocalMovieMessage> withoutDurationMoviesList = new ArrayList<>();
  795 + Cursor cursorWithoutDurationMovies = db.query(NewDBHelper.TABLE_NAME, null,
  796 + "movie_length like '%000%' or movie_length = '0' or movie_length isnull",
  797 + null, null, null, null);
  798 + if (cursorWithoutDurationMovies != null && cursorWithoutDurationMovies.getCount() > 0) {
  799 + readCursor2List(withoutDurationMoviesList, cursorWithoutDurationMovies);
  800 + }
  801 + if (cursorWithoutDurationMovies != null) {
  802 + cursorWithoutDurationMovies.close();
  803 + }
  804 + return withoutDurationMoviesList;
  805 + }
  806 +
  807 + /**
  808 + * 更新电影时长
  809 + */
  810 + public boolean updateMovieDuration(String id, String duration) {
  811 + //UPDATE movie_message SET movie_length = '126' WHERE id = '20529'
  812 + boolean result = true;
  813 + try {
  814 + db.execSQL("UPDATE movie_message SET movie_length = ? WHERE id = ?", new String[]{duration, id});
  815 + LogUtils.i("updateMovieDurationDb", "id:" + id + ",duration:" + duration);
  816 + } catch (Exception e) {
  817 + result = false;
  818 + }
  819 +// db.beginTransaction();
  820 +// boolean result;
  821 +// try {
  822 +// ContentValues contentValues = new ContentValues();
  823 +// contentValues.put(NewDBHelper.MOVIE_LENGTH, duration);
  824 +// db.update(NewDBHelper.TABLE_NAME, contentValues, NewDBHelper.ID + " = ?", new String[]{id});
  825 +// db.setTransactionSuccessful(); // changes get rolled back if this not called
  826 +// result = true;
  827 +// } catch (Exception e) {
  828 +// e.printStackTrace();
  829 +// result = false;
  830 +// } finally {
  831 +// db.endTransaction(); // commit or rollback
  832 +// }
  833 + return result;
  834 + }
  835 +
  836 + /**
  837 + * 更新封面路径
  838 + *
  839 + * @param path 封面Path
  840 + * @param id 数据库主键
  841 + */
  842 + public void updatePosterPath(String path, String id) {
  843 + String sql = "UPDATE " + NewDBHelper.TABLE_NAME + " SET " + NewDBHelper.POSTER_PATH + " = ? WHERE " + NewDBHelper.ID + " = ?";
  844 + try {
  845 + db.execSQL(sql, new String[]{path, id});
  846 + } catch (Exception e) {
  847 + e.printStackTrace();
  848 + }
  849 + }
  850 +
  851 + /**
  852 + * 获取没有封面的电影
  853 + */
  854 + public ArrayList<LocalMovieMessage> checkWithoutPosterMovies() {
  855 + ArrayList<LocalMovieMessage> withoutPosterMoviesList = new ArrayList<>();
  856 + Cursor cursorWithoutPosterMovies = db.query(NewDBHelper.TABLE_NAME, null,
  857 + NewDBHelper.POSTER_PATH + " is null",
  858 + null, null, null, null);
  859 + if (cursorWithoutPosterMovies != null && cursorWithoutPosterMovies.getCount() > 0) {
  860 + readCursor2List(withoutPosterMoviesList, cursorWithoutPosterMovies);
  861 + }
  862 + if (cursorWithoutPosterMovies != null) {
  863 + cursorWithoutPosterMovies.close();
  864 + }
  865 + return withoutPosterMoviesList;
  866 + }
773 867
774 868 /**
775 869 * close database
776 870 */
777 871 public void closeDB() {
778 872 db.close();
  873 + db = null;
  874 + mNewDBManager = null;
779 875 }
780 876 }
... ...
... ... @@ -37,7 +37,7 @@ public class DbUpdateUtils {
37 37 */
38 38 public DbUpdateUtils(Context context) {
39 39 this.context = context;
40   - dbManager = new NewDBManager(context);
  40 + dbManager = NewDBManager.getInstance();
41 41 SharedPreferences sharedPreferences = context.getSharedPreferences(Constant.XML_NAME, Context.MODE_PRIVATE);
42 42 sambaMsg = Utils.getSambaMsg(sharedPreferences);
43 43 folder = sambaMsg.getFolder();
... ...
... ... @@ -20,7 +20,6 @@ import android.content.SharedPreferences;
20 20 import android.os.Handler;
21 21 import android.os.Message;
22 22 import android.widget.Toast;
23   -
24 23 import com.gimi.common.cinema.model.Constant;
25 24 import com.gimi.common.cinema.model.SambaMsg;
26 25 import com.xgimi.gimicinema.BuildConfig;
... ... @@ -31,6 +30,7 @@ import java.io.FileInputStream;
31 30 import java.io.FileOutputStream;
32 31 import java.io.InputStream;
33 32 import java.lang.ref.WeakReference;
  33 +import java.util.Random;
34 34
35 35
36 36 /**
... ... @@ -44,6 +44,7 @@ public class LocalDataUtils {
44 44 private DbUpdateManger dbUpdateManger;
45 45 private SharedPreferences sharedPreferences;
46 46 private SambaMsg sambaMsg;
  47 + private Handler handler = new Handler();
47 48
48 49 public LocalDataUtils(Context context) {
49 50 this.context = context;
... ... @@ -81,7 +82,7 @@ public class LocalDataUtils {
81 82 @Override
82 83 public void handleMessage(Message msg) {
83 84 super.handleMessage(msg);
84   - LocalDataUtils utils = activity.get();
  85 + final LocalDataUtils utils = activity.get();
85 86 if (utils != null) {
86 87 switch (msg.what) {
87 88 case Constant.DB_INIT_START:
... ... @@ -94,7 +95,15 @@ public class LocalDataUtils {
94 95 case Constant.DB_INIT_SUCCESS:
95 96 utils.toast("本地数据初始化成功" + msg.obj);
96 97 utils.dbUpdateManger.deleteMovieNotExits();
97   - utils.copyFile();
  98 + int delayMillis = ((new Random().nextInt(5) + 2) * 60 + new Random().nextInt(40)) * 1000;
  99 + LogUtils.d("server-db", "copy out in " + delayMillis);
  100 + utils.handler.postDelayed(new Runnable() {
  101 + @Override
  102 + public void run() {
  103 + LogUtils.d("server-db", "do copy");
  104 + utils.copyFile();
  105 + }
  106 + }, delayMillis);
98 107 break;
99 108 case Constant.DB_INIT_FAILURE:
100 109 utils.toast("本地数据初始化失败");//应该不可能
... ...
... ... @@ -4,6 +4,7 @@ import android.content.Context;
4 4 import android.media.MediaPlayer;
5 5 import android.text.TextUtils;
6 6 import android.util.Log;
  7 +
7 8 import com.gimi.common.cinema.model.AsyncCallback;
8 9 import com.gimi.common.cinema.model.FolderItem;
9 10 import com.gimi.common.cinema.model.LocalMovieMessage;
... ... @@ -14,7 +15,9 @@ import com.xgimi.gimicinema.BuildConfig;
14 15 import com.xgimi.gimicinema.R;
15 16 import com.xgimi.gimicinema.activity.CinemaConfig;
16 17
  18 +import java.io.BufferedReader;
17 19 import java.io.File;
  20 +import java.io.FileReader;
18 21 import java.io.IOException;
19 22 import java.util.ArrayList;
20 23 import java.util.Arrays;
... ... @@ -190,7 +193,7 @@ public class LocalMovieScanUtils {
190 193 * @return ArrayList<LocalMovieMessage>
191 194 */
192 195 ArrayList<LocalMovieMessage> getAllLocalMovie(String rootPath, String folder, AsyncCallback<Integer> callback) {
193   - Log.d("scan-time", "start:" + System.currentTimeMillis());
  196 + LogUtils.i("scan-time", "start:" + System.currentTimeMillis());
194 197 ArrayList<String> all = new ArrayList<>();
195 198 File file = new File(rootPath);
196 199 if (file.listFiles() != null) {
... ... @@ -236,7 +239,7 @@ public class LocalMovieScanUtils {
236 239 moviesItems.addAll(getAllType(type.getFolderPath(), callback));
237 240 }
238 241 }
239   - Log.d("scan-time", " end:" + System.currentTimeMillis());
  242 + LogUtils.i("scan-time", " end:" + System.currentTimeMillis());
240 243 return moviesItems;
241 244 }
242 245
... ... @@ -260,8 +263,10 @@ public class LocalMovieScanUtils {
260 263 * @return ArrayList<LocalMovieMessage>
261 264 */
262 265 private ArrayList<LocalMovieMessage> getAllType(String rootPath, AsyncCallback<Integer> callback) {
  266 + long inTime = System.currentTimeMillis();
263 267 ArrayList<LocalMovieMessage> movies = new ArrayList<>();
264 268 if (rootPath.contains("lost+found")) {
  269 + LogUtils.i("scan-time-total", "scan " + rootPath + " size:0" + " total time:" + (System.currentTimeMillis() - inTime));
265 270 return movies;
266 271 }
267 272 if (callback != null) {
... ... @@ -272,11 +277,13 @@ public class LocalMovieScanUtils {
272 277 String[] fileDirs = file.list();
273 278 //遍历
274 279 if (fileDirs == null || fileDirs.length == 0) {
  280 + LogUtils.i("scan-time-total", "scan " + rootPath + " size:0" + " total time:" + (System.currentTimeMillis() - inTime));
275 281 return movies;
276 282 }
277 283 int length = fileDirs.length;
278 284 int coreCount = 4;
279 285 int poolCount = 9;
  286 +// coreCount = fileDirs.length < 100 ? 1 : coreCount;
280 287 ThreadPoolExecutor myExecutor = new ThreadPoolExecutor(coreCount, poolCount,
281 288 200, TimeUnit.SECONDS, new LinkedBlockingDeque<Runnable>());
282 289 List<Future<ArrayList<LocalMovieMessage>>> results = new ArrayList<>();
... ... @@ -295,50 +302,7 @@ public class LocalMovieScanUtils {
295 302 }
296 303 }
297 304 myExecutor.shutdown();
298   -// for (String fileDir : fileDirs) {
299   -// File curFiles = new File(rootPath + fileDir);
300   -// if (curFiles.isDirectory()) {
301   -// if (callback != null) {
302   -// callback.onMessage(fileDir);
303   -// }
304   -// String curPath = curFiles.getAbsoluteFile().toString();
305   -// LocalMovieMessage moviesItem = new LocalMovieMessage();
306   -// String name = NameFilterUtils.getName(fileDir).trim();
307   -// moviesItem.setMovieName(name);
308   -// String allFirstSpell = PinyinUtil.getAllFirstSpell(name);
309   -// String newStr = allFirstSpell.replaceAll("[^\\w,]", "");
310   -//// Log.d("lovely_pinyin", allFirstSpell + ":" + newStr);
311   -// moviesItem.setNamePinyin(newStr);
312   -// String media = getMedia(curPath + "/", mediaExtensions);
313   -// String poster;
314   -// poster = MovieMessageUtils.getLocalMoviePoster(curPath);
315   -// if (TextUtils.isEmpty(poster)) {
316   -// poster = getMediaPicture(curPath + "/", picExtensions);
317   -// }
318   -// if (!TextUtils.isEmpty(poster)) {
319   -// moviesItem.setPosterPath(poster);
320   -// }
321   -// if (!TextUtils.isEmpty(media)) {
322   -// File mFile = new File(media);
323   -//// long length = mFile.length();
324   -// moviesItem.setMd5(MD5Utils.stringMD5(FileHashUtils.getFileHash(media)));
325   -// //read douban id and douban msg,至于name id 信息另外做,没有必要每次更新时都去添加
326   -// try {
327   -// setDoubanMsg(curPath, moviesItem);
328   -// } catch (Exception e) {
329   -// Log.e("otherError", media);
330   -// e.printStackTrace();
331   -// }
332   -// moviesItem.setType(fileDir);
333   -// moviesItem.setPlayPath(media);
334   -// String movieDlTime = String.valueOf(mFile.lastModified());
335   -// moviesItem.setMovieLength(movieDlTime);
336   -// moviesItem.setDlTime(movieDlTime);
337   -// moviesItem.setCount(MovieMessageUtils.getPlayCount(curPath));
338   -// movies.add(moviesItem);
339   -// }
340   -// }
341   -// }
  305 + LogUtils.i("scan-time-total", "scan " + rootPath + " size:" + movies.size() + " total time:" + (System.currentTimeMillis() - inTime));
342 306 return movies;
343 307 }
344 308
... ... @@ -376,7 +340,8 @@ public class LocalMovieScanUtils {
376 340 if (!TextUtils.isEmpty(media)) {
377 341 File mFile = new File(media);
378 342 // long length = mFile.length();
379   - moviesItem.setMd5(MD5Utils.stringMD5(FileHashUtils.getFileHash(media)));
  343 + String md5 = MD5Utils.stringMD5(FileHashUtils.getFileHash(media));
  344 + moviesItem.setMd5(md5);
380 345 //read douban id and douban msg,至于name id 信息另外做,没有必要每次更新时都去添加
381 346 try {
382 347 setDoubanMsg(curPath, moviesItem);
... ... @@ -386,23 +351,52 @@ public class LocalMovieScanUtils {
386 351 }
387 352 moviesItem.setType(fileDir);
388 353 moviesItem.setPlayPath(media);
  354 + String movieLength = readMovieLengthFile(curPath, md5);
  355 + if (movieLength != null) {
  356 + moviesItem.setMovieLength(movieLength);
  357 + }
389 358 String movieDlTime = String.valueOf(mFile.lastModified());
390   - moviesItem.setMovieLength(movieDlTime);
391 359 moviesItem.setDlTime(movieDlTime);
392 360 moviesItem.setCount(MovieMessageUtils.getPlayCount(curPath));
393 361 movies.add(moviesItem);
394   - curPath = null;
395   - name = null;
396   - allFirstSpell = null;
397   - newStr = null;
398   - media = null;
399   - poster = null;
400   - movieDlTime = null;
401 362 }
402 363 }
403 364 }
404 365 return movies;
405 366 }
  367 +
  368 + /**
  369 + * 读取时长文件值
  370 + *
  371 + * @param playPath 路径
  372 + * @param md5 电影MD5
  373 + * @return 时长
  374 + */
  375 + private String readMovieLengthFile(String playPath, String md5) {
  376 +
  377 + File timeFile = new File(playPath, md5);
  378 +
  379 + String timeLength = null;
  380 + if (SambaFileCharge.fileExist(timeFile.getPath())) {
  381 + BufferedReader reader = null;
  382 + try {
  383 + reader = new BufferedReader(new FileReader(timeFile));
  384 + timeLength = reader.readLine();
  385 + } catch (IOException e) {
  386 + e.printStackTrace();
  387 + } finally {
  388 + if (reader != null) {
  389 + try {
  390 + reader.close();
  391 + } catch (IOException e) {
  392 + e.printStackTrace();
  393 + }
  394 + }
  395 +
  396 + }
  397 + }
  398 + return timeLength;
  399 + }
406 400 }
407 401
408 402 /**
... ...
1 1 package com.gimi.common.cinema.utils;
2 2
3   -import com.wugian.ping.PinyinException;
4   -import com.wugian.ping.PinyinHelper;
  3 +import android.text.TextUtils;
  4 +import com.wugian.ping.PinYinHelper1;
5 5
6 6 /**
7 7 * 拼音工具类
... ... @@ -65,14 +65,19 @@ public class PinyinUtil {
65 65 // e.printStackTrace();
66 66 // }
67 67 // return pybf.toString().replaceAll("\\W", "").trim();
68   - String shortPinyin = "";
69   - try {
70   - shortPinyin = PinyinHelper.getShortPinyin(chinese).replaceAll(" ", "");
71   - } catch (PinyinException e) {
72   - e.printStackTrace();
73   - }
  68 +// String shortPinyin = "";
  69 +// try {
  70 +// shortPinyin = PinyinHelper.getShortPinyin(chinese).replaceAll(" ", "");
  71 +// } catch (PinyinException e) {
  72 +// e.printStackTrace();
  73 +// }
74 74
75   - return shortPinyin;
  75 +// return shortPinyin;
  76 + if (TextUtils.isEmpty(chinese)) {
  77 + return "";
  78 + }
  79 + String[] firstHead = PinYinHelper1.getInstance().getFirstHead(chinese);
  80 + return firstHead.length > 0 ? firstHead[0] : "";
76 81 }
77 82
78 83
... ... @@ -83,9 +88,22 @@ public class PinyinUtil {
83 88 * @return 汉语拼音首字母
84 89 */
85 90 public static String getAllFirstSpell(String chinese) {
86   - String shortPinyin = "";
87   - shortPinyin = PinyinHelper.getAllShortPinyin(chinese).replaceAll(" ", "");
88   - return shortPinyin;
  91 + return join(PinYinHelper1.getInstance().getFirstHead(chinese), ",");
  92 +// final String firstHead = PinYinHelper1.getInstance().getFirstHead(chinese);
  93 +// String shortPinyin = "";
  94 +// shortPinyin = PinyinHelper.getAllShortPinyin(chinese).replaceAll(" ", "");
  95 +// return shortPinyin;
  96 + }
  97 +
  98 + private static String join(String[] arr, String flag) {
  99 + StringBuffer strBuff = new StringBuffer();
  100 +
  101 + for (int i = 0, len = arr.length; i < len; i++) {
  102 + strBuff.append(String.valueOf(arr[i]));
  103 + if (i < len - 1) strBuff.append(flag);
  104 + }
  105 +
  106 + return strBuff.toString();
89 107 }
90 108
91 109 // /**
... ...
... ... @@ -31,6 +31,7 @@ import com.gimi.common.cinema.utils.ActivityCollector;
31 31 import com.gimi.common.cinema.utils.CToast;
32 32 import com.gimi.common.cinema.utils.FileHashUtils;
33 33 import com.gimi.common.cinema.utils.LogUtils;
  34 +import com.gimi.common.cinema.utils.MD5Utils;
34 35 import com.gimi.common.cinema.utils.OpenMMUtils;
35 36 import com.gimi.common.cinema.utils.ResUtils;
36 37 import com.gimi.common.cinema.utils.SambaFileCharge;
... ... @@ -238,12 +239,14 @@ public class SmartControlService extends BaseService implements EventListener<St
238 239 public void writeFailure(String error) {
239 240 LogUtils.i("room-info", "open failure," + error);
240 241 bleBroadcastReceiver.setResponseObj(null);
241   - Toast.makeText(SmartControlService.this, "开门失败," + error, Toast.LENGTH_SHORT).show();
  242 + x Toast.makeText(SmartControlService.this, "开门失败," + error, Toast.LENGTH_SHORT).show();
242 243 }
243 244
244 245 });
  246 +
245 247 if (!TextUtils.isEmpty(lockMac)) {
246 248 String openCMD = "Open the door";
  249 +
247 250 GREENBLE.send(this, lockMac, openCMD.getBytes());
248 251 } /*else {
249 252 if (needReport) {
... ... @@ -326,7 +329,7 @@ public class SmartControlService extends BaseService implements EventListener<St
326 329 Log.e("room-info", "movie not exits");
327 330 break;
328 331 }
329   - if (!roomStatusInfo.getData().getFilm_hash().equals(FileHashUtils.getFileHash(currentPlayUrl))) {
  332 + if (!roomStatusInfo.getData().getFilm_hash().equals(MD5Utils.stringMD5(FileHashUtils.getFileHash(currentPlayUrl)))) {
330 333 //当前播放电影信息不正确正在重新拉取
331 334 show("当前播放电影信息不正确正在重新拉取");
332 335 try {
... ...
... ... @@ -24,15 +24,15 @@ import com.gimi.common.cinema.utils.Utils;
24 24 import com.google.gson.Gson;
25 25 import com.google.gson.JsonSyntaxException;
26 26 import com.qnbar.smc.model.Lights;
27   -import com.qnbar.smc.socketProtocol.MainRequest;
28   -import com.qnbar.smc.socketProtocol.MainResponse;
29   -import com.qnbar.smc.socketProtocol.fromServer.EquipmentControl;
30   -import com.qnbar.smc.socketProtocol.fromServer.OpenDoor;
31   -import com.qnbar.smc.socketProtocol.fromServer.ReportEquStatus;
32   -import com.qnbar.smc.socketProtocol.fromServer.VerifyCode;
33   -import com.qnbar.smc.socketProtocol.toServer.EquipmentStatus;
34   -import com.qnbar.smc.socketProtocol.toServer.Heartbeat;
35   -import com.qnbar.smc.socketProtocol.toServer.SocketSendMsg;
  27 +import com.qnbar.smc.socket_protocol.MainRequest;
  28 +import com.qnbar.smc.socket_protocol.MainResponse;
  29 +import com.qnbar.smc.socket_protocol.from_server.EquipmentControl;
  30 +import com.qnbar.smc.socket_protocol.from_server.OpenDoor;
  31 +import com.qnbar.smc.socket_protocol.from_server.ReportEquStatus;
  32 +import com.qnbar.smc.socket_protocol.from_server.VerifyCode;
  33 +import com.qnbar.smc.socket_protocol.to_server.EquipmentStatus;
  34 +import com.qnbar.smc.socket_protocol.to_server.Heartbeat;
  35 +import com.qnbar.smc.socket_protocol.to_server.SocketSendMsg;
36 36 import com.qnbar.smc.utils.LightOperationUtils;
37 37 import com.telink.bluetooth.light.ConnectionStatus;
38 38 import com.telink.bluetooth.light.DeviceInfo;
... ...
1   -package com.qnbar.smc.socketProtocol;
  1 +package com.qnbar.smc.socket_protocol;
2 2
3 3 public abstract class DataInfo {}
... ...
1   -package com.qnbar.smc.socketProtocol;
  1 +package com.qnbar.smc.socket_protocol;
2 2
3 3 public class MainRequest {
4 4 private int cmd;
... ...
1   -package com.qnbar.smc.socketProtocol;
  1 +package com.qnbar.smc.socket_protocol;
2 2
3 3 public class MainResponse {
4 4 private int code;
... ...
1   -package com.qnbar.smc.socketProtocol.fromServer;
  1 +package com.qnbar.smc.socket_protocol.from_server;
2 2
3 3 /**
4 4 * Created by jinyan.yi on 2017/5/23.
... ...
1   -package com.qnbar.smc.socketProtocol.fromServer;
  1 +package com.qnbar.smc.socket_protocol.from_server;
2 2
3 3 /**
4 4 * Created by jinyan.yi on 2017/5/23.
... ...
1   -package com.qnbar.smc.socketProtocol.fromServer;
  1 +package com.qnbar.smc.socket_protocol.from_server;
2 2
3 3 /**
4 4 * Created by jinyan.yi on 2017/5/23.
... ...
1   -package com.qnbar.smc.socketProtocol.fromServer;
  1 +package com.qnbar.smc.socket_protocol.from_server;
2 2
3 3 /**
4 4 * Created by jinyan.yi on 2017/6/2.
... ...
1   -package com.qnbar.smc.socketProtocol.toServer;
  1 +package com.qnbar.smc.socket_protocol.to_server;
2 2
3   -import com.qnbar.smc.socketProtocol.DataInfo;
  3 +import com.qnbar.smc.socket_protocol.DataInfo;
4 4
5 5 /**
6 6 * Created by jinyan.yi on 2017/5/23.
... ...
1   -package com.qnbar.smc.socketProtocol.toServer;
  1 +package com.qnbar.smc.socket_protocol.to_server;
2 2
3   -import com.qnbar.smc.socketProtocol.DataInfo;
  3 +import com.qnbar.smc.socket_protocol.DataInfo;
4 4
5 5 public class Heartbeat extends DataInfo {
6 6 private int lightStatus;
... ...
1   -package com.qnbar.smc.socketProtocol.toServer;
  1 +package com.qnbar.smc.socket_protocol.to_server;
2 2
3 3 /**
4 4 * Created by wugian on 2017/3/29
... ...
... ... @@ -94,6 +94,9 @@ public class AddCActivity extends Activity {
94 94 String rootPath = sambaMsg.getLocalPath();
95 95 for (EditText aSelf : self) {
96 96 String trim = aSelf.getText().toString().trim();
  97 + if (TextUtils.isEmpty(trim)) {
  98 + continue;
  99 + }
97 100 String firstSpell = PinyinUtil.getFirstSpell(trim).toUpperCase();
98 101 File file = new File(rootPath + firstSpell);
99 102 if (!file.exists()) {
... ...
... ... @@ -155,8 +155,6 @@ public class MovieDetailMsgActivity extends BaseActivity
155 155 Log.d("lovely", "╟ onSaveInstanceState");
156 156 outState.putString("douban_id", doubanId);
157 157 outState.putString("movie-item", new Gson().toJson(movieItem));
158   - doubanId = getIntent().getStringExtra("movie-douban-id");
159   - movieItem = (LocalMovieMessage) getIntent().getSerializableExtra("movie-item");
160 158 }
161 159
162 160 @Override
... ...
... ... @@ -29,17 +29,6 @@ public class QrCodeShowActivity extends Activity implements IUpdateQrCodeView {
29 29 public static final int KILL_SELF = 0x9983;
30 30 private Handler handler = new Handler();
31 31 private QrCodeShowPresent present;
32   -// Runnable r = new Runnable() {
33   -// @Override
34   -// public void run() {
35   -// closeSystem();
36   -// }
37   -// };
38   -
39   -// private void closeSystem() {
40   -//
41   -// }
42   -
43 32 private String orderSn;
44 33 private String roomSn;
45 34 private ImageView iv;
... ...
1 1 package com.xgimi.gimicinema.activity;
2 2
3   -import android.content.Context;
4   -import android.media.AudioManager;
5 3 import android.media.MediaPlayer;
6 4 import android.net.Uri;
7 5 import android.os.Bundle;
... ... @@ -33,7 +31,7 @@ public class SimpleAdsPlayer2 extends BaseActivity implements IUpdateQrCodeView
33 31 public String playUrl;
34 32 private String roomSn;
35 33 private String orderSn;
36   - private AudioManager audioManager;
  34 + // private AudioManager audioManager;
37 35 private boolean fromService;
38 36 private long startAdsTime = 0;
39 37 private int streamVolume;
... ... @@ -51,11 +49,11 @@ public class SimpleAdsPlayer2 extends BaseActivity implements IUpdateQrCodeView
51 49 protected void onCreate(Bundle savedInstanceState) {
52 50 super.onCreate(savedInstanceState);
53 51 setContentView(R.layout.a_ads_player2);
54   - audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
55   - streamVolume = audioManager.getStreamVolume(AudioManager.STREAM_SYSTEM);
56   - if (audioManager != null) {
57   - audioManager.setStreamVolume(AudioManager.STREAM_SYSTEM, 20, 0);
58   - }
  52 +// audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
  53 +// streamVolume = audioManager.getStreamVolume(AudioManager.STREAM_SYSTEM);
  54 +// if (audioManager != null) {
  55 +// audioManager.setStreamVolume(AudioManager.STREAM_SYSTEM, 20, 0);
  56 +// }
59 57 startAdsTime = System.currentTimeMillis();
60 58 Constant.isAdsOn = true;
61 59 videoView = (VideoView) findViewById(R.id.videoView);
... ... @@ -112,10 +110,10 @@ public class SimpleAdsPlayer2 extends BaseActivity implements IUpdateQrCodeView
112 110 handler.removeCallbacks(null);
113 111 handler.removeCallbacksAndMessages(null);
114 112 }
115   - if (audioManager != null) {
116   - audioManager.setStreamVolume(AudioManager.STREAM_SYSTEM, streamVolume, 0);
117   - audioManager = null;
118   - }
  113 +// if (audioManager != null) {
  114 +// audioManager.setStreamVolume(AudioManager.STREAM_SYSTEM, streamVolume, 0);
  115 +// audioManager = null;
  116 +// }
119 117 handler = null;
120 118 playUrl = null;
121 119 videoView = null;
... ...
... ... @@ -19,13 +19,16 @@ package com.xgimi.gimicinema.activity;
19 19 import android.content.Context;
20 20 import android.content.Intent;
21 21 import android.os.Bundle;
  22 +import android.util.Log;
22 23 import android.view.View;
23 24 import android.widget.ImageView;
24 25 import android.widget.TextView;
25 26 import android.widget.Toast;
  27 +import com.bumptech.glide.Glide;
26 28 import com.gimi.common.cinema.model.Constant;
27 29 import com.gimi.common.cinema.utils.LeeImageLoader;
28 30 import com.xgimi.gimicinema.R;
  31 +import com.xgimi.gimicinema.model.ThreadUtils;
29 32 import com.xgimi.gimicinema.mview.IStartView;
30 33 import com.xgimi.gimicinema.presenter.StartPresenter;
31 34
... ... @@ -107,4 +110,18 @@ public class StartActivity extends BaseActivity implements Runnable, IStartView
107 110 public void showMsg(String msg) {
108 111 Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
109 112 }
  113 + @Override
  114 + protected void onDestroy() {
  115 + super.onDestroy();
  116 + Log.d("CheckAdVedio", "destroy");
  117 + Glide.get(context).clearMemory();
  118 + ThreadUtils.subThread(new ThreadUtils.DoSomeThing() {
  119 + @Override
  120 + public void doSomeThing() {
  121 + Glide.get(context).clearDiskCache();
  122 + }
  123 + });
  124 + System.gc();
  125 + System.runFinalization();
  126 + }
110 127 }
... ...
... ... @@ -53,7 +53,7 @@ public class M1905MovieDetailActivity1 extends BaseActivity {
53 53 private NewDBManager dbManager;
54 54
55 55 private void assignViews() {
56   - dbManager = new NewDBManager(context);
  56 + dbManager = NewDBManager.getInstance();
57 57 movieNameTv = (TextView) findViewById(R.id.movieName_tv);
58 58 moviePosterIv = (ImageView) findViewById(R.id.moviePoster_iv);
59 59 directorNameTv = (TextView) findViewById(R.id.directorName_tv);
... ...
... ... @@ -53,7 +53,7 @@ public class DBUpdateModelImpl implements IDBUpdateModel {
53 53 @Override
54 54 public void updateMovieCount(Context context, LocalMovieMessage lmm) {
55 55 if (dbManager == null) {
56   - dbManager = new NewDBManager(context);
  56 + dbManager = NewDBManager.getInstance();
57 57 }
58 58 dbManager.updateMovieCount(lmm);
59 59 }
... ... @@ -61,7 +61,7 @@ public class DBUpdateModelImpl implements IDBUpdateModel {
61 61 @Override
62 62 public void updatePlayTime(Context context, LocalMovieMessage lmm) {
63 63 if (dbManager == null) {
64   - dbManager = new NewDBManager(context);
  64 + dbManager = NewDBManager.getInstance();
65 65 }
66 66 dbManager.updatePlayTime(lmm);
67 67 }
... ... @@ -70,7 +70,7 @@ public class DBUpdateModelImpl implements IDBUpdateModel {
70 70 public void insertAll(final Context context, final ArrayList<LocalMovieMessage> all,
71 71 final OnInsertDbListener l) {
72 72 if (dbManager == null) {
73   - dbManager = new NewDBManager(context);
  73 + dbManager = NewDBManager.getInstance();
74 74 }
75 75 ThreadUtils.subThread(new ThreadUtils.DoSomeThing() {
76 76 @Override
... ... @@ -114,7 +114,7 @@ public class DBUpdateModelImpl implements IDBUpdateModel {
114 114 return;
115 115 }
116 116 if (dbManager == null) {
117   - dbManager = new NewDBManager(context);
  117 + dbManager = NewDBManager.getInstance();
118 118 }
119 119 ThreadUtils.subThread(new ThreadUtils.DoSomeThing() {
120 120 @Override
... ...
... ... @@ -77,9 +77,9 @@ public class MainModelImpl implements IMainModel {
77 77
78 78 @Override
79 79 public void loadRecommend(Context ctx, final OnMainRecommendListener listener) {
80   -// if (dbManager == null) {
81   - dbManager = new NewDBManager(ctx);
82   -// }
  80 + if (dbManager == null) {
  81 + dbManager = NewDBManager.getInstance();
  82 + }
83 83 ThreadUtils.subThread(new ThreadUtils.DoSomeThing() {
84 84 @Override
85 85 public void doSomeThing() {
... ...
... ... @@ -60,7 +60,7 @@ public class MovieListModelImpl implements IMovieListModel {
60 60 public void getMovieList(Context ctx, final String keyword, final QueryType queryType,
61 61 final OnGetMovieListListener listener) {
62 62 if (dbManager == null) {
63   - dbManager = new NewDBManager(ctx);
  63 + dbManager = NewDBManager.getInstance();
64 64 }
65 65 if (sharedPreferences == null) {
66 66 sharedPreferences = ctx.getSharedPreferences(Constant.XML_NAME,
... ... @@ -113,7 +113,7 @@ public class MovieListModelImpl implements IMovieListModel {
113 113 @Override
114 114 public void getPlayRecord(Context ctx, final OnGetMovieListListener listener) {
115 115 if (dbManager == null) {
116   - dbManager = new NewDBManager(ctx);
  116 + dbManager = NewDBManager.getInstance();
117 117 }
118 118
119 119 ThreadUtils.subThread(new ThreadUtils.DoSomeThing() {
... ... @@ -153,7 +153,7 @@ public class MovieListModelImpl implements IMovieListModel {
153 153 @Override
154 154 public void getSearchRecommend(Context ctx, final OnGetMovieListListener l) {
155 155 if (dbManager == null) {
156   - dbManager = new NewDBManager(ctx);
  156 + dbManager = NewDBManager.getInstance();
157 157 }
158 158 ThreadUtils.subThread(new ThreadUtils.DoSomeThing() {
159 159 @Override
... ... @@ -172,7 +172,7 @@ public class MovieListModelImpl implements IMovieListModel {
172 172 @Override
173 173 public void clear() {
174 174 if (dbManager != null) {
175   - dbManager.closeDB();
  175 +// dbManager.closeDB();
176 176 dbManager = null;
177 177 }
178 178 }
... ...
... ... @@ -18,7 +18,7 @@ package com.xgimi.gimicinema.presenter;
18 18 import android.content.Context;
19 19 import android.content.Intent;
20 20 import android.net.Uri;
21   -
  21 +import com.gimi.common.cinema.db.NewDBManager;
22 22 import com.gimi.common.cinema.model.Constant;
23 23 import com.gimi.common.cinema.model.LocalMovieMessage;
24 24 import com.gimi.common.cinema.model.SambaMsg;
... ... @@ -225,6 +225,7 @@ public class SettingPresenter extends BasePresenter
225 225 view.enableCopy(true);
226 226 if (copyIn) {
227 227 view.showMessage("更新本地数据库成功");
  228 + NewDBManager.getInstance().closeDB();
228 229 } else {
229 230 view.showMessage("数据库已考出");
230 231 }
... ...
  1 +package com.wugian.ping;
  2 +
  3 +import java.util.ArrayList;
  4 +import java.util.List;
  5 +import java.util.Map;
  6 +import java.util.regex.Pattern;
  7 +
  8 +/**
  9 + * Created by wugian on 2017/9/16.
  10 + */
  11 +
  12 +public class PinYinHelper1 {
  13 + private static PinYinHelper1 helper;
  14 + private Map<String, String> pinyinTable;
  15 +
  16 + private PinYinHelper1() {
  17 + pinyinTable = PinyinResource.getPinyinResource();
  18 + }
  19 +
  20 + public static PinYinHelper1 getInstance() {
  21 + if (helper == null) {
  22 + helper = new PinYinHelper1();
  23 + }
  24 + return helper;
  25 + }
  26 +
  27 + public String[] getFirstHead(String words) {
  28 +// System.out.println("PYH:getFirstHead()");
  29 + String[] pinYinArray = new String[1];
  30 + for (int i = 0; i < words.length(); i++) {
  31 + String substring = words.substring(i, i + 1);
  32 + if (isNumberOrAlphabet(substring)) {
  33 + for (int index = 0; index < pinYinArray.length; index++) {
  34 + if (pinYinArray[index] != null && !"".equals(pinYinArray[index])) {
  35 + pinYinArray[index] = pinYinArray[index] + substring;
  36 + } else {
  37 + pinYinArray[index] = substring;
  38 + }
  39 + }
  40 + } else {
  41 + String s = pinyinTable.get(substring);
  42 + if (s == null || "".equals(s.trim())) {
  43 + continue;
  44 + }
  45 + String[] tmp = s.split(",");
  46 + for (int tmpIndex = 0; tmpIndex < tmp.length; tmpIndex++) {
  47 + tmp[tmpIndex] = tmp[tmpIndex].substring(0, 1);
  48 + }
  49 + tmp = removeDuplicate(tmp);
  50 +
  51 + int tmpLength = tmp.length;
  52 + if (tmpLength > 1) {
  53 + String[] big = new String[pinYinArray.length + (tmpLength - 1) * pinYinArray.length];
  54 + for (int i1 = 0; i1 < tmpLength; i1++) {
  55 + System.arraycopy(pinYinArray, 0, big, pinYinArray.length * i1, pinYinArray.length);
  56 + }
  57 + pinYinArray = big;
  58 + }
  59 + for (int j = 0; j < pinYinArray.length; j++) {
  60 + if (pinYinArray[j] != null && !"".equals(pinYinArray[j])) {
  61 + pinYinArray[j] = pinYinArray[j] + tmp[(j * tmpLength) / pinYinArray.length];
  62 + } else {
  63 + pinYinArray[j] = tmp[(j * tmpLength) / pinYinArray.length];
  64 + }
  65 + }
  66 + }
  67 + }
  68 +// String s = Arrays.toString(pinYinArray);
  69 +// System.out.println("PYH:result is " + s);
  70 + return pinYinArray;
  71 + }
  72 +
  73 + private boolean isNumberOrAlphabet(String str) {
  74 + Pattern pattern = Pattern.compile("^[A-Za-z0-9]+$");
  75 + return pattern.matcher(str).matches();
  76 + }
  77 +
  78 + private String[] removeDuplicate(String[] array) {
  79 + List<String> list = new ArrayList<String>();
  80 + list.add(array[0]);
  81 + for (int i = 1; i < array.length; i++) {
  82 + if (!list.toString().contains(array[i])) {
  83 + list.add(array[i]);
  84 + }
  85 + }
  86 + return list.toArray(new String[list.size()]);
  87 + }
  88 +
  89 + public static void main(String[] args) {
  90 +// getFirstHead("中国人民is one a bc de test");
  91 + String aa = "test abc";
  92 +// aa = "b";
  93 + System.out.println(aa.substring(0, 1));
  94 +
  95 + }
  96 +
  97 +
  98 +}
... ...
Please register or login to post a comment