Skip to content

Commit b8fc461

Browse files
author
yangjunbao
committed
files encoding change
1 parent 339b598 commit b8fc461

File tree

11 files changed

+35
-39
lines changed

11 files changed

+35
-39
lines changed

AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
package="com.it114.android.oneframework.core"
44
android:versionCode="1"
55
android:versionName="1.0.0">
6-
<uses-sdk android:minSdkVersion="8" />
6+
<uses-sdk android:minSdkVersion="14" />
77
<application/>
88
</manifest>

src/com/it114/android/oneframework/core/OneApplication.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ private void initImageLoader() {
6868
.memoryCache(new WeakMemoryCache())
6969
.diskCache(new LruDiskCache(cacheDir,new Md5FileNameGenerator(),500))
7070
.denyCacheImageMultipleSizesInMemory()
71-
.threadPoolSize(3)//线程池内加载的数量
71+
.threadPoolSize(3)//线程池内加载的数量
7272
.threadPriority(Thread.NORM_PRIORITY - 2)
73-
.memoryCache(new UsingFreqLimitedMemoryCache(2 * 1024 * 1024)) // You can pass your own memory cache implementation/你可以通过自己的内存缓存实现
73+
.memoryCache(new UsingFreqLimitedMemoryCache(2 * 1024 * 1024)) // You can pass your own memory cache implementation/你可以通过自己的内存缓存实现
7474
.memoryCacheSize(2 * 1024 * 1024)
7575
.discCacheSize(50 * 1024 * 1024)
76-
.discCacheFileNameGenerator(new Md5FileNameGenerator())//将保存的时候的URI名称用MD5 加密
76+
.discCacheFileNameGenerator(new Md5FileNameGenerator())//将保存的时候的URI名称用MD5 加密
7777
.tasksProcessingOrder(QueueProcessingType.LIFO)
78-
.discCacheFileCount(100) //缓存的文件数量
78+
.discCacheFileCount(100) //缓存的文件数量
7979
//.discCache(new UnlimitedDiscCache(cacheDir))
8080
.defaultDisplayImageOptions(options);
8181
} catch (IOException e) {
@@ -89,9 +89,9 @@ private void initImageLoader() {
8989

9090
public void setDebugModel(boolean debugModel){
9191
if(debugModel) {
92-
Config.showLogcat = true;
92+
Config.debug = true;
9393
} else {
94-
Config.showLogcat = false;
94+
Config.debug = false;
9595
}
9696
}
9797
}

src/com/it114/android/oneframework/core/http/HttpRequestHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ public void onSuccess(E data){
77
}
88
public void onSuccess(E data, int totalPages, int currentPage){}
99
public void onFailure(int statusCode,String error){}
10+
public void onFailure(String error){}
1011
public void onFinish(){}
1112
}

