From f705d2beb790d65a29c6d61823eb2ea44f2da4cf Mon Sep 17 00:00:00 2001 From: Harimurti Date: Wed, 16 Jun 2021 08:08:32 +0700 Subject: [PATCH] main: force reload playlist --- app/src/main/java/net/harimurti/tv/MainActivity.java | 4 ++++ app/src/main/res/layout/activity_main.xml | 10 ++++++++++ app/src/main/res/values-id/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 4 +++- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/net/harimurti/tv/MainActivity.java b/app/src/main/java/net/harimurti/tv/MainActivity.java index e93704b..69199ca 100644 --- a/app/src/main/java/net/harimurti/tv/MainActivity.java +++ b/app/src/main/java/net/harimurti/tv/MainActivity.java @@ -2,6 +2,7 @@ import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.AppCompatButton; import androidx.appcompat.widget.SwitchCompat; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; @@ -76,6 +77,8 @@ protected void onCreate(Bundle savedInstanceState) { SwitchCompat swOpenLast = findViewById(R.id.open_last_watched); swOpenLast.setChecked(preferences.isOpenLastWatched()); swOpenLast.setOnClickListener(view -> preferences.setOpenLastWatched(swOpenLast.isChecked())); + AppCompatButton btnReload = findViewById(R.id.reload_playlist); + btnReload.setOnClickListener(view -> request.add(reqPlaylist)); reqPlaylist = new StringRequest(Request.Method.GET, getString(R.string.json_playlist), @@ -84,6 +87,7 @@ protected void onCreate(Bundle savedInstanceState) { playlist = new Gson().fromJson(response, Playlist.class); setPlaylistToViewPager(); new JsonPlaylist(this).write(response); + Toast.makeText(this, R.string.playlist_updated, Toast.LENGTH_SHORT).show(); } catch (JsonSyntaxException error) { showAlertError(error.getMessage()); } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index a198d5a..fda150c 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -93,6 +93,16 @@ android:layout_height="wrap_content" android:text="@string/open_last_watched" /> + + + + diff --git a/app/src/main/res/values-id/strings.xml b/app/src/main/res/values-id/strings.xml index e7e023a..c20762a 100644 --- a/app/src/main/res/values-id/strings.xml +++ b/app/src/main/res/values-id/strings.xml @@ -27,4 +27,6 @@ Jalankan app saat boot Putar terakhir dilihat Android ini tidak punya pengelola unduhan + Muat ulang Playlist + Playlist sudah diperbaharui! \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6a52aae..df17d6e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -14,7 +14,8 @@ No internet connection! Press BACK again to exit! - + + Playlist has been updated! Something wrong Playlist file cannot be accessed!\nResponse code : %d Server cannot be accessed!\nResponse code : %d @@ -34,4 +35,5 @@ Settings Run app on boot Play last seen + Reload Playlist