change handler

master
Administrator 13 years ago
parent ffced9717d
commit 61ca9e8f6a

@ -6,6 +6,7 @@ import java.util.concurrent.TimeUnit;
import android.content.Context; import android.content.Context;
import android.os.Handler; import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet; import android.util.AttributeSet;
/** /**
@ -68,6 +69,11 @@ public class AutoImageIndicatorView extends ImageIndicatorView {
*/ */
private int timesCount = 0; private int timesCount = 0;
/**
*
*/
private Handler broadcastHandler = null;
public AutoImageIndicatorView(Context context, AttributeSet attrs) { public AutoImageIndicatorView(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
this.init(); this.init();
@ -79,6 +85,7 @@ public class AutoImageIndicatorView extends ImageIndicatorView {
} }
private void init() { private void init() {
this.broadcastHandler = new BroadcastHandler(AutoImageIndicatorView.this);
this.scheduler = Executors.newScheduledThreadPool(1); this.scheduler = Executors.newScheduledThreadPool(1);
} }
@ -135,11 +142,7 @@ public class AutoImageIndicatorView extends ImageIndicatorView {
}, this.startMils, this.intevalMils, TimeUnit.MILLISECONDS); }, this.startMils, this.intevalMils, TimeUnit.MILLISECONDS);
} }
/** protected void handleMessage(android.os.Message msg) {
*
*/
private Handler broadcastHandler = new Handler() {
public void handleMessage(android.os.Message msg) {
if (direction == RIGHT) {// roll right if (direction == RIGHT) {// roll right
if (getCurrentIndex() < getTotalCount()) { if (getCurrentIndex() < getTotalCount()) {
if (getCurrentIndex() == getTotalCount() - 1) { if (getCurrentIndex() == getTotalCount() - 1) {
@ -159,6 +162,20 @@ public class AutoImageIndicatorView extends ImageIndicatorView {
} }
} }
} }
}; }
class BroadcastHandler extends Handler {
private AutoImageIndicatorView autoImageIndicatorView;
public BroadcastHandler(AutoImageIndicatorView autoImageIndicatorView) {
this.autoImageIndicatorView = autoImageIndicatorView;
}
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (this.autoImageIndicatorView != null) {
autoImageIndicatorView.handleMessage(msg);
}
}
} }

Loading…
Cancel
Save