The placeholders are better. But the api thing isnt working

This commit is contained in:
LucasGGamerM
2022-12-12 16:10:27 -03:00
parent 0ca9c536cd
commit a3267f6cd3
3 changed files with 36 additions and 11 deletions

View File

@@ -1,10 +1,9 @@
package org.joinmastodon.android.api.requests.lists;
import org.joinmastodon.android.api.MastodonAPIRequest;
import java.util.List;
public class RemoveList extends MastodonAPIRequest<Object> {
public RemoveList(String listId){
public class DeleteList extends MastodonAPIRequest<Object> {
public DeleteList(String listId){
super(HttpMethod.DELETE, "/lists/"+listId, Object.class);
}
}

View File

@@ -18,6 +18,7 @@ import androidx.recyclerview.widget.RecyclerView;
import org.joinmastodon.android.R;
import org.joinmastodon.android.api.MastodonAPIRequest;
import org.joinmastodon.android.api.requests.lists.AddAccountsToList;
import org.joinmastodon.android.api.requests.lists.DeleteList;
import org.joinmastodon.android.api.requests.lists.GetLists;
import org.joinmastodon.android.api.requests.lists.RemoveAccountsFromList;
import org.joinmastodon.android.model.ListTimeline;
@@ -32,6 +33,7 @@ import java.util.List;
import java.util.Map;
import me.grishka.appkit.Nav;
import me.grishka.appkit.api.Callback;
import me.grishka.appkit.api.ErrorResponse;
import me.grishka.appkit.api.SimpleCallback;
import me.grishka.appkit.fragments.BaseRecyclerFragment;
@@ -180,8 +182,8 @@ public class ListTimelinesFragment extends BaseRecyclerFragment<ListTimeline> im
} else {
listToggle.setVisibility(View.GONE);
}
// edit.setOnClickListener();
// delete.setOnClickListener();
edit.setOnClickListener(v -> this.editListName(item.id));
delete.setOnClickListener(v -> this.deleteList(item.id));
}
private void onClickToggle(View view) {
@@ -193,12 +195,35 @@ public class ListTimelinesFragment extends BaseRecyclerFragment<ListTimeline> im
UiUtils.openListTimeline(getActivity(), accountId, item);
}
// private void editListName(){
// new M3AlertDialogBuilder(getActivity())
// .setTitle(R.string.edit_text_edited)
private void editListName(String listId){
new M3AlertDialogBuilder(getActivity())
.setTitle(R.string.edit_text_edited)
// .setPositiveButton(R.string.discard, (dialog, which)-> )
// .setNegativeButton(R.string.cancel, null)
// .show();
// }
.setNegativeButton(R.string.cancel, null)
.show();
}
private void deleteList(String listId){
new M3AlertDialogBuilder(getActivity())
.setTitle(R.string.sk_delete_list_dialog_title)
.setPositiveButton(R.string.delete, (dialog, which)-> new DeleteList(listId))
.setNegativeButton(R.string.cancel, null)
.show();
}
private void actuallyDeleteList(String listId){
new DeleteList(listId).setCallback(new Callback<Object>() {
@Override
public void onSuccess(Object result) {
loadData();
}
@Override
public void onError(ErrorResponse error) {
error.showToast(getActivity());
}
});
}
}
}

View File

@@ -50,4 +50,5 @@
<string name="sk_color_theme_material_you">Material You</string>
<string name="sk_not_supported">Not supported on your device</string>
<string name="sk_lists_timeline">Lists picker</string>
<string name="sk_delete_list_dialog_title">Delete list?</string>
</resources>