Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
package com.panxw.android.imageindicator;
package com.lt.hm.wovideo.widget.indicatorView;

/**
* @author leonardo
* @create_date 16/2/23
* @version 1.0
*/

import android.os.Handler;
import android.os.Message;

import com.lt.hm.wovideo.utils.StringUtils;

import java.lang.ref.WeakReference;


/**
* Auto BrocastManager for ImageIndicatorView
*
*
* @author steven-pan
*
*/
public class AutoPlayManager {
/**
Expand All @@ -25,9 +33,19 @@ public class AutoPlayManager {
*/
private static final int DEFAULT_TIMES = -1;
/**

* turn right
*/
private final static int RIGHT = 0;
/**
* turn left
*/
private final static int LEFT = 1;

* handler ID
*/
private static final int LOOP_ID = 1;

/**
* broadcast flag, play default
*/
Expand All @@ -40,14 +58,6 @@ public class AutoPlayManager {
* play interval ms
*/
private long intevalMils = DEFAULT_INTEVALMILS;
/**
* turn right
*/
private final static int RIGHT = 0;
/**
* turn left
*/
private final static int LEFT = 1;
/**
* current direction
*/
Expand Down Expand Up @@ -78,11 +88,9 @@ public AutoPlayManager(ImageIndicatorView imageIndicatorView) {

/**
* set play start time and interval
*
* @param startMils
* start time ms(>2, default 8s)
* @param intevelMils
* time interval ms(default 3s)
*
* @param startMils start time ms(>2, default 8s)
* @param intevelMils time interval ms(default 3s)
*/
public void setBroadcastTimeIntevel(long startMils, long intevelMils) {
this.startMils = startMils;
Expand All @@ -91,19 +99,17 @@ public void setBroadcastTimeIntevel(long startMils, long intevelMils) {

/**
* set auto play flag
*
* @param flag
* on or off
*
* @param flag on or off
*/
public void setBroadcastEnable(boolean flag) {
this.broadcastEnable = flag;
}

/**
* set loop times
*
* @param times
* loop times
*
* @param times loop times
*/
public void setBroadCastTimes(int times) {
this.broadcastTimes = times;
Expand All @@ -127,7 +133,11 @@ public void stop() {
}

protected void handleMessage(Message msg) {


if (broadcastEnable) {
if (!StringUtils.isNullOrEmpty(System.currentTimeMillis())&&System.currentTimeMillis()
- mImageIndicatorView.getRefreshTime() < 2 * 1000) {// ignore time interval less 2s
if (System.currentTimeMillis()
- mImageIndicatorView.getRefreshTime() < 2 * 1000) {// ignore loop less 2s
broadcastHandler.sendEmptyMessageDelayed(LOOP_ID, this.intevalMils);
Expand All @@ -144,7 +154,9 @@ protected void handleMessage(Message msg) {
if (mImageIndicatorView.getCurrentIndex() == mImageIndicatorView
.getTotalCount()-1) {
timesCount++;// add loop play times
direction = LEFT;
// mImageIndicatorView.setCurrentItem(0);
mImageIndicatorView.getViewPager().setCurrentItem(0);
direction = RIGHT;
} else {
mImageIndicatorView
.getViewPager()
Expand Down Expand Up @@ -177,7 +189,7 @@ private static class BroadcastHandler extends Handler {
private final WeakReference<AutoPlayManager> autoBrocastManagerRef;

public BroadcastHandler(AutoPlayManager autoBrocastManager) {
this.autoBrocastManagerRef = new WeakReference<AutoPlayManager>(
this.autoBrocastManagerRef = new WeakReference<>(
autoBrocastManager);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,19 @@ public void setupLayoutByDrawable(final Integer resArray[]) {

/**
* set Drawable list
*
* 消除 数据刷新 导致的 图片和 指示器重复的问题
* @param resList
* Drawable list
*/
public void setupLayoutByDrawable(final List<Integer> resList) {
if (resList == null)
throw new NullPointerException();

if (this.viewList.size()>0){
this.viewList.clear();
}
if (this.indicateLayout.getChildCount() > 0) {
this.indicateLayout.removeAllViews();
}
final int len = resList.size();
if (len > 0) {
for (int index = 0; index < len; index++) {
Expand All @@ -226,6 +231,32 @@ public void setupLayoutByDrawable(final List<Integer> resList) {
}
}
}

/**
* 设置显示 网络图片,使用ImageLoader 加载网络图片,需要提前配置ImageLoader
*
*/
public void setupLayoutByURL(final List<String> urllist) {
if (urllist == null)
throw new NullPointerException();
final int len = urllist.size();
if (this.viewList.size()>0){
this.viewList.clear();
}
if (this.indicateLayout.getChildCount() > 0) {
this.indicateLayout.removeAllViews();
}
if (len > 0) {
for (int i = 0; i < len; i++) {
final ImageView pageItem = new ImageView(getContext());
ImageLoader.getInstance().displayImage(
Constants.getRequestHost() + urllist.get(i), pageItem,
Utils.getOptions());
addViewItem(pageItem);
}
}
}


/**
* set image url list
Expand Down