diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/MessageRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/MessageRecyclerViewAdapter.java index 3865123b..3807a413 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/MessageRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/MessageRecyclerViewAdapter.java @@ -18,6 +18,7 @@ import androidx.recyclerview.widget.RecyclerView; import CustomView.CustomMarkwonView; import butterknife.BindView; import butterknife.ButterKnife; +import retrofit2.Retrofit; class MessageRecyclerViewAdapter extends PagedListAdapter { private static final int VIEW_TYPE_DATA = 0; @@ -25,7 +26,9 @@ class MessageRecyclerViewAdapter extends PagedListAdapter DIFF_CALLBACK = new DiffUtil.ItemCallback() { @@ -71,11 +76,11 @@ class MessageRecyclerViewAdapter extends PagedListAdapter { @@ -134,9 +154,9 @@ class MessageRecyclerViewAdapter extends PagedListAdapter params = new HashMap<>(); + params.put(RedditUtils.ID_KEY, commaSeparatedFullnames); + oauthRetrofit.create(RedditAPI.class).readMessage(RedditUtils.getOAuthHeader(accessToken), params) + .enqueue(new Callback() { + @Override + public void onResponse(@NonNull Call call, @NonNull Response response) { + if(response.isSuccessful()) { + readMessageListener.readSuccess(); + } else { + readMessageListener.readFailed(); + } + } + + @Override + public void onFailure(@NonNull Call call, @NonNull Throwable t) { + readMessageListener.readFailed(); + } + }); + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditAPI.java b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditAPI.java index a187b521..519bc0ec 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditAPI.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditAPI.java @@ -159,4 +159,8 @@ public interface RedditAPI { @GET("/message/{where}.json?raw_json=1") Call getMessages(@HeaderMap Map headers, @Path("where") String where, @Query("after") String after); + + @FormUrlEncoded + @POST("/api/read_message") + Call readMessage(@HeaderMap Map headers, @FieldMap Map ids); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewMessageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewMessageActivity.java index b61438f4..3f6d5960 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewMessageActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewMessageActivity.java @@ -156,7 +156,7 @@ public class ViewMessageActivity extends AppCompatActivity { } private void bindView() { - mAdapter = new MessageRecyclerViewAdapter(this); + mAdapter = new MessageRecyclerViewAdapter(this, mOauthRetrofit, mAccessToken); LinearLayoutManager layoutManager = new LinearLayoutManager(this); recyclerView.setLayoutManager(layoutManager); recyclerView.setAdapter(mAdapter); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1943b769..ade37480 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -224,10 +224,10 @@ Click here to browse all comments - New Comments + New Comment Account - Post - New Messages + New Post Comment + New Message Subreddit Award %1$d New Messages