stability fix at main screen

This commit is contained in:
Page Asgardius 2022-10-05 12:39:38 -07:00
parent 15cfe7730d
commit 59552f0ebb
2 changed files with 19 additions and 19 deletions

View file

@ -26,6 +26,7 @@ public class MainActivity extends AppCompatActivity {
SQLiteDatabase db; SQLiteDatabase db;
ArrayList Name; ArrayList Name;
ArrayList Img; ArrayList Img;
MyDbHelper dbHelper;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -38,29 +39,28 @@ public class MainActivity extends AppCompatActivity {
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getApplicationContext()); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getApplicationContext());
recyclerView.setLayoutManager(linearLayoutManager); recyclerView.setLayoutManager(linearLayoutManager);
MyDbHelper dbHelper = new MyDbHelper(this); dbHelper = new MyDbHelper(this);
db = dbHelper.getWritableDatabase();
if (db != null) {
// Database Queries
Name = new ArrayList<String>();
Img = new ArrayList<String>();
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();
}
Thread listaccount = new Thread(new Runnable() { Thread listaccount = new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
//Your code goes here //Your code goes here
db = dbHelper.getWritableDatabase();
if (db != null) {
// Database Queries
Name = new ArrayList<String>();
Img = new ArrayList<String>();
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() { runOnUiThread(new Runnable() {
@Override @Override

View file

@ -35,7 +35,7 @@ public class VideoPlayer extends AppCompatActivity {
private WifiManager.WifiLock mWifiLock; private WifiManager.WifiLock mWifiLock;
private PowerManager.WakeLock mWakeLock; private PowerManager.WakeLock mWakeLock;
private PowerManager powerManager; private PowerManager powerManager;
private long maxCacheSize = 100 * 1024 * 1024; private long maxCacheSize = 1024 * 1024 * 1024;
SimpleCache simpleCache; SimpleCache simpleCache;
ExoPlayer player; ExoPlayer player;
@ -55,7 +55,7 @@ public class VideoPlayer extends AppCompatActivity {
player = new ExoPlayer.Builder(this).build(); player = new ExoPlayer.Builder(this).build();
LeastRecentlyUsedCacheEvictor evictor = new LeastRecentlyUsedCacheEvictor(maxCacheSize); LeastRecentlyUsedCacheEvictor evictor = new LeastRecentlyUsedCacheEvictor(maxCacheSize);
simpleCache = new SimpleCache(new File(this.getCacheDir(), "media"), evictor); 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))); .createMediaSource(MediaItem.fromUri(Uri.parse(videoURL)));
//MediaSource audioSource = new ProgressiveMediaSource(Uri.parse("url"), //MediaSource audioSource = new ProgressiveMediaSource(Uri.parse("url"),
// new CacheDataSourceFactory(this, 100 * 1024 * 1024, 5 * 1024 * 1024), new DefaultExtractorsFactory(), null, null); // new CacheDataSourceFactory(this, 100 * 1024 * 1024, 5 * 1024 * 1024), new DefaultExtractorsFactory(), null, null);