Skip to content

Commit

Permalink
同步eclipse版至studio版
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyLemon committed Mar 17, 2017
1 parent a187b64 commit 9f2967f
Show file tree
Hide file tree
Showing 27 changed files with 741 additions and 556 deletions.
26 changes: 14 additions & 12 deletions ZBLibrary(ADT)/ZBLibrary/src/zuo/biao/library/base/BaseAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@

package zuo.biao.library.base;

import java.util.ArrayList;
import java.util.List;

import zuo.biao.library.interfaces.OnReachViewBorderListener;
import zuo.biao.library.util.CommonUtil;
import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

import zuo.biao.library.interfaces.OnReachViewBorderListener;
import zuo.biao.library.util.CommonUtil;
import zuo.biao.library.util.SettingUtil;

/**基础Adapter
* <br> 适用于ListView,GridView等AbsListView的子类
* @author Lemon
Expand All @@ -39,7 +41,7 @@
public abstract class BaseAdapter<T> extends android.widget.BaseAdapter {
// private static final String TAG = "BaseAdapter";


/**
* 管理整个界面的Activity实例
*/
Expand Down Expand Up @@ -69,7 +71,7 @@ public synchronized void refresh(List<T> list) {
this.list = list == null ? null : new ArrayList<T>(list);
notifyDataSetChanged();
}

