mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-23 22:09:30 +00:00
Restructured data folder
This commit is contained in:
parent
a910beca51
commit
5c018aa936
@ -2,9 +2,9 @@ package org.communiquons.android.comunic.client.data.asynctasks;
|
|||||||
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
|
||||||
import org.communiquons.android.comunic.client.api.APIRequest;
|
import org.communiquons.android.comunic.client.data.helpers.APIRequestHelper;
|
||||||
import org.communiquons.android.comunic.client.api.APIRequestParameters;
|
import org.communiquons.android.comunic.client.data.models.APIRequestParameters;
|
||||||
import org.communiquons.android.comunic.client.api.APIResponse;
|
import org.communiquons.android.comunic.client.data.models.APIResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform an API request on the server
|
* Perform an API request on the server
|
||||||
@ -33,7 +33,7 @@ public abstract class APIRequestTask extends AsyncTask<APIRequestParameters, Voi
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
//Perform the API request
|
//Perform the API request
|
||||||
APIRequest req = new APIRequest();
|
APIRequestHelper req = new APIRequestHelper();
|
||||||
return req.exec(params[0]);
|
return req.exec(params[0]);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package org.communiquons.android.comunic.client.api;
|
package org.communiquons.android.comunic.client.data.helpers;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
@ -6,6 +6,8 @@ import android.net.NetworkInfo;
|
|||||||
|
|
||||||
import org.communiquons.android.comunic.client.BuildConfig;
|
import org.communiquons.android.comunic.client.BuildConfig;
|
||||||
import org.communiquons.android.comunic.client.data.helpers.AccountHelper;
|
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.APIResponse;
|
||||||
|
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@ -28,12 +30,12 @@ import java.util.ArrayList;
|
|||||||
* Created by pierre on 11/12/17.
|
* Created by pierre on 11/12/17.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class APIRequest {
|
public class APIRequestHelper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public constructor
|
* Public constructor
|
||||||
*/
|
*/
|
||||||
public APIRequest(){
|
public APIRequestHelper(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -4,9 +4,8 @@ import android.content.Context;
|
|||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
import org.communiquons.android.comunic.client.api.APIRequest;
|
import org.communiquons.android.comunic.client.data.models.APIRequestParameters;
|
||||||
import org.communiquons.android.comunic.client.api.APIRequestParameters;
|
import org.communiquons.android.comunic.client.data.models.APIResponse;
|
||||||
import org.communiquons.android.comunic.client.api.APIResponse;
|
|
||||||
import org.communiquons.android.comunic.client.data.models.Comment;
|
import org.communiquons.android.comunic.client.data.models.Comment;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
@ -59,7 +58,7 @@ public class CommentsHelper {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
//Try to perform the request
|
//Try to perform the request
|
||||||
APIResponse response = new APIRequest().exec(params);
|
APIResponse response = new APIRequestHelper().exec(params);
|
||||||
|
|
||||||
//Check and return success
|
//Check and return success
|
||||||
return response.getJSONObject().getInt("commentID");
|
return response.getJSONObject().getInt("commentID");
|
||||||
@ -87,7 +86,7 @@ public class CommentsHelper {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
//Perform the request
|
//Perform the request
|
||||||
APIResponse response = new APIRequest().exec(params);
|
APIResponse response = new APIRequestHelper().exec(params);
|
||||||
|
|
||||||
//Process result (if any)
|
//Process result (if any)
|
||||||
if(response.getResponse_code() != 200)
|
if(response.getResponse_code() != 200)
|
||||||
@ -119,7 +118,7 @@ public class CommentsHelper {
|
|||||||
|
|
||||||
//Try to perform the request on the server
|
//Try to perform the request on the server
|
||||||
try {
|
try {
|
||||||
APIResponse response = new APIRequest().exec(params);
|
APIResponse response = new APIRequestHelper().exec(params);
|
||||||
return response.getResponse_code() == 200;
|
return response.getResponse_code() == 200;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -143,7 +142,7 @@ public class CommentsHelper {
|
|||||||
//Try to perform the request
|
//Try to perform the request
|
||||||
try {
|
try {
|
||||||
|
|
||||||
APIResponse response = new APIRequest().exec(params);
|
APIResponse response = new APIRequestHelper().exec(params);
|
||||||
|
|
||||||
return response.getResponse_code() == 200;
|
return response.getResponse_code() == 200;
|
||||||
|
|
||||||
|
@ -4,9 +4,8 @@ import android.content.Context;
|
|||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import org.communiquons.android.comunic.client.api.APIRequest;
|
import org.communiquons.android.comunic.client.data.models.APIRequestParameters;
|
||||||
import org.communiquons.android.comunic.client.api.APIRequestParameters;
|
import org.communiquons.android.comunic.client.data.models.APIResponse;
|
||||||
import org.communiquons.android.comunic.client.api.APIResponse;
|
|
||||||
import org.communiquons.android.comunic.client.data.models.ConversationMessage;
|
import org.communiquons.android.comunic.client.data.models.ConversationMessage;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
@ -99,7 +98,7 @@ public class ConversationMessagesHelper {
|
|||||||
params.addString("image", "data:image/png;base64," + image);
|
params.addString("image", "data:image/png;base64," + image);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
new APIRequest().exec(params);
|
new APIRequestHelper().exec(params);
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -163,7 +162,7 @@ public class ConversationMessagesHelper {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
//Perform the request
|
//Perform the request
|
||||||
APIResponse response = new APIRequest().exec(params);
|
APIResponse response = new APIRequestHelper().exec(params);
|
||||||
|
|
||||||
//Get the list of new messages
|
//Get the list of new messages
|
||||||
JSONArray messages = response.getJSONArray();
|
JSONArray messages = response.getJSONArray();
|
||||||
|
@ -6,9 +6,8 @@ import android.support.annotation.Nullable;
|
|||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import org.communiquons.android.comunic.client.api.APIRequest;
|
import org.communiquons.android.comunic.client.data.models.APIRequestParameters;
|
||||||
import org.communiquons.android.comunic.client.api.APIRequestParameters;
|
import org.communiquons.android.comunic.client.data.models.APIResponse;
|
||||||
import org.communiquons.android.comunic.client.api.APIResponse;
|
|
||||||
import org.communiquons.android.comunic.client.data.utils.AccountUtils;
|
import org.communiquons.android.comunic.client.data.utils.AccountUtils;
|
||||||
import org.communiquons.android.comunic.client.data.models.UserInfo;
|
import org.communiquons.android.comunic.client.data.models.UserInfo;
|
||||||
import org.communiquons.android.comunic.client.data.models.ConversationsInfo;
|
import org.communiquons.android.comunic.client.data.models.ConversationsInfo;
|
||||||
@ -121,7 +120,7 @@ public class ConversationsListHelper {
|
|||||||
|
|
||||||
//Try to perform request
|
//Try to perform request
|
||||||
try {
|
try {
|
||||||
APIResponse response = new APIRequest().exec(params);
|
APIResponse response = new APIRequestHelper().exec(params);
|
||||||
JSONObject object = response.getJSONObject();
|
JSONObject object = response.getJSONObject();
|
||||||
|
|
||||||
//Check for conversations ID
|
//Check for conversations ID
|
||||||
@ -217,7 +216,7 @@ public class ConversationsListHelper {
|
|||||||
params.addString("conversationID", ""+convID);
|
params.addString("conversationID", ""+convID);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
new APIRequest().exec(params);
|
new APIRequestHelper().exec(params);
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -251,7 +250,7 @@ public class ConversationsListHelper {
|
|||||||
|
|
||||||
//Perform the request
|
//Perform the request
|
||||||
try {
|
try {
|
||||||
APIResponse response = new APIRequest().exec(params);
|
APIResponse response = new APIRequestHelper().exec(params);
|
||||||
|
|
||||||
//Get conversation ID
|
//Get conversation ID
|
||||||
JSONObject obj = response.getJSONObject();
|
JSONObject obj = response.getJSONObject();
|
||||||
@ -306,7 +305,7 @@ public class ConversationsListHelper {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
//Try to perform the request
|
//Try to perform the request
|
||||||
new APIRequest().exec(params);
|
new APIRequestHelper().exec(params);
|
||||||
|
|
||||||
//Delete the conversation from the local database to force it to be refreshed
|
//Delete the conversation from the local database to force it to be refreshed
|
||||||
//on next load
|
//on next load
|
||||||
@ -334,7 +333,7 @@ public class ConversationsListHelper {
|
|||||||
|
|
||||||
//Prepare the request on the server
|
//Prepare the request on the server
|
||||||
APIRequestParameters params = new APIRequestParameters(mContext, "conversations/getList");
|
APIRequestParameters params = new APIRequestParameters(mContext, "conversations/getList");
|
||||||
APIResponse response = new APIRequest().exec(params);
|
APIResponse response = new APIRequestHelper().exec(params);
|
||||||
|
|
||||||
//Check if an error occurred
|
//Check if an error occurred
|
||||||
JSONArray friends = response.getJSONArray();
|
JSONArray friends = response.getJSONArray();
|
||||||
@ -373,7 +372,7 @@ public class ConversationsListHelper {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
APIResponse response = new APIRequest().exec(params);
|
APIResponse response = new APIRequestHelper().exec(params);
|
||||||
|
|
||||||
JSONObject object = response.getJSONObject();
|
JSONObject object = response.getJSONObject();
|
||||||
|
|
||||||
|
@ -4,9 +4,8 @@ import android.content.Context;
|
|||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import org.communiquons.android.comunic.client.api.APIRequest;
|
import org.communiquons.android.comunic.client.data.models.APIRequestParameters;
|
||||||
import org.communiquons.android.comunic.client.api.APIRequestParameters;
|
import org.communiquons.android.comunic.client.data.models.APIResponse;
|
||||||
import org.communiquons.android.comunic.client.api.APIResponse;
|
|
||||||
import org.communiquons.android.comunic.client.data.models.Friend;
|
import org.communiquons.android.comunic.client.data.models.Friend;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@ -78,7 +77,7 @@ public class FriendsListHelper {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
//Perform the request and retrieve the response
|
//Perform the request and retrieve the response
|
||||||
APIResponse response = new APIRequest().exec(params);
|
APIResponse response = new APIRequestHelper().exec(params);
|
||||||
JSONArray friendsList = response.getJSONArray();
|
JSONArray friendsList = response.getJSONArray();
|
||||||
|
|
||||||
if(friendsList == null)
|
if(friendsList == null)
|
||||||
@ -123,7 +122,7 @@ public class FriendsListHelper {
|
|||||||
//Remove the friend online
|
//Remove the friend online
|
||||||
APIRequestParameters delparams = new APIRequestParameters(mContext, "friends/remove");
|
APIRequestParameters delparams = new APIRequestParameters(mContext, "friends/remove");
|
||||||
delparams.addString("friendID", ""+friend.getId());
|
delparams.addString("friendID", ""+friend.getId());
|
||||||
new APIRequest().exec(delparams);
|
new APIRequestHelper().exec(delparams);
|
||||||
|
|
||||||
//Remove the friend from the local database
|
//Remove the friend from the local database
|
||||||
fdbHelper.delete_friend(friend);
|
fdbHelper.delete_friend(friend);
|
||||||
@ -148,7 +147,7 @@ public class FriendsListHelper {
|
|||||||
"friends/respondRequest");
|
"friends/respondRequest");
|
||||||
reqParams.addInt("friendID", friend.getId());
|
reqParams.addInt("friendID", friend.getId());
|
||||||
reqParams.addString("accept", accept ? "true" : "false");
|
reqParams.addString("accept", accept ? "true" : "false");
|
||||||
new APIRequest().exec(reqParams);
|
new APIRequestHelper().exec(reqParams);
|
||||||
|
|
||||||
//Update the friend in the local database
|
//Update the friend in the local database
|
||||||
if(accept) {
|
if(accept) {
|
||||||
|
@ -6,9 +6,8 @@ import android.support.annotation.Nullable;
|
|||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import org.communiquons.android.comunic.client.api.APIRequest;
|
import org.communiquons.android.comunic.client.data.models.APIRequestParameters;
|
||||||
import org.communiquons.android.comunic.client.api.APIRequestParameters;
|
import org.communiquons.android.comunic.client.data.models.APIResponse;
|
||||||
import org.communiquons.android.comunic.client.api.APIResponse;
|
|
||||||
import org.communiquons.android.comunic.client.data.models.AdvancedUserInfo;
|
import org.communiquons.android.comunic.client.data.models.AdvancedUserInfo;
|
||||||
import org.communiquons.android.comunic.client.data.models.UserInfo;
|
import org.communiquons.android.comunic.client.data.models.UserInfo;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
@ -134,7 +133,7 @@ public class GetUsersHelper {
|
|||||||
|
|
||||||
//Perform the request
|
//Perform the request
|
||||||
try {
|
try {
|
||||||
APIResponse response = new APIRequest().exec(params);
|
APIResponse response = new APIRequestHelper().exec(params);
|
||||||
|
|
||||||
//Parse user informations
|
//Parse user informations
|
||||||
return parse_advanced_user_json(response.getJSONObject());
|
return parse_advanced_user_json(response.getJSONObject());
|
||||||
@ -253,7 +252,7 @@ public class GetUsersHelper {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
//Get and extract the response
|
//Get and extract the response
|
||||||
APIResponse response = new APIRequest().exec(params);
|
APIResponse response = new APIRequestHelper().exec(params);
|
||||||
JSONArray array = response.getJSONArray();
|
JSONArray array = response.getJSONArray();
|
||||||
|
|
||||||
//Make response
|
//Make response
|
||||||
@ -297,7 +296,7 @@ public class GetUsersHelper {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
//Perform the request
|
//Perform the request
|
||||||
APIResponse result = new APIRequest().exec(requestParameters);
|
APIResponse result = new APIRequestHelper().exec(requestParameters);
|
||||||
|
|
||||||
if(result != null) {
|
if(result != null) {
|
||||||
|
|
||||||
|
@ -2,9 +2,8 @@ package org.communiquons.android.comunic.client.data.helpers;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import org.communiquons.android.comunic.client.api.APIRequest;
|
import org.communiquons.android.comunic.client.data.models.APIRequestParameters;
|
||||||
import org.communiquons.android.comunic.client.api.APIRequestParameters;
|
import org.communiquons.android.comunic.client.data.models.APIResponse;
|
||||||
import org.communiquons.android.comunic.client.api.APIResponse;
|
|
||||||
import org.communiquons.android.comunic.client.data.enums.LikesType;
|
import org.communiquons.android.comunic.client.data.enums.LikesType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,7 +63,7 @@ public class LikesHelper {
|
|||||||
|
|
||||||
//Intend to perform the request
|
//Intend to perform the request
|
||||||
try {
|
try {
|
||||||
APIResponse response = new APIRequest().exec(params);
|
APIResponse response = new APIRequestHelper().exec(params);
|
||||||
|
|
||||||
return response.getResponse_code() == 200;
|
return response.getResponse_code() == 200;
|
||||||
|
|
||||||
|
@ -3,9 +3,8 @@ package org.communiquons.android.comunic.client.data.helpers;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
import org.communiquons.android.comunic.client.api.APIRequest;
|
import org.communiquons.android.comunic.client.data.models.APIRequestParameters;
|
||||||
import org.communiquons.android.comunic.client.api.APIRequestParameters;
|
import org.communiquons.android.comunic.client.data.models.APIResponse;
|
||||||
import org.communiquons.android.comunic.client.api.APIResponse;
|
|
||||||
import org.communiquons.android.comunic.client.data.models.Notif;
|
import org.communiquons.android.comunic.client.data.models.Notif;
|
||||||
import org.communiquons.android.comunic.client.data.enums.NotifElemType;
|
import org.communiquons.android.comunic.client.data.enums.NotifElemType;
|
||||||
import org.communiquons.android.comunic.client.data.enums.NotificationTypes;
|
import org.communiquons.android.comunic.client.data.enums.NotificationTypes;
|
||||||
@ -57,7 +56,7 @@ public class NotificationsHelper {
|
|||||||
//Try to perform the request and parse results
|
//Try to perform the request and parse results
|
||||||
try {
|
try {
|
||||||
|
|
||||||
APIResponse response = new APIRequest().exec(params);
|
APIResponse response = new APIRequestHelper().exec(params);
|
||||||
|
|
||||||
//Try to parse results
|
//Try to parse results
|
||||||
JSONObject object = response.getJSONObject();
|
JSONObject object = response.getJSONObject();
|
||||||
@ -85,7 +84,7 @@ public class NotificationsHelper {
|
|||||||
|
|
||||||
//Try to perform the request on the server
|
//Try to perform the request on the server
|
||||||
try {
|
try {
|
||||||
APIResponse response = new APIRequest().exec(params);
|
APIResponse response = new APIRequestHelper().exec(params);
|
||||||
return response.getResponse_code() == 200;
|
return response.getResponse_code() == 200;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -109,7 +108,7 @@ public class NotificationsHelper {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
//Try to perform the request on the server
|
//Try to perform the request on the server
|
||||||
APIResponse response = new APIRequest().exec(params);
|
APIResponse response = new APIRequestHelper().exec(params);
|
||||||
|
|
||||||
//Check for errors
|
//Check for errors
|
||||||
if(response.getResponse_code() != 200)
|
if(response.getResponse_code() != 200)
|
||||||
|
@ -3,9 +3,8 @@ package org.communiquons.android.comunic.client.data.helpers;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
import org.communiquons.android.comunic.client.api.APIRequest;
|
import org.communiquons.android.comunic.client.data.models.APIRequestParameters;
|
||||||
import org.communiquons.android.comunic.client.api.APIRequestParameters;
|
import org.communiquons.android.comunic.client.data.models.APIResponse;
|
||||||
import org.communiquons.android.comunic.client.api.APIResponse;
|
|
||||||
import org.communiquons.android.comunic.client.data.models.CreatePost;
|
import org.communiquons.android.comunic.client.data.models.CreatePost;
|
||||||
import org.communiquons.android.comunic.client.data.enums.PageType;
|
import org.communiquons.android.comunic.client.data.enums.PageType;
|
||||||
import org.communiquons.android.comunic.client.data.models.Post;
|
import org.communiquons.android.comunic.client.data.models.Post;
|
||||||
@ -63,7 +62,7 @@ public class PostsHelper {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
//Send the request to the server
|
//Send the request to the server
|
||||||
APIResponse response = new APIRequest().exec(params);
|
APIResponse response = new APIRequestHelper().exec(params);
|
||||||
|
|
||||||
//Check for errors
|
//Check for errors
|
||||||
if(response.getResponse_code() != 200)
|
if(response.getResponse_code() != 200)
|
||||||
@ -95,7 +94,7 @@ public class PostsHelper {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
//Make the request on the API
|
//Make the request on the API
|
||||||
APIResponse response = new APIRequest().exec(params);
|
APIResponse response = new APIRequestHelper().exec(params);
|
||||||
|
|
||||||
//Get the list of posts and process it
|
//Get the list of posts and process it
|
||||||
JSONArray posts = response.getJSONArray();
|
JSONArray posts = response.getJSONArray();
|
||||||
@ -128,7 +127,7 @@ public class PostsHelper {
|
|||||||
//Intend to perform the request
|
//Intend to perform the request
|
||||||
try {
|
try {
|
||||||
|
|
||||||
APIResponse response = new APIRequest().exec(params);
|
APIResponse response = new APIRequestHelper().exec(params);
|
||||||
|
|
||||||
return response.getResponse_code() == 200;
|
return response.getResponse_code() == 200;
|
||||||
|
|
||||||
@ -200,7 +199,7 @@ public class PostsHelper {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
//Perform the request
|
//Perform the request
|
||||||
APIResponse response = new APIRequest().exec(params);
|
APIResponse response = new APIRequestHelper().exec(params);
|
||||||
|
|
||||||
//Check for errors
|
//Check for errors
|
||||||
if(response.getResponse_code() != 200)
|
if(response.getResponse_code() != 200)
|
||||||
@ -231,7 +230,7 @@ public class PostsHelper {
|
|||||||
|
|
||||||
//Try to perform the request
|
//Try to perform the request
|
||||||
try {
|
try {
|
||||||
APIResponse response = new APIRequest().exec(params);
|
APIResponse response = new APIRequestHelper().exec(params);
|
||||||
return response.getResponse_code() == 200;
|
return response.getResponse_code() == 200;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package org.communiquons.android.comunic.client.api;
|
package org.communiquons.android.comunic.client.data.models;
|
||||||
|
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package org.communiquons.android.comunic.client.api;
|
package org.communiquons.android.comunic.client.data.models;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ public class APIRequestParameters {
|
|||||||
*
|
*
|
||||||
* @return The request URI
|
* @return The request URI
|
||||||
*/
|
*/
|
||||||
String getRequest_uri() {
|
public String getRequest_uri() {
|
||||||
return request_uri;
|
return request_uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ public class APIRequestParameters {
|
|||||||
*
|
*
|
||||||
* @return A string
|
* @return A string
|
||||||
*/
|
*/
|
||||||
String get_parameters_encoded(){
|
public String get_parameters_encoded(){
|
||||||
|
|
||||||
//Return string
|
//Return string
|
||||||
String result = "";
|
String result = "";
|
@ -1,4 +1,4 @@
|
|||||||
package org.communiquons.android.comunic.client.api;
|
package org.communiquons.android.comunic.client.data.models;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
@ -26,14 +26,14 @@ public class APIResponse {
|
|||||||
/**
|
/**
|
||||||
* Constructor of the API response
|
* Constructor of the API response
|
||||||
*/
|
*/
|
||||||
APIResponse(){}
|
public APIResponse(){}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set response string
|
* Set response string
|
||||||
*
|
*
|
||||||
* @param response The request response
|
* @param response The request response
|
||||||
*/
|
*/
|
||||||
void setResponse(String response) {
|
public void setResponse(String response) {
|
||||||
this.response = response;
|
this.response = response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ public class APIResponse {
|
|||||||
*
|
*
|
||||||
* @param response_code The response code
|
* @param response_code The response code
|
||||||
*/
|
*/
|
||||||
void setResponse_code(int response_code) {
|
public void setResponse_code(int response_code) {
|
||||||
this.response_code = response_code;
|
this.response_code = response_code;
|
||||||
}
|
}
|
||||||
|
|
@ -2,9 +2,9 @@ package org.communiquons.android.comunic.client.data.utils;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import org.communiquons.android.comunic.client.api.APIRequestParameters;
|
import org.communiquons.android.comunic.client.data.models.APIRequestParameters;
|
||||||
import org.communiquons.android.comunic.client.data.asynctasks.APIRequestTask;
|
import org.communiquons.android.comunic.client.data.asynctasks.APIRequestTask;
|
||||||
import org.communiquons.android.comunic.client.api.APIResponse;
|
import org.communiquons.android.comunic.client.data.models.APIResponse;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,7 +12,10 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import org.communiquons.android.comunic.client.R;
|
import org.communiquons.android.comunic.client.R;
|
||||||
import org.communiquons.android.comunic.client.data.asynctasks.APIRequestTask;
|
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.helpers.AccountHelper;
|
||||||
|
import org.communiquons.android.comunic.client.data.models.APIRequestParameters;
|
||||||
|
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.AccountUtils;
|
||||||
import org.communiquons.android.comunic.client.data.utils.Utilities;
|
import org.communiquons.android.comunic.client.data.utils.Utilities;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
@ -20,8 +23,6 @@ import org.json.JSONObject;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.communiquons.android.comunic.client.api.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Login activity of the application
|
* Login activity of the application
|
||||||
*
|
*
|
||||||
@ -52,7 +53,7 @@ public class LoginActivity extends AppCompatActivity {
|
|||||||
aUtils = new AccountUtils(this);
|
aUtils = new AccountUtils(this);
|
||||||
|
|
||||||
//Check for connectivity
|
//Check for connectivity
|
||||||
if(!APIRequest.isAPIavailable(this)){
|
if(!APIRequestHelper.isAPIavailable(this)){
|
||||||
Toast.makeText(this, R.string.err_no_internet_connection, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.err_no_internet_connection, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +96,7 @@ public class LoginActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Check internet connection
|
//Check internet connection
|
||||||
if(!APIRequest.isAPIavailable(this)){
|
if(!APIRequestHelper.isAPIavailable(this)){
|
||||||
show_form_error(getString(R.string.err_no_internet_connection));
|
show_form_error(getString(R.string.err_no_internet_connection));
|
||||||
stop = 1;
|
stop = 1;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ import android.view.MenuItem;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.communiquons.android.comunic.client.R;
|
import org.communiquons.android.comunic.client.R;
|
||||||
import org.communiquons.android.comunic.client.api.APIRequest;
|
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.helpers.AccountHelper;
|
||||||
import org.communiquons.android.comunic.client.data.utils.AccountUtils;
|
import org.communiquons.android.comunic.client.data.utils.AccountUtils;
|
||||||
import org.communiquons.android.comunic.client.data.helpers.DatabaseHelper;
|
import org.communiquons.android.comunic.client.data.helpers.DatabaseHelper;
|
||||||
@ -101,7 +101,7 @@ public class MainActivity extends AppCompatActivity
|
|||||||
init_bottom_menu();
|
init_bottom_menu();
|
||||||
|
|
||||||
//Check for connectivity
|
//Check for connectivity
|
||||||
if(!APIRequest.isAPIavailable(this)){
|
if(!APIRequestHelper.isAPIavailable(this)){
|
||||||
Toast.makeText(this, R.string.err_no_internet_connection, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.err_no_internet_connection, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user