Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Room Park Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vladislav Bogdashkin
Room Park Android
Commits
a15369fd
Commit
a15369fd
authored
Apr 14, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix injections
parent
c74bbdeb
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
25 deletions
+44
-25
TourDownloadService.kt
...ual/roompark/data/service/download/TourDownloadService.kt
+3
-4
RoomParkAppLifesycleListener.kt
...rk/data/service/lifecycle/RoomParkAppLifesycleListener.kt
+7
-2
NotificationCenter.kt
.../roompark/data/service/notification/NotificationCenter.kt
+25
-13
AppComponent.kt
...ava/com/biganto/visual/roompark/di/dagger/AppComponent.kt
+4
-4
DataModule.kt
.../java/com/biganto/visual/roompark/di/dagger/DataModule.kt
+5
-2
No files found.
app/src/main/java/com/biganto/visual/roompark/data/service/download/TourDownloadService.kt
View file @
a15369fd
...
...
@@ -6,7 +6,6 @@ import android.content.Intent
import
android.media.MediaScannerConnection
import
android.os.IBinder
import
androidx.core.math.MathUtils.clamp
import
androidx.lifecycle.LifecycleObserver
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.base.RoomParkApplication
import
com.biganto.visual.roompark.data.repository.api.biganto.IBigantoApi
...
...
@@ -16,7 +15,7 @@ import com.biganto.visual.roompark.data.repository.db.requrey.model.FileEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.TourFileJunctionEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.fromRaw
import
com.biganto.visual.roompark.data.repository.file.FileModule
import
com.biganto.visual.roompark.data.service.lifecycle.
AppLifecycleListen
er
import
com.biganto.visual.roompark.data.service.lifecycle.
ForegroundLifecycleObserv
er
import
com.biganto.visual.roompark.data.service.notification.NotificationCenter
import
com.biganto.visual.roomparkvr.data.repository.db.requery.model.DownloadState
import
com.biganto.visual.roomparkvr.data.repository.db.requery.model.TourPreviewEntity
...
...
@@ -68,7 +67,7 @@ class DownloadManagerService @Inject constructor(
lateinit
var
notificationsCenter
:
NotificationCenter
@Inject
lateinit
var
appLifeCycle
:
AppLifecycleListen
er
lateinit
var
appLifeCycle
:
ForegroundLifecycleObserv
er
//endregion
...
...
@@ -489,7 +488,7 @@ class DownloadManagerService @Inject constructor(
disposable
.
add
(
checkService
.
subscribe
{
if
(!
appLifeCycle
.
I
sAppForeground
if
(!
appLifeCycle
.
i
sAppForeground
&&
!
hasTasks
&&
!
activeDownloading
.
get
())
{
stopForeground
(
true
)
...
...
app/src/main/java/com/biganto/visual/roompark/data/service/lifecycle/RoomParkAppLifesycleListener.kt
View file @
a15369fd
...
...
@@ -8,14 +8,15 @@ import androidx.lifecycle.Lifecycle
import
androidx.lifecycle.LifecycleObserver
import
androidx.lifecycle.OnLifecycleEvent
import
timber.log.Timber
import
javax.inject.Inject
import
javax.inject.Singleton
@Singleton
class
AppLifecycleListener
:
LifecycleObserver
{
class
AppLifecycleListener
@Inject
constructor
():
Foreground
LifecycleObserver
{
private
var
isForeground
=
false
val
I
sAppForeground
:
Boolean
override
val
i
sAppForeground
:
Boolean
get
()
=
isForeground
...
...
@@ -31,3 +32,7 @@ class AppLifecycleListener : LifecycleObserver {
isForeground
=
false
}
}
interface
ForegroundLifecycleObserver
:
LifecycleObserver
{
val
isAppForeground
:
Boolean
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/data/service/notification/NotificationCenter.kt
View file @
a15369fd
package
com.biganto.visual.roompark.data.service.notification
import
android.annotation.TargetApi
import
android.app.Notification
import
android.app.NotificationChannel
import
android.app.NotificationManager
import
android.app.PendingIntent
import
android.app.*
import
android.content.Context
import
android.content.Intent
import
android.graphics.BitmapFactory
...
...
@@ -35,8 +32,23 @@ const val NOTIFICATION_INTENT_STOP_SERVICE_ACTION="STOP_DOWNLOADS_SERVICE"
const
val
PENDING_REQUEST_CODE
=
0
interface
INotificationCenter
{
fun
indeterminateProgressMessage
(
progress
:
Int
=
0
,
progressMax
:
Int
=
0
,
message
:
String
)
fun
completeProgressMessage
(
message
:
String
)
fun
donwloadServiceProgressNotfication
(
progress
:
Int
=
0
,
progressMax
:
Int
=
0
,
indeterminate
:
Boolean
=
true
,
message
:
String
)
}
@Singleton
class
NotificationCenter
@Inject
constructor
(
val
context
:
Context
)
{
class
NotificationCenter
@Inject
constructor
(
val
context
:
Application
)
:
INotificationCenter
{
private
val
updateProgressNotificationDelay_Milliseconds
=
333
private
var
lastTimeProgressNotificationUpdated
=
0L
...
...
@@ -82,9 +94,9 @@ class NotificationCenter @Inject constructor(val context: Context) {
fun
indeterminateProgressMessage
(
progress
:
Int
=
0
,
progressMax
:
Int
=
0
,
message
:
String
)
{
override
fun
indeterminateProgressMessage
(
progress
:
Int
,
progressMax
:
Int
,
message
:
String
)
{
if
(
progress
!=
0
)
if
(
System
.
currentTimeMillis
()-
lastTimeProgressNotificationUpdated
<
updateProgressNotificationDelay_Milliseconds
)
...
...
@@ -93,14 +105,14 @@ class NotificationCenter @Inject constructor(val context: Context) {
donwloadServiceProgressNotfication
(
progress
,
progressMax
,
true
,
message
)
}
fun
completeProgressMessage
(
message
:
String
){
override
fun
completeProgressMessage
(
message
:
String
){
donwloadServiceProgressNotfication
(
indeterminate
=
false
,
message
=
message
)
}
fun
donwloadServiceProgressNotfication
(
progress
:
Int
=
0
,
progressMax
:
Int
=
0
,
indeterminate
:
Boolean
=
true
,
message
:
String
){
override
fun
donwloadServiceProgressNotfication
(
progress
:
Int
,
progressMax
:
Int
,
indeterminate
:
Boolean
,
message
:
String
){
val
pendingIntent
=
PendingIntent
.
getActivity
(
context
,
PENDING_REQUEST_CODE
...
...
app/src/main/java/com/biganto/visual/roompark/di/dagger/AppComponent.kt
View file @
a15369fd
...
...
@@ -10,8 +10,8 @@ import com.biganto.visual.roompark.data.repository.api.room_park.IRoomParkApi
import
com.biganto.visual.roompark.data.repository.db.IDb
import
com.biganto.visual.roompark.data.repository.db.requrey.DbModule
import
com.biganto.visual.roompark.data.repository.file.FileModule
import
com.biganto.visual.roompark.data.service.lifecycle.
AppLifecycleListen
er
import
com.biganto.visual.roompark.data.service.notification.NotificationCenter
import
com.biganto.visual.roompark.data.service.lifecycle.
ForegroundLifecycleObserv
er
import
com.biganto.visual.roompark.data.service.notification.
I
NotificationCenter
import
com.biganto.visual.roompark.domain.contract.*
import
dagger.BindsInstance
import
dagger.Component
...
...
@@ -66,9 +66,9 @@ interface AppComponent : AndroidInjector<RoomParkApplication>{
fun
provideTour
():
TourContract
fun
provideLifeCycle
():
AppLifecycleListen
er
fun
provideLifeCycle
():
ForegroundLifecycleObserv
er
fun
provideNotifivations
():
NotificationCenter
fun
provideNotifivations
():
I
NotificationCenter
fun
provideAppContext
():
Application
...
...
app/src/main/java/com/biganto/visual/roompark/di/dagger/DataModule.kt
View file @
a15369fd
...
...
@@ -11,6 +11,8 @@ import com.biganto.visual.roompark.data.repository.db.IDb
import
com.biganto.visual.roompark.data.repository.db.requrey.DbModule
import
com.biganto.visual.roompark.data.repository.db.requrey.RequeryRepository
import
com.biganto.visual.roompark.data.service.lifecycle.AppLifecycleListener
import
com.biganto.visual.roompark.data.service.lifecycle.ForegroundLifecycleObserver
import
com.biganto.visual.roompark.data.service.notification.INotificationCenter
import
com.biganto.visual.roompark.data.service.notification.NotificationCenter
import
com.biganto.visual.roompark.domain.contract.*
import
dagger.Binds
...
...
@@ -73,13 +75,14 @@ abstract class DataModule {
@Binds
abstract
fun
provideRoomParkApi
(
roomParkApi
:
RetrofitRepository
):
IRoomParkApi
@Singleton
@Binds
abstract
fun
provide
LifecycleObserver
(
obs
:
AppLifecycleListener
):
AppLifecycleListen
er
abstract
fun
provide
NotyCenter
(
center
:
NotificationCenter
):
INotificationCent
er
@Singleton
@Binds
abstract
fun
provide
NotyCenter
(
center
:
NotificationCenter
):
NotificationCent
er
abstract
fun
provide
LifecycleObserver
(
obs
:
AppLifecycleListener
):
ForegroundLifecycleObserv
er
@Singleton
@Binds
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment