Commit 5b8e9b48575c1c78bf274313aa85f8c0274cba5a
1 parent
398e2889
movie len ,qr code not back problems
Showing
4 changed files
with
92 additions
and
15 deletions
| ... | ... | @@ -4,7 +4,6 @@ import android.annotation.SuppressLint; |
| 4 | 4 | import android.content.Context; |
| 5 | 5 | import android.text.TextUtils; |
| 6 | 6 | import android.util.Log; |
| 7 | - | |
| 8 | 7 | import com.gimi.common.cinema.model.AsyncCallback; |
| 9 | 8 | import com.gimi.common.cinema.model.FolderItem; |
| 10 | 9 | import com.gimi.common.cinema.model.LocalMovieMessage; |
| ... | ... | @@ -17,6 +16,7 @@ import com.xgimi.gimicinema.activity.CinemaConfig; |
| 17 | 16 | |
| 18 | 17 | import java.io.File; |
| 19 | 18 | import java.util.ArrayList; |
| 19 | +import java.util.HashMap; | |
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * movie scan |
| ... | ... | @@ -25,6 +25,7 @@ import java.util.ArrayList; |
| 25 | 25 | public class LocalMovieScanUtils { |
| 26 | 26 | private String[] picExtensions; |
| 27 | 27 | private String[] mediaExtensions; |
| 28 | +// private ArrayList<SaveMessage> result = new ArrayList<>(); | |
| 28 | 29 | |
| 29 | 30 | public LocalMovieScanUtils(Context context) { |
| 30 | 31 | picExtensions = context.getResources().getStringArray(R.array.photo_filter); |
| ... | ... | @@ -225,6 +226,7 @@ public class LocalMovieScanUtils { |
| 225 | 226 | moviesItems.addAll(getAllType(type.getFolderPath(), callback)); |
| 226 | 227 | } |
| 227 | 228 | } |
| 229 | +// FileReadUtils.writeDate(rootPath + "/length.txt", new Gson().toJson(result)); | |
| 228 | 230 | return moviesItems; |
| 229 | 231 | } |
| 230 | 232 | |
| ... | ... | @@ -268,7 +270,8 @@ public class LocalMovieScanUtils { |
| 268 | 270 | String curPath = curFiles.getAbsoluteFile().toString(); |
| 269 | 271 | LocalMovieMessage moviesItem = new LocalMovieMessage(); |
| 270 | 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 | 275 | String newStr = allFirstSpell.replaceAll("[^\\w,]", ""); |
| 273 | 276 | moviesItem.setNamePinyin(newStr); |
| 274 | 277 | String media = getMedia(curPath + "/", mediaExtensions); |
| ... | ... | @@ -283,7 +286,8 @@ public class LocalMovieScanUtils { |
| 283 | 286 | if (!TextUtils.isEmpty(media)) { |
| 284 | 287 | File mFile = new File(media); |
| 285 | 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 | 291 | //read douban id and douban msg,至于name id 信息另外做,没有必要每次更新时都去添加 |
| 288 | 292 | try { |
| 289 | 293 | setDoubanMsg(curPath, moviesItem); |
| ... | ... | @@ -291,6 +295,12 @@ public class LocalMovieScanUtils { |
| 291 | 295 | Log.e("otherError", media); |
| 292 | 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 | 304 | moviesItem.setType(fileDir); |
| 295 | 305 | moviesItem.setPlayPath(media); |
| 296 | 306 | String movieDlTime = String.valueOf(mFile.lastModified()); |
| ... | ... | @@ -303,4 +313,30 @@ public class LocalMovieScanUtils { |
| 303 | 313 | } |
| 304 | 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 | 789 | presenter.jumpToSearch(); |
| 790 | 790 | // openDoor(); |
| 791 | 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 | 4 | import android.os.Bundle; |
| 5 | 5 | import android.os.Handler; |
| 6 | 6 | import android.util.Log; |
| 7 | +import android.view.KeyEvent; | |
| 7 | 8 | import android.widget.ImageView; |
| 8 | 9 | import android.widget.Toast; |
| 9 | - | |
| 10 | 10 | import com.gimi.common.cinema.model.MessageEvent; |
| 11 | 11 | import com.gimi.common.cinema.utils.QRCodeUtils; |
| 12 | 12 | import com.gimi.common.cinema.utils.SystemUtils; |
| ... | ... | @@ -14,7 +14,6 @@ import com.google.zxing.WriterException; |
| 14 | 14 | import com.qnbar.smc.utils.LightOperationUtils; |
| 15 | 15 | import com.xgimi.gimicinema.R; |
| 16 | 16 | import com.xgimi.gimicinema.presenter.QrCodeShowPresent; |
| 17 | - | |
| 18 | 17 | import org.greenrobot.eventbus.EventBus; |
| 19 | 18 | import org.greenrobot.eventbus.Subscribe; |
| 20 | 19 | import org.greenrobot.eventbus.ThreadMode; |
| ... | ... | @@ -40,7 +39,7 @@ public class QrCodeShowActivity extends Activity { |
| 40 | 39 | super.onCreate(savedInstanceState); |
| 41 | 40 | setContentView(R.layout.activity_qr_code_show); |
| 42 | 41 | EventBus.getDefault().register(this); |
| 43 | - | |
| 42 | + //back press,movie length | |
| 44 | 43 | present = new QrCodeShowPresent(); |
| 45 | 44 | |
| 46 | 45 | final String qr = getIntent().getStringExtra("qr"); |
| ... | ... | @@ -48,9 +47,9 @@ public class QrCodeShowActivity extends Activity { |
| 48 | 47 | roomSn = getIntent().getStringExtra("room_sn"); |
| 49 | 48 | boolean countCall = getIntent().getBooleanExtra("count_call", false); |
| 50 | 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 | 54 | ImageView iv = (ImageView) findViewById(R.id.qrCodeIv); |
| 56 | 55 | try { |
| ... | ... | @@ -60,17 +59,16 @@ public class QrCodeShowActivity extends Activity { |
| 60 | 59 | } |
| 61 | 60 | |
| 62 | 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 | 64 | @Override |
| 72 | 65 | protected void onDestroy() { |
| 73 | 66 | super.onDestroy(); |
| 67 | + try { | |
| 68 | + new SystemUtils().stopMediaPlayer(QrCodeShowActivity.this.getApplicationContext()); | |
| 69 | + } catch (Exception e) { | |
| 70 | + e.printStackTrace(); | |
| 71 | + } | |
| 74 | 72 | handler.removeCallbacks(r); |
| 75 | 73 | handler.removeCallbacks(null); |
| 76 | 74 | EventBus.getDefault().unregister(this); |
| ... | ... | @@ -83,6 +81,15 @@ public class QrCodeShowActivity extends Activity { |
| 83 | 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 | 93 | @Subscribe(threadMode = ThreadMode.MAIN) |
| 87 | 94 | public void onMoonEvent(MessageEvent messageEvent) { |
| 88 | 95 | switch (messageEvent.getEventId()) { | ... | ... |
Please
register
or
login
to post a comment