Added LemmyPostAPI

Forgot to include in my prev commit.

Added LemmyPostAPI

Forgot to include in my prev commit.
This commit is contained in:
Balazs Toldi 2023-08-17 16:26:32 +02:00
parent fd24f04254
commit ac5e67c032
No known key found for this signature in database
GPG Key ID: 6C7D440036F99D58
2 changed files with 36 additions and 4 deletions

View File

@ -193,10 +193,6 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
});
reportTextView.setOnClickListener(view -> {
/*Intent intent = new Intent(activity, ReportActivity.class);
intent.putExtra(ReportActivity.EXTRA_SUBREDDIT_NAME, comment.getCommunityName());
intent.putExtra(ReportActivity.EXTRA_THING_FULLNAME, comment.getFullName());
activity.startActivity(intent);*/
if (accessToken == null) {
Toast.makeText(activity, R.string.login_first, Toast.LENGTH_SHORT).show();
dismiss();

View File

@ -0,0 +1,36 @@
package eu.toldi.infinityforlemmy.post
import eu.toldi.infinityforlemmy.RetrofitHolder
import eu.toldi.infinityforlemmy.apis.LemmyAPI
import eu.toldi.infinityforlemmy.dto.ReportPostDTO
import retrofit2.Call
import retrofit2.Callback
class LemmyPostAPI(val retrofitHolder: RetrofitHolder) {
fun reportPost(postId: Int, reason: String, auth: String, callback: ReportPostCallback) {
val api = retrofitHolder.retrofit.create(LemmyAPI::class.java)
api.postReport(ReportPostDTO(postId, reason, auth)).enqueue(object : Callback<String> {
override fun onResponse(
call: retrofit2.Call<String>,
response: retrofit2.Response<String>
) {
if (response.isSuccessful) {
callback.onSuccess()
} else {
callback.onFailure()
}
}
override fun onFailure(call: Call<String>, t: Throwable) {
callback.onFailure()
}
})
}
public interface ReportPostCallback {
fun onSuccess()
fun onFailure()
}
}