Skip to content

Commit

Permalink
代码修改
Browse files Browse the repository at this point in the history
  • Loading branch information
donkingliang committed Mar 14, 2017
1 parent 3a2eede commit 3829bee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
public class BannerPagerAdapter<T> extends PagerAdapter {

private Context mContext;
private List<T> mDatas;
private List<T> mData;
private CustomBanner.ViewCreator mCreator;
private CustomBanner.OnPageClickListener mOnPageClickListener;

private SparseArray<View> views = new SparseArray<>();

public BannerPagerAdapter(Context context, CustomBanner.ViewCreator<T> creator, List datas) {
public BannerPagerAdapter(Context context, CustomBanner.ViewCreator<T> creator, List data) {
mContext = context;
mCreator = creator;
mDatas = datas;
mData = data;
}

@Override
public int getCount() {
return mDatas == null || mDatas.isEmpty() ? 0 : mDatas.size() + 2;
return mData == null || mData.isEmpty() ? 0 : mData.size() + 2;
}

@Override
Expand Down Expand Up @@ -58,9 +58,9 @@ public Object instantiateItem(ViewGroup container, final int position) {
}

final int item = getActualPosition(position);
final T t = mDatas.get(item);
final T t = mData.get(item);

mCreator.UpdateUI(mContext, view, item, mDatas.get(item));
mCreator.updateUI(mContext, view, item, t);

view.setOnClickListener(new View.OnClickListener() {
@Override
Expand All @@ -77,7 +77,7 @@ public void onClick(View v) {

private int getActualPosition(int position) {
if (position == 0) {
return mDatas.size() - 1;
return mData.size() - 1;
} else if (position == getCount() - 1) {
return 0;
} else {
Expand Down
12 changes: 6 additions & 6 deletions banner/src/main/java/com/donkingliang/banner/CustomBanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,19 @@ private boolean isMarginal(int position) {
* 设置轮播图数据
*
* @param creator 创建和更新轮播图View的接口
* @param datas 轮播图数据
* @param data 轮播图数据
* @return
*/
public CustomBanner<T> setPages(ViewCreator<T> creator, List<T> datas) {
mAdapter = new BannerPagerAdapter<T>(mContext, creator, datas);
public CustomBanner<T> setPages(ViewCreator<T> creator, List<T> data) {
mAdapter = new BannerPagerAdapter<T>(mContext, creator, data);
if (mOnPageClickListener != null) {
mAdapter.setOnPageClickListener(mOnPageClickListener);
}
mBannerViewPager.setAdapter(mAdapter);
if (datas == null) {
if (data == null) {
mIndicatorLayout.removeAllViews();
} else {
initIndicator(datas.size());
initIndicator(data.size());
}
setCurrentItem(0);
updateIndicator();
Expand Down Expand Up @@ -398,6 +398,6 @@ public interface ViewCreator<T> {

View createView(Context context, int position);

void UpdateUI(Context context, View view, int position, T data);
void updateUI(Context context, View view, int position, T t);
}
}

0 comments on commit 3829bee

Please sign in to comment.