示例#1
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);
   }
 }