Skip to content

Commit 0facf07

Browse files
author
jesus
committed
remove un used code
1 parent 95efb44 commit 0facf07

File tree

2 files changed

+14
-31
lines changed

2 files changed

+14
-31
lines changed

libraries/mediaviewer/impl/src/main/kotlin/io/element/android/libraries/mediaviewer/impl/floatingvideo/FloatingVideoService.kt

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,14 @@ class FloatingVideoService : Service(), LifecycleOwner, SavedStateRegistryOwner
5555

5656
companion object {
5757
const val ACTION_START_FLOATING = "START_FLOATING"
58-
const val ACTION_STOP_FLOATING = "STOP_FLOATING"
59-
const val ACTION_UPDATE_POSITION = "UPDATE_POSITION"
6058
const val EXTRA_VIDEO_ID = "video_id"
6159
const val EXTRA_POSITION = "position"
6260

6361
private const val INITIAL_FLOATING_WINDOW_OFFSET_Y = 300
6462

6563
@SuppressLint("ObsoleteSdkInt")
6664
fun startFloating(
67-
context: Context, videoData: MediaViewerPageData.MediaViewerData, position: Long = 0L
65+
context: Context, videoId: String, position: Long = 0L
6866
) {
6967
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(context)) {
7068

@@ -76,13 +74,9 @@ class FloatingVideoService : Service(), LifecycleOwner, SavedStateRegistryOwner
7674
return
7775
}
7876

79-
80-
// Store the video data in repository via DI
81-
val videoId = context.bindings<FloatingVideoServiceBindings>().videoDataRepository().storeVideoData(videoData)
82-
8377
val intent = Intent(context, FloatingVideoService::class.java).apply {
8478
action = ACTION_START_FLOATING
85-
putExtra(EXTRA_VIDEO_ID, videoId) // Pass only the ID, not the whole object
79+
putExtra(EXTRA_VIDEO_ID, videoId)
8680
putExtra(EXTRA_POSITION, position)
8781
}
8882
context.startService(intent)
@@ -136,21 +130,6 @@ class FloatingVideoService : Service(), LifecycleOwner, SavedStateRegistryOwner
136130
}
137131
}
138132
}
139-
140-
ACTION_STOP_FLOATING -> {
141-
// Clean up stored data
142-
currentVideoId?.let { videoId ->
143-
videoDataRepository.removeVideoData(videoId)
144-
}
145-
removeFloatingView()
146-
stopSelf()
147-
}
148-
149-
ACTION_UPDATE_POSITION -> {
150-
val position = intent.getLongExtra(EXTRA_POSITION, 0L)
151-
currentPosition = position
152-
videoView?.seekTo(position.toInt())
153-
}
154133
}
155134
return START_STICKY
156135
}

libraries/mediaviewer/impl/src/main/kotlin/io/element/android/libraries/mediaviewer/impl/viewer/MediaViewerNode.kt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ package io.element.android.libraries.mediaviewer.impl.viewer
1111
import androidx.compose.foundation.layout.Box
1212
import androidx.compose.foundation.layout.fillMaxSize
1313
import androidx.compose.runtime.Composable
14-
import androidx.compose.runtime.mutableStateOf
15-
import androidx.compose.runtime.remember
14+
import androidx.compose.runtime.LaunchedEffect
1615
import androidx.compose.runtime.collectAsState
1716
import androidx.compose.runtime.getValue
17+
import androidx.compose.runtime.mutableStateOf
1818
import androidx.compose.runtime.remember
1919
import androidx.compose.ui.Modifier
2020
import androidx.compose.ui.platform.LocalContext
@@ -43,6 +43,7 @@ import io.element.android.libraries.mediaviewer.api.local.LocalMediaFactory
4343
import io.element.android.libraries.mediaviewer.impl.datasource.FocusedTimelineMediaGalleryDataSourceFactory
4444
import io.element.android.libraries.mediaviewer.impl.datasource.TimelineMediaGalleryDataSource
4545
import io.element.android.libraries.mediaviewer.impl.floatingvideo.FloatingVideoService
46+
import io.element.android.libraries.mediaviewer.impl.floatingvideo.VideoDataRepository
4647
import io.element.android.libraries.mediaviewer.impl.model.hasEvent
4748
import io.element.android.services.toolbox.api.systemclock.SystemClock
4849

@@ -59,6 +60,7 @@ class MediaViewerNode(
5960
coroutineDispatchers: CoroutineDispatchers,
6061
systemClock: SystemClock,
6162
pagerKeysHandler: PagerKeysHandler,
63+
private val videoDataRepository: VideoDataRepository,
6264
private val textFileViewer: TextFileViewer,
6365
private val audioFocus: AudioFocus,
6466
private val sessionId: SessionId,
@@ -145,11 +147,17 @@ class MediaViewerNode(
145147
ForcedDarkElementTheme(
146148
colors = colors,
147149
) {
148-
149-
// ForcedDarkElementTheme {
150150
val state = presenter.present()
151151
val data = state.listData
152152
.getOrNull(state.currentIndex) as? MediaViewerPageData.MediaViewerData
153+
154+
LaunchedEffect(isMinimized, data) {
155+
if ( data != null && isMinimized && data.mediaInfo.mimeType.isMimeTypeVideo() ) {
156+
val videoId = videoDataRepository.storeVideoData(data)
157+
FloatingVideoService.startFloating(context, videoId, 0L)
158+
}
159+
}
160+
153161
Box(modifier = modifier.fillMaxSize()) {
154162
MediaViewerView(
155163
state = state,
@@ -159,10 +167,6 @@ class MediaViewerNode(
159167
onBackClick = callback::onDone,
160168
setMinimize = setMinimized
161169
)
162-
if (isMinimized && data?.mediaInfo?.mimeType.isMimeTypeVideo() && data != null) {
163-
164-
FloatingVideoService.startFloating(context, data, 0L)
165-
}
166170
}
167171
}
168172
}

0 commit comments

Comments
 (0)