From 4c79e5de9fb118f177440c094b1c91772711561a Mon Sep 17 00:00:00 2001 From: Pierre Date: Sat, 21 Apr 2018 12:03:46 +0200 Subject: [PATCH] Renamed APIRequestParameters to APIRequest --- .../client/data/asynctasks/APIRequestTask.java | 6 +++--- .../client/data/helpers/APIRequestHelper.java | 9 ++++----- .../client/data/helpers/CommentsHelper.java | 10 +++++----- .../data/helpers/ConversationMessagesHelper.java | 6 +++--- .../data/helpers/ConversationsListHelper.java | 14 +++++++------- .../client/data/helpers/FriendsListHelper.java | 14 +++++++------- .../client/data/helpers/GetUsersHelper.java | 8 ++++---- .../comunic/client/data/helpers/LikesHelper.java | 4 ++-- .../client/data/helpers/NotificationsHelper.java | 10 +++++----- .../comunic/client/data/helpers/PostsHelper.java | 12 ++++++------ .../{APIRequestParameters.java => APIRequest.java} | 6 +++--- .../comunic/client/data/utils/AccountUtils.java | 4 ++-- .../client/ui/activities/LoginActivity.java | 4 ++-- 13 files changed, 53 insertions(+), 54 deletions(-) rename app/src/main/java/org/communiquons/android/comunic/client/data/models/{APIRequestParameters.java => APIRequest.java} (95%) diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/asynctasks/APIRequestTask.java b/app/src/main/java/org/communiquons/android/comunic/client/data/asynctasks/APIRequestTask.java index 0ede1ef..e64b6d8 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/data/asynctasks/APIRequestTask.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/data/asynctasks/APIRequestTask.java @@ -3,7 +3,7 @@ package org.communiquons.android.comunic.client.data.asynctasks; import android.os.AsyncTask; import org.communiquons.android.comunic.client.data.helpers.APIRequestHelper; -import org.communiquons.android.comunic.client.data.models.APIRequestParameters; +import org.communiquons.android.comunic.client.data.models.APIRequest; import org.communiquons.android.comunic.client.data.models.APIResponse; /** @@ -18,7 +18,7 @@ import org.communiquons.android.comunic.client.data.models.APIResponse; * Created by pierre on 10/31/17. */ @Deprecated -public abstract class APIRequestTask extends AsyncTask { +public abstract class APIRequestTask extends AsyncTask { /** * API request in a Background task @@ -29,7 +29,7 @@ public abstract class APIRequestTask extends AsyncTask downloadNew(int conversationID, int last_message_id){ //Prepare a request on the API - APIRequestParameters params = new APIRequestParameters(mContext, + APIRequest params = new APIRequest(mContext, "conversations/refresh_single"); params.addString("conversationID", ""+conversationID); params.addString("last_message_id", ""+last_message_id); diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/ConversationsListHelper.java b/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/ConversationsListHelper.java index 9a12093..3dcc2be 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/ConversationsListHelper.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/ConversationsListHelper.java @@ -6,7 +6,7 @@ import android.support.annotation.Nullable; import android.util.ArrayMap; import android.util.Log; -import org.communiquons.android.comunic.client.data.models.APIRequestParameters; +import org.communiquons.android.comunic.client.data.models.APIRequest; import org.communiquons.android.comunic.client.data.models.APIResponse; import org.communiquons.android.comunic.client.data.utils.AccountUtils; import org.communiquons.android.comunic.client.data.models.UserInfo; @@ -113,7 +113,7 @@ public class ConversationsListHelper { public Integer getPrivate(int userID, boolean allowCreate){ //Prepare an API request - APIRequestParameters params = new APIRequestParameters(mContext, + APIRequest params = new APIRequest(mContext, "conversations/getPrivate"); params.addInt("otherUser", userID); params.addBoolean("allowCreate", allowCreate); @@ -212,7 +212,7 @@ public class ConversationsListHelper { public boolean delete(int convID){ //Delete the conversation on the API - APIRequestParameters params = new APIRequestParameters(mContext, "conversations/delete"); + APIRequest params = new APIRequest(mContext, "conversations/delete"); params.addString("conversationID", ""+convID); try { @@ -243,7 +243,7 @@ public class ConversationsListHelper { } //Make an API request - APIRequestParameters params = new APIRequestParameters(mContext, "conversations/create"); + APIRequest params = new APIRequest(mContext, "conversations/create"); params.addString("name", name.equals("") ? "false" : name); params.addString("follow", follow ? "true" : "false"); params.addString("users", members_str); @@ -286,7 +286,7 @@ public class ConversationsListHelper { @Nullable ArrayList members, boolean following){ //Prepare a request on the database - APIRequestParameters params = new APIRequestParameters(mContext, + APIRequest params = new APIRequest(mContext, "conversations/updateSettings"); params.addString("conversationID", ""+convID); @@ -332,7 +332,7 @@ public class ConversationsListHelper { try { //Prepare the request on the server - APIRequestParameters params = new APIRequestParameters(mContext, "conversations/getList"); + APIRequest params = new APIRequest(mContext, "conversations/getList"); APIResponse response = new APIRequestHelper().exec(params); //Check if an error occurred @@ -366,7 +366,7 @@ public class ConversationsListHelper { private ConversationsInfo downloadSingle(int convID){ //Perform an API request - APIRequestParameters params = new APIRequestParameters(mContext, + APIRequest params = new APIRequest(mContext, "conversations/getInfosOne"); params.addString("conversationID", ""+convID); diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/FriendsListHelper.java b/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/FriendsListHelper.java index 69bc5e2..7ed7fdd 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/FriendsListHelper.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/FriendsListHelper.java @@ -4,7 +4,7 @@ import android.content.Context; import android.support.annotation.Nullable; import android.util.Log; -import org.communiquons.android.comunic.client.data.models.APIRequestParameters; +import org.communiquons.android.comunic.client.data.models.APIRequest; import org.communiquons.android.comunic.client.data.models.APIResponse; import org.communiquons.android.comunic.client.data.models.Friend; import org.communiquons.android.comunic.client.data.models.FriendshipStatus; @@ -69,7 +69,7 @@ public class FriendsListHelper { public ArrayList download(){ //Prepare the API request - APIRequestParameters params = new APIRequestParameters(mContext, "friends/getList"); + APIRequest params = new APIRequest(mContext, "friends/getList"); params.addBoolean("complete", true); //Prepare the result @@ -121,7 +121,7 @@ public class FriendsListHelper { public void remove(Friend friend){ try { //Remove the friend online - APIRequestParameters delparams = new APIRequestParameters(mContext, "friends/remove"); + APIRequest delparams = new APIRequest(mContext, "friends/remove"); delparams.addString("friendID", ""+friend.getId()); new APIRequestHelper().exec(delparams); @@ -143,7 +143,7 @@ public class FriendsListHelper { public boolean sendRequest(int friendID){ //Prepare the request - APIRequestParameters params = new APIRequestParameters(mContext, "friends/sendRequest"); + APIRequest params = new APIRequest(mContext, "friends/sendRequest"); params.addInt("friendID", friendID); //Try to perform the request @@ -165,7 +165,7 @@ public class FriendsListHelper { public boolean cancelRequest(int friendID){ //Prepare the request - APIRequestParameters params = new APIRequestParameters(mContext, "friends/removeRequest"); + APIRequest params = new APIRequest(mContext, "friends/removeRequest"); params.addInt("friendID", friendID); //Try to perform the request @@ -216,7 +216,7 @@ public class FriendsListHelper { public boolean respondRequest(int friendID, boolean accept){ //Perform a request to update the status online - APIRequestParameters reqParams = new APIRequestParameters(mContext, + APIRequest reqParams = new APIRequest(mContext, "friends/respondRequest"); reqParams.addInt("friendID", friendID); reqParams.addString("accept", accept ? "true" : "false"); @@ -244,7 +244,7 @@ public class FriendsListHelper { public FriendshipStatus getFrienshipStatus(int friendID) { //Perform a request on the API - APIRequestParameters params = new APIRequestParameters(mContext, "friends/getStatus"); + APIRequest params = new APIRequest(mContext, "friends/getStatus"); params.addInt("friendID", friendID); try { diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/GetUsersHelper.java b/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/GetUsersHelper.java index d1a07b2..c125c37 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/GetUsersHelper.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/GetUsersHelper.java @@ -6,7 +6,7 @@ import android.support.annotation.Nullable; import android.util.ArrayMap; import android.util.Log; -import org.communiquons.android.comunic.client.data.models.APIRequestParameters; +import org.communiquons.android.comunic.client.data.models.APIRequest; import org.communiquons.android.comunic.client.data.models.APIResponse; import org.communiquons.android.comunic.client.data.models.AdvancedUserInfo; import org.communiquons.android.comunic.client.data.models.UserInfo; @@ -127,7 +127,7 @@ public class GetUsersHelper { public AdvancedUserInfo get_advanced_infos(int userID){ //Perform an API request - APIRequestParameters params = new APIRequestParameters(mContext, + APIRequest params = new APIRequest(mContext, "user/getAdvancedUserInfos"); params.setTryContinueOnError(true); params.addInt("userID", userID); @@ -263,7 +263,7 @@ public class GetUsersHelper { private ArrayList search_users_online(String query, int limit){ //Make an API request - APIRequestParameters params = new APIRequestParameters(mContext, "search/user"); + APIRequest params = new APIRequest(mContext, "search/user"); params.addString("query", query); params.addString("searchLimit", ""+limit); @@ -299,7 +299,7 @@ public class GetUsersHelper { //Perform a request on the API server //Setup the request - APIRequestParameters requestParameters = new APIRequestParameters(mContext, + APIRequest requestParameters = new APIRequest(mContext, "user/getInfosMultiple"); diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/LikesHelper.java b/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/LikesHelper.java index 1351e13..4e6e92a 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/LikesHelper.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/LikesHelper.java @@ -2,7 +2,7 @@ package org.communiquons.android.comunic.client.data.helpers; import android.content.Context; -import org.communiquons.android.comunic.client.data.models.APIRequestParameters; +import org.communiquons.android.comunic.client.data.models.APIRequest; import org.communiquons.android.comunic.client.data.models.APIResponse; import org.communiquons.android.comunic.client.data.enums.LikesType; @@ -43,7 +43,7 @@ public class LikesHelper { public boolean update(LikesType type, int id, boolean liking){ //Perform an API request - APIRequestParameters params = new APIRequestParameters(mContext, "likes/update"); + APIRequest params = new APIRequest(mContext, "likes/update"); params.addInt("id", id); params.addBoolean("like", liking); diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/NotificationsHelper.java b/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/NotificationsHelper.java index 031dcec..051d7e3 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/NotificationsHelper.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/NotificationsHelper.java @@ -3,7 +3,7 @@ package org.communiquons.android.comunic.client.data.helpers; import android.content.Context; import android.support.annotation.Nullable; -import org.communiquons.android.comunic.client.data.models.APIRequestParameters; +import org.communiquons.android.comunic.client.data.models.APIRequest; import org.communiquons.android.comunic.client.data.models.APIResponse; import org.communiquons.android.comunic.client.data.models.Notif; import org.communiquons.android.comunic.client.data.enums.NotifElemType; @@ -50,7 +50,7 @@ public class NotificationsHelper { public NotificationsCount pullCount(){ //Perform an API request - APIRequestParameters params = new APIRequestParameters(mContext, + APIRequest params = new APIRequest(mContext, "notifications/count_all_news"); //Try to perform the request and parse results @@ -80,7 +80,7 @@ public class NotificationsHelper { public boolean markSeen(int notifID){ //Perform a request on the server - APIRequestParameters params = new APIRequestParameters(mContext, "notifications/mark_seen"); + APIRequest params = new APIRequest(mContext, "notifications/mark_seen"); params.addInt("notifID", notifID); //Try to send the request to the server @@ -102,7 +102,7 @@ public class NotificationsHelper { public boolean deleteAllNotifs(){ //Perform a request on the server - APIRequestParameters params = new APIRequestParameters(mContext, + APIRequest params = new APIRequest(mContext, "notifications/delete_all"); //Try to perform the request on the server @@ -124,7 +124,7 @@ public class NotificationsHelper { public NotifsList getListUnread(){ //Perform a request on the server - APIRequestParameters params = new APIRequestParameters(mContext, + APIRequest params = new APIRequest(mContext, "notifications/get_list_unread"); //Try to perform the request on the server diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/PostsHelper.java b/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/PostsHelper.java index a974e4d..190b198 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/PostsHelper.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/PostsHelper.java @@ -3,7 +3,7 @@ package org.communiquons.android.comunic.client.data.helpers; import android.content.Context; import android.support.annotation.Nullable; -import org.communiquons.android.comunic.client.data.models.APIRequestParameters; +import org.communiquons.android.comunic.client.data.models.APIRequest; import org.communiquons.android.comunic.client.data.models.APIResponse; import org.communiquons.android.comunic.client.data.models.CreatePost; import org.communiquons.android.comunic.client.data.enums.PageType; @@ -56,7 +56,7 @@ public class PostsHelper { public Post getSingle(int id){ //Perform an API request - APIRequestParameters params = new APIRequestParameters(mContext, "posts/get_single"); + APIRequest params = new APIRequest(mContext, "posts/get_single"); params.addInt("postID", id); try { @@ -87,7 +87,7 @@ public class PostsHelper { public PostsList get_user(int userID){ //Perform a request on the API - APIRequestParameters params = new APIRequestParameters(mContext, "posts/get_user"); + APIRequest params = new APIRequest(mContext, "posts/get_user"); params.addInt("userID", userID); //Perform the request @@ -121,7 +121,7 @@ public class PostsHelper { public boolean delete(int postID){ //Perform the request on the server - APIRequestParameters params = new APIRequestParameters(mContext, "posts/delete"); + APIRequest params = new APIRequest(mContext, "posts/delete"); params.addInt("postID", postID); //Intend to perform the request @@ -146,7 +146,7 @@ public class PostsHelper { public int create(CreatePost post){ //Prepare the request on the server - APIRequestParameters params = new APIRequestParameters(mContext, "posts/create"); + APIRequest params = new APIRequest(mContext, "posts/create"); //Put basic information about the post params.addString("content", post.getContent()); @@ -224,7 +224,7 @@ public class PostsHelper { public boolean update_content(int postId, String content) { //Perform a request on the API - APIRequestParameters params = new APIRequestParameters(mContext, "posts/update_content"); + APIRequest params = new APIRequest(mContext, "posts/update_content"); params.addString("new_content", content); params.addInt("postID", postId); diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/models/APIRequestParameters.java b/app/src/main/java/org/communiquons/android/comunic/client/data/models/APIRequest.java similarity index 95% rename from app/src/main/java/org/communiquons/android/comunic/client/data/models/APIRequestParameters.java rename to app/src/main/java/org/communiquons/android/comunic/client/data/models/APIRequest.java index d4f3618..8f40ba4 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/data/models/APIRequestParameters.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/data/models/APIRequest.java @@ -11,7 +11,7 @@ import java.util.ArrayList; * Created by pierre on 10/31/17. */ -public class APIRequestParameters { +public class APIRequest { /** * The context of the request @@ -39,7 +39,7 @@ public class APIRequestParameters { * @param context The context of the request * @param uri The request URI on the server */ - public APIRequestParameters(Context context, String uri){ + public APIRequest(Context context, String uri){ //Save the context this.context = context; @@ -47,7 +47,7 @@ public class APIRequestParameters { //Save request URI request_uri = uri; - //Intialize parameters array + //Initialize parameters array parameters = new ArrayList<>(); } diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/utils/AccountUtils.java b/app/src/main/java/org/communiquons/android/comunic/client/data/utils/AccountUtils.java index 08f94fd..58957e5 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/data/utils/AccountUtils.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/data/utils/AccountUtils.java @@ -2,7 +2,7 @@ package org.communiquons.android.comunic.client.data.utils; import android.content.Context; -import org.communiquons.android.comunic.client.data.models.APIRequestParameters; +import org.communiquons.android.comunic.client.data.models.APIRequest; import org.communiquons.android.comunic.client.data.asynctasks.APIRequestTask; import org.communiquons.android.comunic.client.data.models.APIResponse; import org.json.JSONObject; @@ -66,7 +66,7 @@ public class AccountUtils { public void refresh_current_user_id(final onceRefreshedUserID callback){ //Perform an API request - APIRequestParameters params = new APIRequestParameters(mContext, "user/getCurrentUserID"); + APIRequest params = new APIRequest(mContext, "user/getCurrentUserID"); new APIRequestTask(){ @Override protected void onPostExecute(APIResponse result) { diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/LoginActivity.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/LoginActivity.java index 004955f..7db3b5a 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/LoginActivity.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/LoginActivity.java @@ -14,7 +14,7 @@ import org.communiquons.android.comunic.client.R; import org.communiquons.android.comunic.client.data.asynctasks.APIRequestTask; import org.communiquons.android.comunic.client.data.helpers.APIRequestHelper; import org.communiquons.android.comunic.client.data.helpers.AccountHelper; -import org.communiquons.android.comunic.client.data.models.APIRequestParameters; +import org.communiquons.android.comunic.client.data.models.APIRequest; import org.communiquons.android.comunic.client.data.models.APIResponse; import org.communiquons.android.comunic.client.data.utils.AccountUtils; import org.communiquons.android.comunic.client.data.utils.Utilities; @@ -120,7 +120,7 @@ public class LoginActivity extends AppCompatActivity { //Perform a request on the API to check user credentials and get login tokens - APIRequestParameters params = new APIRequestParameters(this, "user/connectUSER"); + APIRequest params = new APIRequest(this, "user/connectUSER"); params.addString("userMail", ""+login_mail.getText()); params.addString("userPassword", ""+login_password.getText());