示例#1
0
 /**
  * 获取设置的阅览时间
  *
  * @return String
  */
 public String getAutoPlayTime() {
   String content = Utils.getFileRead(Constants.AUTOSHOWTIME);
   if (content != null && content.indexOf("=") != -1) {
     content = content.substring(content.indexOf("=") + 1);
   }
   return content;
 }
示例#2
0
 /**
  * 设置自动阅览漫画时间
  *
  * @param time
  */
 public void setAutoPlayTime(String time) {
   // 我觉得setAutoPlayTime和getAutoPlayTime这两个方法实在没必要
   // 简单的设置一个变量记录自动播放时间不是很好吗?再说,向SD卡中存放写入文件
   // 在runnable中读取SD卡这多耗时间啊,而且又不需要程序启动加载这个播放时间,真是让人困惑
   String content = "time=" + time;
   try {
     Utils.saveFile(Constants.AUTOSHOWTIME, content, false);
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
示例#3
0
 @Override
 public void run() {
   Log.v(TAG, "Runnable执行");
   int imageIndex = -1;
   String time = getAutoPlayTime();
   Log.v(TAG, "得到的time是:" + time);
   if (time != null && time.length() > 0) {
     showTime = Integer.parseInt(time);
   } else {
     handler.removeCallbacks(autoShow);
     handler.removeMessages(1);
   }
   Log.v(TAG, "获得的执行时间为:" + showTime);
   if (imagePosition != null && imagePosition.size() > 0) {
     String index = imagePosition.get("positionId");
     imageIndex = Integer.parseInt(index);
     imageIndex += 1;
     // i从0开始 imageList数组长度从1开始
     // 下边这个判断现在根本没有意义,MainActivity中的handler没有重写handleMessage方法所以不会被处理法这样一个消息
     // 现在完全没有意义,保证功能正常只需设置漫画的判断就够了
     // if(imageIndex == imageList.size() - 1){
     //	Message msg = handler.obtainMessage();
     //	msg.what = 1;
     //	handler.sendMessage(msg);
     // }
     if (imageIndex <= imageList.size() - 1) {
       activity.setImageView(imageIndex);
       // 当前漫画设置
       Utils.showMsg(activity, (imageIndex + 1) + "/" + imageList.size());
       handler.postDelayed(autoShow, showTime * 1000);
     }
   }
   // 如果imagePosition为空则先缓冲3秒在循环
   if (imagePosition == null) {
     handler.postDelayed(autoShow, 3000);
   }
 }