部分改善详情界面,添加 Ripple 效果
This commit is contained in:
1 parent
ee229b11da
commit
e08a9bfdfa
96 files changed
+2585
-2139
No files matched your search
@@ -16,17 +16,6 @@
|
||||
|
||||
package com.hippo.ehviewer.service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.hippo.ehviewer.AppContext;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.ehclient.EhClient;
|
||||
import com.hippo.ehviewer.ehclient.EhClient.DownloadMangaManager;
|
||||
import com.hippo.ehviewer.ui.DownloadActivity;
|
||||
import com.hippo.ehviewer.ui.DownloadInfo;
|
||||
import com.hippo.ehviewer.util.Download;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
@@ -36,6 +25,13 @@ import android.content.Intent;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
|
||||
import com.hippo.ehviewer.AppContext;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.ehclient.EhClient;
|
||||
import com.hippo.ehviewer.ehclient.EhClient.DownloadMangaManager;
|
||||
import com.hippo.ehviewer.ui.DownloadActivity;
|
||||
import com.hippo.ehviewer.ui.DownloadInfo;
|
||||
import com.hippo.ehviewer.util.Download;
|
||||
import com.hippo.ehviewer.util.Log;
|
||||
|
||||
public class DownloadService extends Service {
|
||||
@@ -45,27 +41,27 @@ public class DownloadService extends Service {
|
||||
public static final String KEY_GID = "gid";
|
||||
public static final String KEY_INDEX = "index";
|
||||
public static final String KEY_STATE = "state";
|
||||
|
||||
|
||||
private AppContext mAppContext;
|
||||
|
||||
|
||||
private ServiceBinder mBinder = null;
|
||||
|
||||
|
||||
private NotificationManager mNotifyManager;
|
||||
|
||||
|
||||
private DownloadMangaManager downloadMangaManager;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
|
||||
mAppContext = (AppContext)getApplication();
|
||||
|
||||
|
||||
mBinder = new ServiceBinder();
|
||||
mNotifyManager = (NotificationManager)
|
||||
getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
||||
downloadMangaManager = mAppContext.getEhClient().new DownloadMangaManager();
|
||||
|
||||
|
||||
downloadMangaManager = EhClient.getInstance().new DownloadMangaManager();
|
||||
|
||||
downloadMangaManager.setDownloadService(this);
|
||||
downloadMangaManager.setOnDownloadMangaListener(new EhClient.OnDownloadMangaListener() {
|
||||
@Override
|
||||
@@ -77,13 +73,13 @@ public class DownloadService extends Service {
|
||||
.setProgress(0, 0, true).setOngoing(true).setAutoCancel(false);
|
||||
mNotifyManager.notify(DOWNLOAD_NOTIFY_ID, builder.getNotification());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDownloadMangaAllOver() {
|
||||
mNotifyManager.cancel(DOWNLOAD_NOTIFY_ID);
|
||||
stopSelf();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDownloadMangaStart(String id) {
|
||||
DownloadInfo di = Download.get(id);
|
||||
@@ -99,7 +95,7 @@ public class DownloadService extends Service {
|
||||
mNotifyManager.notify(DOWNLOAD_NOTIFY_ID, builder.getNotification());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDownloadMangaStart(String id, int pageSum, int startIndex) {
|
||||
DownloadInfo di = Download.get(id);
|
||||
@@ -117,13 +113,13 @@ public class DownloadService extends Service {
|
||||
mNotifyManager.cancel(Integer.parseInt(id));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDownloadMangaStop(String id) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDownloadMangaOver(String id, boolean ok) {
|
||||
String mesg = null;
|
||||
@@ -140,7 +136,7 @@ public class DownloadService extends Service {
|
||||
builder.setContentText(null).setProgress(0, 0, false).setOngoing(false);
|
||||
mNotifyManager.notify(Integer.parseInt(id), builder.getNotification());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDownloadPage(String id, int pageSum, int index) {
|
||||
DownloadInfo di = Download.get(id);
|
||||
@@ -162,45 +158,45 @@ public class DownloadService extends Service {
|
||||
public void onDownloadPageProgress(String id, int pageSum,
|
||||
int index, float totalSize, float downloadSize) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void setNotification(Notification.Builder builder) {
|
||||
|
||||
|
||||
builder.setSmallIcon(R.drawable.ic_launcher);
|
||||
|
||||
Intent intent = new Intent(DownloadService.this,DownloadActivity.class);
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(DownloadService.this, 1, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
builder.setContentIntent(pendingIntent);
|
||||
|
||||
Intent intent = new Intent(DownloadService.this,DownloadActivity.class);
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(DownloadService.this, 1, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
builder.setContentIntent(pendingIntent);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
Log.d(TAG, "Service onStartCommand");
|
||||
|
||||
return START_NOT_STICKY;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
return START_NOT_STICKY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
Log.d(TAG, "Service onBind");
|
||||
|
||||
|
||||
return mBinder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
|
||||
Log.d(TAG, "Service onDestroy");
|
||||
mNotifyManager.cancel(DOWNLOAD_NOTIFY_ID);
|
||||
|
||||
|
||||
mBinder = null;
|
||||
mNotifyManager = null;
|
||||
}
|
||||
|
||||
|
||||
public void add(String gid, String thumb, String detailUrlStr, String title) {
|
||||
DownloadInfo di = Download.get(gid);
|
||||
if (di == null) {
|
||||
@@ -216,7 +212,7 @@ public class DownloadService extends Service {
|
||||
}
|
||||
add(di);
|
||||
}
|
||||
|
||||
|
||||
public void add(String gid, String thumb, String detailUrlStr,
|
||||
String pageUrlStr, int pageSum, int lastStartIndex, String title) {
|
||||
DownloadInfo di = Download.get(gid);
|
||||
@@ -236,7 +232,7 @@ public class DownloadService extends Service {
|
||||
}
|
||||
add(di);
|
||||
}
|
||||
|
||||
|
||||
public void add(DownloadInfo di) {
|
||||
if (di.status == DownloadInfo.DOWNLOADING
|
||||
|| di.status == DownloadInfo.WAITING)
|
||||
@@ -244,16 +240,16 @@ public class DownloadService extends Service {
|
||||
di.status = DownloadInfo.WAITING;
|
||||
downloadMangaManager.add(di);
|
||||
}
|
||||
|
||||
|
||||
public void cancel(String id) {
|
||||
downloadMangaManager.cancel(id);
|
||||
}
|
||||
|
||||
|
||||
public void notifyUpdate(){
|
||||
Intent it = new Intent(ACTION_UPDATE);
|
||||
sendBroadcast(it);
|
||||
}
|
||||
|
||||
|
||||
public void notifyUpdate(String gid, int index, int state){
|
||||
Intent it = new Intent(ACTION_UPDATE);
|
||||
it.putExtra(KEY_GID, gid);
|
||||
@@ -261,7 +257,7 @@ public class DownloadService extends Service {
|
||||
it.putExtra(KEY_STATE, state);
|
||||
sendBroadcast(it);
|
||||
}
|
||||
|
||||
|
||||
public class ServiceBinder extends Binder{
|
||||
public DownloadService getService(){
|
||||
return DownloadService.this;
|
||||
|
||||
Reference in new issue
Block a user