Skip to content

Commit 696eb79

Browse files
committed
Release V1.0.8
1 parent b84f5d8 commit 696eb79

File tree

4 files changed

+43
-9
lines changed

4 files changed

+43
-9
lines changed

GSYVideoPlayer

app/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ android {
1919
vectorDrawables.useSupportLibrary = true
2020

2121
ndk {
22-
abiFilters 'armeabi-v7a'
22+
abiFilters 'armeabi-v7a', 'x86'
2323
}
2424
}
2525
signingConfigs {

app/src/main/kotlin/me/sweetll/tucao/business/home/MainActivity.kt

+5-4
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ import javax.inject.Inject
5555
class MainActivity : BaseActivity() {
5656

5757
companion object {
58-
const val NOTIFICATION_ID = 1
58+
const val NOTIFICATION_ID = 10
5959
}
6060

6161
lateinit var binding : ActivityMainBinding
@@ -131,7 +131,8 @@ class MainActivity : BaseActivity() {
131131
.into(avatarImg)
132132

133133
avatarImg.setOnClickListener {
134-
LoginActivity.intentTo(this)
134+
"放个入口在这里,下个版本做登陆系统(・∀・)".toast()
135+
// LoginActivity.intentTo(this)
135136
}
136137

137138
checkUpdate(true)
@@ -275,7 +276,7 @@ class MainActivity : BaseActivity() {
275276
})
276277

277278
val builder = NotificationCompat.Builder(this)
278-
.setSmallIcon(R.drawable.ic_file_download_white)
279+
.setSmallIcon(R.mipmap.ic_launcher)
279280
val notifyMgr = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
280281

281282
processor.sample(500, TimeUnit.MILLISECONDS)
@@ -370,7 +371,7 @@ class MainActivity : BaseActivity() {
370371
})
371372

372373
val builder = NotificationCompat.Builder(this)
373-
.setSmallIcon(R.drawable.ic_file_download_white)
374+
.setSmallIcon(R.mipmap.ic_launcher)
374375
val notifyMgr = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
375376

376377
processor.sample(500, TimeUnit.MILLISECONDS)

app/src/main/kotlin/me/sweetll/tucao/rxdownload/function/DownloadService.kt

+36-3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class DownloadService: Service() {
4242
companion object {
4343
const val ONGOING_NOTIFICATION_ID = 1
4444
const val COMPLETED_NOTIFICATION_ID = 2
45+
const val FAILED_NOTIFICATION_ID =3
4546

4647
const val ACTION_PAUSE = "pause"
4748
const val ACTION_CANCEL = "cancel"
@@ -210,6 +211,7 @@ class DownloadService: Service() {
210211
file.close()
211212
} catch (error: Exception) {
212213
error.printStackTrace()
214+
processor.onNext(DownloadEvent(DownloadStatus.FAILED))
213215
}
214216
}, {
215217
error ->
@@ -268,6 +270,10 @@ class DownloadService: Service() {
268270
mission.bean.save()
269271
stopForeground(true)
270272
}
273+
DownloadStatus.FAILED -> {
274+
mission.pause = true
275+
mission.bean.save()
276+
}
271277
DownloadStatus.COMPLETED -> {
272278
mission.bean.save()
273279
part.durls.find {
@@ -285,6 +291,7 @@ class DownloadService: Service() {
285291
}
286292

287293
private fun sendNotification(event: DownloadEvent, url: String) {
294+
"Send Notification ${event.status}...".logD()
288295
when (event.status) {
289296
DownloadStatus.STARTED, DownloadStatus.READY -> {
290297
val nfIntent = Intent(this, DownloadActivity::class.java)
@@ -308,7 +315,7 @@ class DownloadService: Service() {
308315
val piCancel = PendingIntent.getService(this, 0, cancelIntent, PendingIntent.FLAG_UPDATE_CURRENT)
309316

310317
val builder = NotificationCompat.Builder(this)
311-
.setSmallIcon(R.drawable.ic_file_download_white)
318+
.setSmallIcon(R.mipmap.ic_launcher)
312319
.setContentTitle(event.taskName)
313320
.setContentIntent(pendingIntent)
314321
.addAction(R.drawable.ic_action_pause, "暂停", piPause)
@@ -322,7 +329,7 @@ class DownloadService: Service() {
322329
builder.setContentText("连接中...")
323330
}
324331
val notification = builder.build()
325-
notification.flags = notification.flags or Notification.FLAG_NO_CLEAR or Notification.FLAG_ONGOING_EVENT
332+
notification.flags = notification.flags or Notification.FLAG_NO_CLEAR
326333

327334
startForeground(ONGOING_NOTIFICATION_ID, notification)
328335
}
@@ -339,7 +346,7 @@ class DownloadService: Service() {
339346

340347
val builder = NotificationCompat.Builder(this)
341348
.setProgress(0, 0, false)
342-
.setSmallIcon(R.drawable.ic_file_download_white)
349+
.setSmallIcon(R.mipmap.ic_launcher)
343350
.setContentTitle(event.taskName)
344351
.setContentText("${event.totalSize.formatWithUnit()}/已完成")
345352
.setContentIntent(pendingIntent)
@@ -352,6 +359,32 @@ class DownloadService: Service() {
352359

353360
notifyMgr.notify(COMPLETED_NOTIFICATION_ID, notification)
354361
}
362+
DownloadStatus.FAILED -> {
363+
val nfIntent = Intent(this, DownloadActivity::class.java)
364+
nfIntent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP
365+
nfIntent.action = DownloadActivity.ACTION_DOWNLOADING
366+
367+
val stackBuilder = TaskStackBuilder.create(this)
368+
stackBuilder.addParentStack(DownloadActivity::class.java)
369+
stackBuilder.addNextIntent(nfIntent)
370+
371+
val pendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT)
372+
373+
val builder = NotificationCompat.Builder(this)
374+
.setProgress(0, 0, false)
375+
.setSmallIcon(R.mipmap.ic_launcher)
376+
.setContentTitle(event.taskName)
377+
.setContentText("下载失败")
378+
.setContentIntent(pendingIntent)
379+
val notification = builder.build()
380+
notification.flags = notification.flags or Notification.FLAG_AUTO_CANCEL
381+
382+
val notifyMgr = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
383+
384+
stopForeground(true)
385+
386+
notifyMgr.notify(FAILED_NOTIFICATION_ID, notification)
387+
}
355388
}
356389
}
357390

0 commit comments

Comments
 (0)