fix some lint warnings

This commit is contained in:
Konrad Pozniak 2019-04-20 22:36:44 +02:00 committed by Konrad Pozniak
parent 1ae3e86378
commit ef66deeae7
36 changed files with 52 additions and 105 deletions

View file

@ -55,13 +55,13 @@ class AccountListActivity : BaseActivity(), HasSupportFragmentInjector {
setSupportActionBar(toolbar)
supportActionBar?.apply {
when (type) {
AccountListActivity.Type.BLOCKS -> setTitle(R.string.title_blocks)
AccountListActivity.Type.MUTES -> setTitle(R.string.title_mutes)
AccountListActivity.Type.FOLLOW_REQUESTS -> setTitle(R.string.title_follow_requests)
AccountListActivity.Type.FOLLOWERS -> setTitle(R.string.title_followers)
AccountListActivity.Type.FOLLOWS -> setTitle(R.string.title_follows)
AccountListActivity.Type.REBLOGGED -> setTitle(R.string.title_reblogged_by)
AccountListActivity.Type.FAVOURITED -> setTitle(R.string.title_favourited_by)
Type.BLOCKS -> setTitle(R.string.title_blocks)
Type.MUTES -> setTitle(R.string.title_mutes)
Type.FOLLOW_REQUESTS -> setTitle(R.string.title_follow_requests)
Type.FOLLOWERS -> setTitle(R.string.title_followers)
Type.FOLLOWS -> setTitle(R.string.title_follows)
Type.REBLOGGED -> setTitle(R.string.title_reblogged_by)
Type.FAVOURITED -> setTitle(R.string.title_favourited_by)
}
setDisplayHomeAsUpEnabled(true)
setDisplayShowHomeEnabled(true)

View file

@ -28,7 +28,6 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.keylesspalace.tusky.di.Injectable
import com.keylesspalace.tusky.di.ViewModelFactory
import com.keylesspalace.tusky.entity.Account
@ -75,7 +74,7 @@ class AccountsInListFragment : DialogFragment(), Injectable {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(DialogFragment.STYLE_NORMAL, R.style.TuskyDialogFragmentStyle)
setStyle(STYLE_NORMAL, R.style.TuskyDialogFragmentStyle)
viewModel = viewModelFactory.create(AccountsInListViewModel::class.java)
val args = arguments!!
listId = args.getString(LIST_ID_ARG)!!

View file

@ -118,7 +118,7 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
return true;
}
private int textStyle(String name) {
private static int textStyle(String name) {
int style;
switch (name) {
case "smallest":

View file

@ -22,7 +22,6 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior
import android.view.View
import android.widget.LinearLayout
import com.keylesspalace.tusky.entity.SearchResults
import com.keylesspalace.tusky.entity.Status
import com.keylesspalace.tusky.network.MastodonApi
import com.keylesspalace.tusky.util.LinkHelper
import retrofit2.Call

View file

@ -29,7 +29,6 @@ import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.media.Image;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
@ -53,7 +52,6 @@ import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.MimeTypeMap;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;

View file

@ -248,13 +248,13 @@ class EditProfileActivity : BaseActivity(), Injectable {
intent.addCategory(Intent.CATEGORY_OPENABLE)
intent.type = "image/*"
when (currentlyPicking) {
EditProfileActivity.PickType.AVATAR -> {
PickType.AVATAR -> {
startActivityForResult(intent, AVATAR_PICK_RESULT)
}
EditProfileActivity.PickType.HEADER -> {
PickType.HEADER -> {
startActivityForResult(intent, HEADER_PICK_RESULT)
}
EditProfileActivity.PickType.NOTHING -> { /* do nothing */ }
PickType.NOTHING -> { /* do nothing */ }
}
}
@ -297,18 +297,18 @@ class EditProfileActivity : BaseActivity(), Injectable {
private fun beginMediaPicking() {
when (currentlyPicking) {
EditProfileActivity.PickType.AVATAR -> {
PickType.AVATAR -> {
avatarProgressBar.visibility = View.VISIBLE
avatarPreview.visibility = View.INVISIBLE
avatarButton.setImageDrawable(null)
}
EditProfileActivity.PickType.HEADER -> {
PickType.HEADER -> {
headerProgressBar.visibility = View.VISIBLE
headerPreview.visibility = View.INVISIBLE
headerButton.setImageDrawable(null)
}
EditProfileActivity.PickType.NOTHING -> { /* do nothing */ }
PickType.NOTHING -> { /* do nothing */ }
}
}
@ -359,10 +359,10 @@ class EditProfileActivity : BaseActivity(), Injectable {
beginMediaPicking()
when (currentlyPicking) {
EditProfileActivity.PickType.AVATAR -> {
PickType.AVATAR -> {
viewModel.newAvatar(uri, this)
}
EditProfileActivity.PickType.HEADER -> {
PickType.HEADER -> {
viewModel.newHeader(uri, this)
}
else -> {

View file

@ -92,7 +92,7 @@ class FiltersActivity: BaseActivity() {
}
override fun onFailure(call: Call<Filter>, t: Throwable) {
Toast.makeText(this@FiltersActivity, "Error creating filter '${phrase}'", Toast.LENGTH_SHORT).show()
Toast.makeText(this@FiltersActivity, "Error creating filter '$phrase'", Toast.LENGTH_SHORT).show()
}
})
}

View file

@ -598,7 +598,7 @@ public final class MainActivity extends BottomSheetActivity implements ActionBut
headerResult.setActiveProfile(accountManager.getActiveAccount().getId());
}
private void onFetchUserInfoFailure(Exception exception) {
private static void onFetchUserInfoFailure(Exception exception) {
Log.e(TAG, "Failed to fetch user info. " + exception.getMessage());
}

View file

@ -44,7 +44,6 @@ import dagger.android.DispatchingAndroidInjector;
import dagger.android.HasActivityInjector;
import dagger.android.HasBroadcastReceiverInjector;
import dagger.android.HasServiceInjector;
import okhttp3.OkHttpClient;
public class TuskyApplication extends Application implements HasActivityInjector, HasServiceInjector, HasBroadcastReceiverInjector {
@Inject
@ -55,8 +54,6 @@ public class TuskyApplication extends Application implements HasActivityInjector
DispatchingAndroidInjector<BroadcastReceiver> dispatchingBroadcastReceiverInjector;
@Inject
NotificationPullJobCreator notificationPullJobCreator;
@Inject
OkHttpClient okHttpClient;
private AppDatabase appDatabase;
private AccountManager accountManager;

View file

@ -35,12 +35,12 @@ class AccountFieldAdapter(private val linkListener: LinkListener) : RecyclerView
override fun getItemCount() = fields.size
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AccountFieldAdapter.ViewHolder {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_account_field, parent, false)
return ViewHolder(view)
}
override fun onBindViewHolder(viewHolder: AccountFieldAdapter.ViewHolder, position: Int) {
override fun onBindViewHolder(viewHolder: ViewHolder, position: Int) {
val field = fields[position]
viewHolder.nameTextView.text = field.name
val emojifiedValue = CustomEmojiHelper.emojifyText(field.value, emojis, viewHolder.valueTextView)

View file

@ -56,12 +56,12 @@ class AccountFieldEditAdapter : RecyclerView.Adapter<AccountFieldEditAdapter.Vie
override fun getItemCount(): Int = fieldData.size
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AccountFieldEditAdapter.ViewHolder {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_edit_field, parent, false)
return ViewHolder(view)
}
override fun onBindViewHolder(viewHolder: AccountFieldEditAdapter.ViewHolder, position: Int) {
override fun onBindViewHolder(viewHolder: ViewHolder, position: Int) {
viewHolder.nameTextView.setText(fieldData[position].first)
viewHolder.valueTextView.setText(fieldData[position].second)

View file

@ -1,6 +1,5 @@
package com.keylesspalace.tusky.adapter;
import android.content.Context;
import androidx.recyclerview.widget.RecyclerView;
import android.preference.PreferenceManager;

View file

@ -208,15 +208,15 @@ public class ComposeAutoCompleteAdapter extends BaseAdapter
return view;
}
private String formatUsername(AccountResult result) {
private static String formatUsername(AccountResult result) {
return String.format("@%s", result.account.getUsername());
}
private String formatHashtag(HashtagResult result) {
private static String formatHashtag(HashtagResult result) {
return String.format("#%s", result.hashtag);
}
private String formatEmoji(EmojiResult result) {
private static String formatEmoji(EmojiResult result) {
return String.format(":%s:", result.emoji.getShortcode());
}

View file

@ -34,12 +34,12 @@ class EmojiAdapter(emojiList: List<Emoji>, private val onEmojiSelectedListener:
return emojiList.size
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): EmojiAdapter.EmojiHolder {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): EmojiHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_emoji_button, parent, false) as ImageView
return EmojiHolder(view)
}
override fun onBindViewHolder(viewHolder: EmojiAdapter.EmojiHolder, position: Int) {
override fun onBindViewHolder(viewHolder: EmojiHolder, position: Int) {
val emoji = emojiList[position]
Glide.with(viewHolder.emojiImageView)

View file

@ -17,7 +17,6 @@ package com.keylesspalace.tusky.adapter;
import android.content.Context;
import android.text.InputFilter;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
import android.widget.ToggleButton;

View file

@ -140,7 +140,7 @@ public class ThreadAdapter extends RecyclerView.Adapter {
@Nullable
public StatusViewData.Concrete getItem(int position) {
if (position != RecyclerView.NO_POSITION && position >= 0 && position < statuses.size()) {
if (position >= 0 && position < statuses.size()) {
return statuses.get(position);
} else {
return null;

View file

@ -25,7 +25,7 @@ data class Filter (
val irreversible: Boolean,
@SerializedName("whole_word") val wholeWord: Boolean
) {
public companion object {
companion object {
const val HOME = "home"
const val NOTIFICATIONS = "notifications"
const val PUBLIC = "public"

View file

@ -65,8 +65,8 @@ data class Notification(
class NotificationTypeAdapter : JsonDeserializer<Type> {
@Throws(JsonParseException::class)
override fun deserialize(json: JsonElement, typeOfT: java.lang.reflect.Type, context: JsonDeserializationContext): Notification.Type {
return Notification.Type.byString(json.asString)
override fun deserialize(json: JsonElement, typeOfT: java.lang.reflect.Type, context: JsonDeserializationContext): Type {
return Type.byString(json.asString)
}
}

View file

@ -28,7 +28,6 @@ import androidx.core.view.ViewCompat
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.DownsampleStrategy
import com.keylesspalace.tusky.R
import com.keylesspalace.tusky.ViewMediaActivity
import com.keylesspalace.tusky.di.Injectable
@ -234,9 +233,8 @@ class AccountMediaFragment : BaseFragment(), Injectable {
}
private fun viewMedia(items: List<AttachmentViewData>, currentIndex: Int, view: View?) {
val type = items[currentIndex].attachment.type
when (type) {
when (items[currentIndex].attachment.type) {
Attachment.Type.IMAGE,
Attachment.Type.GIFV,
Attachment.Type.VIDEO -> {

View file

@ -34,7 +34,6 @@ import android.widget.ProgressBar;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.tabs.TabLayout;
import com.keylesspalace.tusky.R;
import com.keylesspalace.tusky.adapter.NotificationsAdapter;
import com.keylesspalace.tusky.adapter.StatusBaseViewHolder;
@ -154,7 +153,6 @@ public class NotificationsFragment extends SFragment implements
private LinearLayoutManager layoutManager;
private EndlessOnScrollListener scrollListener;
private NotificationsAdapter adapter;
private TabLayout.OnTabSelectedListener onTabSelectedListener;
private Button buttonFilter;
private boolean hideFab;
private boolean topLoading;

View file

@ -84,13 +84,13 @@ class ViewVideoFragment : ViewMediaFragment() {
videoView.setOnPreparedListener { mp ->
progressBar.hide()
mp.isLooping = true
if (arguments!!.getBoolean(ViewMediaFragment.ARG_START_POSTPONED_TRANSITION)) {
if (arguments!!.getBoolean(ARG_START_POSTPONED_TRANSITION)) {
hideToolbarAfterDelay(TOOLBAR_HIDE_DELAY_MS)
videoView.start()
}
}
if (arguments!!.getBoolean(ViewMediaFragment.ARG_START_POSTPONED_TRANSITION)) {
if (arguments!!.getBoolean(ARG_START_POSTPONED_TRANSITION)) {
mediaActivity.onBringUp()
}
}
@ -107,7 +107,7 @@ class ViewVideoFragment : ViewMediaFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val attachment = arguments?.getParcelable<Attachment>(ViewMediaFragment.ARG_ATTACHMENT)
val attachment = arguments?.getParcelable<Attachment>(ARG_ATTACHMENT)
val url: String
if (attachment == null) {

View file

@ -273,7 +273,7 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(),
return drawable
}
fun launchFilterActivity(filterContext: String, titleResource: Int): Boolean {
private fun launchFilterActivity(filterContext: String, titleResource: Int): Boolean {
val intent = Intent(context, FiltersActivity::class.java)
intent.putExtra(FiltersActivity.FILTERS_CONTEXT, filterContext)
intent.putExtra(FiltersActivity.FILTERS_TITLE, getString(titleResource))

View file

@ -18,7 +18,6 @@ package com.keylesspalace.tusky.fragment.preference
import android.content.SharedPreferences
import android.os.Bundle
import androidx.preference.EditTextPreference
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import com.keylesspalace.tusky.R

View file

@ -89,7 +89,7 @@ class TimelineCasesImpl(
override fun block(id: String) {
val call = mastodonApi.blockAccount(id)
call.enqueue(object : Callback<Relationship> {
override fun onResponse(call: Call<Relationship>, response: retrofit2.Response<Relationship>) {}
override fun onResponse(call: Call<Relationship>, response: Response<Relationship>) {}
override fun onFailure(call: Call<Relationship>, t: Throwable) {}
})
@ -100,7 +100,7 @@ class TimelineCasesImpl(
override fun delete(id: String) {
val call = mastodonApi.deleteStatus(id)
call.enqueue(object : Callback<ResponseBody> {
override fun onResponse(call: Call<ResponseBody>, response: retrofit2.Response<ResponseBody>) {}
override fun onResponse(call: Call<ResponseBody>, response: Response<ResponseBody>) {}
override fun onFailure(call: Call<ResponseBody>, t: Throwable) {}
})

View file

@ -43,6 +43,7 @@ public class AccountPagerAdapter extends FragmentPagerAdapter {
pageTitles = titles;
}
@NonNull
@Override
public Fragment getItem(int position) {
switch (position) {

View file

@ -28,7 +28,6 @@ public class HtmlUtils {
return s.subSequence(0, i + 1);
}
@SuppressWarnings("deprecation")
public static Spanned fromHtml(String html) {
Spanned result;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
@ -41,7 +40,6 @@ public class HtmlUtils {
return (Spanned) trimTrailingWhitespace(result);
}
@SuppressWarnings("deprecation")
public static String toHtml(Spanned text) {
String result;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {

View file

@ -18,7 +18,6 @@ package com.keylesspalace.tusky.util;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.preference.PreferenceManager;
import androidx.annotation.Nullable;

View file

@ -244,7 +244,6 @@ public class NotificationHelper {
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
//noinspection ConstantConditions
notificationManager.notify(notificationId, builder.build());
if (currentNotifications.length() == 1) {
notificationManager.notify((int) account.getId(), builder.setGroupSummary(true).build());
@ -375,7 +374,6 @@ public class NotificationHelper {
channels.add(channel);
}
//noinspection ConstantConditions
notificationManager.createNotificationChannels(channels);
}

View file

@ -26,7 +26,7 @@ import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* A helper class for {@link androidx.paging.PagedList.BoundaryCallback BoundaryCallback}s and
* {@link DataSource}s to help with tracking network requests.
* {@link androidx.paging.DataSource}s to help with tracking network requests.
* <p>
* It is designed to support 3 types of requests, {@link RequestType#INITIAL INITIAL},
* {@link RequestType#BEFORE BEFORE} and {@link RequestType#AFTER AFTER} and runs only 1 request
@ -456,18 +456,18 @@ public class PagingRequestHelper {
*/
public enum RequestType {
/**
* Corresponds to an initial request made to a {@link DataSource} or the empty state for
* Corresponds to an initial request made to a {@link androidx.paging.DataSource} or the empty state for
* a {@link androidx.paging.PagedList.BoundaryCallback BoundaryCallback}.
*/
INITIAL,
/**
* Corresponds to the {@code loadBefore} calls in {@link DataSource} or
* Corresponds to the {@code loadBefore} calls in {@link androidx.paging.DataSource} or
* {@code onItemAtFrontLoaded} in
* {@link androidx.paging.PagedList.BoundaryCallback BoundaryCallback}.
*/
BEFORE,
/**
* Corresponds to the {@code loadAfter} calls in {@link DataSource} or
* Corresponds to the {@code loadAfter} calls in {@link androidx.paging.DataSource} or
* {@code onItemAtEndLoaded} in
* {@link androidx.paging.PagedList.BoundaryCallback BoundaryCallback}.
*/

View file

@ -77,10 +77,10 @@ defStyleAttr: Int = 0
* even if we have a focus point set.
*/
override fun getScaleType(): ScaleType {
if (focus != null) {
return ScaleType.CENTER_CROP
return if (focus != null) {
ScaleType.CENTER_CROP
} else {
return super.getScaleType()
super.getScaleType()
}
}

View file

@ -194,12 +194,10 @@ public class RoundedImageView extends AppCompatImageView {
}
private void applyColorFilter() {
if (mBitmapPaint != null) {
mBitmapPaint.setColorFilter(mColorFilter);
}
}
private Bitmap getBitmapFromDrawable(Drawable drawable) {
private static Bitmap getBitmapFromDrawable(Drawable drawable) {
if (drawable == null) {
return null;
}

View file

@ -269,7 +269,7 @@ public abstract class StatusViewData {
@Override public long getViewDataId() {
// Chance of collision is super low and impact of mistake is low as well
return getId().hashCode();
return id.hashCode();
}
public boolean deepEquals(StatusViewData o) {
@ -311,7 +311,7 @@ public abstract class StatusViewData {
}
static CharSequence replaceCrashingCharacters(CharSequence content) {
Boolean replacing = false;
boolean replacing = false;
SpannableStringBuilder builder = null;
int length = content.length();

View file

@ -54,7 +54,7 @@ internal class ListsViewModel @Inject constructor(private val api: MastodonApi)
private fun loadIfNeeded() {
val state = _state.value!!
if (state.loadingState == LoadingState.LOADING || !state.lists.isEmpty()) return
if (state.loadingState == LoadingState.LOADING || state.lists.isNotEmpty()) return
updateState {
copy(loadingState = LoadingState.LOADING)
}

View file

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<scale
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="300"
android:fromXScale="0"
android:fromYScale="0"

View file

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="4dp" />
<solid android:color="?attr/window_background" />
</shape>

View file

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/filter_favourites"
android:checkable="true"
android:checked="true"
android:title="@string/filter_favorites" />
<item
android:id="@+id/filter_boosts"
android:checkable="true"
android:checked="true"
android:title="@string/filter_boosts" />
<item
android:id="@+id/filter_follows"
android:checkable="true"
android:checked="true"
android:title="@string/filter_follows" />
<item
android:id="@+id/filter_mentions"
android:checkable="true"
android:checked="true"
android:title="@string/filter_mentions" />
<item
android:id="@+id/filter_apply"
android:title="@string/filter_apply" />
</menu>