src/com/it114/android/oneframework/core/http/OneApi.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ private static AsyncHttpClient getHttpClient(){
2727

2828
private static void get(RequestParams params,String url, AsyncHttpResponseHandler responseHandler) {
2929
if(!NetUtil.isOpenNetwork()) {
30-
//返回数据库缓存
31-
//String content = HttpCacheManager.get(url,params);
30+
//返回数据库缓存
31+
// String content = HttpCacheManager.get(url,params);
3232
return;
3333
}
3434
LogUtil.d(TAG, params.toString());
@@ -37,7 +37,7 @@ private static void get(RequestParams params,String url, AsyncHttpResponseHandle
3737

3838
private static void post(RequestParams params,String url,AsyncHttpResponseHandler responseHandler) {
3939
if(!NetUtil.isOpenNetwork()){
40-
//返回数据库缓存
40+
//返回数据库缓存
4141
return ;
4242
}
4343
LogUtil.d(TAG, params.toString());
@@ -60,19 +60,20 @@ public static String makeUrl(String uri){
6060

6161

6262
/**
63-
* get请求
64-
* @param useCache 是否使用缓存
65-
* @param cacheTime 缓存时间:单位秒
66-
* @param url 访问地址
67-
* @param params 访问参数
63+
* get请求
64+
* @param useCache 是否使用缓存
65+
* @param cacheTime 缓存时间:单位秒
66+
* @param url 访问地址
67+
* @param params 访问参数
6868
* @param handler
69+
* @param dataModel
6970
*/
7071
public static void get(boolean useCache,long cacheTime,String url,RequestParams params, final HttpRequestHandler handler, final DataModel dataModel){
7172
HttpCache cache = null;
7273
if(useCache) {
7374
cache = HttpCacheManager.get(url, params);
7475
if(cache!=null){
75-
if(cache.updateTime+cacheTime*1000 < System.currentTimeMillis()){ //走缓存逻辑
76+
if(cache.updateTime+cacheTime*1000 < System.currentTimeMillis()){ //走缓存逻辑
7677
SafeHandler.onSuccess(handler,cache.content);
7778
handler.onFinish();
7879
return;

src/com/it114/android/oneframework/core/http/UserApi.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.it114.android.oneframework.core.http;
22

3+
import com.it114.android.oneframework.core.model.DataModel;
34
import com.it114.android.oneframework.core.model.UserModel;
45
import com.loopj.android.http.RequestParams;
56

@@ -29,7 +30,7 @@ public static void login(String userName,String password,HttpRequestHandler hand
2930
* use cache example
3031
* @param handler
3132
*/
32-
public static void getUserList(HttpRequestHandler handler){
33-
get(true,5*60,makeUrl(URI_USER_RPOFIE),getRequestParams(),handler);
33+
public static void getUserList(HttpRequestHandler handler, DataModel dataModel){
34+
get(true,5*60,makeUrl(URI_USER_RPOFIE),getRequestParams(),handler,dataModel);
3435
}
3536
}
Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
11
package com.it114.android.oneframework.core.model;
22

3+
34
import android.widget.Toast;
4-
import com.google.gson.Gson;
5-
import com.google.gson.GsonBuilder;
65
import com.it114.android.oneframework.core.OneApplication;
7-
import com.it114.android.oneframework.core.R;
86
import org.json.JSONObject;
97

108
import java.io.Serializable;
119

1210
/**
1311
* Created by andy on 10/12/2015.
1412
*
15-
* 基类解析。注意您的数据格式必须是下面这个格式的才可以直接用这个model
13+
* 基类解析。注意您的数据格式必须是下面这个格式的才可以直接用这个model
1614
* {"code":1,"msg":"success","data":"{----}"}
17-
* 不是如上格式的请自行根据您的格式来写基类的解析
15+
* 不是如上格式的请自行根据您的格式来写基类的解析
1816
*
1917
*/
2018
public abstract class BaseModel implements Serializable {
2119
private static final long serialVersionUID = 2015082101L;
2220
public String msg="";
2321
public int code;
2422
protected boolean showErrorJsonMsg = true;
25-
abstract public boolean parseSuc();
23+
abstract public boolean parseSuccess();
2624

2725
public void parse(String jsonObject) throws Exception {
2826
JSONObject object = new JSONObject(jsonObject);
@@ -32,7 +30,7 @@ public void parse(String jsonObject) throws Exception {
3230
parseModel(object);
3331
} else {
3432
if(showErrorJsonMsg) {
35-
Toast.makeText(OneApplication.getInstance(),OneApplication.getInstance().getString(R.string.error_data_valid),Toast.LENGTH_LONG).show();
33+
Toast.makeText(OneApplication.getInstance(), "服务器返回数据不合法",Toast.LENGTH_LONG).show();
3634
}
3735
}
3836
}
@@ -44,22 +42,19 @@ protected void setShowErrorJsonMsg(boolean show){
4442
abstract void parseModel(JSONObject object) throws Exception;
4543

4644
/**
47-
* 数据返回是否成功
45+
* 数据返回是否成功
4846
* @return
4947
*/
50-
public boolean dataSuc(){
48+
public boolean dataSuccess(){
5149
return this.code == 1;
5250
}
5351

5452
/**
55-
* 服务器返回的json中的msg数据
53+
* 服务器返回的json中的msg数据
5654
* @return
5755
*/
5856
public String modelMessage(){
5957
return msg;
6058
}
6159

62-
63-
64-
65-
}
60+
}

src/com/it114/android/oneframework/core/model/DataModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
public class DataModel extends BaseModel {
99
@Override
10-
public boolean parseSuc() {
10+
public boolean parseSuccess() {
1111
return false;
1212
}
1313

src/com/it114/android/oneframework/core/model/HttpCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class HttpCache extends BaseModel{
1212

1313

1414
@Override
15-
public boolean parseSuc() {
15+
public boolean parseSuccess() {
1616
return false;
1717
}
1818

src/com/it114/android/oneframework/core/model/UserModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class UserModel extends DataModel {
1111
public String username;
1212

1313
@Override
14-
public boolean parseSuc() {
14+
public boolean parseSuccess() {
1515
return false;
1616
}
1717

src/com/it114/android/oneframework/core/util/FileUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
public class FileUtil {
1212

1313
/**
14-
* 得到app缓存文件夹,优先使用外部存储设备
14+
* 得到app缓存文件夹,优先使用外部存储设备
1515
* @return
1616
*/
1717
public static File getCacheDir(){

0 commit comments

Comments
 (0)