Commit a15369fd authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

fix injections

parent c74bbdeb
......@@ -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.AppLifecycleListener
import com.biganto.visual.roompark.data.service.lifecycle.ForegroundLifecycleObserver
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: AppLifecycleListener
lateinit var appLifeCycle: ForegroundLifecycleObserver
//endregion
......@@ -489,7 +488,7 @@ class DownloadManagerService @Inject constructor(
disposable.add(
checkService
.subscribe {
if (!appLifeCycle.IsAppForeground
if (!appLifeCycle.isAppForeground
&& !hasTasks
&& !activeDownloading.get()) {
stopForeground(true)
......
......@@ -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(): ForegroundLifecycleObserver {
private var isForeground=false
val IsAppForeground : Boolean
override val isAppForeground : Boolean
get() = isForeground
......@@ -31,3 +32,7 @@ class AppLifecycleListener : LifecycleObserver {
isForeground=false
}
}
interface ForegroundLifecycleObserver : LifecycleObserver{
val isAppForeground : Boolean
}
\ No newline at end of file
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
......
......@@ -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.AppLifecycleListener
import com.biganto.visual.roompark.data.service.notification.NotificationCenter
import com.biganto.visual.roompark.data.service.lifecycle.ForegroundLifecycleObserver
import com.biganto.visual.roompark.data.service.notification.INotificationCenter
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(): AppLifecycleListener
fun provideLifeCycle(): ForegroundLifecycleObserver
fun provideNotifivations():NotificationCenter
fun provideNotifivations(): INotificationCenter
fun provideAppContext():Application
......
......@@ -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 provideLifecycleObserver(obs:AppLifecycleListener): AppLifecycleListener
abstract fun provideNotyCenter(center: NotificationCenter): INotificationCenter
@Singleton
@Binds
abstract fun provideNotyCenter(center:NotificationCenter): NotificationCenter
abstract fun provideLifecycleObserver(obs:AppLifecycleListener): ForegroundLifecycleObserver
@Singleton
@Binds
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment