clean
This commit is contained in:
parent
0fcad881bf
commit
f139d02c2c
|
@ -23,14 +23,21 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.widget.PopupMenu;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import app.fedilab.fedilabtube.PeertubeEditUploadActivity;
|
||||
import app.fedilab.fedilabtube.PlaylistsActivity;
|
||||
import app.fedilab.fedilabtube.R;
|
||||
import app.fedilab.fedilabtube.asynctasks.ManagePlaylistsAsyncTask;
|
||||
|
@ -77,18 +84,27 @@ public class PlaylistAdapter extends BaseAdapter implements OnPlaylistActionInte
|
|||
if (convertView == null) {
|
||||
convertView = layoutInflater.inflate(R.layout.drawer_playlist, parent, false);
|
||||
holder = new ViewHolder();
|
||||
holder.search_title = convertView.findViewById(R.id.search_keyword);
|
||||
holder.search_container = convertView.findViewById(R.id.search_container);
|
||||
holder.action_delete = convertView.findViewById(R.id.action_delete);
|
||||
holder.preview_title = convertView.findViewById(R.id.preview_title);
|
||||
holder.preview_visibility = convertView.findViewById(R.id.preview_visibility);
|
||||
holder.preview_description = convertView.findViewById(R.id.preview_description);
|
||||
holder.playlist_container = convertView.findViewById(R.id.playlist_container);
|
||||
holder.preview_playlist = convertView.findViewById(R.id.preview_playlist);
|
||||
holder.playlist_more = convertView.findViewById(R.id.playlist_more);
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
Glide.with(context)
|
||||
.load("https://"+playlist.getOwnerAccount().getHost()+playlist.getThumbnailPath())
|
||||
.into(holder.preview_playlist);
|
||||
|
||||
holder.search_title.setText(playlist.getDisplayName());
|
||||
holder.preview_title.setText(playlist.getDisplayName());
|
||||
holder.preview_description.setText(playlist.getDescription());
|
||||
Map.Entry<Integer, String> privacyM = playlist.getPrivacy().entrySet().iterator().next();
|
||||
holder.preview_visibility.setText(privacyM.getValue());
|
||||
|
||||
holder.search_container.setOnClickListener(v -> {
|
||||
holder.playlist_container.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(context, PlaylistsActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putParcelable("playlist", playlist);
|
||||
|
@ -97,21 +113,36 @@ public class PlaylistAdapter extends BaseAdapter implements OnPlaylistActionInte
|
|||
});
|
||||
|
||||
|
||||
holder.action_delete.setOnClickListener(v -> {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle(context.getString(R.string.action_lists_delete) + ": " + playlist.getDisplayName());
|
||||
builder.setMessage(context.getString(R.string.action_lists_confirm_delete));
|
||||
builder.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.setPositiveButton(R.string.yes, (dialog, which) -> {
|
||||
playlists.remove(playlist);
|
||||
notifyDataSetChanged();
|
||||
new ManagePlaylistsAsyncTask(context, ManagePlaylistsAsyncTask.action.DELETE_PLAYLIST, playlist, null, null, PlaylistAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
if (playlists.size() == 0 && textviewNoAction != null && textviewNoAction.getVisibility() == View.GONE)
|
||||
textviewNoAction.setVisibility(View.VISIBLE);
|
||||
dialog.dismiss();
|
||||
})
|
||||
.setNegativeButton(R.string.no, (dialog, which) -> dialog.dismiss())
|
||||
.show();
|
||||
holder.playlist_more.setOnClickListener(v -> {
|
||||
PopupMenu popup = new PopupMenu(context, holder.playlist_more);
|
||||
popup.getMenuInflater()
|
||||
.inflate(R.menu.playlist_menu, popup.getMenu());
|
||||
popup.setOnMenuItemClickListener(item -> {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_delete:
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle(context.getString(R.string.action_lists_delete) + ": " + playlist.getDisplayName());
|
||||
builder.setMessage(context.getString(R.string.action_lists_confirm_delete));
|
||||
builder.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.setPositiveButton(R.string.yes, (dialog, which) -> {
|
||||
playlists.remove(playlist);
|
||||
notifyDataSetChanged();
|
||||
new ManagePlaylistsAsyncTask(context, ManagePlaylistsAsyncTask.action.DELETE_PLAYLIST, playlist, null, null, PlaylistAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
if (playlists.size() == 0 && textviewNoAction != null && textviewNoAction.getVisibility() == View.GONE)
|
||||
textviewNoAction.setVisibility(View.VISIBLE);
|
||||
dialog.dismiss();
|
||||
})
|
||||
.setNegativeButton(R.string.no, (dialog, which) -> dialog.dismiss())
|
||||
.show();
|
||||
break;
|
||||
case R.id.action_edit:
|
||||
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
popup.show();
|
||||
|
||||
});
|
||||
return convertView;
|
||||
}
|
||||
|
@ -122,9 +153,10 @@ public class PlaylistAdapter extends BaseAdapter implements OnPlaylistActionInte
|
|||
}
|
||||
|
||||
private static class ViewHolder {
|
||||
LinearLayout search_container;
|
||||
TextView search_title;
|
||||
FloatingActionButton action_delete;
|
||||
LinearLayout playlist_container;
|
||||
ImageView preview_playlist;
|
||||
TextView preview_title, preview_visibility, preview_description;
|
||||
ImageButton playlist_more;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="?attr/colorControlNormal"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M12,8c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM12,16c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z" />
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M12,8c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM12,16c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z"/>
|
||||
</vector>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/search_container"
|
||||
android:id="@+id/playlist_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:divider="?android:dividerHorizontal"
|
||||
|
@ -29,44 +29,60 @@
|
|||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<ImageView
|
||||
android:id="@+id/preview_playlist"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleType="centerCrop"
|
||||
android:layout_gravity="center"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:contentDescription="@string/preview" />
|
||||
<TextView
|
||||
android:id="@+id/preview_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_weight="1"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/playlist_more"
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/action_delete"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
<TextView
|
||||
android:id="@+id/preview_visibility"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_margin="5dp"
|
||||
android:contentDescription="@string/delete_list"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/ic_baseline_delete_24"
|
||||
app:backgroundTint="?colorAccent"
|
||||
app:fabSize="mini"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
app:layout_constraintEnd_toStartOf="@+id/preview_description"
|
||||
app:layout_constraintStart_toEndOf="@+id/preview_playlist"
|
||||
app:layout_constraintTop_toBottomOf="@+id/preview_title" />
|
||||
<TextView
|
||||
android:id="@+id/search_keyword"
|
||||
android:id="@+id/preview_description"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/display_playlist"
|
||||
app:layout_constraintStart_toEndOf="@+id/action_delete"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/display_playlist"
|
||||
app:layout_constraintEnd_toStartOf="@+id/playlist_more"
|
||||
app:layout_constraintStart_toEndOf="@+id/preview_playlist"
|
||||
app:layout_constraintTop_toBottomOf="@+id/preview_title" />
|
||||
<ImageButton
|
||||
android:id="@+id/playlist_more"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:contentDescription="@string/display_list"
|
||||
android:src="@drawable/ic_baseline_arrow_forward_ios_24"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
android:contentDescription="@string/display_more"
|
||||
android:src="@drawable/ic_baseline_more_vert_24"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/action_delete"
|
||||
android:icon="@drawable/ic_baseline_delete_24"
|
||||
android:title="@string/delete"
|
||||
app:showAsAction="ifRoom" />
|
||||
<item
|
||||
android:id="@+id/action_edit"
|
||||
android:icon="@drawable/ic_baseline_edit_24"
|
||||
android:title="@string/edit"
|
||||
app:showAsAction="ifRoom" />
|
||||
</menu>
|
|
@ -207,4 +207,5 @@
|
|||
<string name="delete_channel">Supprimer la chaîne</string>
|
||||
<string name="display_list">Afficher la liste</string>
|
||||
<string name="delete_list">Supprimer la liste de lecture</string>
|
||||
<string name="edit">Modifier</string>
|
||||
</resources>
|
Loading…
Reference in New Issue