Removed sliding panel for now
This commit is contained in:
parent
2af26548ee
commit
636da3daa8
7 changed files with 223 additions and 542 deletions
|
@ -21,30 +21,55 @@ import android.content.Intent;
|
|||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.activities.saf.SAFGuideActivity;
|
||||
import code.name.monkey.retromusic.misc.DialogAsyncTask;
|
||||
import code.name.monkey.retromusic.model.Song;
|
||||
import code.name.monkey.retromusic.util.SAFUtil;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by hemanths on 2019-07-31.
|
||||
*/
|
||||
public class DeleteSongsAsyncTask extends DialogAsyncTask<DeleteSongsAsyncTask.LoadingInfo, Integer, Void> {
|
||||
private WeakReference<DeleteSongsDialog> dialogReference;
|
||||
|
||||
public static class LoadingInfo {
|
||||
|
||||
public Intent intent;
|
||||
|
||||
public boolean isIntent;
|
||||
|
||||
public int requestCode;
|
||||
|
||||
public int resultCode;
|
||||
|
||||
public List<Uri> safUris;
|
||||
|
||||
public List<Song> songs;
|
||||
|
||||
public LoadingInfo(List<Song> songs, List<Uri> safUris) {
|
||||
this.isIntent = false;
|
||||
this.songs = songs;
|
||||
this.safUris = safUris;
|
||||
}
|
||||
|
||||
public LoadingInfo(int requestCode, int resultCode, Intent intent) {
|
||||
this.isIntent = true;
|
||||
this.requestCode = requestCode;
|
||||
this.resultCode = resultCode;
|
||||
this.intent = intent;
|
||||
}
|
||||
}
|
||||
|
||||
private WeakReference<FragmentActivity> activityWeakReference;
|
||||
|
||||
private WeakReference<DeleteSongsDialog> dialogReference;
|
||||
|
||||
public DeleteSongsAsyncTask(@NonNull DeleteSongsDialog dialog) {
|
||||
super(dialog.getActivity());
|
||||
|
@ -82,7 +107,8 @@ public class DeleteSongsAsyncTask extends DialogAsyncTask<DeleteSongsAsyncTask.L
|
|||
if (SAFUtil.isSDCardAccessGranted(fragmentActivity)) {
|
||||
dialog.deleteSongs(info.songs, null);
|
||||
} else {
|
||||
dialog.startActivityForResult(new Intent(fragmentActivity, SAFGuideActivity.class), SAFGuideActivity.REQUEST_CODE_SAF_GUIDE);
|
||||
dialog.startActivityForResult(new Intent(fragmentActivity, SAFGuideActivity.class),
|
||||
SAFGuideActivity.REQUEST_CODE_SAF_GUIDE);
|
||||
}
|
||||
} else {
|
||||
Log.i("Hmm", "doInBackground: kitkat delete songs");
|
||||
|
@ -100,7 +126,8 @@ public class DeleteSongsAsyncTask extends DialogAsyncTask<DeleteSongsAsyncTask.L
|
|||
break;
|
||||
case SAFUtil.REQUEST_SAF_PICK_FILE:
|
||||
if (info.resultCode == Activity.RESULT_OK) {
|
||||
dialog.deleteSongs(Collections.singletonList(dialog.currentSong), Collections.singletonList(info.intent.getData()));
|
||||
dialog.deleteSongs(Collections.singletonList(dialog.currentSong),
|
||||
Collections.singletonList(info.intent.getData()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -111,28 +138,4 @@ public class DeleteSongsAsyncTask extends DialogAsyncTask<DeleteSongsAsyncTask.L
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class LoadingInfo {
|
||||
public boolean isIntent;
|
||||
|
||||
public List<Song> songs;
|
||||
public List<Uri> safUris;
|
||||
|
||||
public int requestCode;
|
||||
public int resultCode;
|
||||
public Intent intent;
|
||||
|
||||
public LoadingInfo(List<Song> songs, List<Uri> safUris) {
|
||||
this.isIntent = false;
|
||||
this.songs = songs;
|
||||
this.safUris = safUris;
|
||||
}
|
||||
|
||||
public LoadingInfo(int requestCode, int resultCode, Intent intent) {
|
||||
this.isIntent = true;
|
||||
this.requestCode = requestCode;
|
||||
this.resultCode = resultCode;
|
||||
this.intent = intent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ import com.afollestad.materialdialogs.LayoutMode
|
|||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||
|
||||
|
||||
class DeleteSongsDialog : DialogFragment() {
|
||||
@JvmField
|
||||
var currentSong: Song? = null
|
||||
|
@ -40,7 +39,6 @@ class DeleteSongsDialog : DialogFragment() {
|
|||
|
||||
private var deleteSongsAsyncTask: DeleteSongsAsyncTask? = null
|
||||
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val songs: ArrayList<Song>? = arguments?.getParcelableArrayList("songs")
|
||||
var title = 0
|
||||
|
@ -95,7 +93,7 @@ class DeleteSongsDialog : DialogFragment() {
|
|||
}
|
||||
|
||||
fun deleteSongs(songs: List<Song>, safUris: List<Uri>?) {
|
||||
MusicUtil.deleteTracks(activity!!, songs, safUris) { this.dismiss() }
|
||||
MusicUtil.deleteTracks(requireActivity(), songs, safUris) { this.dismiss() }
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue