cleanup code
This commit is contained in:
parent
3c685800d8
commit
50b0d1fb8d
|
@ -17,7 +17,6 @@ package com.keylesspalace.tusky;
|
|||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
|
|
|
@ -75,7 +75,7 @@ class NetworkModule {
|
|||
.apply {
|
||||
addInterceptor(InstanceSwitchAuthInterceptor(accountManager))
|
||||
if (BuildConfig.DEBUG) {
|
||||
addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
|
||||
addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BASIC))
|
||||
}
|
||||
}
|
||||
.build()
|
||||
|
|
|
@ -21,7 +21,6 @@ import android.os.Bundle
|
|||
import android.support.v4.app.ActivityOptionsCompat
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.support.v4.view.ViewCompat
|
||||
import android.support.v4.widget.SwipeRefreshLayout
|
||||
import android.support.v7.widget.GridLayoutManager
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.util.Log
|
||||
|
@ -29,8 +28,6 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.TextView
|
||||
import com.keylesspalace.tusky.R
|
||||
import com.keylesspalace.tusky.ViewMediaActivity
|
||||
import com.keylesspalace.tusky.ViewVideoActivity
|
||||
|
|
|
@ -58,8 +58,6 @@ import javax.inject.Inject;
|
|||
* overlap functionality. So, I'm momentarily leaving it and hopefully working on those will clear
|
||||
* up what needs to be where. */
|
||||
public abstract class SFragment extends BaseFragment {
|
||||
protected static final int COMPOSE_RESULT = 1;
|
||||
|
||||
protected String loggedInAccountId;
|
||||
protected String loggedInUsername;
|
||||
|
||||
|
@ -137,7 +135,7 @@ public abstract class SFragment extends BaseFragment {
|
|||
.repyingStatusAuthor(actionableStatus.getAccount().getLocalUsername())
|
||||
.replyingStatusContent(actionableStatus.getContent().toString())
|
||||
.build(getContext());
|
||||
startActivityForResult(intent, COMPOSE_RESULT);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
protected void more(final Status status, View view, final int position) {
|
||||
|
|
|
@ -266,7 +266,7 @@ public class TimelineFragment extends SFragment implements
|
|||
}
|
||||
|
||||
private void setupSwipeRefreshLayout() {
|
||||
Context context = Objects.requireNonNull(getContext());
|
||||
Context context = requireContext();
|
||||
swipeRefreshLayout.setOnRefreshListener(this);
|
||||
swipeRefreshLayout.setColorSchemeResources(R.color.primary);
|
||||
swipeRefreshLayout.setProgressBackgroundColorSchemeColor(ThemeUtils.getColor(context,
|
||||
|
@ -274,7 +274,7 @@ public class TimelineFragment extends SFragment implements
|
|||
}
|
||||
|
||||
private void setupRecyclerView() {
|
||||
Context context = Objects.requireNonNull(getContext());
|
||||
Context context = requireContext();
|
||||
recyclerView.setHasFixedSize(true);
|
||||
layoutManager = new LinearLayoutManager(context);
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
|
@ -349,7 +349,7 @@ public class TimelineFragment extends SFragment implements
|
|||
super.onActivityCreated(savedInstanceState);
|
||||
|
||||
if (jumpToTopAllowed()) {
|
||||
TabLayout layout = Objects.requireNonNull(getActivity()).findViewById(R.id.tab_layout);
|
||||
TabLayout layout = requireActivity().findViewById(R.id.tab_layout);
|
||||
if (layout != null) {
|
||||
onTabSelectedListener = new TabLayout.OnTabSelectedListener() {
|
||||
@Override
|
||||
|
@ -417,8 +417,7 @@ public class TimelineFragment extends SFragment implements
|
|||
@Override
|
||||
public void onDestroyView() {
|
||||
if (jumpToTopAllowed()) {
|
||||
TabLayout tabLayout = Objects.requireNonNull(getActivity())
|
||||
.findViewById(R.id.tab_layout);
|
||||
TabLayout tabLayout = requireActivity().findViewById(R.id.tab_layout);
|
||||
if (tabLayout != null) {
|
||||
tabLayout.removeOnTabSelectedListener(onTabSelectedListener);
|
||||
}
|
||||
|
@ -427,8 +426,7 @@ public class TimelineFragment extends SFragment implements
|
|||
}
|
||||
|
||||
private void setupNothingView() {
|
||||
Drawable top = AppCompatResources.getDrawable(Objects.requireNonNull(getContext()),
|
||||
R.drawable.elephant_friend);
|
||||
Drawable top = AppCompatResources.getDrawable(requireContext(), R.drawable.elephant_friend);
|
||||
if (top != null) {
|
||||
top.setBounds(0, 0, top.getIntrinsicWidth() / 2, top.getIntrinsicHeight() / 2);
|
||||
}
|
||||
|
@ -663,7 +661,7 @@ public class TimelineFragment extends SFragment implements
|
|||
updateAdapter();
|
||||
}
|
||||
|
||||
public void removeAllByAccountId(String accountId) {
|
||||
private void removeAllByAccountId(String accountId) {
|
||||
// using iterator to safely remove items while iterating
|
||||
Iterator<Either<Placeholder, Status>> iterator = statuses.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
|
@ -1067,7 +1065,7 @@ public class TimelineFragment extends SFragment implements
|
|||
public void onInserted(int position, int count) {
|
||||
adapter.notifyItemRangeInserted(position, count);
|
||||
if (position == 0) {
|
||||
recyclerView.scrollBy(0, Utils.dpToPx(Objects.requireNonNull(getContext()), -30));
|
||||
recyclerView.scrollBy(0, Utils.dpToPx(requireContext(), -30));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,6 @@ package com.keylesspalace.tusky.interfaces;
|
|||
|
||||
import android.view.View;
|
||||
|
||||
import com.keylesspalace.tusky.entity.Attachment;
|
||||
|
||||
public interface StatusActionListener extends LinkListener {
|
||||
void onReply(int position);
|
||||
void onReblog(final boolean reblog, final int position);
|
||||
|
|
|
@ -37,7 +37,6 @@ import okhttp3.MultipartBody;
|
|||
import okhttp3.RequestBody;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.DELETE;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
|
@ -185,7 +184,6 @@ public interface MastodonApi {
|
|||
* @param limit Limit returned statuses (current API limits: default - 20, max - 40)
|
||||
* @param excludeReplies only return statuses that are no replies
|
||||
* @param onlyMedia only return statuses that have media attached
|
||||
* @return
|
||||
*/
|
||||
@GET("api/v1/accounts/{id}/statuses")
|
||||
Call<List<Status>> accountStatuses(
|
||||
|
|
|
@ -32,35 +32,8 @@ public class TuskyTileService extends TileService {
|
|||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTileAdded() {
|
||||
super.onTileAdded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTileRemoved() {
|
||||
super.onTileRemoved();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartListening() {
|
||||
super.onStartListening();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopListening() {
|
||||
super.onStopListening();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick() {
|
||||
super.onClick();
|
||||
|
||||
startActivityAndCollapse(new Intent(this, ComposeActivity.class));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
/* Copyright 2017 Andrew Dawson
|
||||
*
|
||||
* This file is a part of Tusky.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with Tusky; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
package com.keylesspalace.tusky.util;
|
||||
|
||||
import com.keylesspalace.tusky.BuildConfig;
|
||||
|
||||
/** Android Studio complains about built-in assertions so this is an alternative. */
|
||||
public class Assert {
|
||||
private static boolean ENABLED = BuildConfig.DEBUG;
|
||||
|
||||
public static void expect(boolean expression) {
|
||||
if (ENABLED && !expression) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -100,7 +100,7 @@ public final class Either<L, R> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Same as {@link #getAsRightOrNull()} but returns {@code null} is the value if Left instead of
|
||||
* Same as {@link #getAsRight()} but returns {@code null} is the value if Left instead of
|
||||
* throwing an exception.
|
||||
* @return contained value as Right or null
|
||||
*/
|
||||
|
|
|
@ -216,7 +216,7 @@ public class EmojiCompatFont {
|
|||
BufferedSink sink = Okio.buffer(Okio.sink(downloadFile));
|
||||
Source source = null;
|
||||
try {
|
||||
long size = 0;
|
||||
long size;
|
||||
// Download!
|
||||
if (response.body() != null
|
||||
&& response.isSuccessful()
|
||||
|
|
|
@ -183,5 +183,4 @@ public class LinkHelper {
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ class ComposeOptionsView @JvmOverloads constructor(context: Context, attrs: Attr
|
|||
directRadioButton.setButtonDrawable(R.drawable.ic_email_24dp)
|
||||
}
|
||||
|
||||
visibilityRadioGroup.setOnCheckedChangeListener({ _, checkedId ->
|
||||
visibilityRadioGroup.setOnCheckedChangeListener { _, checkedId ->
|
||||
val visibility = when (checkedId) {
|
||||
R.id.publicRadioButton ->
|
||||
Status.Visibility.PUBLIC
|
||||
|
@ -52,7 +52,7 @@ class ComposeOptionsView @JvmOverloads constructor(context: Context, attrs: Attr
|
|||
Status.Visibility.PUBLIC
|
||||
}
|
||||
listener?.onVisibilityChanged(visibility)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fun setStatusVisibility(visibility: Status.Visibility) {
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
<vector android:height="40dp" android:viewportHeight="24.0"
|
||||
android:viewportWidth="24.0" android:width="40dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M7,10l5,5 5,-5z"/>
|
||||
</vector>
|
|
@ -1,4 +0,0 @@
|
|||
<vector android:height="40dp" android:viewportHeight="24.0"
|
||||
android:viewportWidth="24.0" android:width="40dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M7,14l5,-5 5,5z"/>
|
||||
</vector>
|
Loading…
Reference in New Issue