From 42a8f47991e66a1d957339d46d6da6128cd224ca Mon Sep 17 00:00:00 2001 From: Vavassor Date: Thu, 9 Mar 2017 18:20:08 -0500 Subject: [PATCH] Removed most references to Volley. --- .../keylesspalace/tusky/AccountActivity.java | 8 +--- .../keylesspalace/tusky/AccountFragment.java | 8 +--- .../keylesspalace/tusky/ComposeActivity.java | 21 +--------- .../keylesspalace/tusky/LoginActivity.java | 3 -- .../tusky/NotificationsFragment.java | 17 +------- .../keylesspalace/tusky/ReportActivity.java | 40 +------------------ .../com/keylesspalace/tusky/SFragment.java | 28 ------------- .../keylesspalace/tusky/TimelineFragment.java | 17 +------- 8 files changed, 7 insertions(+), 135 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java index 14e6834e2..2cd848d0e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java @@ -52,7 +52,7 @@ import retrofit2.Callback; import retrofit2.Response; public class AccountActivity extends BaseActivity { - private static final String TAG = "AccountActivity"; // Volley request tag and logging tag + private static final String TAG = "AccountActivity"; // logging tag private String accountId; private boolean following = false; @@ -155,12 +155,6 @@ public class AccountActivity extends BaseActivity { } } - @Override - protected void onDestroy() { - VolleySingleton.getInstance(this).cancelAll(TAG); - super.onDestroy(); - } - private void obtainAccount() { mastodonAPI.account(accountId).enqueue(new Callback() { @Override diff --git a/app/src/main/java/com/keylesspalace/tusky/AccountFragment.java b/app/src/main/java/com/keylesspalace/tusky/AccountFragment.java index 09115c601..fa0e67297 100644 --- a/app/src/main/java/com/keylesspalace/tusky/AccountFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/AccountFragment.java @@ -47,7 +47,7 @@ import retrofit2.Callback; public class AccountFragment extends Fragment implements AccountActionListener, FooterActionListener { - private static final String TAG = "Account"; // logging tag and Volley request tag + private static final String TAG = "Account"; // logging tag public enum Type { FOLLOWS, @@ -97,12 +97,6 @@ public class AccountFragment extends Fragment implements AccountActionListener, api = ((BaseActivity) getActivity()).mastodonAPI; } - @Override - public void onDestroy() { - VolleySingleton.getInstance(getContext()).cancelAll(TAG); - super.onDestroy(); - } - @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, diff --git a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java index 4c8f21548..6889bc8ec 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java @@ -69,20 +69,10 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; -import android.widget.Toast; -import com.android.volley.AuthFailureError; -import com.android.volley.Request; -import com.android.volley.Response; -import com.android.volley.VolleyError; -import com.android.volley.toolbox.JsonObjectRequest; import com.keylesspalace.tusky.entity.Media; import com.keylesspalace.tusky.entity.Status; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - import java.io.ByteArrayOutputStream; import java.io.FileNotFoundException; import java.io.IOException; @@ -90,11 +80,9 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; -import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Locale; -import java.util.Map; import java.util.Random; import okhttp3.MediaType; @@ -104,7 +92,7 @@ import retrofit2.Call; import retrofit2.Callback; public class ComposeActivity extends BaseActivity { - private static final String TAG = "ComposeActivity"; // logging tag, and volley request tag + private static final String TAG = "ComposeActivity"; // logging tag private static final int STATUS_CHARACTER_LIMIT = 500; private static final int STATUS_MEDIA_SIZE_LIMIT = 4000000; // 4MB private static final int MEDIA_PICK_RESULT = 1; @@ -534,12 +522,6 @@ public class ComposeActivity extends BaseActivity { editor.apply(); } - @Override - protected void onDestroy() { - super.onDestroy(); - VolleySingleton.getInstance(this).cancelAll(TAG); - } - private EditText createEditText(String[] contentMimeTypes) { final String[] mimeTypes; if (contentMimeTypes == null || contentMimeTypes.length == 0) { @@ -966,6 +948,7 @@ public class ComposeActivity extends BaseActivity { @Override public void onFailure(Call call, Throwable t) { + Log.d(TAG, t.getMessage()); onUploadFailure(item); } }); diff --git a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java index c99da8a1b..c83f12472 100644 --- a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java @@ -22,12 +22,10 @@ import android.content.Intent; import android.content.SharedPreferences; import android.net.Uri; import android.os.Bundle; -import android.support.design.widget.Snackbar; import android.support.v7.widget.Toolbar; import android.view.View; import android.widget.Button; import android.widget.EditText; -import android.widget.FrameLayout; import android.widget.TextView; import com.android.volley.Request; @@ -38,7 +36,6 @@ import com.android.volley.toolbox.JsonObjectRequest; import org.json.JSONException; import org.json.JSONObject; -import java.io.UnsupportedEncodingException; import java.util.HashMap; import java.util.Map; diff --git a/app/src/main/java/com/keylesspalace/tusky/NotificationsFragment.java b/app/src/main/java/com/keylesspalace/tusky/NotificationsFragment.java index 5e0f3f203..8a410661d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/NotificationsFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/NotificationsFragment.java @@ -29,19 +29,10 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import com.android.volley.AuthFailureError; -import com.android.volley.Response; -import com.android.volley.VolleyError; -import com.android.volley.toolbox.JsonArrayRequest; import com.keylesspalace.tusky.entity.Notification; import com.keylesspalace.tusky.entity.Status; -import org.json.JSONArray; -import org.json.JSONException; - -import java.util.HashMap; import java.util.List; -import java.util.Map; import retrofit2.Call; import retrofit2.Callback; @@ -49,7 +40,7 @@ import retrofit2.Callback; public class NotificationsFragment extends SFragment implements SwipeRefreshLayout.OnRefreshListener, StatusActionListener, FooterActionListener, NotificationsAdapter.FollowListener { - private static final String TAG = "Notifications"; // logging tag and Volley request tag + private static final String TAG = "Notifications"; // logging tag private SwipeRefreshLayout swipeRefreshLayout; private RecyclerView recyclerView; @@ -65,12 +56,6 @@ public class NotificationsFragment extends SFragment implements return fragment; } - @Override - public void onDestroy() { - VolleySingleton.getInstance(getContext()).cancelAll(TAG); - super.onDestroy(); - } - @Override public void onCreate(@Nullable Bundle savedInstanceState) { NotificationManager notificationManager = diff --git a/app/src/main/java/com/keylesspalace/tusky/ReportActivity.java b/app/src/main/java/com/keylesspalace/tusky/ReportActivity.java index 3c13570ad..e53601c52 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ReportActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ReportActivity.java @@ -15,9 +15,7 @@ package com.keylesspalace.tusky; -import android.content.Context; import android.content.Intent; -import android.content.SharedPreferences; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.support.annotation.Nullable; @@ -30,35 +28,20 @@ import android.support.v7.widget.Toolbar; import android.view.View; import android.widget.Button; import android.widget.EditText; -import android.widget.Toast; -import com.android.volley.AuthFailureError; -import com.android.volley.Request; -import com.android.volley.Response; -import com.android.volley.VolleyError; -import com.android.volley.toolbox.JsonArrayRequest; -import com.android.volley.toolbox.JsonObjectRequest; import com.keylesspalace.tusky.entity.Status; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - import java.util.ArrayList; import java.util.Arrays; -import java.util.HashMap; import java.util.List; -import java.util.Map; import okhttp3.ResponseBody; import retrofit2.Call; import retrofit2.Callback; public class ReportActivity extends BaseActivity { - private static final String TAG = "ReportActivity"; // logging tag and Volley request tag + private static final String TAG = "ReportActivity"; // logging tag - private String domain; - private String accessToken; private View anyView; // what Snackbar will use to find the root view private ReportAdapter adapter; private boolean reportAlreadyInFlight; @@ -74,11 +57,6 @@ public class ReportActivity extends BaseActivity { String statusId = intent.getStringExtra("status_id"); String statusContent = intent.getStringExtra("status_content"); - SharedPreferences preferences = getSharedPreferences( - getString(R.string.preferences_file_key), Context.MODE_PRIVATE); - domain = preferences.getString("domain", null); - accessToken = preferences.getString("accessToken", null); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar bar = getSupportActionBar(); @@ -129,22 +107,6 @@ public class ReportActivity extends BaseActivity { fetchRecentStatuses(accountId); } - @Override - protected void onDestroy() { - VolleySingleton.getInstance(this).cancelAll(TAG); - super.onDestroy(); - } - - /* JSONArray has a constructor to take primitive arrays but it's restricted to API level 19 and - * above, so this is an alternative. */ - private static JSONArray makeStringArrayCompat(String[] stringArray) throws JSONException { - JSONArray result = new JSONArray(); - for (int i = 0; i < stringArray.length; i++) { - result.put(i, stringArray[i]); - } - return result; - } - private void sendReport(final String accountId, final String[] statusIds, final String comment) { mastodonAPI.report(accountId, Arrays.asList(statusIds), comment).enqueue(new Callback() { diff --git a/app/src/main/java/com/keylesspalace/tusky/SFragment.java b/app/src/main/java/com/keylesspalace/tusky/SFragment.java index 6b7845f5d..033445b95 100644 --- a/app/src/main/java/com/keylesspalace/tusky/SFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/SFragment.java @@ -28,20 +28,11 @@ import android.text.Spanned; import android.view.MenuItem; import android.view.View; -import com.android.volley.AuthFailureError; -import com.android.volley.Request; -import com.android.volley.Response; -import com.android.volley.VolleyError; -import com.android.volley.toolbox.JsonObjectRequest; import com.keylesspalace.tusky.entity.Relationship; import com.keylesspalace.tusky.entity.Status; -import org.json.JSONObject; - import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; import okhttp3.ResponseBody; import retrofit2.Call; @@ -54,8 +45,6 @@ import retrofit2.Callback; * overlap functionality. So, I'm momentarily leaving it and hopefully working on those will clear * up what needs to be where. */ public class SFragment extends Fragment { - private static final String TAG = "SFragment"; // logging tag and Volley request tag - protected String domain; protected String accessToken; protected String loggedInAccountId; @@ -75,12 +64,6 @@ public class SFragment extends Fragment { api = ((BaseActivity) getActivity()).mastodonAPI; } - @Override - public void onDestroy() { - VolleySingleton.getInstance(getContext()).cancelAll(TAG); - super.onDestroy(); - } - protected void reply(Status status) { String inReplyToId = status.getActionableId(); Status.Mention[] mentions = status.mentions; @@ -234,17 +217,6 @@ public class SFragment extends Fragment { popup.show(); } - private boolean fileExtensionMatches(String url, String extension) { - extension = "." + extension; - int parametersStart = url.indexOf('?'); - if (parametersStart == -1) { - return url.toLowerCase().endsWith(extension); - } else { - int start = parametersStart - extension.length(); - return start > 0 && url.substring(start, parametersStart).equals(extension); - } - } - protected void viewMedia(String url, Status.MediaAttachment.Type type) { switch (type) { case IMAGE: { diff --git a/app/src/main/java/com/keylesspalace/tusky/TimelineFragment.java b/app/src/main/java/com/keylesspalace/tusky/TimelineFragment.java index 907d6c906..9788c1080 100644 --- a/app/src/main/java/com/keylesspalace/tusky/TimelineFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/TimelineFragment.java @@ -27,25 +27,16 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import com.android.volley.AuthFailureError; -import com.android.volley.Response; -import com.android.volley.VolleyError; -import com.android.volley.toolbox.JsonArrayRequest; import com.keylesspalace.tusky.entity.Status; -import org.json.JSONArray; -import org.json.JSONException; - -import java.util.HashMap; import java.util.List; -import java.util.Map; import retrofit2.Call; import retrofit2.Callback; public class TimelineFragment extends SFragment implements SwipeRefreshLayout.OnRefreshListener, StatusActionListener, FooterActionListener { - private static final String TAG = "Timeline"; // logging tag and Volley request tag + private static final String TAG = "Timeline"; // logging tag public enum Kind { HOME, @@ -82,12 +73,6 @@ public class TimelineFragment extends SFragment implements return fragment; } - @Override - public void onDestroy() { - VolleySingleton.getInstance(getContext()).cancelAll(TAG); - super.onDestroy(); - } - @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {