fixed playlist rename bug

This commit is contained in:
h4h13 2018-07-30 00:38:52 +05:30
parent 210feb7aec
commit 45df5596b8
2 changed files with 49 additions and 49 deletions

View file

@ -40,5 +40,5 @@ public class Constants {
public static final String APP_INSTAGRAM_LINK = "https://www.instagram.com/retromusicapp/"; 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_TELEGRAM_LINK = "https://t.me/retromusicapp/";
public static final String APP_TWITTER_LINK = "https://twitter.com/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";
} }

View file

@ -3,15 +3,11 @@ package code.name.monkey.retromusic.dialogs;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.design.widget.BottomSheetDialogFragment;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import java.util.Objects;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.OnClick; 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.R;
import code.name.monkey.retromusic.util.PlaylistsUtil; import code.name.monkey.retromusic.util.PlaylistsUtil;
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment; import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment;
import java.util.Objects;
/** /**
* @author Karim Abou Zeid (kabouzeid), Aidan Follestad (afollestad) * @author Karim Abou Zeid (kabouzeid), Aidan Follestad (afollestad)
*/ */
public class RenamePlaylistDialog extends RoundedBottomSheetDialogFragment { 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 @BindView(R.id.option_1)
public static RenamePlaylistDialog create(long playlistId) { EditText playlistName;
RenamePlaylistDialog dialog = new RenamePlaylistDialog(); @BindView(R.id.action_cancel)
Bundle args = new Bundle(); Button cancel;
args.putLong("playlist_id", playlistId); @BindView(R.id.action_rename)
dialog.setArguments(args); Button rename;
return dialog;
}
@OnClick({R.id.action_cancel, R.id.action_rename}) @NonNull
void actions(View view) { public static RenamePlaylistDialog create(long playlistId) {
switch (view.getId()) { RenamePlaylistDialog dialog = new RenamePlaylistDialog();
case R.id.action_cancel: Bundle args = new Bundle();
dismiss(); args.putLong("playlist_id", playlistId);
break; dialog.setArguments(args);
case R.id.action_rename: return dialog;
if (!playlistName.toString().trim().equals("")) { }
long playlistId = getArguments().getLong("playlist_id");
PlaylistsUtil.renamePlaylist(getActivity(), playlistId, playlistName.toString()); @OnClick({R.id.action_cancel, R.id.action_rename})
} void actions(View view) {
break; switch (view.getId()) {
} case R.id.action_cancel:
dismiss(); 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 @Nullable
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
View layout = inflater.inflate(R.layout.dialog_playlist_rename, container, false); @Nullable Bundle savedInstanceState) {
ButterKnife.bind(this, layout); View layout = inflater.inflate(R.layout.dialog_playlist_rename, container, false);
return layout; ButterKnife.bind(this, layout);
} return layout;
}
@Override @Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState); super.onViewCreated(view, savedInstanceState);
int accentColor = ThemeStore.accentColor(Objects.requireNonNull(getContext())); int accentColor = ThemeStore.accentColor(Objects.requireNonNull(getContext()));
TintHelper.setTintAuto(playlistName, accentColor, true); TintHelper.setTintAuto(playlistName, accentColor, true);
TintHelper.setTintAuto(rename, accentColor, true); TintHelper.setTintAuto(rename, accentColor, true);
cancel.setTextColor(accentColor); cancel.setTextColor(accentColor);
long playlistId = getArguments().getLong("playlist_id"); long playlistId = getArguments().getLong("playlist_id");
playlistName.setText(PlaylistsUtil.getNameForPlaylist(getActivity(), playlistId)); playlistName.setText(PlaylistsUtil.getNameForPlaylist(getActivity(), playlistId));
} }
} }