@Override
public int getCount() {
return list == null ? 0 : list.size();
Expand All @@ -89,17 +91,17 @@ public long getItemId(int position) {
return position;
}


//预加载,可不使用 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

protected OnReachViewBorderListener onReachViewBorderListener;
/**设置到达parent的边界的监听
* @param onReachViewBorderListener
*/
public void setOnReachViewBorderListener(OnReachViewBorderListener onReachViewBorderListener) {
this.onReachViewBorderListener = onReachViewBorderListener;
}

/**
* 预加载提前数
* @use 可在子类getView前赋值;
Expand All @@ -115,14 +117,14 @@ public void setOnReachViewBorderListener(OnReachViewBorderListener onReachViewBo
*/
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (onReachViewBorderListener != null && position >= getCount() - 1 - preloadCount) {
if (SettingUtil.preload && onReachViewBorderListener != null && position >= getCount() - 1 - preloadCount) {
onReachViewBorderListener.onReach(OnReachViewBorderListener.TYPE_BOTTOM, parent);
}
return convertView;
}

//预加载,可不使用 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>




Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

package zuo.biao.library.base;

import android.view.View;
import android.widget.BaseAdapter;

import java.util.List;

import zuo.biao.library.interfaces.AdapterCallBack;
Expand All @@ -23,8 +26,6 @@
import zuo.biao.library.ui.xlistview.XListView;
import zuo.biao.library.ui.xlistview.XListView.IXListViewListener;
import zuo.biao.library.util.Log;
import android.view.View;
import android.widget.BaseAdapter;

/**基础http获取列表的Activity
* @author Lemon
Expand All @@ -51,7 +52,7 @@ public void initView() {
}

/**设置列表适配器
* @param adapter if (adapter != null && adapter instanceof BaseHttpAdapter) >> 预加载
* @param callBack
*/
@SuppressWarnings("unchecked")
@Override
Expand Down Expand Up @@ -123,7 +124,7 @@ public void initEvent() {// 必须调用
lvBaseList.setXListViewListener(this);
}

/*
/*
* @param page 用-page作为requestCode
*/
@Override
Expand Down Expand Up @@ -152,8 +153,8 @@ public void run() {

/**
* @param requestCode = -page {@link #getListAsync(int)}
* @param resultJson
* @param e
* @param resultJson
* @param e
*/
@Override
public void onHttpResponse(final int requestCode, final String resultJson, final Exception e) {
Expand All @@ -175,7 +176,7 @@ public void run() {
onLoadSucceed(page, array);
}
}
});
});
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
* @param <T> 数据模型(model/JavaBean)类
* @param <LV> AbsListView的子类(ListView,GridView等)
* @param <BA> 管理LV的Adapter
* @see #onCreateView
* @see #setContentView
* @see #lvBaseList
* @see #initCache
* @see #initView
Expand All @@ -62,8 +60,8 @@ protected void setOnStopLoadListener(OnStopLoadListener onStopLoadListener) {
* @warn 在initData前使用才有效
* @param cacheCallBack
*/
protected void initCache(CacheCallBack<T> onCacheCallBack) {
this.cacheCallBack = onCacheCallBack;
protected void initCache(CacheCallBack<T> cacheCallBack) {
this.cacheCallBack = cacheCallBack;
}


Expand Down Expand Up @@ -202,7 +200,7 @@ public void run() {
getListAsync(page);
} else {//从缓存获取数据
onLoadSucceed(page, CacheManager.getInstance().getList(cacheCallBack.getCacheClass()
, cacheCallBack.getCacheGroup(), loadCacheStart, cacheCallBack.getCacheCount()),
, cacheCallBack.getCacheGroup(), loadCacheStart, cacheCallBack.getCacheCount()),
true);
if (page <= HttpManager.PAGE_NUM_0) {
isLoading = false;//stopLoadeData在其它线程isLoading = false;后这个线程里还是true
Expand All @@ -215,13 +213,13 @@ public void run() {

/**停止加载数据
* isCache = false;
* @param page
* @param page
*/
public synchronized void stopLoadData(int page) {
stopLoadData(page, false);
}
/**停止加载数据
* @param page
* @param page
* @param isCache
*/
private synchronized void stopLoadData(int page, boolean isCache) {
Expand All @@ -248,10 +246,10 @@ private synchronized void stopLoadData(int page, boolean isCache) {

private boolean isSucceed = false;
/**处理列表
* @param page
* @param page
* @param newList 新数据列表
* @param isCache
* @return
* @param isCache
* @return
* @return
*/
public synchronized void handleList(int page, List<T> newList, boolean isCache) {
Expand Down Expand Up @@ -350,7 +348,7 @@ public synchronized void onLoadFailed(int page, Exception e) {

private int saveCacheStart;
/**保存缓存
* @param newList
* @param newList
*/
public synchronized void saveCache(List<T> newList) {
if (cacheCallBack == null || newList == null || newList.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ protected void setOnStopLoadListener(OnStopLoadListener onStopLoadListener) {
* @warn 在initData前使用才有效
* @param cacheCallBack
*/
protected void initCache(CacheCallBack<T> onCacheCallBack) {
this.cacheCallBack = onCacheCallBack;
protected void initCache(CacheCallBack<T> cacheCallBack) {
this.cacheCallBack = cacheCallBack;
}


Expand Down Expand Up @@ -170,7 +170,7 @@ public void setAdapter(BA adapter) {
public abstract void setList(List<T> list);

/**显示列表(已在UI线程中)
* @param list
* @param callBack
*/
public void setList(AdapterCallBack<BA> callBack) {
if (adapter == null) {
Expand Down Expand Up @@ -267,7 +267,7 @@ public void run() {
getListAsync(page);
} else {//从缓存获取数据
onLoadSucceed(page, CacheManager.getInstance().getList(cacheCallBack.getCacheClass()
, cacheCallBack.getCacheGroup(), loadCacheStart, cacheCallBack.getCacheCount()),
, cacheCallBack.getCacheGroup(), loadCacheStart, cacheCallBack.getCacheCount()),
true);
if (page <= HttpManager.PAGE_NUM_0) {
isLoading = false;//stopLoadeData在其它线程isLoading = false;后这个线程里还是true
Expand All @@ -280,13 +280,13 @@ public void run() {

/**停止加载数据
* isCache = false;
* @param page
* @param page
*/
public synchronized void stopLoadData(int page) {
stopLoadData(page, false);
}
/**停止加载数据
* @param page
* @param page
* @param isCache
*/
private synchronized void stopLoadData(int page, boolean isCache) {
Expand All @@ -313,10 +313,10 @@ private synchronized void stopLoadData(int page, boolean isCache) {

private boolean isSucceed = false;
/**处理列表
* @param page
* @param page
* @param newList 新数据列表
* @param isCache
* @return
* @param isCache
* @return
* @return
*/
public synchronized void handleList(int page, List<T> newList, boolean isCache) {
Expand Down Expand Up @@ -415,7 +415,7 @@ public synchronized void onLoadFailed(int page, Exception e) {

private int saveCacheStart;
/**保存缓存
* @param newList
* @param newList
*/
public synchronized void saveCache(List<T> newList) {
if (cacheCallBack == null || newList == null || newList.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@

package zuo.biao.library.base;

import java.util.ArrayList;
import java.util.List;

import zuo.biao.library.interfaces.OnReachViewBorderListener;
import zuo.biao.library.util.CommonUtil;
import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

import zuo.biao.library.interfaces.OnReachViewBorderListener;
import zuo.biao.library.util.CommonUtil;
import zuo.biao.library.util.SettingUtil;

/**基础Adapter
* <br> 适用于ListView,GridView等AbsListView的子类
* @author Lemon
Expand All @@ -39,7 +41,7 @@
public abstract class BaseAdapter<T> extends android.widget.BaseAdapter {
// private static final String TAG = "BaseAdapter";


/**
* 管理整个界面的Activity实例
*/
Expand Down Expand Up @@ -69,7 +71,7 @@ public synchronized void refresh(List<T> list) {
this.list = list == null ? null : new ArrayList<T>(list);
notifyDataSetChanged();
}

@Override
public int getCount() {
return list == null ? 0 : list.size();
Expand All @@ -89,17 +91,17 @@ public long getItemId(int position) {
return position;
}


//预加载,可不使用 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

protected OnReachViewBorderListener onReachViewBorderListener;
/**设置到达parent的边界的监听
* @param onReachViewBorderListener
*/
public void setOnReachViewBorderListener(OnReachViewBorderListener onReachViewBorderListener) {
this.onReachViewBorderListener = onReachViewBorderListener;
}

/**
* 预加载提前数
* @use 可在子类getView前赋值;
Expand All @@ -115,14 +117,14 @@ public void setOnReachViewBorderListener(OnReachViewBorderListener onReachViewBo
*/
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (onReachViewBorderListener != null && position >= getCount() - 1 - preloadCount) {
if (SettingUtil.preload && onReachViewBorderListener != null && position >= getCount() - 1 - preloadCount) {
onReachViewBorderListener.onReach(OnReachViewBorderListener.TYPE_BOTTOM, parent);
}
return convertView;
}

//预加载,可不使用 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>




Expand Down
Loading

0 comments on commit 9f2967f

Please sign in to comment.