diff options
author | Allan Wang <me@allanwang.ca> | 2018-09-26 14:56:44 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-26 14:56:44 -0400 |
commit | 438affb07ae106e490884fafa3c2dd825e7649a4 (patch) | |
tree | b94e182bf4d083af049120a6b5f94f82c4595318 /app/src/main/kotlin/com/pitchedapps/frost/views | |
parent | c5e769deabeb80d7257b85c5c3d802cf46e6b191 (diff) | |
download | frost-438affb07ae106e490884fafa3c2dd825e7649a4.tar.gz frost-438affb07ae106e490884fafa3c2dd825e7649a4.tar.bz2 frost-438affb07ae106e490884fafa3c2dd825e7649a4.zip |
Cleanup (#1087)
* Feature/download manager (#855)
* Add initial github release check
* Create update service
* Clean old manager directory
* Update kau
* Update updateActivity snippet
* Add back gradle keys
* Remove update service functionality
* Update changelog
* Misc (#865)
* Clean up git code
* Update download link
* Update theme
* Reorder settings, resolvees #856
* Do not log undeliverable exception
* Handle potential lack of webview
* Set notification epoch default to now, resolves #857
* Fix notification epoch time init
* Update changelog
* Update theme
* Add slack url, resolves #880
* Prepare for image update
* Fix view full image (#882)
* Test including full photo viewer
* Test cookie in glide
* Fix parser and add redirects to view full image
* Update changelog
* Fix compilation and add new keys
* Update all versions
* Fix signing configs
* Fix exoplayer api update
* Change string usage
* Test scss on travis
* Test with node_js flag
* Add back css
* Update versions and fix video view
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/views')
3 files changed, 20 insertions, 16 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt index 4622971b..19b1176e 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt @@ -17,7 +17,9 @@ import com.pitchedapps.frost.facebook.WEB_LOAD_DELAY import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.Prefs import io.reactivex.android.schedulers.AndroidSchedulers +import io.reactivex.disposables.CompositeDisposable import io.reactivex.disposables.Disposable +import io.reactivex.rxkotlin.addTo import io.reactivex.subjects.BehaviorSubject import io.reactivex.subjects.PublishSubject @@ -53,6 +55,8 @@ abstract class FrostContentView<out T> @JvmOverloads constructor( override val refreshObservable: PublishSubject<Boolean> = PublishSubject.create() override val titleObservable: BehaviorSubject<String> = BehaviorSubject.create() + private val compositeDisposable = CompositeDisposable() + override lateinit var baseUrl: String override var baseEnum: FbItem? = null @@ -81,14 +85,14 @@ abstract class FrostContentView<out T> @JvmOverloads constructor( progress.setProgress(it, true) else progress.progress = it - } + }.addTo(compositeDisposable) refreshObservable .observeOn(AndroidSchedulers.mainThread()) .subscribe { refresh.isRefreshing = it refresh.isEnabled = true - } + }.addTo(compositeDisposable) refresh.setOnRefreshListener { coreView.reload(true) } reloadThemeSelf() @@ -126,6 +130,7 @@ abstract class FrostContentView<out T> @JvmOverloads constructor( progressObservable.onComplete() refreshObservable.onComplete() core.destroy() + compositeDisposable.dispose() } private var dispose: Disposable? = null diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt index c45bf23d..d7f44420 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt @@ -14,6 +14,7 @@ import ca.allanwang.kau.utils.AnimHolder import ca.allanwang.kau.utils.dpToPx import ca.allanwang.kau.utils.scaleXY import ca.allanwang.kau.utils.toast +import com.devbrackets.android.exomedia.ui.widget.VideoControls import com.devbrackets.android.exomedia.ui.widget.VideoView import com.pitchedapps.frost.R import com.pitchedapps.frost.utils.L @@ -78,7 +79,7 @@ class FrostVideoView @JvmOverloads constructor( if (!isPlaying) showControls() else viewerContract.onControlsHidden() } - } + }.start() } else { hideControls() val (scale, tX, tY) = mapBounds() @@ -89,7 +90,7 @@ class FrostVideoView @JvmOverloads constructor( withAnimator(origScale, scale) { scaleXY = it } withAnimator(origX, tX) { translationX = it } withAnimator(origY, tY) { translationY = it } - } + }.start() } } @@ -144,7 +145,8 @@ class FrostVideoView @JvmOverloads constructor( } setOnTouchListener(FrameTouchListener(context)) v.setOnTouchListener(VideoTouchListener(context)) - setOnVideoSizedChangedListener { intrinsicWidth, intrinsicHeight -> + setOnVideoSizedChangedListener { intrinsicWidth, intrinsicHeight, pixelWidthHeightRatio -> + // todo use provided ratio? val ratio = Math.min(width.toFloat() / intrinsicWidth, height.toFloat() / intrinsicHeight.toFloat()) /** * Only remap if not expanded and if dimensions have changed @@ -158,7 +160,7 @@ class FrostVideoView @JvmOverloads constructor( fun setViewerContract(contract: FrostVideoViewerContract) { this.viewerContract = contract - videoControls?.setVisibilityListener(viewerContract) + (videoControls as? VideoControls)?.setVisibilityListener(viewerContract) } fun jumpToStart() { @@ -186,7 +188,7 @@ class FrostVideoView @JvmOverloads constructor( private fun hideControls() { if (videoControls?.isVisible == true) - videoControls?.hide() + videoControls?.hide(false) } private fun toggleControls() { @@ -204,11 +206,11 @@ class FrostVideoView @JvmOverloads constructor( fun destroy() { stopPlayback() if (alpha > 0f) - ProgressAnimator.ofFloat(alpha, 0f) { + ProgressAnimator.ofFloat { duration = FAST_ANIMATION_DURATION - withAnimator { alpha = it } + withAnimator(alpha, 0f) { alpha = it } withEndAction { onFinishedListener() } - } + }.start() else onFinishedListener() } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/Keywords.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/Keywords.kt index d005e58a..8092133b 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/Keywords.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/Keywords.kt @@ -10,7 +10,6 @@ import android.support.v7.widget.RecyclerView import android.util.AttributeSet import android.view.View import android.widget.ImageView -import ca.allanwang.kau.kpref.StringSet import ca.allanwang.kau.utils.bindView import ca.allanwang.kau.utils.string import ca.allanwang.kau.utils.tint @@ -42,10 +41,10 @@ class Keywords @JvmOverloads constructor( editText.tint(Prefs.textColor) addIcon.setImageDrawable(GoogleMaterial.Icon.gmd_add.keywordDrawable(context)) addIcon.setOnClickListener { - if (editText.text.isEmpty()) editText.error = context.string(R.string.empty_keyword) + if (editText.text.isNullOrEmpty()) editText.error = context.string(R.string.empty_keyword) else { adapter.add(0, KeywordItem(editText.text.toString())) - editText.text.clear() + editText.text?.clear() } } adapter.add(Prefs.notificationKeywords.map { KeywordItem(it) }) @@ -61,11 +60,9 @@ class Keywords @JvmOverloads constructor( } fun save() { - val keywords = adapter.adapterItems.map { it.keyword } - Prefs.notificationKeywords = StringSet(keywords) + Prefs.notificationKeywords = adapter.adapterItems.mapTo(mutableSetOf()) { it.keyword } } - } private fun IIcon.keywordDrawable(context: Context): Drawable = toDrawable(context, 20, Prefs.textColor) |