From 6eecaaccfa358d0dfd9ef3b514db5faad9c96edd Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Wed, 7 Jul 2021 22:13:56 +0800 Subject: Cannot use Strapi to send comments, upvote or downvote in RPAN. --- .../infinityforreddit/RPANBroadcast.java | 4 +- .../infinityforreddit/activities/RPANActivity.java | 1 + .../RPANCommentStreamRecyclerViewAdapter.java | 12 +----- .../infinityforreddit/apis/Strapi.java | 43 ---------------------- .../fragments/ViewRPANBroadcastFragment.java | 12 +++--- .../infinityforreddit/utils/Utils.java | 7 ++++ 6 files changed, 18 insertions(+), 61 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/RPANBroadcast.java b/app/src/main/java/ml/docilealligator/infinityforreddit/RPANBroadcast.java index 43b8ef55..1d317e2d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/RPANBroadcast.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/RPANBroadcast.java @@ -77,6 +77,7 @@ public class RPANBroadcast implements Parcelable { } public static class RPANPost implements Parcelable{ + public String fullname; public String title; public String subredditName; public String subredditIconUrl; @@ -92,10 +93,11 @@ public class RPANBroadcast implements Parcelable { public String suggestedCommentSort; public String liveCommentsWebsocketUrl; - public RPANPost(String title, String subredditName, String subredditIconUrl, String username, + public RPANPost(String fullname, String title, String subredditName, String subredditIconUrl, String username, int postScore, String voteState, double upvoteRatio, String postPermalink, String rpanUrl, boolean isNsfw, boolean isLocked, boolean isArchived, boolean isSpoiler, String suggestedCommentSort, String liveCommentsWebsocketUrl) { + this.fullname = fullname; this.title = title; this.subredditName = subredditName; this.subredditIconUrl = subredditIconUrl; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java index c22d481f..cc4c83ef 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java @@ -159,6 +159,7 @@ public class RPANActivity extends AppCompatActivity { JSONObject singleData = dataArray.getJSONObject(i); JSONObject rpanPostObject = singleData.getJSONObject(JSONUtils.POST_KEY); RPANBroadcast.RPANPost rpanPost = new RPANBroadcast.RPANPost( + rpanPostObject.getString(JSONUtils.ID_KEY), rpanPostObject.getString(JSONUtils.TITLE_KEY), rpanPostObject.getJSONObject(JSONUtils.SUBREDDIT_KEY).getString(JSONUtils.NAME_KEY), rpanPostObject.getJSONObject(JSONUtils.SUBREDDIT_KEY).getJSONObject(JSONUtils.STYLES_KEY).getString(JSONUtils.ICON_KEY), diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RPANCommentStreamRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RPANCommentStreamRecyclerViewAdapter.java index 60f596ab..ba7dcd34 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RPANCommentStreamRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RPANCommentStreamRecyclerViewAdapter.java @@ -23,12 +23,10 @@ import ml.docilealligator.infinityforreddit.RPANComment; public class RPANCommentStreamRecyclerViewAdapter extends RecyclerView.Adapter { private RequestManager glide; private ArrayList rpanComments; - private ItemClickListener itemClickListener; - public RPANCommentStreamRecyclerViewAdapter(Context context, ItemClickListener itemClickListener) { + public RPANCommentStreamRecyclerViewAdapter(Context context) { glide = Glide.with(context); rpanComments = new ArrayList<>(); - this.itemClickListener = itemClickListener; } @NonNull @@ -80,14 +78,6 @@ public class RPANCommentStreamRecyclerViewAdapter extends RecyclerView.Adapter { - itemClickListener.onClick(); - }); } } - - public interface ItemClickListener { - void onClick(); - } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/Strapi.java b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/Strapi.java index 02af768f..e4bfe573 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/Strapi.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/Strapi.java @@ -3,57 +3,14 @@ package ml.docilealligator.infinityforreddit.apis; import java.util.Map; import retrofit2.Call; -import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; import retrofit2.http.HeaderMap; -import retrofit2.http.POST; import retrofit2.http.Path; public interface Strapi { @GET("/broadcasts") Call getAllBroadcasts(@HeaderMap Map headers); - /* - Response: - {"status": "success", "status_message": ""} - */ - @FormUrlEncoded - @POST("/videos/{rpan_id}/vote/up") - Call upvote(@HeaderMap Map headers, @Path("rpan_id") String rpanId); - - @FormUrlEncoded - @POST("/videos/{rpan_id}/vote/down") - Call downvote(@HeaderMap Map headers, @Path("rpan_id") String rpanId); - - @FormUrlEncoded - @POST("/videos/{rpan_id}/vote/unset") - Call unsetVote(@HeaderMap Map headers, @Path("rpan_id") String rpanId); - - /* - Request payload: {text: "Noice"} - - Response: - {"status": "success", "status_message": "", "data": {"auto_mute_status": {"level": 0, "level_changed": false}, - "r2_comment": {"total_awards_received": 0, "approved_at_utc": null, "comment_type": null, "edited": false, - "mod_reason_by": null, "banned_by": null, "author_flair_type": "text", "removal_reason": null, "link_id": "t3_of7btc", - "author_flair_template_id": null, "likes": true, "rtjson": {"document": [{"c": [{"e": "text", "t": "Noice"}], "e": "par"}]}, - "replies": "", "user_reports": [], "saved": false, "id": "h4avk42", "banned_at_utc": null, "mod_reason_title": null, - "gilded": 0, "archived": false, "no_follow": false, "author": "Hostilenemy", "can_mod_post": false, "send_replies": true, - "parent_id": "t3_of7btc", "score": 1, "author_fullname": "t2_z40p4", "approved_by": null, "mod_note": null, - "all_awardings": [], "subreddit_id": "t5_3psukr", "body": "Noice", "awarders": [], "downs": 0, "author_flair_css_class": null, - "name": "t1_h4avk42", "author_patreon_flair": false, "collapsed": false, "author_flair_richtext": [], "is_submitter": false, - "body_html": "

Noice

\n
", "gildings": {}, "collapsed_reason": null, "distinguished": null, - "associated_award": null, "stickied": false, "author_premium": false, "can_gild": false, "top_awarded_type": null, - "author_flair_text_color": null, "score_hidden": false, "permalink": "/r/RedditSets/comments/of7btc/whistleface_762021_house_music/h4avk42/", - "num_reports": null, "locked": false, "report_reasons": null, "created": 1625647709.0, "subreddit": "RedditSets", "author_flair_text": null, - "treatment_tags": [], "rte_mode": "markdown", "created_utc": 1625618909.0, "subreddit_name_prefixed": "r/RedditSets", - "controversiality": 0, "author_flair_background_color": null, "collapsed_because_crowd_control": null, "mod_reports": [], - "subreddit_type": "public", "ups": 1}}} - */ - @FormUrlEncoded - @POST("/broadcasts/{rpan_id}/comment_v2") - Call sendComment(@HeaderMap Map headers, @Path("rpan_id") String rpanId); - @GET("/videos/{rpan_id_or_fullname}") Call getRPANBroadcast(@Path("rpan_id_or_fullname") String rpanIdOrFullname); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRPANBroadcastFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRPANBroadcastFragment.java index 219a55de..09aa6ee7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRPANBroadcastFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRPANBroadcastFragment.java @@ -59,6 +59,7 @@ import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.WebSocket; import okhttp3.WebSocketListener; +import retrofit2.Retrofit; public class ViewRPANBroadcastFragment extends Fragment { @@ -76,6 +77,9 @@ public class ViewRPANBroadcastFragment extends Fragment { @BindView(R.id.hd_exo_rpan_broadcast_playback_control_view) ImageButton hdButton; @Inject + @Named("strapi") + Retrofit mStrapiRetrofit; + @Inject @Named("default") SharedPreferences mSharedPreferences; @Inject @@ -142,6 +146,7 @@ public class ViewRPANBroadcastFragment extends Fragment { | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE); + playerView.setControllerShowTimeoutMs(0); break; case View.VISIBLE: mActivity.getWindow().getDecorView().setSystemUiVisibility( @@ -248,12 +253,7 @@ public class ViewRPANBroadcastFragment extends Fragment { return false; } }); - adapter = new RPANCommentStreamRecyclerViewAdapter(mActivity, new RPANCommentStreamRecyclerViewAdapter.ItemClickListener() { - @Override - public void onClick() { - - } - }); + adapter = new RPANCommentStreamRecyclerViewAdapter(mActivity); recyclerView.setAdapter(adapter); handler = new Handler(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java index e01f41cd..567f3afe 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java @@ -311,6 +311,13 @@ public class Utils { } public static void hideKeyboard(Activity activity) { + /*if (activity.getCurrentFocus() == null || !(activity.getCurrentFocus() instanceof EditText)) { + editText.requestFocus(); + } + InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); + activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);*/ + InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE); if (inputMethodManager != null && activity.getCurrentFocus() != null) { inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0); -- cgit v1.2.3