diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/bottomsheetfragments/CommentMoreBottomSheetFragment.java b/app/src/main/java/eu/toldi/infinityforlemmy/bottomsheetfragments/CommentMoreBottomSheetFragment.java index 09f622be..1e270aaa 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/bottomsheetfragments/CommentMoreBottomSheetFragment.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/bottomsheetfragments/CommentMoreBottomSheetFragment.java @@ -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(); diff --git a/app/src/main/kotlin/eu/toldi/infinityforlemmy/post/LemmyPostAPI.kt b/app/src/main/kotlin/eu/toldi/infinityforlemmy/post/LemmyPostAPI.kt new file mode 100644 index 00000000..a889d219 --- /dev/null +++ b/app/src/main/kotlin/eu/toldi/infinityforlemmy/post/LemmyPostAPI.kt @@ -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 { + override fun onResponse( + call: retrofit2.Call, + response: retrofit2.Response + ) { + if (response.isSuccessful) { + callback.onSuccess() + } else { + callback.onFailure() + } + } + + override fun onFailure(call: Call, t: Throwable) { + callback.onFailure() + } + + }) + } + + public interface ReportPostCallback { + fun onSuccess() + fun onFailure() + } +} \ No newline at end of file