fixed playlist rename bug
This commit is contained in:
parent
210feb7aec
commit
45df5596b8
2 changed files with 49 additions and 49 deletions
|
@ -40,5 +40,5 @@ public class Constants {
|
|||
public static final String APP_INSTAGRAM_LINK = "https://www.instagram.com/retromusicapp/";
|
||||
public static final String APP_TELEGRAM_LINK = "https://t.me/retromusicapp/";
|
||||
public static final String APP_TWITTER_LINK = "https://twitter.com/retromusicapp";
|
||||
public static final String FAQ_LINK = "https://raw.githubusercontent.com/h4h13/RetroMusicPlayer/master/FAQ.md";
|
||||
public static final String FAQ_LINK = "https://github.com/h4h13/RetroMusicPlayer/blob/master/FAQ.md";
|
||||
}
|
||||
|
|
|
@ -3,15 +3,11 @@ package code.name.monkey.retromusic.dialogs;
|
|||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.BottomSheetDialogFragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
@ -20,60 +16,64 @@ import code.name.monkey.appthemehelper.util.TintHelper;
|
|||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.util.PlaylistsUtil;
|
||||
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid), Aidan Follestad (afollestad)
|
||||
*/
|
||||
public class RenamePlaylistDialog extends RoundedBottomSheetDialogFragment {
|
||||
@BindView(R.id.option_1)
|
||||
EditText playlistName;
|
||||
@BindView(R.id.action_cancel)
|
||||
Button cancel;
|
||||
@BindView(R.id.action_rename)
|
||||
Button rename;
|
||||
|
||||
@NonNull
|
||||
public static RenamePlaylistDialog create(long playlistId) {
|
||||
RenamePlaylistDialog dialog = new RenamePlaylistDialog();
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("playlist_id", playlistId);
|
||||
dialog.setArguments(args);
|
||||
return dialog;
|
||||
}
|
||||
@BindView(R.id.option_1)
|
||||
EditText playlistName;
|
||||
@BindView(R.id.action_cancel)
|
||||
Button cancel;
|
||||
@BindView(R.id.action_rename)
|
||||
Button rename;
|
||||
|
||||
@OnClick({R.id.action_cancel, R.id.action_rename})
|
||||
void actions(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.action_cancel:
|
||||
dismiss();
|
||||
break;
|
||||
case R.id.action_rename:
|
||||
if (!playlistName.toString().trim().equals("")) {
|
||||
long playlistId = getArguments().getLong("playlist_id");
|
||||
PlaylistsUtil.renamePlaylist(getActivity(), playlistId, playlistName.toString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@NonNull
|
||||
public static RenamePlaylistDialog create(long playlistId) {
|
||||
RenamePlaylistDialog dialog = new RenamePlaylistDialog();
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("playlist_id", playlistId);
|
||||
dialog.setArguments(args);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@OnClick({R.id.action_cancel, R.id.action_rename})
|
||||
void actions(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.action_cancel:
|
||||
dismiss();
|
||||
break;
|
||||
case R.id.action_rename:
|
||||
if (!playlistName.toString().trim().equals("")) {
|
||||
long playlistId = getArguments().getLong("playlist_id");
|
||||
PlaylistsUtil.renamePlaylist(getActivity(), playlistId,
|
||||
playlistName.getText().toString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View layout = inflater.inflate(R.layout.dialog_playlist_rename, container, false);
|
||||
ButterKnife.bind(this, layout);
|
||||
return layout;
|
||||
}
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View layout = inflater.inflate(R.layout.dialog_playlist_rename, container, false);
|
||||
ButterKnife.bind(this, layout);
|
||||
return layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
int accentColor = ThemeStore.accentColor(Objects.requireNonNull(getContext()));
|
||||
TintHelper.setTintAuto(playlistName, accentColor, true);
|
||||
TintHelper.setTintAuto(rename, accentColor, true);
|
||||
cancel.setTextColor(accentColor);
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
int accentColor = ThemeStore.accentColor(Objects.requireNonNull(getContext()));
|
||||
TintHelper.setTintAuto(playlistName, accentColor, true);
|
||||
TintHelper.setTintAuto(rename, accentColor, true);
|
||||
cancel.setTextColor(accentColor);
|
||||
|
||||
long playlistId = getArguments().getLong("playlist_id");
|
||||
playlistName.setText(PlaylistsUtil.getNameForPlaylist(getActivity(), playlistId));
|
||||
}
|
||||
long playlistId = getArguments().getLong("playlist_id");
|
||||
playlistName.setText(PlaylistsUtil.getNameForPlaylist(getActivity(), playlistId));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue