mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 18:56:44 -04:00
Fixed some notification visual glitches #460
This commit is contained in:
parent
f22e6bf212
commit
0abc7a61d8
@ -157,7 +157,10 @@ public class DownloadFragment extends Fragment {
|
||||
ProgressBar downloadProgress = (ProgressBar) convertView.findViewById(R.id.downloadProgress);
|
||||
ImageView pause = (ImageView) convertView.findViewById(R.id.pause);
|
||||
|
||||
if (LibraryFragment.mService.downloadProgress.get(mKeys[position]) != 0) {
|
||||
if (LibraryFragment.mService.downloadStatus.get(mKeys[position]) == 0) {
|
||||
downloadProgress.setProgress(0);
|
||||
pause.setImageDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.ic_pause_black_24dp));
|
||||
} else {
|
||||
downloadProgress.setProgress(LibraryFragment.mService.downloadProgress.get(mKeys[position]));
|
||||
if (LibraryFragment.mService.downloadStatus.get(mKeys[position]) == DownloadService.PAUSE) {
|
||||
pause.setImageDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.ic_play_arrow_black_24dp));
|
||||
@ -170,10 +173,10 @@ public class DownloadFragment extends Fragment {
|
||||
pause.setOnClickListener(v -> {
|
||||
if (LibraryFragment.mService.downloadStatus.get(mKeys[position]) == DownloadService.PLAY) {
|
||||
LibraryFragment.mService.pauseDownload(mKeys[position]);
|
||||
pause.setImageDrawable(getResources().getDrawable(R.drawable.ic_play_arrow_black_24dp));
|
||||
pause.setImageDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.ic_play_arrow_black_24dp));
|
||||
} else {
|
||||
LibraryFragment.mService.playDownload(mKeys[position]);
|
||||
pause.setImageDrawable(getResources().getDrawable(R.drawable.ic_pause_black_24dp));
|
||||
pause.setImageDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.ic_pause_black_24dp));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -143,6 +143,7 @@ public class DownloadService extends Service {
|
||||
.addAction(stop)
|
||||
.setOngoing(true));
|
||||
|
||||
notificationManager.notify(notificationCount, notification.get(notificationCount).build());
|
||||
downloadStatus.put(notificationCount, PLAY);
|
||||
LibraryFragment.downloadingBooks.remove(book);
|
||||
String url = intent.getExtras().getString(DownloadIntent.DOWNLOAD_URL_PARAMETER);
|
||||
@ -234,12 +235,13 @@ public class DownloadService extends Service {
|
||||
notification.get(notificationID).setContentIntent(pendingIntent);
|
||||
notification.get(notificationID).mActions.clear();
|
||||
updateForeground();
|
||||
} else if (progress == 0) {
|
||||
// Tells android to not kill the service
|
||||
startForeground(notificationCount, notification.get(notificationCount).build());
|
||||
}
|
||||
notification.get(notificationID).setProgress(100, progress, false);
|
||||
notificationManager.notify(notificationID, notification.get(notificationID).build());
|
||||
if (progress == 0) {
|
||||
// Tells android to not kill the service
|
||||
updateForeground();
|
||||
}
|
||||
if (DownloadFragment.mDownloads != null && DownloadFragment.mDownloads.get(notificationID) != null) {
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
@ -314,6 +316,8 @@ public class DownloadService extends Service {
|
||||
book.remoteUrl = book.getUrl();
|
||||
book.file = fullFile;
|
||||
bookDao.saveBook(book);
|
||||
downloadStatus.put(chunk.getNotificationID(), PLAY);
|
||||
downloadProgress.put(chunk.getNotificationID(), 0);
|
||||
}
|
||||
|
||||
byte[] buffer = new byte[2048];
|
||||
|
Loading…
x
Reference in New Issue
Block a user