Merge pull request #233 from tinywombat765/download-ind
Add cached indicator to song list
This commit is contained in:
commit
c659447dcd
5 changed files with 36 additions and 0 deletions
|
|
@ -27,6 +27,9 @@ public class MediaEntryViewHolder extends RecyclerView.ViewHolder implements Vie
|
|||
@Nullable
|
||||
public View menu;
|
||||
|
||||
@Nullable
|
||||
public View cached;
|
||||
|
||||
@Nullable
|
||||
public View separator;
|
||||
|
||||
|
|
@ -47,6 +50,7 @@ public class MediaEntryViewHolder extends RecyclerView.ViewHolder implements Vie
|
|||
title = itemView.findViewById(R.id.title);
|
||||
text = itemView.findViewById(R.id.text);
|
||||
menu = itemView.findViewById(R.id.menu);
|
||||
cached = itemView.findViewById(R.id.cached);
|
||||
separator = itemView.findViewById(R.id.separator);
|
||||
shortSeparator = itemView.findViewById(R.id.short_separator);
|
||||
dragView = itemView.findViewById(R.id.drag_view);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.dkanada.gramophone.adapter.song;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
|
@ -12,6 +13,7 @@ import androidx.annotation.Nullable;
|
|||
import androidx.core.util.Pair;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.dkanada.gramophone.App;
|
||||
import com.dkanada.gramophone.util.ThemeUtil;
|
||||
import com.dkanada.gramophone.R;
|
||||
import com.dkanada.gramophone.adapter.base.AbsMultiSelectAdapter;
|
||||
|
|
@ -111,6 +113,14 @@ public class SongAdapter extends AbsMultiSelectAdapter<SongAdapter.ViewHolder, S
|
|||
holder.text.setText(getSongText(song));
|
||||
}
|
||||
|
||||
if (holder.cached != null) {
|
||||
if (App.getDatabase().cacheDao().isCached(song.id)) {
|
||||
holder.cached.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.cached.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
loadAlbumCover(song, holder);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,4 +16,7 @@ public interface CacheDao {
|
|||
|
||||
@Query("SELECT * FROM songs LEFT JOIN cache USING(id) WHERE songs.id IN (:ids)")
|
||||
List<Song> getSongs(List<String> ids);
|
||||
|
||||
@Query("SELECT cache FROM cache WHERE id = :id")
|
||||
boolean isCached(String id);
|
||||
}
|
||||
|
|
|
|||
9
app/src/main/res/drawable/ic_download_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_download_24dp.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M220,800Q196,800 178,782Q160,764 160,740L160,597L220,597L220,740Q220,740 220,740Q220,740 220,740L740,740Q740,740 740,740Q740,740 740,740L740,597L800,597L800,740Q800,764 782,782Q764,800 740,800L220,800ZM480,647L287,454L330,411L450,531L450,160L510,160L510,531L630,411L673,454L480,647Z"/>
|
||||
</vector>
|
||||
|
|
@ -81,6 +81,16 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<com.dkanada.gramophone.views.IconImageView
|
||||
android:id="@+id/cached"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:scaleType="centerCrop"
|
||||
app:srcCompat="@drawable/ic_download_24dp"
|
||||
tools:ignore="ContentDescription"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<com.dkanada.gramophone.views.IconImageView
|
||||
android:id="@+id/menu"
|
||||
style="@style/OverFlowButton"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue