From 59552f0ebb6424f56ec124cd7914146c3f77d222 Mon Sep 17 00:00:00 2001 From: Page Asgardius Date: Wed, 5 Oct 2022 12:39:38 -0700 Subject: [PATCH] stability fix at main screen --- .../page/s3manager/MainActivity.java | 34 +++++++++---------- .../asgardius/page/s3manager/VideoPlayer.java | 4 +-- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/asgardius/page/s3manager/MainActivity.java b/app/src/main/java/asgardius/page/s3manager/MainActivity.java index 99de11f..f2fe71f 100644 --- a/app/src/main/java/asgardius/page/s3manager/MainActivity.java +++ b/app/src/main/java/asgardius/page/s3manager/MainActivity.java @@ -26,6 +26,7 @@ public class MainActivity extends AppCompatActivity { SQLiteDatabase db; ArrayList Name; ArrayList Img; + MyDbHelper dbHelper; @Override protected void onCreate(Bundle savedInstanceState) { @@ -38,29 +39,28 @@ public class MainActivity extends AppCompatActivity { LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getApplicationContext()); recyclerView.setLayoutManager(linearLayoutManager); - MyDbHelper dbHelper = new MyDbHelper(this); - db = dbHelper.getWritableDatabase(); - if (db != null) { - // Database Queries - Name = new ArrayList(); - Img = new ArrayList(); - String query = "SELECT id FROM account"; - Cursor cursor = db.rawQuery(query,null); - while (cursor.moveToNext()){ - Name.add(cursor.getString(0)); - Img.add(R.drawable.account); - } - db.close(); - } else { - Toast.makeText(getApplicationContext(),getResources().getString(R.string.broken_database), Toast.LENGTH_SHORT).show(); - } - + dbHelper = new MyDbHelper(this); Thread listaccount = new Thread(new Runnable() { @Override public void run() { try { //Your code goes here + db = dbHelper.getWritableDatabase(); + if (db != null) { + // Database Queries + Name = new ArrayList(); + Img = new ArrayList(); + String query = "SELECT id FROM account"; + Cursor cursor = db.rawQuery(query,null); + while (cursor.moveToNext()){ + Name.add(cursor.getString(0)); + Img.add(R.drawable.account); + } + db.close(); + } else { + Toast.makeText(getApplicationContext(),getResources().getString(R.string.broken_database), Toast.LENGTH_SHORT).show(); + } runOnUiThread(new Runnable() { @Override diff --git a/app/src/main/java/asgardius/page/s3manager/VideoPlayer.java b/app/src/main/java/asgardius/page/s3manager/VideoPlayer.java index 7b8f20c..e6730fe 100644 --- a/app/src/main/java/asgardius/page/s3manager/VideoPlayer.java +++ b/app/src/main/java/asgardius/page/s3manager/VideoPlayer.java @@ -35,7 +35,7 @@ public class VideoPlayer extends AppCompatActivity { private WifiManager.WifiLock mWifiLock; private PowerManager.WakeLock mWakeLock; private PowerManager powerManager; - private long maxCacheSize = 100 * 1024 * 1024; + private long maxCacheSize = 1024 * 1024 * 1024; SimpleCache simpleCache; ExoPlayer player; @@ -55,7 +55,7 @@ public class VideoPlayer extends AppCompatActivity { player = new ExoPlayer.Builder(this).build(); LeastRecentlyUsedCacheEvictor evictor = new LeastRecentlyUsedCacheEvictor(maxCacheSize); simpleCache = new SimpleCache(new File(this.getCacheDir(), "media"), evictor); - MediaSource mediaSource = new ProgressiveMediaSource.Factory(new CacheDataSourceFactory(this, simpleCache, 512 * 1024 * 1024)) + MediaSource mediaSource = new ProgressiveMediaSource.Factory(new CacheDataSourceFactory(this, simpleCache, maxCacheSize)) .createMediaSource(MediaItem.fromUri(Uri.parse(videoURL))); //MediaSource audioSource = new ProgressiveMediaSource(Uri.parse("url"), // new CacheDataSourceFactory(this, 100 * 1024 * 1024, 5 * 1024 * 1024), new DefaultExtractorsFactory(), null, null);