Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused module matrix-sdk-android-rx and do some cleanup #4942

Merged
merged 5 commits into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions attachment-viewer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,10 @@ android {

dependencies {
implementation project(":library:ui-styles")
implementation project(":library:core-utils")

implementation 'com.github.chrisbanes:PhotoView:2.3.0'

implementation libs.rx.rxKotlin
implementation libs.rx.rxAndroid

implementation libs.androidx.core
implementation libs.androidx.appCompat
implementation libs.androidx.recyclerview
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@ import android.util.Log
import android.view.View
import androidx.core.view.isVisible
import im.vector.lib.attachmentviewer.databinding.ItemVideoAttachmentBinding
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import im.vector.lib.core.utils.timer.CountUpTimer
import java.io.File
import java.lang.ref.WeakReference
import java.util.concurrent.TimeUnit

// TODO, it would be probably better to use a unique media player
// for better customization and control
Expand All @@ -35,7 +32,7 @@ class VideoViewHolder constructor(itemView: View) :

private var isSelected = false
private var mVideoPath: String? = null
private var progressDisposable: Disposable? = null
private var countUpTimer: CountUpTimer? = null
private var progress: Int = 0
private var wasPaused = false

Expand All @@ -47,8 +44,7 @@ class VideoViewHolder constructor(itemView: View) :

override fun onRecycled() {
super.onRecycled()
progressDisposable?.dispose()
progressDisposable = null
stopTimer()
mVideoPath = null
}

Expand All @@ -72,8 +68,7 @@ class VideoViewHolder constructor(itemView: View) :
override fun entersBackground() {
if (views.videoView.isPlaying) {
progress = views.videoView.currentPosition
progressDisposable?.dispose()
progressDisposable = null
stopTimer()
views.videoView.stopPlayback()
views.videoView.pause()
}
Expand All @@ -91,8 +86,7 @@ class VideoViewHolder constructor(itemView: View) :
} else {
progress = 0
}
progressDisposable?.dispose()
progressDisposable = null
stopTimer()
} else {
if (mVideoPath != null) {
startPlaying()
Expand All @@ -107,17 +101,19 @@ class VideoViewHolder constructor(itemView: View) :
views.videoView.isVisible = true

views.videoView.setOnPreparedListener {
progressDisposable?.dispose()
progressDisposable = Observable.interval(100, TimeUnit.MILLISECONDS)
.timeInterval()
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
stopTimer()
countUpTimer = CountUpTimer(100).also {
it.tickListener = object : CountUpTimer.TickListener {
override fun onTick(milliseconds: Long) {
val duration = views.videoView.duration
val progress = views.videoView.currentPosition
val isPlaying = views.videoView.isPlaying
// Log.v("FOO", "isPlaying $isPlaying $progress/$duration")
eventListener?.get()?.onEvent(AttachmentEvents.VideoEvent(isPlaying, progress, duration))
}
}
it.resume()
}
}
try {
views.videoView.setVideoPath(mVideoPath)
Expand All @@ -134,6 +130,11 @@ class VideoViewHolder constructor(itemView: View) :
}
}

private fun stopTimer() {
countUpTimer?.stop()
countUpTimer = null
}

override fun handleCommand(commands: AttachmentCommands) {
if (!isSelected) return
when (commands) {
Expand Down
10 changes: 0 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,3 @@ project(":diff-match-patch") {
// }
// }
//}
//
//project(":matrix-sdk-android-rx") {
// sonarqube {
// properties {
// property "sonar.sources", project(":matrix-sdk-android-rx").android.sourceSets.main.java.srcDirs
// // exclude source code from analyses separated by a colon (:)
// // property "sonar.exclusions", "**/*.*"
// }
// }
//}
1 change: 1 addition & 0 deletions changelog.d/4942.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove unused module matrix-sdk-android-rx and do some cleanup
4 changes: 1 addition & 3 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ ext.libs = [
jetbrains : [
'coroutinesCore' : "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutines",
'coroutinesAndroid' : "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinCoroutines",
'coroutinesRx2' : "org.jetbrains.kotlinx:kotlinx-coroutines-rx2:$kotlinCoroutines",
'coroutinesTest' : "org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinCoroutines"
],
androidx : [
Expand Down Expand Up @@ -87,8 +86,7 @@ ext.libs = [
'retrofitMoshi' : "com.squareup.retrofit2:converter-moshi:$retrofit"
],
rx : [
'rxKotlin' : "io.reactivex.rxjava2:rxkotlin:2.4.0",
'rxAndroid' : "io.reactivex.rxjava2:rxandroid:2.1.1"
'rxKotlin' : "io.reactivex.rxjava2:rxkotlin:2.4.0"
],
arrow : [
'core' : "io.arrow-kt:arrow-core:$arrow",
Expand Down
1 change: 1 addition & 0 deletions library/core-utils/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
55 changes: 55 additions & 0 deletions library/core-utils/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (c) 2021 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

plugins {
id 'com.android.library'
id 'kotlin-android'
}

android {
compileSdk versions.compileSdk
defaultConfig {
minSdk versions.minSdk
targetSdk versions.targetSdk

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility versions.sourceCompat
targetCompatibility versions.targetCompat
}

kotlinOptions {
jvmTarget = "11"
freeCompilerArgs += [
"-Xopt-in=kotlin.RequiresOptIn"
]
}
}

dependencies {
implementation libs.androidx.appCompat
implementation libs.jetbrains.coroutinesAndroid
}
2 changes: 2 additions & 0 deletions library/core-utils/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="im.vector.lib.core.utils" />
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package im.vector.app.core.flow
package im.vector.lib.core.utils.flow

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
Expand Down Expand Up @@ -85,10 +85,12 @@ fun <T> Flow<T>.throttleFirst(windowDuration: Long): Flow<T> = flow {
}
}

@ExperimentalCoroutinesApi
fun tickerFlow(scope: CoroutineScope, delayMillis: Long, initialDelayMillis: Long = delayMillis): Flow<Unit> {
return scope.fixedPeriodTicker(delayMillis, initialDelayMillis).consumeAsFlow()
}

@ExperimentalCoroutinesApi
private fun CoroutineScope.fixedPeriodTicker(delayMillis: Long, initialDelayMillis: Long = delayMillis): ReceiveChannel<Unit> {
require(delayMillis >= 0) { "Expected non-negative delay, but has $delayMillis ms" }
require(initialDelayMillis >= 0) { "Expected non-negative initial delay, but has $initialDelayMillis ms" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*/

package im.vector.app.core.utils
package im.vector.lib.core.utils.timer

import im.vector.app.core.flow.tickerFlow
import im.vector.lib.core.utils.flow.tickerFlow
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.cancel
Expand All @@ -27,6 +27,7 @@ import kotlinx.coroutines.flow.onEach
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicLong

@OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class)
class CountUpTimer(private val intervalInMs: Long = 1_000) {

private val coroutineScope = CoroutineScope(Dispatchers.Main)
Expand Down
1 change: 0 additions & 1 deletion matrix-sdk-android-rx/.gitignore

This file was deleted.

47 changes: 0 additions & 47 deletions matrix-sdk-android-rx/build.gradle

This file was deleted.

21 changes: 0 additions & 21 deletions matrix-sdk-android-rx/proguard-rules.pro

This file was deleted.

1 change: 0 additions & 1 deletion matrix-sdk-android-rx/src/main/AndroidManifest.xml

This file was deleted.

This file was deleted.

Loading