diff --git a/res/drawable-xxhdpi/star.png b/res/drawable-xxhdpi/star_small.png
similarity index 100%
rename from res/drawable-xxhdpi/star.png
rename to res/drawable-xxhdpi/star_small.png
diff --git a/res/drawable-xxhdpi/star_empty.png b/res/drawable-xxhdpi/star_small_empty.png
similarity index 100%
rename from res/drawable-xxhdpi/star_empty.png
rename to res/drawable-xxhdpi/star_small_empty.png
diff --git a/res/drawable-xxhdpi/star_half.png b/res/drawable-xxhdpi/star_small_half.png
similarity index 100%
rename from res/drawable-xxhdpi/star_half.png
rename to res/drawable-xxhdpi/star_small_half.png
diff --git a/res/drawable/ratingbar_small.xml b/res/drawable/ratingbar_small.xml
new file mode 100644
index 000000000..479424187
--- /dev/null
+++ b/res/drawable/ratingbar_small.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/detail_normal.xml b/res/layout/detail_normal.xml
index 8ac7e9a47..b71df4916 100644
--- a/res/layout/detail_normal.xml
+++ b/res/layout/detail_normal.xml
@@ -16,12 +16,12 @@
android:layout_height="wrap_content"
android:orientation = "horizontal" >
-
+ android:layout_centerVertical="true" />
+ android:orientation="vertical" >
+ android:cacheColorHint="@color/main_background"
+ android:fitsSystemWindows="true"
+ android:clipToPadding="false" >
\ No newline at end of file
diff --git a/res/layout/list_item.xml b/res/layout/list_item.xml
index 2ac247cf8..40bb899cb 100644
--- a/res/layout/list_item.xml
+++ b/res/layout/list_item.xml
@@ -38,14 +38,14 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
-
-
+ android:layout_marginTop="2.0dip" >
+
8.0dp
2.0dp
+
+ 14.0dip
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 61e8395b7..33721ef60 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -152,4 +152,18 @@
- 8.0dp
+
+
diff --git a/src/com/hippo/ehviewer/ImageGeterManager.java b/src/com/hippo/ehviewer/ImageGeterManager.java
index ea362ea51..e8ec87182 100644
--- a/src/com/hippo/ehviewer/ImageGeterManager.java
+++ b/src/com/hippo/ehviewer/ImageGeterManager.java
@@ -19,21 +19,22 @@ import com.hippo.ehviewer.util.Log;
public class ImageGeterManager {
private static final String TAG = "ImageGeterManager";
- private static final int CACHE = 0x0;
- private static final int DOWNLOAD = 0x1;
+ public static final int MEMORY_CACHE = 0x1;
+ public static final int DISK_CACHE = 0x2;
+ public static final int DOWNLOAD = 0x4;
private class LoadTask {
public String url;
public String key;
+ public int mode;
public OnGetImageListener listener;
- public boolean download;
public Bitmap bitmap;
- public LoadTask(String url, String key, OnGetImageListener listener, boolean download) {
+ public LoadTask(String url, String key, int mode, OnGetImageListener listener) {
this.url = url;
this.key = key;
+ this.mode = mode;
this.listener = listener;
- this.download = download;
}
}
private Context mContext;
@@ -51,19 +52,10 @@ public class ImageGeterManager {
@Override
public void handleMessage(Message msg) {
LoadTask task = (LoadTask)msg.obj;
- switch (msg.what) {
- case Constants.TRUE:
- if (msg.arg1 == CACHE)
- task.listener.onGetImageFromCacheSuccess(task.key, task.bitmap);
- else if (msg.arg1 == DOWNLOAD)
- task.listener.onGetImageFromDownloadSuccess(task.key, task.bitmap);
- break;
- case Constants.FALSE:
- if (msg.arg1 == CACHE)
- task.listener.onGetImageFromCacheFail(task.key);
- else
- task.listener.onGetImageFail(task.key);
- break;
+ if (msg.what == Constants.TRUE) {
+ task.listener.onGetImageSuccess(task.key, task.bitmap, msg.arg1);
+ } else if (msg.what == Constants.FALSE){
+ task.listener.onGetImageFail(task.key);
}
}
};
@@ -81,9 +73,9 @@ public class ImageGeterManager {
new Thread(new LoadFromCacheTask()).start();
}
- public void add(String url, String key, OnGetImageListener listener, boolean download) {
+ public void add(String url, String key, int mode, OnGetImageListener listener) {
synchronized (mLock) {
- mLoadCacheTask.push(new LoadTask(url, key, listener, download));
+ mLoadCacheTask.push(new LoadTask(url, key, mode, listener));
mLock.notify();
}
}
@@ -106,33 +98,37 @@ public class ImageGeterManager {
}
// Continue if do not need any more
- if (!loadTask.listener.onGetImage(loadTask.key))
+ if (!loadTask.listener.onGetImageStart(loadTask.key))
continue;
String key = loadTask.key;
- if (mMemoryCache == null || (loadTask.bitmap = mMemoryCache.get(key)) == null) {
- if (mDiskCache != null
- && (loadTask.bitmap = (Bitmap)mDiskCache.get(key, Util.BITMAP)) != null
- && mMemoryCache != null)
+ int mode = loadTask.mode;
+ int getMode = MEMORY_CACHE;
+ if ((mode & MEMORY_CACHE) != 0 && mMemoryCache != null
+ && (loadTask.bitmap = mMemoryCache.get(key)) != null)
+ getMode = MEMORY_CACHE;
+ else if ((mode & DISK_CACHE) != 0 && mDiskCache != null
+ && (loadTask.bitmap = (Bitmap)mDiskCache.get(key, Util.BITMAP)) != null) {
+ getMode = DISK_CACHE;
+ if (mMemoryCache != null)
mMemoryCache.put(key, loadTask.bitmap);
}
- Message msg = new Message();
- msg.obj = loadTask;
- if (loadTask.bitmap == null) {
- if (loadTask.download) {
+ if (loadTask.bitmap != null) { // Get bitmap
+ Message msg = new Message();
+ msg.obj = loadTask;
+ msg.what = Constants.TRUE;
+ msg.arg1 = getMode;
+ mHandler.sendMessage(msg);
+ } else { // get from cache miss
+ if ((mode & DOWNLOAD) != 0) {
mImageDownloadTask.add(loadTask);
- msg.what = Constants.FALSE;
- mHandler.sendMessage(msg);
} else {
+ Message msg = new Message();
+ msg.obj = loadTask;
msg.what = Constants.FALSE;
- msg.arg1 = CACHE;
mHandler.sendMessage(msg);
}
- } else {
- msg.what = Constants.TRUE;
- msg.arg1 = CACHE;
- mHandler.sendMessage(msg);
}
}
}
@@ -173,17 +169,9 @@ public class ImageGeterManager {
loadTask = mDownloadTask.pop();
}
- // Continue if do not need any more
- if (!loadTask.listener.onGetImage(loadTask.key))
- continue;
-
loadTask.bitmap = httpHelper.getImage(loadTask.url,
loadTask.key, mMemoryCache, mDiskCache, true);
- // Continue if do not need any more
- if (!loadTask.listener.onGetImage(loadTask.key))
- continue;
-
Message msg = new Message();
msg.obj = loadTask;
if (loadTask.bitmap == null) {
@@ -202,15 +190,8 @@ public class ImageGeterManager {
/**
* @return False if you wanna stop get
*/
- boolean onGetImage(String key);
-
- /**
- * It will call when active download and get from cache miss
- * @param key
- */
- void onGetImageFromCacheFail(String key);
- void onGetImageFromCacheSuccess(String key, Bitmap bmp);
- void onGetImageFromDownloadSuccess(String key, Bitmap bmp);
+ boolean onGetImageStart(String key);
+ void onGetImageSuccess(String key, Bitmap bmp, int mode);
void onGetImageFail(String key);
}
}
diff --git a/src/com/hippo/ehviewer/activity/DownloadActivity.java b/src/com/hippo/ehviewer/activity/DownloadActivity.java
index 7b7277013..75bb643ce 100644
--- a/src/com/hippo/ehviewer/activity/DownloadActivity.java
+++ b/src/com/hippo/ehviewer/activity/DownloadActivity.java
@@ -31,6 +31,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.res.Configuration;
+import android.graphics.Bitmap;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
@@ -150,9 +151,20 @@ public class DownloadActivity extends Activity {
LoadImageView thumb = (LoadImageView)view
.findViewById(R.id.thumb);
- thumb.setLoadInfo(di.thumb, di.gid);
- mImageGeterManager.add(di.thumb, di.gid,
- new LoadImageView.SimpleImageGetListener(thumb), true);
+ Bitmap bmp = null;
+ if (Cache.memoryCache != null &&
+ (bmp = Cache.memoryCache.get(di.gid)) != null) {
+ thumb.setLoadInfo(di.thumb, di.gid);
+ thumb.setImageBitmap(bmp);
+ thumb.setState(LoadImageView.LOADED);
+ } else {
+ thumb.setImageDrawable(null);
+ thumb.setLoadInfo(di.thumb, di.gid);
+ thumb.setState(LoadImageView.NONE);
+ mImageGeterManager.add(di.thumb, di.gid,
+ ImageGeterManager.DISK_CACHE | ImageGeterManager.DOWNLOAD,
+ new LoadImageView.SimpleImageGetListener(thumb));
+ }
TextView title = (TextView)view.findViewById(R.id.title);
title.setText(di.title);
@@ -205,9 +217,20 @@ public class DownloadActivity extends Activity {
LoadImageView thumb = (LoadImageView)view
.findViewById(R.id.thumb);
- thumb.setLoadInfo(di.thumb, di.gid);
- mImageGeterManager.add(di.thumb, di.gid,
- new LoadImageView.SimpleImageGetListener(thumb), true);
+ Bitmap bmp = null;
+ if (Cache.memoryCache != null &&
+ (bmp = Cache.memoryCache.get(di.gid)) != null) {
+ thumb.setLoadInfo(di.thumb, di.gid);
+ thumb.setImageBitmap(bmp);
+ thumb.setState(LoadImageView.LOADED);
+ } else {
+ thumb.setImageDrawable(null);
+ thumb.setLoadInfo(di.thumb, di.gid);
+ thumb.setState(LoadImageView.NONE);
+ mImageGeterManager.add(di.thumb, di.gid,
+ ImageGeterManager.DISK_CACHE | ImageGeterManager.DOWNLOAD,
+ new LoadImageView.SimpleImageGetListener(thumb));
+ }
TextView title = (TextView)view.findViewById(R.id.title);
title.setText(di.title);
diff --git a/src/com/hippo/ehviewer/activity/FavouriteActivity.java b/src/com/hippo/ehviewer/activity/FavouriteActivity.java
index 8ba242ef8..ec5d80274 100644
--- a/src/com/hippo/ehviewer/activity/FavouriteActivity.java
+++ b/src/com/hippo/ehviewer/activity/FavouriteActivity.java
@@ -6,6 +6,7 @@ import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.content.res.Configuration;
+import android.graphics.Bitmap;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
@@ -17,6 +18,7 @@ import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
+import android.widget.RatingBar;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
@@ -121,9 +123,20 @@ public class FavouriteActivity extends Activity{
LoadImageView thumb = (LoadImageView)convertView.findViewById(R.id.cover);
if (!String.valueOf(lmd.gid).equals(thumb.getKey())) {
- thumb.setLoadInfo(lmd.thumb, String.valueOf(lmd.gid));
- mImageGeterManager.add(lmd.thumb, String.valueOf(lmd.gid),
- new LoadImageView.SimpleImageGetListener(thumb), true);
+ Bitmap bmp = null;
+ if (Cache.memoryCache != null &&
+ (bmp = Cache.memoryCache.get(String.valueOf(lmd.gid))) != null) {
+ thumb.setLoadInfo(lmd.thumb, String.valueOf(lmd.gid));
+ thumb.setImageBitmap(bmp);
+ thumb.setState(LoadImageView.LOADED);
+ } else {
+ thumb.setImageDrawable(null);
+ thumb.setLoadInfo(lmd.thumb, String.valueOf(lmd.gid));
+ thumb.setState(LoadImageView.NONE);
+ mImageGeterManager.add(lmd.thumb, String.valueOf(lmd.gid),
+ ImageGeterManager.DISK_CACHE | ImageGeterManager.DOWNLOAD,
+ new LoadImageView.SimpleImageGetListener(thumb));
+ }
// Set manga name
TextView name = (TextView) convertView.findViewById(R.id.name);
@@ -142,9 +155,9 @@ public class FavouriteActivity extends Activity{
}
// Add star
- LinearLayout rate = (LinearLayout) convertView
+ RatingBar rate = (RatingBar) convertView
.findViewById(R.id.rate);
- Ui.addStar(rate, lmd.rating);
+ rate.setRating(lmd.rating);
// set posted
TextView posted = (TextView) convertView.findViewById(R.id.posted);
@@ -157,9 +170,6 @@ public class FavouriteActivity extends Activity{
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
- if (Build.VERSION.SDK_INT >= 19) {
- BeautifyScreen.fixColour(this);
- }
}
@Override
@@ -186,6 +196,8 @@ public class FavouriteActivity extends Activity{
if (screenOri != getRequestedOrientation())
setRequestedOrientation(screenOri);
+ Ui.translucent(this);
+
// Download service
Intent it = new Intent(FavouriteActivity.this, DownloadService.class);
bindService(it, mServiceConn, BIND_AUTO_CREATE);
@@ -194,11 +206,6 @@ public class FavouriteActivity extends Activity{
getActionBar().setDisplayHomeAsUpEnabled(true);
- // For colourfy the activity
- if (Build.VERSION.SDK_INT >= 19) {
- BeautifyScreen.ColourfyScreen(this);
- }
-
mFavouriteLmd = mData.getAllLocalFavourites();
ListView listView = (ListView)findViewById(R.id.favourite);
diff --git a/src/com/hippo/ehviewer/activity/MangaDetailActivity.java b/src/com/hippo/ehviewer/activity/MangaDetailActivity.java
index 3ba043de2..cbe412ad2 100644
--- a/src/com/hippo/ehviewer/activity/MangaDetailActivity.java
+++ b/src/com/hippo/ehviewer/activity/MangaDetailActivity.java
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import com.hippo.ehviewer.AppContext;
import com.hippo.ehviewer.BeautifyScreen;
+import com.hippo.ehviewer.ImageGeterManager;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.data.Data;
import com.hippo.ehviewer.data.GalleryDetail;
@@ -388,8 +389,8 @@ public class MangaDetailActivity extends Activity {
mangaDetail.people = ratingCnt;
if (!MangaDetailActivity.this.isFinishing()) {
//Reset start
- LinearLayout rate = (LinearLayout) findViewById(R.id.detail_rate);
- Ui.addStar(rate, mangaDetail.rating);
+ RatingBar rate = (RatingBar)findViewById(R.id.detail_rate);
+ rate.setRating(mangaDetail.rating);
// Animation
TextView averagePeople = (TextView)findViewById(
@@ -608,11 +609,21 @@ public class MangaDetailActivity extends Activity {
setTitle(String.valueOf(mangaDetail.gid));
- LoadImageView coverImage = (LoadImageView) findViewById(R.id.detail_cover);
- coverImage.setLoadInfo(mangaDetail.thumb, String.valueOf(mangaDetail.gid));
- mAppContext.getImageGeterManager().add(mangaDetail.thumb,
- String.valueOf(mangaDetail.gid),
- new LoadImageView.SimpleImageGetListener(coverImage), true);
+ LoadImageView thumb = (LoadImageView) findViewById(R.id.detail_cover);
+ Bitmap bmp = null;
+ if (Cache.memoryCache != null &&
+ (bmp = Cache.memoryCache.get(String.valueOf(mangaDetail.gid))) != null) {
+ thumb.setLoadInfo(mangaDetail.thumb, String.valueOf(mangaDetail.gid));
+ thumb.setImageBitmap(bmp);
+ thumb.setState(LoadImageView.LOADED);
+ } else {
+ thumb.setImageDrawable(null);
+ thumb.setLoadInfo(mangaDetail.thumb, String.valueOf(mangaDetail.gid));
+ thumb.setState(LoadImageView.NONE);
+ mAppContext.getImageGeterManager().add(mangaDetail.thumb, String.valueOf(mangaDetail.gid),
+ ImageGeterManager.DISK_CACHE | ImageGeterManager.DOWNLOAD,
+ new LoadImageView.SimpleImageGetListener(thumb));
+ }
TextView title = (TextView) findViewById(R.id.detail_title);
title.setText(mangaDetail.title);
@@ -662,8 +673,8 @@ public class MangaDetailActivity extends Activity {
readButton.setEnabled(true);
rateButton.setEnabled(true);
- LinearLayout rate = (LinearLayout) findViewById(R.id.detail_rate);
- Ui.addStar(rate, mangaDetail.rating);
+ RatingBar rate = (RatingBar)findViewById(R.id.detail_rate);
+ rate.setRating(mangaDetail.rating);
TextView averagePeople = (TextView) findViewById(R.id.detail_average_people);
averagePeople.setText(String.format("%.2f (%d)", mangaDetail.rating, mangaDetail.people));
diff --git a/src/com/hippo/ehviewer/activity/MangaListActivity.java b/src/com/hippo/ehviewer/activity/MangaListActivity.java
index cdb0c575b..e6af0426a 100644
--- a/src/com/hippo/ehviewer/activity/MangaListActivity.java
+++ b/src/com/hippo/ehviewer/activity/MangaListActivity.java
@@ -24,6 +24,7 @@ import com.hippo.ehviewer.ehclient.EhClient;
import com.hippo.ehviewer.network.Downloader;
import com.hippo.ehviewer.service.DownloadService;
import com.hippo.ehviewer.service.DownloadServiceConnection;
+import com.hippo.ehviewer.util.Cache;
import com.hippo.ehviewer.util.Config;
import com.hippo.ehviewer.util.Log;
import com.hippo.ehviewer.util.Ui;
@@ -49,6 +50,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
+import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
@@ -73,6 +75,7 @@ import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
+import android.widget.RatingBar;
import android.widget.RelativeLayout;
import android.widget.SearchView;
import android.widget.Spinner;
@@ -979,9 +982,20 @@ public class MangaListActivity extends SlidingActivity {
final LoadImageView thumb = (LoadImageView)convertView.findViewById(R.id.cover);
if (!String.valueOf(lmd.gid).equals(thumb.getKey())) {
- thumb.setLoadInfo(lmd.thumb, String.valueOf(lmd.gid));
- mImageGeterManager.add(lmd.thumb, String.valueOf(lmd.gid),
- new LoadImageView.SimpleImageGetListener(thumb), true);
+ Bitmap bmp = null;
+ if (Cache.memoryCache != null &&
+ (bmp = Cache.memoryCache.get(String.valueOf(lmd.gid))) != null) {
+ thumb.setLoadInfo(lmd.thumb, String.valueOf(lmd.gid));
+ thumb.setImageBitmap(bmp);
+ thumb.setState(LoadImageView.LOADED);
+ } else {
+ thumb.setImageDrawable(null);
+ thumb.setLoadInfo(lmd.thumb, String.valueOf(lmd.gid));
+ thumb.setState(LoadImageView.NONE);
+ mImageGeterManager.add(lmd.thumb, String.valueOf(lmd.gid),
+ ImageGeterManager.DISK_CACHE | ImageGeterManager.DOWNLOAD,
+ new LoadImageView.SimpleImageGetListener(thumb));
+ }
// Set manga name
TextView name = (TextView) convertView.findViewById(R.id.name);
@@ -1000,9 +1014,9 @@ public class MangaListActivity extends SlidingActivity {
}
// Add star
- LinearLayout rate = (LinearLayout) convertView
+ RatingBar rate = (RatingBar) convertView
.findViewById(R.id.rate);
- Ui.addStar(rate, lmd.rating);
+ rate.setRating(lmd.rating);
// set posted
TextView posted = (TextView) convertView.findViewById(R.id.posted);
@@ -1399,13 +1413,6 @@ public class MangaListActivity extends SlidingActivity {
}
});
- mHlv.setVisibility(View.GONE);
- waitView.setVisibility(View.VISIBLE);
- freshButton.setVisibility(View.GONE);
- noFoundView.setVisibility(View.GONE);
- sadpanda.setVisibility(View.GONE);
- layoutDrawRight();
-
// Check update
checkUpdate();
@@ -1417,6 +1424,14 @@ public class MangaListActivity extends SlidingActivity {
mTitle = mResources.getString(R.string.homepage);
setTitle();
refresh(false);
+
+ // set layout
+ mHlv.setVisibility(View.GONE);
+ waitView.setVisibility(View.VISIBLE);
+ freshButton.setVisibility(View.GONE);
+ noFoundView.setVisibility(View.GONE);
+ sadpanda.setVisibility(View.GONE);
+ layoutDrawRight();
}
@Override
diff --git a/src/com/hippo/ehviewer/util/Ui.java b/src/com/hippo/ehviewer/util/Ui.java
index 9786ed4b3..bfe94b868 100644
--- a/src/com/hippo/ehviewer/util/Ui.java
+++ b/src/com/hippo/ehviewer/util/Ui.java
@@ -201,54 +201,20 @@ public class Ui {
}
}
- /**
- * Add star to a ViewGroup according to the
- *
- * @param context
- * @param viewGroup
- * @param rawRateString
- */
- public static void addStar(ViewGroup viewGroup,
- float rawRate) {
- if (!mInit) {
- throw new IllegalStateException("Please init Ui first.");
- }
- if (viewGroup == null)
- return;
- viewGroup.removeAllViews();
-
- int leve = (int)((rawRate + 0.4999)/0.5);
- int starNum = 5;
-
- for (int i = 0; i < leve/2; i++) {
- ImageView IvStar = new ImageView(mContext);
- IvStar.setImageResource(R.drawable.star);
- viewGroup.addView(IvStar);
- starNum--;
- }
- if (leve % 2 != 0) {
- ImageView IvStarHalf = new ImageView(mContext);
- IvStarHalf.setImageResource(R.drawable.star_half);
- viewGroup.addView(IvStarHalf);
- starNum--;
- }
- for (int i = 0; i < starNum; i++) {
- ImageView IvStarEmpty = new ImageView(mContext);
- IvStarEmpty.setImageResource(R.drawable.star_empty);
- viewGroup.addView(IvStarEmpty);
- }
- }
-
/**
* dp conversion to pix
*
* @param dp The value you want to conversion
* @return value in pix
*/
- public static int dp2pix(int dp) {
+ public static int dp2pix(float dp) {
return (int) (mContext.getResources().getDisplayMetrics().density * dp + 0.5f);
}
+ public static float pix2dp(int pix) {
+ return pix/mContext.getResources().getDisplayMetrics().density;
+ }
+
/**
* Get default BitmapFactory.Options
*
diff --git a/src/com/hippo/ehviewer/widget/LoadImageView.java b/src/com/hippo/ehviewer/widget/LoadImageView.java
index 7ace3793b..d5caed53b 100644
--- a/src/com/hippo/ehviewer/widget/LoadImageView.java
+++ b/src/com/hippo/ehviewer/widget/LoadImageView.java
@@ -65,7 +65,8 @@ public class LoadImageView extends ImageView {
setClickable(false);
setImageDrawable(null);
mImageGeterManager.add(mUrl, mKey,
- new SimpleImageGetListener(LoadImageView.this), true);
+ ImageGeterManager.DISK_CACHE | ImageGeterManager.DOWNLOAD,
+ new SimpleImageGetListener(LoadImageView.this));
}
});
}
@@ -131,30 +132,32 @@ public class LoadImageView extends ImageView {
}
@Override
- public boolean onGetImage(String key) {
- return isVaild(key);
- }
- @Override
- public void onGetImageFromCacheFail(String key) {
- mLiv.setImageDrawable(null);
+ public boolean onGetImageStart(String key) {
+ boolean re = isVaild(key) && (mLiv.getState() == LoadImageView.NONE ||
+ mLiv.getState() == LoadImageView.FAIL);
+ if (re)
+ mLiv.setState(LoadImageView.LOADING);
+ return re;
}
@Override
public void onGetImageFail(String key) {
- if (isVaild(key)) {
+ if (isVaild(key) && mLiv.getState() == LoadImageView.LOADING) {
mLiv.setTouchImage();
mLiv.setOnClick();
+ mLiv.setState(LoadImageView.FAIL);
}
}
@Override
- public void onGetImageFromCacheSuccess(String key, Bitmap bmp) {
- if (isVaild(key))
- mLiv.setImageBitmap(bmp);
- }
-
- @Override
- public void onGetImageFromDownloadSuccess(String key, Bitmap bmp) {
- if (isVaild(key))
- mLiv.setContextImage(bmp);
+ public void onGetImageSuccess(String key, Bitmap bmp, int mode) {
+ if (isVaild(key) && mLiv.getState() == LoadImageView.LOADING) {
+ if (mode == ImageGeterManager.MEMORY_CACHE
+ || mode == ImageGeterManager.DISK_CACHE)
+ mLiv.setImageBitmap(bmp);
+ else if (mode == ImageGeterManager.DOWNLOAD) {
+ mLiv.setContextImage(bmp);
+ }
+ mLiv.setState(LoadImageView.LOADED);
+ }
}
}
}