修正 ratingbar
This commit is contained in:
1 parent
c97dccaf04
commit
80e0432c73
16 files changed
+189
-159
No files matched your search
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@android:id/background" android:drawable="@drawable/star_small_empty" />
|
||||
<item android:id="@android:id/secondaryProgress" android:drawable="@drawable/star_small_half" />
|
||||
<item android:id="@android:id/progress" android:drawable="@drawable/star_small" />
|
||||
</layer-list>
|
||||
@@ -16,12 +16,12 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation = "horizontal" >
|
||||
|
||||
<LinearLayout
|
||||
<RatingBar
|
||||
android:id="@+id/detail_rate"
|
||||
style="@style/RatingBarSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:orientation = "horizontal" />
|
||||
android:layout_centerVertical="true" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/detail_average_people"
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical"
|
||||
android:fitsSystemWindows="true" >
|
||||
android:orientation="vertical" >
|
||||
|
||||
<ListView
|
||||
android:id="@+id/favourite"
|
||||
@@ -10,7 +9,9 @@
|
||||
android:layout_height="fill_parent"
|
||||
android:divider="@null"
|
||||
android:listSelector="@android:color/transparent"
|
||||
android:cacheColorHint="@color/main_background" >
|
||||
android:cacheColorHint="@color/main_background"
|
||||
android:fitsSystemWindows="true"
|
||||
android:clipToPadding="false" >
|
||||
</ListView>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -38,14 +38,14 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<LinearLayout
|
||||
<RatingBar
|
||||
android:id="@+id/rate"
|
||||
style="@style/RatingBarSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="2.0dip"
|
||||
android:layout_marginTop="2.0dip"
|
||||
android:orientation="horizontal" >
|
||||
</LinearLayout>
|
||||
android:layout_marginTop="2.0dip" >
|
||||
</RatingBar>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
|
||||
@@ -33,4 +33,6 @@
|
||||
<dimen name="button_tag_padding_x">8.0dp</dimen>
|
||||
<dimen name="button_tag_padding_y">2.0dp</dimen>
|
||||
|
||||
<!-- Rating bar -->
|
||||
<dimen name="rating_bar_small_height">14.0dip</dimen>
|
||||
</resources>
|
||||
@@ -152,4 +152,18 @@
|
||||
<item name="android:paddingRight">8.0dp</item>
|
||||
</style>
|
||||
|
||||
<style name="RatingBarSmall">
|
||||
<item name="android:background">@null</item>
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:button">@null</item>
|
||||
<item name="android:maxHeight">@dimen/rating_bar_small_height</item>
|
||||
<item name="android:progressDrawable">@drawable/ratingbar_small</item>
|
||||
<item name="android:minHeight">@dimen/rating_bar_small_height</item>
|
||||
<item name="android:thumb">@null</item>
|
||||
<item name="android:numStars">5</item>
|
||||
<item name="android:stepSize">0.5</item>
|
||||
<item name="android:isIndicator">true</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user