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.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.appcompat.widget.PopupMenu;
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import app.fedilab.fedilabtube.PeertubeEditUploadActivity;
|
||||||
import app.fedilab.fedilabtube.PlaylistsActivity;
|
import app.fedilab.fedilabtube.PlaylistsActivity;
|
||||||
import app.fedilab.fedilabtube.R;
|
import app.fedilab.fedilabtube.R;
|
||||||
import app.fedilab.fedilabtube.asynctasks.ManagePlaylistsAsyncTask;
|
import app.fedilab.fedilabtube.asynctasks.ManagePlaylistsAsyncTask;
|
||||||
|
@ -77,18 +84,27 @@ public class PlaylistAdapter extends BaseAdapter implements OnPlaylistActionInte
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
convertView = layoutInflater.inflate(R.layout.drawer_playlist, parent, false);
|
convertView = layoutInflater.inflate(R.layout.drawer_playlist, parent, false);
|
||||||
holder = new ViewHolder();
|
holder = new ViewHolder();
|
||||||
holder.search_title = convertView.findViewById(R.id.search_keyword);
|
holder.preview_title = convertView.findViewById(R.id.preview_title);
|
||||||
holder.search_container = convertView.findViewById(R.id.search_container);
|
holder.preview_visibility = convertView.findViewById(R.id.preview_visibility);
|
||||||
holder.action_delete = convertView.findViewById(R.id.action_delete);
|
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);
|
convertView.setTag(holder);
|
||||||
} else {
|
} else {
|
||||||
holder = (ViewHolder) convertView.getTag();
|
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);
|
Intent intent = new Intent(context, PlaylistsActivity.class);
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
b.putParcelable("playlist", playlist);
|
b.putParcelable("playlist", playlist);
|
||||||
|
@ -97,7 +113,13 @@ public class PlaylistAdapter extends BaseAdapter implements OnPlaylistActionInte
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
holder.action_delete.setOnClickListener(v -> {
|
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);
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
builder.setTitle(context.getString(R.string.action_lists_delete) + ": " + playlist.getDisplayName());
|
builder.setTitle(context.getString(R.string.action_lists_delete) + ": " + playlist.getDisplayName());
|
||||||
builder.setMessage(context.getString(R.string.action_lists_confirm_delete));
|
builder.setMessage(context.getString(R.string.action_lists_confirm_delete));
|
||||||
|
@ -112,6 +134,15 @@ public class PlaylistAdapter extends BaseAdapter implements OnPlaylistActionInte
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.no, (dialog, which) -> dialog.dismiss())
|
.setNegativeButton(R.string.no, (dialog, which) -> dialog.dismiss())
|
||||||
.show();
|
.show();
|
||||||
|
break;
|
||||||
|
case R.id.action_edit:
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
popup.show();
|
||||||
|
|
||||||
});
|
});
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
@ -122,9 +153,10 @@ public class PlaylistAdapter extends BaseAdapter implements OnPlaylistActionInte
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ViewHolder {
|
private static class ViewHolder {
|
||||||
LinearLayout search_container;
|
LinearLayout playlist_container;
|
||||||
TextView search_title;
|
ImageView preview_playlist;
|
||||||
FloatingActionButton action_delete;
|
TextView preview_title, preview_visibility, preview_description;
|
||||||
|
ImageButton playlist_more;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:width="24dp"
|
android:width="24dp"
|
||||||
android:height="24dp"
|
android:height="24dp"
|
||||||
android:tint="?attr/colorControlNormal"
|
|
||||||
android:viewportWidth="24"
|
android:viewportWidth="24"
|
||||||
android:viewportHeight="24">
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
<path
|
<path
|
||||||
android:fillColor="@android:color/white"
|
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: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>
|
</vector>
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
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_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:divider="?android:dividerHorizontal"
|
android:divider="?android:dividerHorizontal"
|
||||||
|
@ -29,44 +29,60 @@
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
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
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
android:id="@+id/action_delete"
|
<TextView
|
||||||
|
android:id="@+id/preview_visibility"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:layout_margin="5dp"
|
android:layout_weight="1"
|
||||||
android:contentDescription="@string/delete_list"
|
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:scaleType="fitXY"
|
android:textStyle="bold"
|
||||||
android:src="@drawable/ic_baseline_delete_24"
|
|
||||||
app:backgroundTint="?colorAccent"
|
|
||||||
app:fabSize="mini"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintEnd_toStartOf="@+id/preview_description"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintStart_toEndOf="@+id/preview_playlist"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/preview_title" />
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/search_keyword"
|
android:id="@+id/preview_description"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textSize="18sp"
|
android:textSize="14sp"
|
||||||
android:textStyle="bold"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/display_playlist"
|
app:layout_constraintEnd_toStartOf="@+id/playlist_more"
|
||||||
app:layout_constraintStart_toEndOf="@+id/action_delete"
|
app:layout_constraintStart_toEndOf="@+id/preview_playlist"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toBottomOf="@+id/preview_title" />
|
||||||
|
<ImageButton
|
||||||
<ImageView
|
android:id="@+id/playlist_more"
|
||||||
android:id="@+id/display_playlist"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:contentDescription="@string/display_list"
|
style="@style/Widget.AppCompat.Button.Borderless"
|
||||||
android:src="@drawable/ic_baseline_arrow_forward_ios_24"
|
android:contentDescription="@string/display_more"
|
||||||
|
android:src="@drawable/ic_baseline_more_vert_24"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="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="delete_channel">Supprimer la chaîne</string>
|
||||||
<string name="display_list">Afficher la liste</string>
|
<string name="display_list">Afficher la liste</string>
|
||||||
<string name="delete_list">Supprimer la liste de lecture</string>
|
<string name="delete_list">Supprimer la liste de lecture</string>
|
||||||
|
<string name="edit">Modifier</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue