add AutoPlayManager

master
panxw 11 years ago
parent 19422c07cb
commit 5146b6f0e9

@ -11,7 +11,7 @@ import com.allthelucky.common.view.ImageIndicatorView;
* @author steven-pan * @author steven-pan
* *
*/ */
public class AutoBrocastManager { public class AutoPlayManager {
/** /**
* *
@ -72,16 +72,16 @@ public class AutoBrocastManager {
*/ */
private ImageIndicatorView mImageIndicatorView = null; private ImageIndicatorView mImageIndicatorView = null;
public AutoBrocastManager(ImageIndicatorView imageIndicatorView) { public AutoPlayManager(ImageIndicatorView imageIndicatorView) {
this.mImageIndicatorView = imageIndicatorView; this.mImageIndicatorView = imageIndicatorView;
this.broadcastHandler = new BroadcastHandler(AutoBrocastManager.this); this.broadcastHandler = new BroadcastHandler(AutoPlayManager.this);
} }
/** /**
* *
* *
* @param startMils * @param startMils
* ms(8s) * ms(>5, 8s)
* @param intevelMils * @param intevelMils
* ms(3s) * ms(3s)
*/ */
@ -122,7 +122,7 @@ public class AutoBrocastManager {
protected void handleMessage(android.os.Message msg) { protected void handleMessage(android.os.Message msg) {
if (broadcastEnable) { if (broadcastEnable) {
if (System.currentTimeMillis() if (System.currentTimeMillis()
- mImageIndicatorView.getRefreshTime() < 5 * 1000) {// 最近一次划动间隔小于5s - mImageIndicatorView.getRefreshTime() < 5 * 1000) {// 最近一次划动间隔小于2s
return; return;
} }
if ((broadcastTimes != DEFAULT_TIMES) if ((broadcastTimes != DEFAULT_TIMES)
@ -164,9 +164,9 @@ public class AutoBrocastManager {
} }
static class BroadcastHandler extends Handler { static class BroadcastHandler extends Handler {
private AutoBrocastManager autoBrocastManager; private AutoPlayManager autoBrocastManager;
public BroadcastHandler(AutoBrocastManager autoBrocastManager) { public BroadcastHandler(AutoPlayManager autoBrocastManager) {
this.autoBrocastManager = autoBrocastManager; this.autoBrocastManager = autoBrocastManager;
} }

@ -3,7 +3,7 @@ package com.allthelucky.common.view.sample;
import android.app.Activity; import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import com.allthelucky.common.view.AutoBrocastManager; import com.allthelucky.common.view.AutoPlayManager;
import com.allthelucky.common.view.ImageIndicatorView; import com.allthelucky.common.view.ImageIndicatorView;
import com.app.library.common.view.R; import com.app.library.common.view.R;
@ -38,10 +38,10 @@ public class AutoImageIndicatorActivity extends Activity {
this.autoImageIndicatorView.setupLayoutByDrawable(resArray);//图片 this.autoImageIndicatorView.setupLayoutByDrawable(resArray);//图片
this.autoImageIndicatorView.show(); this.autoImageIndicatorView.show();
AutoBrocastManager autoBrocastManager = new AutoBrocastManager(this.autoImageIndicatorView); AutoPlayManager autoBrocastManager = new AutoPlayManager(this.autoImageIndicatorView);
autoBrocastManager.setBroadcastEnable(true); autoBrocastManager.setBroadcastEnable(true);
autoBrocastManager.setBroadCastTimes(5);//循环播放5次 autoBrocastManager.setBroadCastTimes(5);//循环播放5次
autoBrocastManager.setBroadcastTimeIntevel(2 * 1000, 3 * 1000);//播放启动时间及间隔 autoBrocastManager.setBroadcastTimeIntevel(5 * 1000, 3 * 1000);//播放启动时间及间隔
autoBrocastManager.loop(); autoBrocastManager.loop();
} }

Loading…
Cancel
Save