cleanup code

This commit is contained in:
Conny Duck 2018-06-25 14:44:29 +02:00
parent 3c685800d8
commit 50b0d1fb8d
15 changed files with 13 additions and 90 deletions

View File

@ -17,7 +17,6 @@ package com.keylesspalace.tusky;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;

View File

@ -75,7 +75,7 @@ class NetworkModule {
.apply { .apply {
addInterceptor(InstanceSwitchAuthInterceptor(accountManager)) addInterceptor(InstanceSwitchAuthInterceptor(accountManager))
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)) addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BASIC))
} }
} }
.build() .build()

View File

@ -21,7 +21,6 @@ import android.os.Bundle
import android.support.v4.app.ActivityOptionsCompat import android.support.v4.app.ActivityOptionsCompat
import android.support.v4.content.ContextCompat import android.support.v4.content.ContextCompat
import android.support.v4.view.ViewCompat import android.support.v4.view.ViewCompat
import android.support.v4.widget.SwipeRefreshLayout
import android.support.v7.widget.GridLayoutManager import android.support.v7.widget.GridLayoutManager
import android.support.v7.widget.RecyclerView import android.support.v7.widget.RecyclerView
import android.util.Log import android.util.Log
@ -29,8 +28,6 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ImageView import android.widget.ImageView
import android.widget.ProgressBar
import android.widget.TextView
import com.keylesspalace.tusky.R import com.keylesspalace.tusky.R
import com.keylesspalace.tusky.ViewMediaActivity import com.keylesspalace.tusky.ViewMediaActivity
import com.keylesspalace.tusky.ViewVideoActivity import com.keylesspalace.tusky.ViewVideoActivity

View File

@ -58,8 +58,6 @@ import javax.inject.Inject;
* 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 abstract class SFragment extends BaseFragment { public abstract class SFragment extends BaseFragment {
protected static final int COMPOSE_RESULT = 1;
protected String loggedInAccountId; protected String loggedInAccountId;
protected String loggedInUsername; protected String loggedInUsername;
@ -137,7 +135,7 @@ public abstract class SFragment extends BaseFragment {
.repyingStatusAuthor(actionableStatus.getAccount().getLocalUsername()) .repyingStatusAuthor(actionableStatus.getAccount().getLocalUsername())
.replyingStatusContent(actionableStatus.getContent().toString()) .replyingStatusContent(actionableStatus.getContent().toString())
.build(getContext()); .build(getContext());
startActivityForResult(intent, COMPOSE_RESULT); startActivity(intent);
} }
protected void more(final Status status, View view, final int position) { protected void more(final Status status, View view, final int position) {

View File

@ -266,7 +266,7 @@ public class TimelineFragment extends SFragment implements
} }
private void setupSwipeRefreshLayout() { private void setupSwipeRefreshLayout() {
Context context = Objects.requireNonNull(getContext()); Context context = requireContext();
swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setOnRefreshListener(this);
swipeRefreshLayout.setColorSchemeResources(R.color.primary); swipeRefreshLayout.setColorSchemeResources(R.color.primary);
swipeRefreshLayout.setProgressBackgroundColorSchemeColor(ThemeUtils.getColor(context, swipeRefreshLayout.setProgressBackgroundColorSchemeColor(ThemeUtils.getColor(context,
@ -274,7 +274,7 @@ public class TimelineFragment extends SFragment implements
} }
private void setupRecyclerView() { private void setupRecyclerView() {
Context context = Objects.requireNonNull(getContext()); Context context = requireContext();
recyclerView.setHasFixedSize(true); recyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(context); layoutManager = new LinearLayoutManager(context);
recyclerView.setLayoutManager(layoutManager); recyclerView.setLayoutManager(layoutManager);
@ -349,7 +349,7 @@ public class TimelineFragment extends SFragment implements
super.onActivityCreated(savedInstanceState); super.onActivityCreated(savedInstanceState);
if (jumpToTopAllowed()) { if (jumpToTopAllowed()) {
TabLayout layout = Objects.requireNonNull(getActivity()).findViewById(R.id.tab_layout); TabLayout layout = requireActivity().findViewById(R.id.tab_layout);
if (layout != null) { if (layout != null) {
onTabSelectedListener = new TabLayout.OnTabSelectedListener() { onTabSelectedListener = new TabLayout.OnTabSelectedListener() {
@Override @Override
@ -417,8 +417,7 @@ public class TimelineFragment extends SFragment implements
@Override @Override
public void onDestroyView() { public void onDestroyView() {
if (jumpToTopAllowed()) { if (jumpToTopAllowed()) {
TabLayout tabLayout = Objects.requireNonNull(getActivity()) TabLayout tabLayout = requireActivity().findViewById(R.id.tab_layout);
.findViewById(R.id.tab_layout);
if (tabLayout != null) { if (tabLayout != null) {
tabLayout.removeOnTabSelectedListener(onTabSelectedListener); tabLayout.removeOnTabSelectedListener(onTabSelectedListener);
} }
@ -427,8 +426,7 @@ public class TimelineFragment extends SFragment implements
} }
private void setupNothingView() { private void setupNothingView() {
Drawable top = AppCompatResources.getDrawable(Objects.requireNonNull(getContext()), Drawable top = AppCompatResources.getDrawable(requireContext(), R.drawable.elephant_friend);
R.drawable.elephant_friend);
if (top != null) { if (top != null) {
top.setBounds(0, 0, top.getIntrinsicWidth() / 2, top.getIntrinsicHeight() / 2); top.setBounds(0, 0, top.getIntrinsicWidth() / 2, top.getIntrinsicHeight() / 2);
} }
@ -663,7 +661,7 @@ public class TimelineFragment extends SFragment implements
updateAdapter(); updateAdapter();
} }
public void removeAllByAccountId(String accountId) { private void removeAllByAccountId(String accountId) {
// using iterator to safely remove items while iterating // using iterator to safely remove items while iterating
Iterator<Either<Placeholder, Status>> iterator = statuses.iterator(); Iterator<Either<Placeholder, Status>> iterator = statuses.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
@ -1067,7 +1065,7 @@ public class TimelineFragment extends SFragment implements
public void onInserted(int position, int count) { public void onInserted(int position, int count) {
adapter.notifyItemRangeInserted(position, count); adapter.notifyItemRangeInserted(position, count);
if (position == 0) { if (position == 0) {
recyclerView.scrollBy(0, Utils.dpToPx(Objects.requireNonNull(getContext()), -30)); recyclerView.scrollBy(0, Utils.dpToPx(requireContext(), -30));
} }
} }

View File

@ -17,8 +17,6 @@ package com.keylesspalace.tusky.interfaces;
import android.view.View; import android.view.View;
import com.keylesspalace.tusky.entity.Attachment;
public interface StatusActionListener extends LinkListener { public interface StatusActionListener extends LinkListener {
void onReply(int position); void onReply(int position);
void onReblog(final boolean reblog, final int position); void onReblog(final boolean reblog, final int position);

View File

@ -37,7 +37,6 @@ import okhttp3.MultipartBody;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import okhttp3.ResponseBody; import okhttp3.ResponseBody;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.DELETE; import retrofit2.http.DELETE;
import retrofit2.http.Field; import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded; import retrofit2.http.FormUrlEncoded;
@ -185,7 +184,6 @@ public interface MastodonApi {
* @param limit Limit returned statuses (current API limits: default - 20, max - 40) * @param limit Limit returned statuses (current API limits: default - 20, max - 40)
* @param excludeReplies only return statuses that are no replies * @param excludeReplies only return statuses that are no replies
* @param onlyMedia only return statuses that have media attached * @param onlyMedia only return statuses that have media attached
* @return
*/ */
@GET("api/v1/accounts/{id}/statuses") @GET("api/v1/accounts/{id}/statuses")
Call<List<Status>> accountStatuses( Call<List<Status>> accountStatuses(

View File

@ -32,35 +32,8 @@ public class TuskyTileService extends TileService {
super(); 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 @Override
public void onClick() { public void onClick() {
super.onClick();
startActivityAndCollapse(new Intent(this, ComposeActivity.class)); startActivityAndCollapse(new Intent(this, ComposeActivity.class));
} }
} }

View File

@ -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();
}
}
}

View File

@ -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. * throwing an exception.
* @return contained value as Right or null * @return contained value as Right or null
*/ */

View File

@ -216,7 +216,7 @@ public class EmojiCompatFont {
BufferedSink sink = Okio.buffer(Okio.sink(downloadFile)); BufferedSink sink = Okio.buffer(Okio.sink(downloadFile));
Source source = null; Source source = null;
try { try {
long size = 0; long size;
// Download! // Download!
if (response.body() != null if (response.body() != null
&& response.isSuccessful() && response.isSuccessful()

View File

@ -183,5 +183,4 @@ public class LinkHelper {
} }
} }

View File

@ -38,7 +38,7 @@ class ComposeOptionsView @JvmOverloads constructor(context: Context, attrs: Attr
directRadioButton.setButtonDrawable(R.drawable.ic_email_24dp) directRadioButton.setButtonDrawable(R.drawable.ic_email_24dp)
} }
visibilityRadioGroup.setOnCheckedChangeListener({ _, checkedId -> visibilityRadioGroup.setOnCheckedChangeListener { _, checkedId ->
val visibility = when (checkedId) { val visibility = when (checkedId) {
R.id.publicRadioButton -> R.id.publicRadioButton ->
Status.Visibility.PUBLIC Status.Visibility.PUBLIC
@ -52,7 +52,7 @@ class ComposeOptionsView @JvmOverloads constructor(context: Context, attrs: Attr
Status.Visibility.PUBLIC Status.Visibility.PUBLIC
} }
listener?.onVisibilityChanged(visibility) listener?.onVisibilityChanged(visibility)
}) }
} }
fun setStatusVisibility(visibility: Status.Visibility) { fun setStatusVisibility(visibility: Status.Visibility) {

View File

@ -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>

View File

@ -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>