Skip to content

Commit

Permalink
[optimize] Convert PlayerControlViewLayoutManager.java to Kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyD666 committed Apr 11, 2024
1 parent f14ce28 commit 29560aa
Show file tree
Hide file tree
Showing 16 changed files with 675 additions and 802 deletions.
4 changes: 1 addition & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ android {
minSdk = 24
targetSdk = 34
versionCode = 10
versionName = "1.1-beta04"
versionName = "1.1-beta05"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

Expand All @@ -32,8 +32,6 @@ android {

signingConfigs {
create("release") {
// You need to specify either an absolute path or include the
// keystore file in the same directory as the build.gradle file.
@Suppress("UNCHECKED_CAST")
val sign = ((extra["secret"] as Map<*, *>)["sign"] as Map<String, String>)
storeFile = file("../key.jks")
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/skyd/anivu/model/db/AppDatabase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ abstract class AppDatabase : RoomDatabase() {
)
.addMigrations(*migrations)
.build()
.apply { instance = this }
} else {
instance as AppDatabase
}
Expand Down
8 changes: 7 additions & 1 deletion app/src/main/java/com/skyd/anivu/ui/activity/PlayActivity.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.skyd.anivu.ui.activity

import android.content.Intent
import android.media.MediaMetadataRetriever
import android.net.Uri
import android.os.Bundle
import android.view.WindowManager
Expand All @@ -16,6 +17,7 @@ import com.skyd.anivu.ext.dataStore
import com.skyd.anivu.ext.getOrDefault
import com.skyd.anivu.model.preference.player.PlayerShow85sButtonPreference


class PlayActivity : BaseActivity<ActivityPlayBinding>() {
companion object {
const val VIDEO_URI_KEY = "videoUri"
Expand Down Expand Up @@ -57,7 +59,11 @@ class PlayActivity : BaseActivity<ActivityPlayBinding>() {

override fun ActivityPlayBinding.initView() {
playerView.setForward85sButton(dataStore.getOrDefault(PlayerShow85sButtonPreference))

// playerView.setOnScreenshotListener {
// val retriever = MediaMetadataRetriever()
// retriever.setDataSource(player.curren)
// val bitmap = retriever.getFrameAtTime(simpleExoPlayer.getCurrentPosition())
// }
videoUri = IntentCompat.getParcelableExtra(intent, VIDEO_URI_KEY, Uri::class.java)
?: intent.data

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class AniVuItemDecoration(
}

companion object {
val H_ITEM_SPACE: Int = 12.dp
val H_ITEM_SPACE: Int = 16.dp
val HORIZONTAL_PADDING: Int = 16.dp
val VERTICAL_PADDING: Int = 16.dp

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.recyclerview.widget.GridLayoutManager
import com.skyd.anivu.appContext
import com.skyd.anivu.ext.screenIsLand
import com.skyd.anivu.model.bean.FeedBean
import com.skyd.anivu.model.bean.LicenseBean
import com.skyd.anivu.model.bean.MoreBean
import com.skyd.anivu.model.bean.OtherWorksBean

Expand All @@ -17,14 +18,13 @@ class AniSpanSize(
fun getSpanSize(data: Any?, enableLandScape: Boolean): Int {
return if (enableLandScape && appContext.screenIsLand) {
when (data) {
is FeedBean -> MAX_SPAN_SIZE
is MoreBean -> MAX_SPAN_SIZE / 3
is OtherWorksBean -> MAX_SPAN_SIZE / 2
is LicenseBean -> MAX_SPAN_SIZE / 2
else -> MAX_SPAN_SIZE
}
} else {
when (data) {
is FeedBean -> MAX_SPAN_SIZE
is MoreBean -> MAX_SPAN_SIZE / 2
else -> MAX_SPAN_SIZE
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import androidx.recyclerview.widget.GridLayoutManager
import com.skyd.anivu.base.BaseFragment
import com.skyd.anivu.databinding.FragmentLicenseBinding
import com.skyd.anivu.ext.addInsetsByPadding
import com.skyd.anivu.ext.dp
import com.skyd.anivu.ext.popBackStackWithLifecycle
import com.skyd.anivu.model.bean.LicenseBean
import com.skyd.anivu.ui.adapter.decoration.AniVuItemDecoration
import com.skyd.anivu.ui.adapter.variety.AniSpanSize
import com.skyd.anivu.ui.adapter.variety.VarietyAdapter
import com.skyd.anivu.ui.adapter.variety.proxy.License1Proxy
Expand Down Expand Up @@ -38,6 +40,7 @@ class LicenseFragment : BaseFragment<FragmentLicenseBinding>() {
).apply {
spanSizeLookup = AniSpanSize(adapter)
}
rvLicenseFragment.addItemDecoration(AniVuItemDecoration())
rvLicenseFragment.adapter = adapter
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,8 @@ public interface OnFullScreenModeChangedListener {
@Nullable
private final View forward85sView;
@Nullable
private final View screenshotView;
@Nullable
private final ViewGroup brightnessControlsView;
@Nullable
private final LinearProgressIndicator brightnessProgressView;
Expand Down Expand Up @@ -576,6 +578,11 @@ public PlayerControlView(
});
}

screenshotView = findViewById(com.skyd.anivu.R.id.exo_screenshot);
if (screenshotView != null) {
if (!screenshotView.hasOnClickListeners()) screenshotView.setVisibility(View.GONE);
}

longPressPlaybackSpeedView = findViewById(com.skyd.anivu.R.id.exo_long_press_playback_speed);
if (longPressPlaybackSpeedView != null) {
longPressPlaybackSpeedView.setVisibility(View.GONE);
Expand Down Expand Up @@ -1126,6 +1133,13 @@ public void setForward85sButton(boolean visible) {
}
}

public void setOnScreenshotListener(@Nullable View.OnClickListener listener) {
if (screenshotView != null) {
screenshotView.setVisibility(listener == null ? View.GONE : View.VISIBLE);
screenshotView.setOnClickListener(listener);
}
}

public void setLongPressPlaybackSpeedVisibility(int visibility) {
if (longPressPlaybackSpeedView != null) {
longPressPlaybackSpeedView.setVisibility(visibility);
Expand Down Expand Up @@ -1901,7 +1915,7 @@ public boolean dispatchMediaKeyEvent(KeyEvent event) {
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
controlViewLayoutManager.onLayout(changed, left, top, right, bottom);
controlViewLayoutManager.onLayout(left, top, right, bottom);
}

private void onLayoutChange(
Expand Down
Loading

0 comments on commit 29560aa

Please sign in to comment.