From e67301c07667376b0b92cb63302af9ac353c2f76 Mon Sep 17 00:00:00 2001 From: Gideon Okuro Date: Thu, 14 Sep 2023 20:31:14 +0300 Subject: [PATCH] resources: refactor viewer modules (fixes #2390) (#2394) Co-authored-by: dogi --- app/build.gradle | 4 +- .../ui/viewer/AudioPlayerActivity.java | 30 +++++++------- .../myplanet/ui/viewer/CSVViewerActivity.java | 24 ++++-------- .../ui/viewer/ImageViewerActivity.java | 23 ++++------- .../ui/viewer/MarkdownViewerActivity.java | 23 ++++------- .../myplanet/ui/viewer/PDFReaderActivity.java | 39 +++++++------------ .../ui/viewer/TextFileViewerActivity.java | 25 ++++-------- .../ui/viewer/VideoPlayerActivity.java | 12 +++--- 8 files changed, 67 insertions(+), 113 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index e51448176f..55e1f9de43 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "org.ole.planet.myplanet" minSdkVersion 21 targetSdkVersion 34 - versionCode 1035 - versionName "0.10.35" + versionCode 1036 + versionName "0.10.36" ndkVersion '21.3.6528147' testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/viewer/AudioPlayerActivity.java b/app/src/main/java/org/ole/planet/myplanet/ui/viewer/AudioPlayerActivity.java index fe082fe0f6..5b5ad05c3e 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/viewer/AudioPlayerActivity.java +++ b/app/src/main/java/org/ole/planet/myplanet/ui/viewer/AudioPlayerActivity.java @@ -1,33 +1,33 @@ package org.ole.planet.myplanet.ui.viewer; -import androidx.appcompat.app.AppCompatActivity; - import android.os.Bundle; import android.view.MenuItem; import android.view.View; +import androidx.appcompat.app.AppCompatActivity; + import com.example.jean.jcplayer.JcPlayerManagerListener; import com.example.jean.jcplayer.general.JcStatus; import com.example.jean.jcplayer.model.JcAudio; -import com.example.jean.jcplayer.view.JcPlayerView; import org.jetbrains.annotations.NotNull; import org.ole.planet.myplanet.R; +import org.ole.planet.myplanet.databinding.ActivityAudioPlayerBinding; import org.ole.planet.myplanet.utilities.Utilities; import java.io.File; import java.util.ArrayList; public class AudioPlayerActivity extends AppCompatActivity implements JcPlayerManagerListener { - JcPlayerView jcplayer; + private ActivityAudioPlayerBinding activityAudioPlayerBinding; ArrayList jcAudios; boolean isFullPath; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_audio_player); - jcplayer = findViewById(R.id.jcplayer); + activityAudioPlayerBinding = ActivityAudioPlayerBinding.inflate(getLayoutInflater()); + setContentView(activityAudioPlayerBinding.getRoot()); String filePath = getIntent().getStringExtra("TOUCHED_FILE"); jcAudios = new ArrayList<>(); isFullPath = getIntent().getBooleanExtra("isFullPath", false); @@ -41,10 +41,10 @@ protected void onCreate(Bundle savedInstanceState) { } jcAudios.add(JcAudio.createFromFilePath(fullPath)); - jcplayer.initPlaylist(jcAudios, null); - jcplayer.getRootView().findViewById(R.id.btnNext).setVisibility(View.GONE); - jcplayer.getRootView().findViewById(R.id.btnPrev).setVisibility(View.GONE); - jcplayer.getRootView().findViewById(R.id.btnRepeatOne).setVisibility(View.GONE); + activityAudioPlayerBinding.jcplayer.initPlaylist(jcAudios, null); + activityAudioPlayerBinding.jcplayer.getRootView().findViewById(R.id.btnNext).setVisibility(View.GONE); + activityAudioPlayerBinding.jcplayer.getRootView().findViewById(R.id.btnPrev).setVisibility(View.GONE); + activityAudioPlayerBinding.jcplayer.getRootView().findViewById(R.id.btnRepeatOne).setVisibility(View.GONE); } @Override @@ -58,22 +58,22 @@ public boolean onOptionsItemSelected(MenuItem item) { @Override protected void onPause() { super.onPause(); - if (jcplayer != null && jcplayer.isPlaying()) { - jcplayer.pause(); + if (activityAudioPlayerBinding.jcplayer != null && activityAudioPlayerBinding.jcplayer.isPlaying()) { + activityAudioPlayerBinding.jcplayer.pause(); } } @Override protected void onStop() { super.onStop(); - if (jcplayer != null) jcplayer.kill(); + if (activityAudioPlayerBinding.jcplayer != null) activityAudioPlayerBinding.jcplayer.kill(); } @Override protected void onResume() { super.onResume(); - if (jcplayer != null && jcAudios.size() > 0) { - jcplayer.playAudio(jcAudios.get(0)); + if (activityAudioPlayerBinding.jcplayer != null && jcAudios.size() > 0) { + activityAudioPlayerBinding.jcplayer.playAudio(jcAudios.get(0)); } } diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/viewer/CSVViewerActivity.java b/app/src/main/java/org/ole/planet/myplanet/ui/viewer/CSVViewerActivity.java index 8d9a4f5ae8..7a2024f16d 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/viewer/CSVViewerActivity.java +++ b/app/src/main/java/org/ole/planet/myplanet/ui/viewer/CSVViewerActivity.java @@ -3,7 +3,6 @@ import android.content.Intent; import android.os.Bundle; import android.view.View; -import android.widget.TextView; import androidx.appcompat.app.AppCompatActivity; @@ -11,7 +10,7 @@ import com.opencsv.CSVReader; import com.opencsv.CSVReaderBuilder; -import org.ole.planet.myplanet.R; +import org.ole.planet.myplanet.databinding.ActivityCsvviewerBinding; import java.io.File; import java.io.FileReader; @@ -19,30 +18,23 @@ import java.util.List; public class CSVViewerActivity extends AppCompatActivity { - - private TextView mCSVNameTitle; - private TextView mCSVContent; + private ActivityCsvviewerBinding activityCsvviewerBinding; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_csvviewer); - declareElements(); + activityCsvviewerBinding = ActivityCsvviewerBinding.inflate(getLayoutInflater()); + setContentView(activityCsvviewerBinding.getRoot()); renderCSVFile(); } - private void declareElements() { - mCSVNameTitle = (TextView) findViewById(R.id.csvFileName); - mCSVContent = (TextView) findViewById(R.id.csvFileContent); - } - private void renderCSVFile() { Intent csvFileOpenIntent = getIntent(); String fileName = csvFileOpenIntent.getStringExtra("TOUCHED_FILE"); if (fileName != null && !fileName.isEmpty()) { - mCSVNameTitle.setText(fileName); - mCSVNameTitle.setVisibility(View.VISIBLE); + activityCsvviewerBinding.csvFileName.setText(fileName); + activityCsvviewerBinding.csvFileName.setVisibility(View.VISIBLE); } @@ -65,8 +57,8 @@ private void renderCSVFile() { List allRows = reader.readAll(); for (String[] row : allRows) { - mCSVContent.append(Arrays.toString(row)); - mCSVContent.append("\n"); + activityCsvviewerBinding.csvFileContent.append(Arrays.toString(row)); + activityCsvviewerBinding.csvFileContent.append("\n"); } } catch (Exception e) { e.printStackTrace(); diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/viewer/ImageViewerActivity.java b/app/src/main/java/org/ole/planet/myplanet/ui/viewer/ImageViewerActivity.java index eca24286b0..b771316907 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/viewer/ImageViewerActivity.java +++ b/app/src/main/java/org/ole/planet/myplanet/ui/viewer/ImageViewerActivity.java @@ -3,43 +3,34 @@ import android.content.Intent; import android.os.Bundle; import android.view.View; -import android.widget.ImageView; -import android.widget.TextView; import androidx.appcompat.app.AppCompatActivity; import com.bumptech.glide.Glide; -import org.ole.planet.myplanet.R; -import org.ole.planet.myplanet.utilities.Utilities; +import org.ole.planet.myplanet.databinding.ActivityImageViewerBinding; import java.io.File; public class ImageViewerActivity extends AppCompatActivity { - private TextView mImageFileNameTitle; - private ImageView mImageViewer; + private ActivityImageViewerBinding activityImageViewerBinding; private boolean isFullPath = false; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_image_viewer); - declareElements(); + activityImageViewerBinding = ActivityImageViewerBinding.inflate(getLayoutInflater()); + setContentView(activityImageViewerBinding.getRoot()); renderImageFile(); } - private void declareElements() { - mImageFileNameTitle = (TextView) findViewById(R.id.imageFileName); - mImageViewer = (ImageView) findViewById(R.id.imageViewer); - } - private void renderImageFile() { isFullPath = getIntent().getBooleanExtra("isFullPath", false); Intent imageOpenIntent = getIntent(); String fileName = imageOpenIntent.getStringExtra("TOUCHED_FILE"); if (fileName != null && !fileName.isEmpty()) { - mImageFileNameTitle.setText(fileName); - mImageFileNameTitle.setVisibility(View.VISIBLE); + activityImageViewerBinding.imageFileName.setText(fileName); + activityImageViewerBinding.imageFileName.setVisibility(View.VISIBLE); } try { @@ -50,7 +41,7 @@ private void renderImageFile() { File basePath = getExternalFilesDir(null); imageFile = new File(basePath, "ole/" + fileName); } - Glide.with(getApplicationContext()).load(imageFile).into(mImageViewer); + Glide.with(getApplicationContext()).load(imageFile).into(activityImageViewerBinding.imageViewer); } catch (Exception e) { e.printStackTrace(); } diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/viewer/MarkdownViewerActivity.java b/app/src/main/java/org/ole/planet/myplanet/ui/viewer/MarkdownViewerActivity.java index ca66d1db85..c1467b31db 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/viewer/MarkdownViewerActivity.java +++ b/app/src/main/java/org/ole/planet/myplanet/ui/viewer/MarkdownViewerActivity.java @@ -3,43 +3,34 @@ import android.content.Intent; import android.os.Bundle; import android.view.View; -import android.widget.TextView; import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; import org.ole.planet.myplanet.R; -import org.ole.planet.myplanet.utilities.Utilities; +import org.ole.planet.myplanet.databinding.ActivityMarkdownViewerBinding; import java.io.File; -import br.tiagohm.markdownview.MarkdownView; - public class MarkdownViewerActivity extends AppCompatActivity { - private TextView mMarkdownNameTitle; - private MarkdownView mMarkdownContent; + private ActivityMarkdownViewerBinding activityMarkdownViewerBinding; private String fileName; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_markdown_viewer); - declareElements(); + activityMarkdownViewerBinding = ActivityMarkdownViewerBinding.inflate(getLayoutInflater()); + setContentView(activityMarkdownViewerBinding.getRoot()); renderMarkdownFile(); } - private void declareElements() { - mMarkdownNameTitle = (TextView) findViewById(R.id.markdownFileName); - mMarkdownContent = (MarkdownView) findViewById(R.id.markdown_view); - } - private void renderMarkdownFile() { Intent markdownOpenIntent = getIntent(); String fileName = markdownOpenIntent.getStringExtra("TOUCHED_FILE"); if (fileName != null && !fileName.isEmpty()) { - mMarkdownNameTitle.setText(fileName); - mMarkdownNameTitle.setVisibility(View.VISIBLE); + activityMarkdownViewerBinding.markdownFileName.setText(fileName); + activityMarkdownViewerBinding.markdownFileName.setVisibility(View.VISIBLE); } try { @@ -47,7 +38,7 @@ private void renderMarkdownFile() { File markdownFile = new File(basePath, "ole/" + fileName); if (markdownFile.exists()) { - mMarkdownContent.loadMarkdownFromFile(markdownFile); + activityMarkdownViewerBinding.markdownView.loadMarkdownFromFile(markdownFile); } else { Toast.makeText(this, getString(R.string.unable_to_load) + fileName, Toast.LENGTH_LONG).show(); } diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/viewer/PDFReaderActivity.java b/app/src/main/java/org/ole/planet/myplanet/ui/viewer/PDFReaderActivity.java index c9b2d2ae9e..651992b848 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/viewer/PDFReaderActivity.java +++ b/app/src/main/java/org/ole/planet/myplanet/ui/viewer/PDFReaderActivity.java @@ -2,23 +2,20 @@ import android.content.Intent; import android.os.Bundle; - -import androidx.appcompat.app.AppCompatActivity; - import android.text.TextUtils; import android.util.Log; import android.view.View; -import android.widget.TextView; import android.widget.Toast; -import com.github.barteksc.pdfviewer.PDFView; +import androidx.appcompat.app.AppCompatActivity; + import com.github.barteksc.pdfviewer.listener.OnLoadCompleteListener; import com.github.barteksc.pdfviewer.listener.OnPageChangeListener; import com.github.barteksc.pdfviewer.listener.OnPageErrorListener; import com.github.barteksc.pdfviewer.scroll.DefaultScrollHandle; -import com.github.clans.fab.FloatingActionButton; import org.ole.planet.myplanet.R; +import org.ole.planet.myplanet.databinding.ActivityPdfreaderBinding; import org.ole.planet.myplanet.datamanager.DatabaseService; import org.ole.planet.myplanet.model.RealmMyLibrary; import org.ole.planet.myplanet.service.AudioRecorderService; @@ -32,11 +29,9 @@ import io.realm.Realm; public class PDFReaderActivity extends AppCompatActivity implements OnPageChangeListener, OnLoadCompleteListener, OnPageErrorListener, AudioRecorderService.AudioRecordListener { + private ActivityPdfreaderBinding activityPdfreaderBinding; private static final String TAG = "PDF Reader Log"; - private TextView mPdfFileNameTitle; private String fileName; - private PDFView pdfView; - private FloatingActionButton fabRecord, fabPlay; private AudioRecorderService audioRecorderService; private RealmMyLibrary library; private Realm mRealm; @@ -44,23 +39,17 @@ public class PDFReaderActivity extends AppCompatActivity implements OnPageChange @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_pdfreader); + activityPdfreaderBinding = ActivityPdfreaderBinding.inflate(getLayoutInflater()); + setContentView(activityPdfreaderBinding.getRoot()); audioRecorderService = new AudioRecorderService().setAudioRecordListener(this); mRealm = new DatabaseService(this).getRealmInstance(); if (getIntent().hasExtra("resourceId")) { String resourceID = getIntent().getStringExtra("resourceId"); library = mRealm.where(RealmMyLibrary.class).equalTo("id", resourceID).findFirst(); } - declareElements(); renderPdfFile(); - } - private void declareElements() { - mPdfFileNameTitle = findViewById(R.id.pdfFileName); - pdfView = findViewById(R.id.pdfView); - fabRecord = findViewById(R.id.fab_record); - fabPlay = findViewById(R.id.fab_play); - fabRecord.setOnClickListener(view -> { + activityPdfreaderBinding.fabRecord.setOnClickListener(view -> { if (audioRecorderService.isRecording()) { audioRecorderService.stopRecording(); } else { @@ -68,7 +57,7 @@ private void declareElements() { } }); - fabPlay.setOnClickListener(view -> { + activityPdfreaderBinding.fabPlay.setOnClickListener(view -> { if (library != null && !TextUtils.isEmpty(library.getTranslationAudioPath())) { IntentUtils.openAudioFile(this, library.getTranslationAudioPath()); } @@ -79,15 +68,15 @@ private void renderPdfFile() { Intent pdfOpenIntent = getIntent(); fileName = pdfOpenIntent.getStringExtra("TOUCHED_FILE"); if (fileName != null && !fileName.isEmpty()) { - mPdfFileNameTitle.setText(fileName); - mPdfFileNameTitle.setVisibility(View.VISIBLE); + activityPdfreaderBinding.pdfFileName.setText(fileName); + activityPdfreaderBinding.pdfFileName.setVisibility(View.VISIBLE); } File file = new File(getExternalFilesDir(null), "ole/" + fileName); if (file.exists()) { try { Utilities.log(file.getAbsolutePath()); - pdfView.fromFile(file).defaultPage(0).enableAnnotationRendering(true).onLoad(this).onPageChange(this).scrollHandle(new DefaultScrollHandle(this)).load(); + activityPdfreaderBinding.pdfView.fromFile(file).defaultPage(0).enableAnnotationRendering(true).onLoad(this).onPageChange(this).scrollHandle(new DefaultScrollHandle(this)).load(); } catch (Exception e) { e.printStackTrace(); Toast.makeText(getApplicationContext(), getString(R.string.unable_to_load) + fileName, Toast.LENGTH_LONG).show(); @@ -112,7 +101,7 @@ public void onPageError(int page, Throwable t) { public void onRecordStarted() { Utilities.toast(this, getString(R.string.recording_started)); NotificationUtil.create(this, R.drawable.ic_mic, "Recording Audio", getString(R.string.ole_is_recording_audio)); - fabRecord.setImageResource(R.drawable.ic_stop); + activityPdfreaderBinding.fabRecord.setImageResource(R.drawable.ic_stop); } @Override @@ -123,7 +112,7 @@ public void onRecordStopped(String outputFile) { updateTranslation(outputFile); AddResourceFragment.showAlert(this, outputFile); } - fabRecord.setImageResource(R.drawable.ic_mic); + activityPdfreaderBinding.fabRecord.setImageResource(R.drawable.ic_mic); } private void updateTranslation(String outputFile) { @@ -146,6 +135,6 @@ protected void onDestroy() { public void onError(String error) { NotificationUtil.cancellAll(this); Utilities.toast(this, error); - fabRecord.setImageResource(R.drawable.ic_mic); + activityPdfreaderBinding.fabRecord.setImageResource(R.drawable.ic_mic); } } diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/viewer/TextFileViewerActivity.java b/app/src/main/java/org/ole/planet/myplanet/ui/viewer/TextFileViewerActivity.java index 9aa756fd75..4759dcb587 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/viewer/TextFileViewerActivity.java +++ b/app/src/main/java/org/ole/planet/myplanet/ui/viewer/TextFileViewerActivity.java @@ -2,43 +2,34 @@ import android.content.Intent; import android.os.Bundle; +import android.view.View; import androidx.appcompat.app.AppCompatActivity; -import android.view.View; -import android.widget.TextView; - -import org.ole.planet.myplanet.R; -import org.ole.planet.myplanet.utilities.Utilities; +import org.ole.planet.myplanet.databinding.ActivityTextfileViewerBinding; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; public class TextFileViewerActivity extends AppCompatActivity { - private TextView mTextFileNameTitle; - private TextView mTextFileContent; + private ActivityTextfileViewerBinding activityTextfileViewerBinding; private String fileName; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_textfile_viewer); - declareElements(); + activityTextfileViewerBinding = ActivityTextfileViewerBinding.inflate(getLayoutInflater()); + setContentView(activityTextfileViewerBinding.getRoot()); renderTextFile(); } - private void declareElements() { - mTextFileNameTitle = (TextView) findViewById(R.id.textFileName); - mTextFileContent = (TextView) findViewById(R.id.textFileContent); - } - private void renderTextFile() { Intent textFileOpenIntent = getIntent(); fileName = textFileOpenIntent.getStringExtra("TOUCHED_FILE"); if (fileName != null && !fileName.isEmpty()) { - mTextFileNameTitle.setText(fileName); - mTextFileNameTitle.setVisibility(View.VISIBLE); + activityTextfileViewerBinding.textFileName.setText(fileName); + activityTextfileViewerBinding.textFileName.setVisibility(View.VISIBLE); } renderTextFileThread(); } @@ -59,7 +50,7 @@ public void run() { text.append('\n'); } reader.close(); - mTextFileContent.setText(text.toString()); + activityTextfileViewerBinding.textFileContent.setText(text.toString()); } catch (Exception e) { e.printStackTrace(); } diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/viewer/VideoPlayerActivity.java b/app/src/main/java/org/ole/planet/myplanet/ui/viewer/VideoPlayerActivity.java index d8def1be03..ef0bc09c8d 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/viewer/VideoPlayerActivity.java +++ b/app/src/main/java/org/ole/planet/myplanet/ui/viewer/VideoPlayerActivity.java @@ -17,7 +17,6 @@ import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; import com.google.android.exoplayer2.trackselection.TrackSelector; -import com.google.android.exoplayer2.ui.SimpleExoPlayerView; import com.google.android.exoplayer2.upstream.BandwidthMeter; import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DataSpec; @@ -28,6 +27,7 @@ import com.google.gson.Gson; import org.ole.planet.myplanet.R; +import org.ole.planet.myplanet.databinding.ActivityExoPlayerVideoBinding; import org.ole.planet.myplanet.ui.sync.SyncActivity; import org.ole.planet.myplanet.utilities.AuthSessionUpdater; import org.ole.planet.myplanet.utilities.Utilities; @@ -36,8 +36,8 @@ import java.util.Map; public class VideoPlayerActivity extends AppCompatActivity implements AuthSessionUpdater.AuthCallback { + private ActivityExoPlayerVideoBinding activityExoPlayerVideoBinding; SimpleExoPlayer exoPlayer; - SimpleExoPlayerView exoPlayerView; String auth = ""; String videoURL = ""; SharedPreferences settings; @@ -45,9 +45,9 @@ public class VideoPlayerActivity extends AppCompatActivity implements AuthSessio @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_exo_player_video); + activityExoPlayerVideoBinding = ActivityExoPlayerVideoBinding.inflate(getLayoutInflater()); + setContentView(activityExoPlayerVideoBinding.getRoot()); settings = getSharedPreferences(SyncActivity.PREFS_NAME, MODE_PRIVATE); - exoPlayerView = findViewById(R.id.exo_player_simple); Intent intentExtras = getIntent(); Bundle extras = intentExtras.getExtras(); @@ -89,7 +89,7 @@ public void streamVideoFromUrl(String videoUrl, String auth) { ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory(); MediaSource mediaSource = new ExtractorMediaSource(videoUri, defaultHttpDataSourceFactory, extractorsFactory, null, null); - exoPlayerView.setPlayer(exoPlayer); + activityExoPlayerVideoBinding.exoPlayerSimple.setPlayer(exoPlayer); exoPlayer.prepare(mediaSource); exoPlayer.setPlayWhenReady(true); } @@ -109,7 +109,7 @@ public void prepareExoPlayerFromFileUri(String uristring) { DataSource.Factory factory = () -> fileDataSource; MediaSource audioSource = new ExtractorMediaSource(fileDataSource.getUri(), factory, new DefaultExtractorsFactory(), null, null); - exoPlayerView.setPlayer(exoPlayer); + activityExoPlayerVideoBinding.exoPlayerSimple.setPlayer(exoPlayer); exoPlayer.prepare(audioSource); exoPlayer.setPlayWhenReady(true); }