Created an api package

This commit is contained in:
Pierre 2017-11-02 08:58:54 +01:00
parent ab905a5316
commit b7a07ab2ed
5 changed files with 15 additions and 10 deletions

View File

@ -15,6 +15,8 @@ import org.json.JSONObject;
import java.util.ArrayList; import java.util.ArrayList;
import org.communiquons.android.comunic.client.api.*;
public class LoginActivity extends AppCompatActivity { public class LoginActivity extends AppCompatActivity {
/** /**

View File

@ -1,4 +1,4 @@
package org.communiquons.android.comunic.client; package org.communiquons.android.comunic.client.api;
import java.net.URLEncoder; import java.net.URLEncoder;

View File

@ -1,4 +1,6 @@
package org.communiquons.android.comunic.client; package org.communiquons.android.comunic.client.api;
import org.communiquons.android.comunic.client.api.APIPostData;
import java.util.ArrayList; import java.util.ArrayList;
@ -8,7 +10,7 @@ import java.util.ArrayList;
* Created by pierre on 10/31/17. * Created by pierre on 10/31/17.
*/ */
class APIRequestParameters { public class APIRequestParameters {
/** /**
* Parameters of the request * Parameters of the request
@ -25,7 +27,7 @@ class APIRequestParameters {
* *
* @param uri The request URI on the server * @param uri The request URI on the server
*/ */
APIRequestParameters(String uri){ public APIRequestParameters(String uri){
//Save request URI //Save request URI
request_uri = uri; request_uri = uri;
@ -39,7 +41,7 @@ class APIRequestParameters {
* @param name The name of the new key * @param name The name of the new key
* @param value The value of the new key * @param value The value of the new key
*/ */
void addParameter(String name, String value){ public void addParameter(String name, String value){
parameters.add(new APIPostData(name, value)); parameters.add(new APIPostData(name, value));
} }

View File

@ -1,10 +1,11 @@
package org.communiquons.android.comunic.client; package org.communiquons.android.comunic.client.api;
import android.content.Context; import android.content.Context;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.NetworkInfo; import android.net.NetworkInfo;
import android.os.AsyncTask; import android.os.AsyncTask;
import org.communiquons.android.comunic.client.BuildConfig;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
@ -23,7 +24,7 @@ import java.net.URL;
* *
* Created by pierre on 10/31/17. * Created by pierre on 10/31/17.
*/ */
abstract class APIRequestTask extends AsyncTask<APIRequestParameters, Void, APIResponse> { public abstract class APIRequestTask extends AsyncTask<APIRequestParameters, Void, APIResponse> {
/** /**
* Background task * Background task
@ -127,7 +128,7 @@ abstract class APIRequestTask extends AsyncTask<APIRequestParameters, Void, APIR
* @param context The context used to perform the test * @param context The context used to perform the test
* @return True if a network connection is available * @return True if a network connection is available
*/ */
static boolean isAPIavailable(Context context){ public static boolean isAPIavailable(Context context){
ConnectivityManager connMgr = (ConnectivityManager) ConnectivityManager connMgr = (ConnectivityManager)
context.getSystemService(Context.CONNECTIVITY_SERVICE); context.getSystemService(Context.CONNECTIVITY_SERVICE);

View File

@ -1,4 +1,4 @@
package org.communiquons.android.comunic.client; package org.communiquons.android.comunic.client.api;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
@ -9,7 +9,7 @@ import org.json.JSONObject;
* Created by pierre on 10/31/17. * Created by pierre on 10/31/17.
*/ */
class APIResponse { public class APIResponse {
/** /**
* Reponse code * Reponse code