From a3f0667c7db74c1e3afabcec947d36f7e9cffbfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20=C3=87erri?= <64997243+deniscerri@users.noreply.github.com> Date: Sat, 8 Oct 2022 00:41:15 +0200 Subject: [PATCH] fixed bug when queued audio and video were of same source 2nd click downloaded the same type as the first. Now they download as expected --- .idea/deploymentTargetDropDown.xml | 17 ----- .../deniscerri/ytdlnis/DownloaderService.java | 1 + .../adapter/HomeRecyclerViewAdapter.java | 20 ++++-- .../ytdlnis/database/DBManager.java | 68 +++++++++++-------- .../deniscerri/ytdlnis/database/Video.java | 13 +++- .../ytdlnis/page/DownloadsFragment.java | 3 + .../deniscerri/ytdlnis/page/HomeFragment.java | 33 +++++---- .../ytdlnis/service/DownloadInfo.java | 8 +++ .../com/deniscerri/ytdlnis/util/InfoUtil.java | 12 +++- app/src/main/res/values-sq-rAL/strings.xml | 7 ++ app/src/main/res/values/strings.xml | 1 + 11 files changed, 116 insertions(+), 67 deletions(-) delete mode 100644 .idea/deploymentTargetDropDown.xml diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml deleted file mode 100644 index 9cd0de67..00000000 --- a/.idea/deploymentTargetDropDown.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/java/com/deniscerri/ytdlnis/DownloaderService.java b/app/src/main/java/com/deniscerri/ytdlnis/DownloaderService.java index e1dd7883..f3ed0eb7 100644 --- a/app/src/main/java/com/deniscerri/ytdlnis/DownloaderService.java +++ b/app/src/main/java/com/deniscerri/ytdlnis/DownloaderService.java @@ -328,6 +328,7 @@ public class DownloaderService extends Service { .observeOn(AndroidSchedulers.mainThread()) .subscribe(youtubeDLResponse -> { downloadInfo.setDownloadPath(youtubeDLDir.getAbsolutePath()); + downloadInfo.setDownloadType(type); try{ for (Activity activity: activities.keySet()){ activity.runOnUiThread(() -> { diff --git a/app/src/main/java/com/deniscerri/ytdlnis/adapter/HomeRecyclerViewAdapter.java b/app/src/main/java/com/deniscerri/ytdlnis/adapter/HomeRecyclerViewAdapter.java index d0741215..bb0c68c0 100644 --- a/app/src/main/java/com/deniscerri/ytdlnis/adapter/HomeRecyclerViewAdapter.java +++ b/app/src/main/java/com/deniscerri/ytdlnis/adapter/HomeRecyclerViewAdapter.java @@ -110,21 +110,26 @@ public class HomeRecyclerViewAdapter extends RecyclerView.Adapter getResults(){ SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM " + results_table_name, null); @@ -148,18 +153,19 @@ public class DBManager extends SQLiteOpenHelper { if(cursor.moveToFirst()){ do { // on below line we are adding the data from cursor to our array list. - list.add(new Video(cursor.getString(1), //videoId - cursor.getString(2), //url - cursor.getString(3), //title - cursor.getString(4), //author - cursor.getString(5), //duration - cursor.getString(6), //thumb - cursor.getInt(7), //downloadedAudio - cursor.getInt(8), //downloadedVideo - cursor.getInt(9), //isPlaylistItem - cursor.getString(10), //website - cursor.getInt(11), //isDownloadingAudio - cursor.getInt(12))); //isDownloadingVideo + list.add(new Video(cursor.getString(cursor.getColumnIndex(videoId)), + cursor.getString(cursor.getColumnIndex(url)), + cursor.getString(cursor.getColumnIndex(title)), + cursor.getString(cursor.getColumnIndex(author)), + cursor.getString(cursor.getColumnIndex(duration)), + cursor.getString(cursor.getColumnIndex(thumb)), + cursor.getInt(cursor.getColumnIndex(downloadedAudio)), + cursor.getInt(cursor.getColumnIndex(downloadedVideo)), + cursor.getInt(cursor.getColumnIndex(isPlaylistItem)), + cursor.getString(cursor.getColumnIndex(website)), + cursor.getInt(cursor.getColumnIndex(downloadedAudio)), + cursor.getInt(cursor.getColumnIndex(downloadingVideo)), + cursor.getString(cursor.getColumnIndex(playlistTitle)))); } while (cursor.moveToNext()); } @@ -167,14 +173,15 @@ public class DBManager extends SQLiteOpenHelper { return list; } - public ArrayList