Commit 5b8e9b48575c1c78bf274313aa85f8c0274cba5a

Authored by wugian
1 parent 398e2889

movie len ,qr code not back problems

@@ -4,7 +4,6 @@ import android.annotation.SuppressLint; @@ -4,7 +4,6 @@ import android.annotation.SuppressLint;
4 import android.content.Context; 4 import android.content.Context;
5 import android.text.TextUtils; 5 import android.text.TextUtils;
6 import android.util.Log; 6 import android.util.Log;
7 -  
8 import com.gimi.common.cinema.model.AsyncCallback; 7 import com.gimi.common.cinema.model.AsyncCallback;
9 import com.gimi.common.cinema.model.FolderItem; 8 import com.gimi.common.cinema.model.FolderItem;
10 import com.gimi.common.cinema.model.LocalMovieMessage; 9 import com.gimi.common.cinema.model.LocalMovieMessage;
@@ -17,6 +16,7 @@ import com.xgimi.gimicinema.activity.CinemaConfig; @@ -17,6 +16,7 @@ import com.xgimi.gimicinema.activity.CinemaConfig;
17 16
18 import java.io.File; 17 import java.io.File;
19 import java.util.ArrayList; 18 import java.util.ArrayList;
  19 +import java.util.HashMap;
20 20
21 /** 21 /**
22 * movie scan 22 * movie scan
@@ -25,6 +25,7 @@ import java.util.ArrayList; @@ -25,6 +25,7 @@ import java.util.ArrayList;
25 public class LocalMovieScanUtils { 25 public class LocalMovieScanUtils {
26 private String[] picExtensions; 26 private String[] picExtensions;
27 private String[] mediaExtensions; 27 private String[] mediaExtensions;
  28 +// private ArrayList<SaveMessage> result = new ArrayList<>();
28 29
29 public LocalMovieScanUtils(Context context) { 30 public LocalMovieScanUtils(Context context) {
30 picExtensions = context.getResources().getStringArray(R.array.photo_filter); 31 picExtensions = context.getResources().getStringArray(R.array.photo_filter);
@@ -225,6 +226,7 @@ public class LocalMovieScanUtils { @@ -225,6 +226,7 @@ public class LocalMovieScanUtils {
225 moviesItems.addAll(getAllType(type.getFolderPath(), callback)); 226 moviesItems.addAll(getAllType(type.getFolderPath(), callback));
226 } 227 }
227 } 228 }
  229 +// FileReadUtils.writeDate(rootPath + "/length.txt", new Gson().toJson(result));
228 return moviesItems; 230 return moviesItems;
229 } 231 }
230 232
@@ -268,7 +270,8 @@ public class LocalMovieScanUtils { @@ -268,7 +270,8 @@ public class LocalMovieScanUtils {
268 String curPath = curFiles.getAbsoluteFile().toString(); 270 String curPath = curFiles.getAbsoluteFile().toString();
269 LocalMovieMessage moviesItem = new LocalMovieMessage(); 271 LocalMovieMessage moviesItem = new LocalMovieMessage();
270 String name = NameFilterUtils.getName(fileDir).trim(); 272 String name = NameFilterUtils.getName(fileDir).trim();
271 - moviesItem.setMovieName(name);String allFirstSpell = PinyinUtil.getAllFirstSpell(name); 273 + moviesItem.setMovieName(name);
  274 + String allFirstSpell = PinyinUtil.getAllFirstSpell(name);
272 String newStr = allFirstSpell.replaceAll("[^\\w,]", ""); 275 String newStr = allFirstSpell.replaceAll("[^\\w,]", "");
273 moviesItem.setNamePinyin(newStr); 276 moviesItem.setNamePinyin(newStr);
274 String media = getMedia(curPath + "/", mediaExtensions); 277 String media = getMedia(curPath + "/", mediaExtensions);
@@ -283,7 +286,8 @@ public class LocalMovieScanUtils { @@ -283,7 +286,8 @@ public class LocalMovieScanUtils {
283 if (!TextUtils.isEmpty(media)) { 286 if (!TextUtils.isEmpty(media)) {
284 File mFile = new File(media); 287 File mFile = new File(media);
285 long length = mFile.length(); 288 long length = mFile.length();
286 - moviesItem.setMd5(MD5Utils.stringMD5(FileHashUtils.getFileHash(media))); 289 + String md5 = MD5Utils.stringMD5(FileHashUtils.getFileHash(media));
  290 + moviesItem.setMd5(md5);
287 //read douban id and douban msg,至于name id 信息另外做,没有必要每次更新时都去添加 291 //read douban id and douban msg,至于name id 信息另外做,没有必要每次更新时都去添加
288 try { 292 try {
289 setDoubanMsg(curPath, moviesItem); 293 setDoubanMsg(curPath, moviesItem);
@@ -291,6 +295,12 @@ public class LocalMovieScanUtils { @@ -291,6 +295,12 @@ public class LocalMovieScanUtils {
291 Log.e("otherError", media); 295 Log.e("otherError", media);
292 e.printStackTrace(); 296 e.printStackTrace();
293 } 297 }
  298 +// SaveMessage saveMessage = new SaveMessage();
  299 +// saveMessage.setFile_hash(md5);
  300 +// long movieLength = getMovieLength(media);
  301 +// int len = (int) (movieLength / 60);
  302 +// saveMessage.setLength(len+"");
  303 +// result.add(saveMessage);
294 moviesItem.setType(fileDir); 304 moviesItem.setType(fileDir);
295 moviesItem.setPlayPath(media); 305 moviesItem.setPlayPath(media);
296 String movieDlTime = String.valueOf(mFile.lastModified()); 306 String movieDlTime = String.valueOf(mFile.lastModified());
@@ -303,4 +313,30 @@ public class LocalMovieScanUtils { @@ -303,4 +313,30 @@ public class LocalMovieScanUtils {
303 } 313 }
304 return movies; 314 return movies;
305 } 315 }
  316 +
  317 + private long getMovieLength(String mUri) {
  318 + long l = System.currentTimeMillis();
  319 +
  320 + long duration = 5400000;
  321 + android.media.MediaMetadataRetriever mmr = new android.media.MediaMetadataRetriever();
  322 +
  323 + try {
  324 + if (mUri != null) {
  325 + HashMap<String, String> headers = null;
  326 + if (headers == null) {
  327 + headers = new HashMap<String, String>();
  328 + headers.put("User-Agent", "Mozilla/5.0 (Linux; U; Android 4.4.2; zh-CN; MW-KW-001 Build/JRO03C) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 UCBrowser/1.0.0.001 U4/0.8.0 Mobile Safari/533.1");
  329 + }
  330 + mmr.setDataSource(mUri, headers);
  331 + }
  332 +
  333 + String durationStr = mmr.extractMetadata(android.media.MediaMetadataRetriever.METADATA_KEY_DURATION);
  334 + duration = Long.parseLong(durationStr);
  335 + } catch (Exception ex) {
  336 + } finally {
  337 + mmr.release();
  338 + }
  339 + Log.d("getAllType", "" + (System.currentTimeMillis() - l));
  340 + return duration / 1000;
  341 + }
306 } 342 }
  1 +package com.gimi.common.cinema.utils;
  2 +
  3 +/**
  4 + * Created by wugian on 2017/5/9
  5 + */
  6 +public class SaveMessage {
  7 + private String file_hash;
  8 + private String length;
  9 +
  10 + public String getFile_hash() {
  11 + return file_hash;
  12 + }
  13 +
  14 + public void setFile_hash(String file_hash) {
  15 + this.file_hash = file_hash;
  16 + }
  17 +
  18 + public String getLength() {
  19 + return length;
  20 + }
  21 +
  22 + public void setLength(String length) {
  23 + this.length = length;
  24 + }
  25 +}
