From b57ef5a256ac020ff6eee7efd54762b407fd0041 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Tue, 7 Jun 2022 07:46:07 +0200 Subject: [PATCH 1/3] thumbnail --- app/src/main/java/com/github/libretube/Home.kt | 5 ----- .../com/github/libretube/adapters/PlaylistsAdapter.kt | 7 +++++-- app/src/main/res/layout/fragment_home.xml | 11 ----------- app/src/main/res/layout/playlists_row.xml | 1 + 4 files changed, 6 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/github/libretube/Home.kt b/app/src/main/java/com/github/libretube/Home.kt index aeea5434f..49bfa1423 100644 --- a/app/src/main/java/com/github/libretube/Home.kt +++ b/app/src/main/java/com/github/libretube/Home.kt @@ -41,11 +41,6 @@ class Home : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - val searchButton = view.findViewById(R.id.search_fab) - searchButton.setOnClickListener { - findNavController().navigate(R.id.searchFragment) - } val recyclerView = view.findViewById(R.id.recview) val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext()) val grid = sharedPreferences.getString( diff --git a/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt b/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt index 9aa860f27..462645cc2 100644 --- a/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt @@ -8,6 +8,7 @@ import android.view.View import android.view.ViewGroup import android.widget.ImageView import android.widget.TextView +import androidx.core.net.toUri import androidx.core.os.bundleOf import androidx.recyclerview.widget.RecyclerView import com.github.libretube.MainActivity @@ -46,12 +47,14 @@ class PlaylistsAdapter( val playlist = playlists[position] val thumbnailImage = holder.v.findViewById(R.id.playlist_thumbnail) Picasso.get().load(playlist.thumbnail).into(thumbnailImage) + // set imageview drawable as empty playlist if imageview empty + // if (thumbnailImage.drawable == null) thumbnailImage.setImageResource(R.mipmap.empty_playlist) holder.v.findViewById(R.id.playlist_title).text = playlist.name holder.v.findViewById(R.id.delete_playlist).setOnClickListener { val builder = MaterialAlertDialogBuilder(holder.v.context) builder.setTitle(R.string.deletePlaylist) builder.setMessage(R.string.areYouSure) - builder.setPositiveButton(R.string.yes) { dialog, which -> + builder.setPositiveButton(R.string.yes) { _, _ -> val sharedPref = holder.v.context.getSharedPreferences( "token", Context.MODE_PRIVATE @@ -59,7 +62,7 @@ class PlaylistsAdapter( val token = sharedPref?.getString("token", "")!! deletePlaylist(playlist.id!!, token, position) } - builder.setNegativeButton(R.string.cancel) { dialog, which -> + builder.setNegativeButton(R.string.cancel) { _, _ -> } builder.show() } diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index aff1dc0dd..f11eb5dbc 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -32,15 +32,4 @@ - - \ No newline at end of file diff --git a/app/src/main/res/layout/playlists_row.xml b/app/src/main/res/layout/playlists_row.xml index c9cb7ec18..0d8b60e63 100644 --- a/app/src/main/res/layout/playlists_row.xml +++ b/app/src/main/res/layout/playlists_row.xml @@ -21,6 +21,7 @@ app:cardCornerRadius="8dp" android:layout_width="0dp" android:layout_height="0dp" + app:strokeWidth="0dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintDimensionRatio="16:9" app:layout_constraintHorizontal_bias="0.0" From abb584618bba2d2c43147fc8f23057acc72bd95b Mon Sep 17 00:00:00 2001 From: Bnyro Date: Wed, 8 Jun 2022 11:33:11 +0200 Subject: [PATCH 2/3] empty playlist thumbnail --- .../com/github/libretube/adapters/PlaylistsAdapter.kt | 8 +++++--- app/src/main/res/drawable/ic_empty_playlist.xml | 11 +++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 app/src/main/res/drawable/ic_empty_playlist.xml diff --git a/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt b/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt index 462645cc2..63fd37428 100644 --- a/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt @@ -8,7 +8,6 @@ import android.view.View import android.view.ViewGroup import android.widget.ImageView import android.widget.TextView -import androidx.core.net.toUri import androidx.core.os.bundleOf import androidx.recyclerview.widget.RecyclerView import com.github.libretube.MainActivity @@ -18,10 +17,10 @@ import com.github.libretube.obj.Playlists import com.github.libretube.util.RetrofitInstance import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.squareup.picasso.Picasso -import java.io.IOException import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import retrofit2.HttpException +import java.io.IOException class PlaylistsAdapter( private val playlists: MutableList, @@ -48,7 +47,10 @@ class PlaylistsAdapter( val thumbnailImage = holder.v.findViewById(R.id.playlist_thumbnail) Picasso.get().load(playlist.thumbnail).into(thumbnailImage) // set imageview drawable as empty playlist if imageview empty - // if (thumbnailImage.drawable == null) thumbnailImage.setImageResource(R.mipmap.empty_playlist) + if (thumbnailImage.drawable == null) { + thumbnailImage.setImageResource(R.drawable.ic_empty_playlist) + thumbnailImage.setBackgroundColor(R.attr.colorSurface) + } holder.v.findViewById(R.id.playlist_title).text = playlist.name holder.v.findViewById(R.id.delete_playlist).setOnClickListener { val builder = MaterialAlertDialogBuilder(holder.v.context) diff --git a/app/src/main/res/drawable/ic_empty_playlist.xml b/app/src/main/res/drawable/ic_empty_playlist.xml new file mode 100644 index 000000000..819452cc1 --- /dev/null +++ b/app/src/main/res/drawable/ic_empty_playlist.xml @@ -0,0 +1,11 @@ + + + From d7e251d607c5e5062813278ca202706bf4669074 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Wed, 8 Jun 2022 11:39:07 +0200 Subject: [PATCH 3/3] ktlint --- .../main/java/com/github/libretube/adapters/PlaylistsAdapter.kt | 2 +- app/src/main/java/com/github/libretube/fragments/Home.kt | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt b/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt index 63fd37428..1d3c8e5a2 100644 --- a/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt @@ -17,10 +17,10 @@ import com.github.libretube.obj.Playlists import com.github.libretube.util.RetrofitInstance import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.squareup.picasso.Picasso +import java.io.IOException import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import retrofit2.HttpException -import java.io.IOException class PlaylistsAdapter( private val playlists: MutableList, diff --git a/app/src/main/java/com/github/libretube/fragments/Home.kt b/app/src/main/java/com/github/libretube/fragments/Home.kt index 91dd64eb6..5235e72c7 100644 --- a/app/src/main/java/com/github/libretube/fragments/Home.kt +++ b/app/src/main/java/com/github/libretube/fragments/Home.kt @@ -9,7 +9,6 @@ import android.widget.ProgressBar import android.widget.Toast import androidx.fragment.app.Fragment import androidx.lifecycle.lifecycleScope -import androidx.navigation.fragment.findNavController import androidx.preference.PreferenceManager import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.RecyclerView