Skip to content

Commit

Permalink
Merge pull request #233 from tinywombat765/download-ind
Browse files Browse the repository at this point in the history
Add cached indicator to song list
  • Loading branch information
dkanada authored Mar 4, 2023
2 parents 9cc0356 + bf261d3 commit c659447
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public class MediaEntryViewHolder extends RecyclerView.ViewHolder implements Vie
@Nullable
public View menu;

@Nullable
public View cached;

@Nullable
public View separator;

Expand All @@ -47,6 +50,7 @@ public MediaEntryViewHolder(View itemView) {
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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -12,6 +13,7 @@
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;
Expand Down Expand Up @@ -111,6 +113,14 @@ public void onBindViewHolder(@NonNull final ViewHolder holder, int position) {
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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_download_24dp.xml
Original file line number Diff line number Diff line change
@@ -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>
10 changes: 10 additions & 0 deletions app/src/main/res/layout/item_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit c659447

Please sign in to comment.