mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-23 13:59:29 +00:00
Removed useless classes.
This commit is contained in:
parent
a90ee9d5f5
commit
9bbc82d3a5
@ -1,53 +0,0 @@
|
||||
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.APIRequest;
|
||||
import org.communiquons.android.comunic.client.data.models.APIResponse;
|
||||
|
||||
/**
|
||||
* Perform an API request on the server
|
||||
*
|
||||
* API requests are made on a separate Thread using AsyncTask.
|
||||
*
|
||||
* The method requesting an API request has to implement the onPostExecute method in order to be
|
||||
* able to have a personalized data process
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
* Created by pierre on 10/31/17.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class APIRequestTask extends AsyncTask<APIRequest, Void, APIResponse> {
|
||||
|
||||
/**
|
||||
* API request in a Background task
|
||||
*
|
||||
* Warning: This method support only one request per object
|
||||
*
|
||||
* @param params Parameters required to perform the API request
|
||||
* @return JSONObject The result of the request
|
||||
*/
|
||||
@Override
|
||||
protected APIResponse doInBackground(APIRequest... params) {
|
||||
|
||||
try {
|
||||
//Perform the API request
|
||||
APIRequestHelper req = new APIRequestHelper();
|
||||
return req.exec(params[0]);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The next action to do once we got a response is implemented by the method that perform
|
||||
* the request.
|
||||
*
|
||||
* @param result The result of the request
|
||||
*/
|
||||
abstract protected void onPostExecute(APIResponse result);
|
||||
}
|
@ -1,119 +0,0 @@
|
||||
package org.communiquons.android.comunic.client.data.asynctasks;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.ArrayMap;
|
||||
|
||||
import org.communiquons.android.comunic.client.data.helpers.DatabaseHelper;
|
||||
import org.communiquons.android.comunic.client.data.helpers.GetUsersHelper;
|
||||
import org.communiquons.android.comunic.client.data.models.UserInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* This class handles informations requests about user informations
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
* Created by pierre on 11/5/17.
|
||||
*/
|
||||
|
||||
public class GetUsersInfos {
|
||||
|
||||
/**
|
||||
* User information database helper
|
||||
*/
|
||||
private GetUsersHelper uHelper = null;
|
||||
|
||||
/**
|
||||
* Public constructor
|
||||
*
|
||||
* @param context The context of the application
|
||||
* @param dbHelper Database helper object
|
||||
*/
|
||||
public GetUsersInfos(Context context, DatabaseHelper dbHelper){
|
||||
|
||||
//Save database helper object
|
||||
this.uHelper = new GetUsersHelper(context, dbHelper);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This interface must be implemented to perform an API request
|
||||
*/
|
||||
public interface getUserInfosCallback{
|
||||
|
||||
/**
|
||||
* Callback function called when we got informations about user
|
||||
*
|
||||
* @param info Information about the user
|
||||
*/
|
||||
void callback(UserInfo info);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This interface must be implemented to perform an API request
|
||||
*/
|
||||
public interface getMultipleUserInfosCallback{
|
||||
|
||||
/**
|
||||
* Callback function called when we got informations about user
|
||||
*
|
||||
* @param info Information about the user
|
||||
*/
|
||||
void callback(ArrayMap<Integer, UserInfo> info);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get and return informations about a user
|
||||
*
|
||||
* @param id The ID of the user to get the informations
|
||||
* @param callback What to do once we got the response
|
||||
*/
|
||||
@Deprecated
|
||||
public void get(int id, final getUserInfosCallback callback){
|
||||
|
||||
//Check if the ID is positive, error else
|
||||
if(id < 1){
|
||||
callback.callback(null); //This is an error
|
||||
}
|
||||
|
||||
new AsyncTask<Integer, Void, UserInfo>(){
|
||||
@Override
|
||||
protected UserInfo doInBackground(Integer... params) {
|
||||
return uHelper.getSingle(params[0], false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(UserInfo userInfo) {
|
||||
callback.callback(userInfo);
|
||||
}
|
||||
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, id);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get informations about multiple users
|
||||
*
|
||||
* @param IDs The ID of the user to get
|
||||
* @param callback The result once we got all the users
|
||||
*/
|
||||
@Deprecated
|
||||
public void getMultiple(final ArrayList<Integer> IDs, final getMultipleUserInfosCallback callback){
|
||||
|
||||
new AsyncTask<Void, Void, ArrayMap<Integer, UserInfo>>(){
|
||||
@Override
|
||||
protected ArrayMap<Integer, UserInfo> doInBackground(Void... params) {
|
||||
return uHelper.getMultiple(IDs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(ArrayMap<Integer, UserInfo> integerUserInfoArrayMap) {
|
||||
callback.callback(integerUserInfoArrayMap);
|
||||
}
|
||||
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,177 +0,0 @@
|
||||
package org.communiquons.android.comunic.client.data.asynctasks;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import org.communiquons.android.comunic.client.data.utils.ImageLoadUtils;
|
||||
import org.communiquons.android.comunic.client.data.utils.Utilities;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* Web image loader and renderer
|
||||
*
|
||||
* Warning : Using ImageLoadTask is a quite bad idea to load multiple images,
|
||||
* ImageLoad class should be preferred
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
* Created by pierre on 11/8/17.
|
||||
*/
|
||||
@Deprecated
|
||||
public class ImageLoadTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
/**
|
||||
* The URL pointing on the image
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* The target image view
|
||||
*/
|
||||
private ImageView view;
|
||||
|
||||
/**
|
||||
* The context of execution of the request
|
||||
*/
|
||||
private Context mContext;
|
||||
|
||||
/**
|
||||
* Image file object
|
||||
*/
|
||||
private File img_file = null;
|
||||
|
||||
/**
|
||||
* Bitmap object
|
||||
*/
|
||||
private Bitmap bitmap = null;
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param context The context of the request, in order to be able to access the cache directory
|
||||
* @param url The URL of the image to display
|
||||
* @param view The target image view for the image
|
||||
*/
|
||||
public ImageLoadTask(Context context, String url, ImageView view){
|
||||
//Save the values
|
||||
this.mContext = context;
|
||||
this.url = url;
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Background task
|
||||
*/
|
||||
@Override
|
||||
protected Void doInBackground(Void... param) {
|
||||
|
||||
//Determine the file name for the view
|
||||
String filename = ImageLoadUtils.get_file_name(url);
|
||||
if (filename == null) {
|
||||
Log.e("ImageLoadTask", "Couldn't generate file storage name !");
|
||||
return null; //An error occured
|
||||
}
|
||||
String full_filename = ImageLoadUtils.IMAGE_CACHE_DIRECTORY + filename;
|
||||
|
||||
//Try to open the file
|
||||
img_file = new File(mContext.getCacheDir(), full_filename);
|
||||
|
||||
//Check if file exists or not
|
||||
if (!img_file.exists())
|
||||
//Download it
|
||||
download_image();
|
||||
|
||||
//Check if there is still no file
|
||||
if(!img_file.exists())
|
||||
return null;
|
||||
|
||||
//Try to read file
|
||||
try {
|
||||
FileInputStream is = new FileInputStream(img_file);
|
||||
bitmap = BitmapFactory.decodeStream(is);
|
||||
is.close();
|
||||
} catch (FileNotFoundException e){
|
||||
e.printStackTrace();
|
||||
} catch (IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//Check for errors
|
||||
if(bitmap == null){
|
||||
|
||||
//Delete cached file
|
||||
img_file.delete();
|
||||
|
||||
Log.e("ImageLoadTask", "File is corrupted, will have to be downloaded again !");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* On post execution operations
|
||||
*/
|
||||
@Override
|
||||
protected void onPostExecute(Void aVoid) {
|
||||
if(bitmap != null)
|
||||
view.setImageBitmap(bitmap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Download the file and store it in the cache
|
||||
*
|
||||
* @return True in case of success
|
||||
*/
|
||||
private boolean download_image(){
|
||||
|
||||
//Create cache parent directory
|
||||
if(!ImageLoadUtils.create_parent_directory(mContext))
|
||||
return false;
|
||||
|
||||
try {
|
||||
|
||||
//Open the file for writing
|
||||
if(!img_file.createNewFile())
|
||||
return false;
|
||||
OutputStream os = new FileOutputStream(img_file, false);
|
||||
|
||||
//Open the connection
|
||||
URL urlObj = new URL(url);
|
||||
HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection();
|
||||
|
||||
conn.setDoInput(true);
|
||||
conn.setConnectTimeout(3000);
|
||||
conn.setReadTimeout(3000);
|
||||
|
||||
conn.connect();
|
||||
|
||||
//Get input stream
|
||||
InputStream is = conn.getInputStream();
|
||||
|
||||
//Transfer bytes
|
||||
Utilities.InputToOutputStream(is, os);
|
||||
|
||||
os.close();
|
||||
is.close();
|
||||
conn.disconnect();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@ import android.widget.TextView;
|
||||
|
||||
import org.communiquons.android.comunic.client.BuildConfig;
|
||||
import org.communiquons.android.comunic.client.R;
|
||||
import org.communiquons.android.comunic.client.data.asynctasks.SafeAsyncTask;
|
||||
import org.communiquons.android.comunic.client.ui.asynctasks.SafeAsyncTask;
|
||||
import org.communiquons.android.comunic.client.data.enums.CreateAccountResult;
|
||||
import org.communiquons.android.comunic.client.data.helpers.AccountHelper;
|
||||
import org.communiquons.android.comunic.client.data.models.NewAccount;
|
||||
@ -212,10 +212,9 @@ public class CreateAccountActivity extends AppCompatActivity
|
||||
* @return TRUE if a request is running / FALSE else
|
||||
*/
|
||||
private boolean isCreating() {
|
||||
if (mCreateAccountTask == null)
|
||||
return false;
|
||||
|
||||
return !mCreateAccountTask.isCancelled() && mCreateAccountTask.getStatus() != FINISHED;
|
||||
return mCreateAccountTask != null
|
||||
&& !mCreateAccountTask.isCancelled()
|
||||
&& mCreateAccountTask.getStatus() != FINISHED;
|
||||
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.communiquons.android.comunic.client.R;
|
||||
import org.communiquons.android.comunic.client.data.asynctasks.SafeAsyncTask;
|
||||
import org.communiquons.android.comunic.client.ui.asynctasks.SafeAsyncTask;
|
||||
import org.communiquons.android.comunic.client.data.enums.LoginResult;
|
||||
import org.communiquons.android.comunic.client.data.helpers.APIRequestHelper;
|
||||
import org.communiquons.android.comunic.client.data.helpers.AccountHelper;
|
||||
|
@ -2,7 +2,6 @@ package org.communiquons.android.comunic.client.ui.asynctasks;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.communiquons.android.comunic.client.data.asynctasks.SafeAsyncTask;
|
||||
import org.communiquons.android.comunic.client.data.helpers.APIRequestHelper;
|
||||
import org.communiquons.android.comunic.client.data.models.APIRequest;
|
||||
import org.communiquons.android.comunic.client.data.models.APIResponse;
|
||||
|
@ -2,7 +2,6 @@ package org.communiquons.android.comunic.client.ui.asynctasks;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.communiquons.android.comunic.client.data.asynctasks.SafeAsyncTask;
|
||||
import org.communiquons.android.comunic.client.data.helpers.ConversationMessagesHelper;
|
||||
|
||||
/**
|
||||
|
@ -3,8 +3,6 @@ package org.communiquons.android.comunic.client.ui.asynctasks;
|
||||
import android.content.Context;
|
||||
|
||||
import org.communiquons.android.comunic.client.data.arrays.PostsList;
|
||||
import org.communiquons.android.comunic.client.data.asynctasks.SafeAsyncTask;
|
||||
import org.communiquons.android.comunic.client.data.helpers.GetUsersHelper;
|
||||
import org.communiquons.android.comunic.client.data.helpers.PostsHelper;
|
||||
|
||||
/**
|
||||
|
@ -3,8 +3,6 @@ package org.communiquons.android.comunic.client.ui.asynctasks;
|
||||
import android.content.Context;
|
||||
|
||||
import org.communiquons.android.comunic.client.data.arrays.PostsList;
|
||||
import org.communiquons.android.comunic.client.data.asynctasks.SafeAsyncTask;
|
||||
import org.communiquons.android.comunic.client.data.helpers.GetUsersHelper;
|
||||
import org.communiquons.android.comunic.client.data.helpers.PostsHelper;
|
||||
import org.communiquons.android.comunic.client.data.models.Post;
|
||||
|
||||
|
@ -3,7 +3,6 @@ package org.communiquons.android.comunic.client.ui.asynctasks;
|
||||
import android.content.Context;
|
||||
import android.util.ArrayMap;
|
||||
|
||||
import org.communiquons.android.comunic.client.data.asynctasks.SafeAsyncTask;
|
||||
import org.communiquons.android.comunic.client.data.helpers.FriendsListHelper;
|
||||
import org.communiquons.android.comunic.client.data.helpers.GetUsersHelper;
|
||||
import org.communiquons.android.comunic.client.data.models.UserInfo;
|
||||
|
@ -3,8 +3,6 @@ package org.communiquons.android.comunic.client.ui.asynctasks;
|
||||
import android.content.Context;
|
||||
|
||||
import org.communiquons.android.comunic.client.data.arrays.PostsList;
|
||||
import org.communiquons.android.comunic.client.data.asynctasks.SafeAsyncTask;
|
||||
import org.communiquons.android.comunic.client.data.helpers.GetUsersHelper;
|
||||
import org.communiquons.android.comunic.client.data.helpers.PostsHelper;
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,6 @@ package org.communiquons.android.comunic.client.ui.asynctasks;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.communiquons.android.comunic.client.data.asynctasks.SafeAsyncTask;
|
||||
import org.communiquons.android.comunic.client.data.enums.LoginResult;
|
||||
import org.communiquons.android.comunic.client.data.helpers.AccountHelper;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.communiquons.android.comunic.client.data.asynctasks;
|
||||
package org.communiquons.android.comunic.client.ui.asynctasks;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
@ -2,7 +2,6 @@ package org.communiquons.android.comunic.client.ui.asynctasks;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.communiquons.android.comunic.client.data.asynctasks.SafeAsyncTask;
|
||||
import org.communiquons.android.comunic.client.data.helpers.ConversationMessagesHelper;
|
||||
import org.communiquons.android.comunic.client.data.models.ConversationMessage;
|
||||
|
||||
|
@ -26,7 +26,7 @@ import android.widget.Toast;
|
||||
|
||||
import org.communiquons.android.comunic.client.R;
|
||||
import org.communiquons.android.comunic.client.data.arrays.ConversationMessagesList;
|
||||
import org.communiquons.android.comunic.client.data.asynctasks.SafeAsyncTask;
|
||||
import org.communiquons.android.comunic.client.ui.asynctasks.SafeAsyncTask;
|
||||
import org.communiquons.android.comunic.client.data.helpers.ConversationMessagesHelper;
|
||||
import org.communiquons.android.comunic.client.data.helpers.ConversationsListHelper;
|
||||
import org.communiquons.android.comunic.client.data.helpers.DatabaseHelper;
|
||||
|
@ -21,7 +21,7 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.communiquons.android.comunic.client.R;
|
||||
import org.communiquons.android.comunic.client.data.asynctasks.SafeAsyncTask;
|
||||
import org.communiquons.android.comunic.client.ui.asynctasks.SafeAsyncTask;
|
||||
import org.communiquons.android.comunic.client.data.helpers.DatabaseHelper;
|
||||
import org.communiquons.android.comunic.client.data.helpers.FriendsListHelper;
|
||||
import org.communiquons.android.comunic.client.data.helpers.GetUsersHelper;
|
||||
|
@ -6,7 +6,7 @@ import android.widget.Toast;
|
||||
|
||||
import org.communiquons.android.comunic.client.R;
|
||||
import org.communiquons.android.comunic.client.data.arrays.PostsList;
|
||||
import org.communiquons.android.comunic.client.data.asynctasks.SafeAsyncTask;
|
||||
import org.communiquons.android.comunic.client.ui.asynctasks.SafeAsyncTask;
|
||||
import org.communiquons.android.comunic.client.ui.activities.MainActivity;
|
||||
import org.communiquons.android.comunic.client.ui.asynctasks.GetLatestPostsTask;
|
||||
|
||||
|
@ -7,7 +7,7 @@ import android.widget.Toast;
|
||||
|
||||
import org.communiquons.android.comunic.client.R;
|
||||
import org.communiquons.android.comunic.client.data.arrays.PostsList;
|
||||
import org.communiquons.android.comunic.client.data.asynctasks.SafeAsyncTask;
|
||||
import org.communiquons.android.comunic.client.ui.asynctasks.SafeAsyncTask;
|
||||
import org.communiquons.android.comunic.client.ui.asynctasks.GetSinglePostTask;
|
||||
|
||||
/**
|
||||
|
@ -16,7 +16,7 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.communiquons.android.comunic.client.R;
|
||||
import org.communiquons.android.comunic.client.data.asynctasks.SafeAsyncTask;
|
||||
import org.communiquons.android.comunic.client.ui.asynctasks.SafeAsyncTask;
|
||||
import org.communiquons.android.comunic.client.data.models.UserInfo;
|
||||
import org.communiquons.android.comunic.client.ui.adapters.UsersBasicAdapter;
|
||||
import org.communiquons.android.comunic.client.ui.asynctasks.GetUserFriendsListTask;
|
||||
|
@ -5,13 +5,11 @@ import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.View;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.communiquons.android.comunic.client.R;
|
||||
import org.communiquons.android.comunic.client.data.arrays.PostsList;
|
||||
import org.communiquons.android.comunic.client.data.asynctasks.SafeAsyncTask;
|
||||
import org.communiquons.android.comunic.client.data.models.Post;
|
||||
import org.communiquons.android.comunic.client.ui.asynctasks.SafeAsyncTask;
|
||||
import org.communiquons.android.comunic.client.ui.asynctasks.LoadUserPostsTask;
|
||||
|
||||
/**
|
||||
|
@ -12,7 +12,7 @@ import android.widget.ProgressBar;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.communiquons.android.comunic.client.R;
|
||||
import org.communiquons.android.comunic.client.data.asynctasks.SafeAsyncTask;
|
||||
import org.communiquons.android.comunic.client.ui.asynctasks.SafeAsyncTask;
|
||||
import org.communiquons.android.comunic.client.data.helpers.FriendsListHelper;
|
||||
import org.communiquons.android.comunic.client.data.models.FriendshipStatus;
|
||||
import org.communiquons.android.comunic.client.ui.listeners.OnFriendsStatusUpdateListener;
|
||||
|
Loading…
Reference in New Issue
Block a user