mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-29 04:17:12 +01:00
Added LemmyPostAPI
Forgot to include in my prev commit. Added LemmyPostAPI Forgot to include in my prev commit.
This commit is contained in:
parent
fd24f04254
commit
ac5e67c032
@ -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();
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user