Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.os.Handler
import android.widget.ImageButton
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import ordering: The ImageButton import appears to be placed between OS imports and Media3 imports. Consider organizing imports by grouping (Android framework, third-party libraries, app-specific) for better readability.

import androidx.annotation.OptIn
import androidx.media3.common.C
import androidx.media3.common.MediaItem
Expand Down Expand Up @@ -50,6 +51,8 @@ import com.instructure.pandautils.base.BaseCanvasActivity
import com.instructure.pandautils.binding.viewBinding
import com.instructure.pandautils.utils.ThemePrefs
import com.instructure.pandautils.utils.ViewStyler
import com.instructure.pandautils.utils.setGone
import com.instructure.student.R
import com.instructure.student.databinding.ActivityVideoViewBinding
import com.instructure.student.util.Const

Expand All @@ -72,6 +75,7 @@ class VideoViewActivity : BaseCanvasActivity() {
mainHandler = Handler()
val videoTrackSelectionFactory: ExoTrackSelection.Factory = AdaptiveTrackSelection.Factory()
trackSelector = DefaultTrackSelector(applicationContext, videoTrackSelectionFactory)
binding.playerView.findViewById<ImageButton>(R.id.fullscreenButton).setGone()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential NullPointerException: The findViewById<ImageButton>(R.id.fullscreenButton) call could return null if the button doesn't exist in the player view's layout. This would cause a crash when calling setGone() on a null object.

Consider using a safe call or null check:

binding.playerView.findViewById<ImageButton>(R.id.fullscreenButton)?.setGone()

Or verify the button exists and handle the null case:

binding.playerView.findViewById<ImageButton>(R.id.fullscreenButton)?.let { button ->
    button.setGone()
} ?: run {
    // Log warning or handle missing button case
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Timing concern: This code runs in onCreate() before fetchMediaUri() is called. If the PlayerView hasn't fully initialized its internal layout at this point, the findViewById() might not locate the button even if it exists.

Consider moving this after the player is fully set up, or using a post handler:

binding.playerView.post {
    binding.playerView.findViewById<ImageButton>(R.id.fullscreenButton)?.setGone()
}

fetchMediaUri(Uri.parse(intent?.extras?.getString(Const.URL)))
ViewStyler.setStatusBarDark(this, ThemePrefs.primaryColor)
}
Expand Down
Loading