Skip to content

Commit

Permalink
KJBitmap添加加载加密传输的图片功能
Browse files Browse the repository at this point in the history
  • Loading branch information
kymjs committed Sep 7, 2015
1 parent 6f7a79c commit a44ce6d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion KJFrame/kjframe/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.github.dcendents.android-maven'

version = "2.4.3"
version = "2.4.3.2"

android {
compileSdkVersion 22
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@ public KJBitmap() {
}

public KJBitmap(BitmapConfig bitmapConfig) {
this(new HttpConfig(), bitmapConfig);
}

public KJBitmap(HttpConfig httpConfig, BitmapConfig bitmapConfig) {
this.mConfig = bitmapConfig;
displayer = new ImageDisplayer(mConfig);
displayer = new ImageDisplayer(httpConfig, mConfig);
doLoadingViews = new Vector<View>(30);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
*/
package org.kymjs.kjframe.bitmap;

import java.util.HashMap;
import java.util.LinkedList;
import android.graphics.Bitmap;
import android.os.Handler;
import android.os.Looper;

import org.kymjs.kjframe.KJHttp;
import org.kymjs.kjframe.http.HttpCallBack;
import org.kymjs.kjframe.http.HttpConfig;
import org.kymjs.kjframe.http.KJHttpException;
import org.kymjs.kjframe.http.Request;

import android.graphics.Bitmap;
import android.os.Handler;
import android.os.Looper;
import java.util.HashMap;
import java.util.LinkedList;

/**
* 图片显示器
Expand All @@ -49,18 +49,17 @@ public class ImageDisplayer {

/**
* 创建一个图片显示器
*
*
* @param bitmapConfig
*/
public ImageDisplayer(BitmapConfig bitmapConfig) {
HttpConfig config = new HttpConfig();
public ImageDisplayer(HttpConfig httpConfig, BitmapConfig bitmapConfig) {
// 靠,在这里踩了个坑。 最初写的是Integer.MAX_VALUE,
// 结果把这个值*60000转成毫秒long以后溢出了 这次我给个死的值行不行。1000天,能不能算永久了
// 其实还有一种解决办法是直接在缓存读取的时候,看到是bitmap缓存不管是否失效都返回,
// 但是这种不利于自定义扩展,就不用了,有兴趣的可以看CacheDispatcher的105行
// @kymjs记录于2015.4.30
// config.cacheTime = bitmapConfig.cacheTime;
mKJHttp = new KJHttp(config);
mKJHttp = new KJHttp(httpConfig);
mMemoryCache = BitmapConfig.mMemoryCache;
mResponseDelayMs = bitmapConfig.delayTime;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@

package org.kymjs.kjframe.bitmap;

import java.util.Map;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import org.kymjs.kjframe.http.HttpCallBack;
import org.kymjs.kjframe.http.HttpConfig;
import org.kymjs.kjframe.http.HttpHeaderParser;
import org.kymjs.kjframe.http.KJHttpException;
import org.kymjs.kjframe.http.NetworkResponse;
import org.kymjs.kjframe.http.Request;
import org.kymjs.kjframe.http.Response;
import org.kymjs.kjframe.utils.KJLoger;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import java.util.HashMap;
import java.util.Map;

/**
* 从网络下载一张bitmap
Expand All @@ -41,9 +43,12 @@ public class ImageRequest extends Request<Bitmap> {
// 用来保证当前对象只有一个线程在访问
private static final Object sDecodeLock = new Object();

private final Map<String, String> mHeaders = new HashMap<String, String>();

public ImageRequest(String url, int maxWidth, int maxHeight,
HttpCallBack callback) {
super(HttpMethod.GET, url, callback);
mHeaders.put("cookie", HttpConfig.sCookie);
mMaxWidth = maxWidth;
mMaxHeight = maxHeight;
}
Expand All @@ -58,6 +63,11 @@ public String getCacheKey() {
return getUrl();
}

@Override
public Map<String, String> getHeaders() {
return mHeaders;
}

/**
* 框架会自动将大于设定值的bitmap转换成设定值,所以需要这个方法来判断应该显示默认大小或者是设定值大小。<br>
* 本方法会根据maxPrimary与actualPrimary比较来判断,如果无法判断则会根据辅助值判断,辅助值一般是主要值对应的。
Expand Down

0 comments on commit a44ce6d

Please sign in to comment.