Removed most references to Volley.
This commit is contained in:
parent
e43ddbcc70
commit
42a8f47991
8 changed files with 7 additions and 135 deletions
|
@ -52,7 +52,7 @@ import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
|
|
||||||
public class AccountActivity extends BaseActivity {
|
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 String accountId;
|
||||||
private boolean following = false;
|
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() {
|
private void obtainAccount() {
|
||||||
mastodonAPI.account(accountId).enqueue(new Callback<Account>() {
|
mastodonAPI.account(accountId).enqueue(new Callback<Account>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -47,7 +47,7 @@ import retrofit2.Callback;
|
||||||
|
|
||||||
public class AccountFragment extends Fragment implements AccountActionListener,
|
public class AccountFragment extends Fragment implements AccountActionListener,
|
||||||
FooterActionListener {
|
FooterActionListener {
|
||||||
private static final String TAG = "Account"; // logging tag and Volley request tag
|
private static final String TAG = "Account"; // logging tag
|
||||||
|
|
||||||
public enum Type {
|
public enum Type {
|
||||||
FOLLOWS,
|
FOLLOWS,
|
||||||
|
@ -97,12 +97,6 @@ public class AccountFragment extends Fragment implements AccountActionListener,
|
||||||
api = ((BaseActivity) getActivity()).mastodonAPI;
|
api = ((BaseActivity) getActivity()).mastodonAPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
VolleySingleton.getInstance(getContext()).cancelAll(TAG);
|
|
||||||
super.onDestroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
|
||||||
|
|
|
@ -69,20 +69,10 @@ import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
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.Media;
|
||||||
import com.keylesspalace.tusky.entity.Status;
|
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.ByteArrayOutputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -90,11 +80,9 @@ import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import okhttp3.MediaType;
|
import okhttp3.MediaType;
|
||||||
|
@ -104,7 +92,7 @@ import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
|
||||||
public class ComposeActivity extends BaseActivity {
|
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_CHARACTER_LIMIT = 500;
|
||||||
private static final int STATUS_MEDIA_SIZE_LIMIT = 4000000; // 4MB
|
private static final int STATUS_MEDIA_SIZE_LIMIT = 4000000; // 4MB
|
||||||
private static final int MEDIA_PICK_RESULT = 1;
|
private static final int MEDIA_PICK_RESULT = 1;
|
||||||
|
@ -534,12 +522,6 @@ public class ComposeActivity extends BaseActivity {
|
||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
VolleySingleton.getInstance(this).cancelAll(TAG);
|
|
||||||
}
|
|
||||||
|
|
||||||
private EditText createEditText(String[] contentMimeTypes) {
|
private EditText createEditText(String[] contentMimeTypes) {
|
||||||
final String[] mimeTypes;
|
final String[] mimeTypes;
|
||||||
if (contentMimeTypes == null || contentMimeTypes.length == 0) {
|
if (contentMimeTypes == null || contentMimeTypes.length == 0) {
|
||||||
|
@ -966,6 +948,7 @@ public class ComposeActivity extends BaseActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call<Media> call, Throwable t) {
|
public void onFailure(Call<Media> call, Throwable t) {
|
||||||
|
Log.d(TAG, t.getMessage());
|
||||||
onUploadFailure(item);
|
onUploadFailure(item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -22,12 +22,10 @@ import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.design.widget.Snackbar;
|
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.volley.Request;
|
import com.android.volley.Request;
|
||||||
|
@ -38,7 +36,6 @@ import com.android.volley.toolbox.JsonObjectRequest;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
|
@ -29,19 +29,10 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
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.Notification;
|
||||||
import com.keylesspalace.tusky.entity.Status;
|
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.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
@ -49,7 +40,7 @@ import retrofit2.Callback;
|
||||||
public class NotificationsFragment extends SFragment implements
|
public class NotificationsFragment extends SFragment implements
|
||||||
SwipeRefreshLayout.OnRefreshListener, StatusActionListener, FooterActionListener,
|
SwipeRefreshLayout.OnRefreshListener, StatusActionListener, FooterActionListener,
|
||||||
NotificationsAdapter.FollowListener {
|
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 SwipeRefreshLayout swipeRefreshLayout;
|
||||||
private RecyclerView recyclerView;
|
private RecyclerView recyclerView;
|
||||||
|
@ -65,12 +56,6 @@ public class NotificationsFragment extends SFragment implements
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
VolleySingleton.getInstance(getContext()).cancelAll(TAG);
|
|
||||||
super.onDestroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
NotificationManager notificationManager =
|
NotificationManager notificationManager =
|
||||||
|
|
|
@ -15,9 +15,7 @@
|
||||||
|
|
||||||
package com.keylesspalace.tusky;
|
package com.keylesspalace.tusky;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
@ -30,35 +28,20 @@ import android.support.v7.widget.Toolbar;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
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 com.keylesspalace.tusky.entity.Status;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONException;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
|
||||||
public class ReportActivity extends BaseActivity {
|
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 View anyView; // what Snackbar will use to find the root view
|
||||||
private ReportAdapter adapter;
|
private ReportAdapter adapter;
|
||||||
private boolean reportAlreadyInFlight;
|
private boolean reportAlreadyInFlight;
|
||||||
|
@ -74,11 +57,6 @@ public class ReportActivity extends BaseActivity {
|
||||||
String statusId = intent.getStringExtra("status_id");
|
String statusId = intent.getStringExtra("status_id");
|
||||||
String statusContent = intent.getStringExtra("status_content");
|
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);
|
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
ActionBar bar = getSupportActionBar();
|
ActionBar bar = getSupportActionBar();
|
||||||
|
@ -129,22 +107,6 @@ public class ReportActivity extends BaseActivity {
|
||||||
fetchRecentStatuses(accountId);
|
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,
|
private void sendReport(final String accountId, final String[] statusIds,
|
||||||
final String comment) {
|
final String comment) {
|
||||||
mastodonAPI.report(accountId, Arrays.asList(statusIds), comment).enqueue(new Callback<ResponseBody>() {
|
mastodonAPI.report(accountId, Arrays.asList(statusIds), comment).enqueue(new Callback<ResponseBody>() {
|
||||||
|
|
|
@ -28,20 +28,11 @@ import android.text.Spanned;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
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.Relationship;
|
||||||
import com.keylesspalace.tusky.entity.Status;
|
import com.keylesspalace.tusky.entity.Status;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
import retrofit2.Call;
|
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
|
* overlap functionality. So, I'm momentarily leaving it and hopefully working on those will clear
|
||||||
* up what needs to be where. */
|
* up what needs to be where. */
|
||||||
public class SFragment extends Fragment {
|
public class SFragment extends Fragment {
|
||||||
private static final String TAG = "SFragment"; // logging tag and Volley request tag
|
|
||||||
|
|
||||||
protected String domain;
|
protected String domain;
|
||||||
protected String accessToken;
|
protected String accessToken;
|
||||||
protected String loggedInAccountId;
|
protected String loggedInAccountId;
|
||||||
|
@ -75,12 +64,6 @@ public class SFragment extends Fragment {
|
||||||
api = ((BaseActivity) getActivity()).mastodonAPI;
|
api = ((BaseActivity) getActivity()).mastodonAPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
VolleySingleton.getInstance(getContext()).cancelAll(TAG);
|
|
||||||
super.onDestroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void reply(Status status) {
|
protected void reply(Status status) {
|
||||||
String inReplyToId = status.getActionableId();
|
String inReplyToId = status.getActionableId();
|
||||||
Status.Mention[] mentions = status.mentions;
|
Status.Mention[] mentions = status.mentions;
|
||||||
|
@ -234,17 +217,6 @@ public class SFragment extends Fragment {
|
||||||
popup.show();
|
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) {
|
protected void viewMedia(String url, Status.MediaAttachment.Type type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case IMAGE: {
|
case IMAGE: {
|
||||||
|
|
|
@ -27,25 +27,16 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
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 com.keylesspalace.tusky.entity.Status;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONException;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
|
||||||
public class TimelineFragment extends SFragment implements
|
public class TimelineFragment extends SFragment implements
|
||||||
SwipeRefreshLayout.OnRefreshListener, StatusActionListener, FooterActionListener {
|
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 {
|
public enum Kind {
|
||||||
HOME,
|
HOME,
|
||||||
|
@ -82,12 +73,6 @@ public class TimelineFragment extends SFragment implements
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
VolleySingleton.getInstance(getContext()).cancelAll(TAG);
|
|
||||||
super.onDestroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
|
Loading…
Reference in a new issue