@@ -789,6 +789,15 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen @@ -789,6 +789,15 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
789 presenter.jumpToSearch(); 789 presenter.jumpToSearch();
790 // openDoor(); 790 // openDoor();
791 // PollingUtils.startPollingService(this.getApplicationContext(), 60, PollingServiceDemo.class, PollingServiceDemo.ACTION); 791 // PollingUtils.startPollingService(this.getApplicationContext(), 60, PollingServiceDemo.class, PollingServiceDemo.ACTION);
  792 +// ArrayList<SaveMessage> saveMessages = new ArrayList<>();
  793 +// for (LocalMovieMessage localMovieMessage : new NewDBManager(this).query()) {
  794 +// final SaveMessage saveMessage = new SaveMessage();
  795 +// saveMessage.setLength(localMovieMessage.getMovieLength());
  796 +// saveMessage.setFile_hash(localMovieMessage.getMd5());
  797 +// saveMessages.add(saveMessage);
  798 +// }
  799 +// Log.d("save", "" + saveMessages.size());
  800 +// FileReadUtils.writeDate("/mnt/samba/192.168.200.241/root/" + "length.txt", new Gson().toJson(saveMessages));
792 } 801 }
793 802
794 803
@@ -4,9 +4,9 @@ import android.app.Activity; @@ -4,9 +4,9 @@ import android.app.Activity;
4 import android.os.Bundle; 4 import android.os.Bundle;
5 import android.os.Handler; 5 import android.os.Handler;
6 import android.util.Log; 6 import android.util.Log;
  7 +import android.view.KeyEvent;
7 import android.widget.ImageView; 8 import android.widget.ImageView;
8 import android.widget.Toast; 9 import android.widget.Toast;
9 -  
10 import com.gimi.common.cinema.model.MessageEvent; 10 import com.gimi.common.cinema.model.MessageEvent;
11 import com.gimi.common.cinema.utils.QRCodeUtils; 11 import com.gimi.common.cinema.utils.QRCodeUtils;
12 import com.gimi.common.cinema.utils.SystemUtils; 12 import com.gimi.common.cinema.utils.SystemUtils;
@@ -14,7 +14,6 @@ import com.google.zxing.WriterException; @@ -14,7 +14,6 @@ import com.google.zxing.WriterException;
14 import com.qnbar.smc.utils.LightOperationUtils; 14 import com.qnbar.smc.utils.LightOperationUtils;
15 import com.xgimi.gimicinema.R; 15 import com.xgimi.gimicinema.R;
16 import com.xgimi.gimicinema.presenter.QrCodeShowPresent; 16 import com.xgimi.gimicinema.presenter.QrCodeShowPresent;
17 -  
18 import org.greenrobot.eventbus.EventBus; 17 import org.greenrobot.eventbus.EventBus;
19 import org.greenrobot.eventbus.Subscribe; 18 import org.greenrobot.eventbus.Subscribe;
20 import org.greenrobot.eventbus.ThreadMode; 19 import org.greenrobot.eventbus.ThreadMode;
@@ -40,7 +39,7 @@ public class QrCodeShowActivity extends Activity { @@ -40,7 +39,7 @@ public class QrCodeShowActivity extends Activity {
40 super.onCreate(savedInstanceState); 39 super.onCreate(savedInstanceState);
41 setContentView(R.layout.activity_qr_code_show); 40 setContentView(R.layout.activity_qr_code_show);
42 EventBus.getDefault().register(this); 41 EventBus.getDefault().register(this);
43 - 42 + //back press,movie length
44 present = new QrCodeShowPresent(); 43 present = new QrCodeShowPresent();
45 44
46 final String qr = getIntent().getStringExtra("qr"); 45 final String qr = getIntent().getStringExtra("qr");
@@ -48,9 +47,9 @@ public class QrCodeShowActivity extends Activity { @@ -48,9 +47,9 @@ public class QrCodeShowActivity extends Activity {
48 roomSn = getIntent().getStringExtra("room_sn"); 47 roomSn = getIntent().getStringExtra("room_sn");
49 boolean countCall = getIntent().getBooleanExtra("count_call", false); 48 boolean countCall = getIntent().getBooleanExtra("count_call", false);
50 if (countCall) { 49 if (countCall) {
51 - Toast.makeText(this,"你预定的时段已结束,请携带好随身物品,欢迎下次光临",Toast.LENGTH_LONG).show();  
52 - }else{  
53 - Toast.makeText(this,"电影观看完成,请携带好随身物品,欢迎下次光临",Toast.LENGTH_LONG).show(); 50 + Toast.makeText(this, "你预定的时段已结束,请携带好随身物品,欢迎下次光临", Toast.LENGTH_LONG).show();
  51 + } else {
  52 + Toast.makeText(this, "电影观看完成,请携带好随身物品,欢迎下次光临", Toast.LENGTH_LONG).show();
54 } 53 }
55 ImageView iv = (ImageView) findViewById(R.id.qrCodeIv); 54 ImageView iv = (ImageView) findViewById(R.id.qrCodeIv);
56 try { 55 try {
@@ -60,17 +59,16 @@ public class QrCodeShowActivity extends Activity { @@ -60,17 +59,16 @@ public class QrCodeShowActivity extends Activity {
60 } 59 }
61 60
62 handler.postDelayed(r, 20 * 60 * 1000); 61 handler.postDelayed(r, 20 * 60 * 1000);
63 - try {  
64 - new SystemUtils().stopMediaPlayer(QrCodeShowActivity.this.getApplicationContext());  
65 - } catch (Exception e) {  
66 - e.printStackTrace();  
67 - }  
68 -  
69 } 62 }
70 63
71 @Override 64 @Override
72 protected void onDestroy() { 65 protected void onDestroy() {
73 super.onDestroy(); 66 super.onDestroy();
  67 + try {
  68 + new SystemUtils().stopMediaPlayer(QrCodeShowActivity.this.getApplicationContext());
  69 + } catch (Exception e) {
  70 + e.printStackTrace();
  71 + }
74 handler.removeCallbacks(r); 72 handler.removeCallbacks(r);
75 handler.removeCallbacks(null); 73 handler.removeCallbacks(null);
76 EventBus.getDefault().unregister(this); 74 EventBus.getDefault().unregister(this);
@@ -83,6 +81,15 @@ public class QrCodeShowActivity extends Activity { @@ -83,6 +81,15 @@ public class QrCodeShowActivity extends Activity {
83 handler.removeCallbacks(null); 81 handler.removeCallbacks(null);
84 } 82 }
85 83
  84 + @Override
  85 + public boolean onKeyDown(int keyCode, KeyEvent event) {
  86 + if (keyCode == KeyEvent.KEYCODE_BACK) {
  87 + Toast.makeText(this,"请用管理端扫描或者等待清理时间结束",Toast.LENGTH_SHORT).show();
  88 + return true;
  89 + }
  90 + return super.onKeyDown(keyCode, event);
  91 + }
  92 +
86 @Subscribe(threadMode = ThreadMode.MAIN) 93 @Subscribe(threadMode = ThreadMode.MAIN)
87 public void onMoonEvent(MessageEvent messageEvent) { 94 public void onMoonEvent(MessageEvent messageEvent) {
88 switch (messageEvent.getEventId()) { 95 switch (messageEvent.getEventId()) {
Please register or login to post a comment