fixing lint problems
This commit is contained in:
parent
51f05c0f68
commit
b69f89df8b
|
@ -18,6 +18,7 @@
|
|||
|
||||
package org.mariotaku.microblog.library.twitter.auth;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Base64;
|
||||
|
||||
import org.mariotaku.restfu.RestRequest;
|
||||
|
@ -38,7 +39,7 @@ public final class BasicAuthorization implements Authorization {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getHeader(Endpoint endpoint, RestRequest info) {
|
||||
public String getHeader(@NonNull Endpoint endpoint, @NonNull RestRequest info) {
|
||||
if (!hasAuthorization()) return null;
|
||||
return "Basic " + Base64.encodeToString((user + ":" + password).getBytes(), Base64.NO_WRAP);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
package org.mariotaku.microblog.library.twitter.auth;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import org.mariotaku.restfu.RestRequest;
|
||||
import org.mariotaku.restfu.http.Authorization;
|
||||
import org.mariotaku.restfu.http.Endpoint;
|
||||
|
@ -34,7 +36,7 @@ public class BearerAuthorization implements Authorization {
|
|||
|
||||
|
||||
@Override
|
||||
public String getHeader(Endpoint endpoint, RestRequest info) {
|
||||
public String getHeader(@NonNull Endpoint endpoint, @NonNull RestRequest info) {
|
||||
return "Bearer " + accessToken;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
package org.mariotaku.microblog.library.twitter.auth;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import org.mariotaku.restfu.RestRequest;
|
||||
import org.mariotaku.restfu.http.Authorization;
|
||||
import org.mariotaku.restfu.http.Endpoint;
|
||||
|
@ -28,7 +30,7 @@ import org.mariotaku.restfu.http.Endpoint;
|
|||
public final class EmptyAuthorization implements Authorization {
|
||||
|
||||
@Override
|
||||
public String getHeader(Endpoint endpoint, RestRequest info) {
|
||||
public String getHeader(@NonNull Endpoint endpoint, @NonNull RestRequest info) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
package org.mariotaku.microblog.library.twitter.model;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.bluelinelabs.logansquare.LoganSquare;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
|
||||
|
@ -49,15 +51,16 @@ public class CardDataMap implements ValueMap {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String key) {
|
||||
public boolean has(@NonNull String key) {
|
||||
return map.containsKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(String key) {
|
||||
public Object get(@NonNull String key) {
|
||||
return map.get(key);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String[] keys() {
|
||||
final Set<String> keySet = map.keySet();
|
||||
|
@ -72,8 +75,9 @@ public class CardDataMap implements ValueMap {
|
|||
}
|
||||
|
||||
public static class BodyConverter implements RestConverter<CardDataMap, Body, MicroBlogException> {
|
||||
@NonNull
|
||||
@Override
|
||||
public Body convert(CardDataMap obj) throws ConvertException, IOException, MicroBlogException {
|
||||
public Body convert(@NonNull CardDataMap obj) throws ConvertException, IOException, MicroBlogException {
|
||||
final StringWriter sw = new StringWriter();
|
||||
final JsonGenerator generator = LoganSquare.JSON_FACTORY.createGenerator(sw);
|
||||
generator.writeStartObject();
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.mariotaku.microblog.library.twitter.model;
|
|||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
|
||||
|
||||
|
@ -100,17 +101,18 @@ public class GeoLocation implements ValueMap, Parcelable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String key) {
|
||||
public boolean has(@NonNull String key) {
|
||||
return "lat".equals(key) || "long".equals(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(String key) {
|
||||
public Object get(@NonNull String key) {
|
||||
if ("lat".equals(key)) return latitude;
|
||||
if ("long".equals(key)) return longitude;
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String[] keys() {
|
||||
return new String[]{"lat", "long"};
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
package org.mariotaku.microblog.library.twitter.model;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import org.mariotaku.restfu.http.ValueMap;
|
||||
|
||||
|
||||
|
@ -162,7 +164,7 @@ public final class GeoQuery implements ValueMap {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String key) {
|
||||
public boolean has(@NonNull String key) {
|
||||
switch (key) {
|
||||
case "lat":
|
||||
case "long": {
|
||||
|
@ -185,7 +187,7 @@ public final class GeoQuery implements ValueMap {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String get(String key) {
|
||||
public String get(@NonNull String key) {
|
||||
switch (key) {
|
||||
case "lat": {
|
||||
if (location == null) return null;
|
||||
|
|
|
@ -20,12 +20,12 @@ package org.mariotaku.twidere.model;
|
|||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.bluelinelabs.logansquare.annotation.JsonField;
|
||||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.mariotaku.commons.objectcursor.LoganSquareCursorFieldConverter;
|
||||
import org.mariotaku.library.objectcursor.annotation.CursorField;
|
||||
import org.mariotaku.library.objectcursor.annotation.CursorObject;
|
||||
|
|
|
@ -38,8 +38,11 @@ import java.util.List;
|
|||
@ParcelablePlease
|
||||
public class UserKey implements Comparable<UserKey>, Parcelable {
|
||||
|
||||
@NonNull
|
||||
private static final String ID_PLACEHOLDER = "#placeholder";
|
||||
@NonNull
|
||||
public static final UserKey SELF = new UserKey("#self#", "#self#");
|
||||
@NonNull
|
||||
public static final UserKey INVALID = new UserKey("#invalid#", "#invalid#");
|
||||
|
||||
public static final Creator<UserKey> CREATOR = new Creator<UserKey>() {
|
||||
|
|
|
@ -25,8 +25,6 @@ import com.bluelinelabs.logansquare.annotation.JsonField;
|
|||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
|
||||
|
||||
import org.mariotaku.microblog.library.twitter.model.DMResponse;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2017/2/13.
|
||||
*/
|
||||
|
|
|
@ -13,11 +13,11 @@ public class MainActivity extends Activity {
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub);
|
||||
final WatchViewStub stub = findViewById(R.id.watch_view_stub);
|
||||
stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
|
||||
@Override
|
||||
public void onLayoutInflated(WatchViewStub stub) {
|
||||
mTextView = (TextView) stub.findViewById(R.id.text);
|
||||
mTextView = stub.findViewById(R.id.text);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.mariotaku.twidere.util;
|
|||
|
||||
import android.app.Application;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.webkit.WebView;
|
||||
|
||||
import com.facebook.stetho.DumperPluginsProvider;
|
||||
|
@ -56,7 +57,7 @@ public class DebugModeUtils {
|
|||
|
||||
builder.addNetworkInterceptor(new Interceptor() {
|
||||
@Override
|
||||
public Response intercept(Chain chain) throws IOException {
|
||||
public Response intercept(@NonNull Chain chain) throws IOException {
|
||||
if (chain.request().tag() == NoIntercept.INSTANCE) {
|
||||
return chain.proceed(chain.request());
|
||||
}
|
||||
|
|
|
@ -316,12 +316,10 @@ class AccountsDumperPlugin(val context: Context) : DumperPlugin {
|
|||
return JsonPath.parse(JsonSerializer.serialize(details), configuration)
|
||||
}
|
||||
|
||||
private fun Any.prettyPrint() = if (this is JSONObject) {
|
||||
toString(4)
|
||||
} else if (this is JSONArray) {
|
||||
toString(4)
|
||||
} else {
|
||||
toString()
|
||||
private fun Any.prettyPrint() = when {
|
||||
this is JSONObject -> toString(4)
|
||||
this is JSONArray -> toString(4)
|
||||
else -> toString()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--suppress XmlUnboundNsPrefix -->
|
||||
<android>
|
||||
<config>
|
||||
<overridenavbar />
|
||||
|
|
|
@ -26,6 +26,7 @@ package io.nayuki.qrcodegen;
|
|||
import android.support.annotation.NonNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
@ -69,7 +70,7 @@ public final class QrCode {
|
|||
*/
|
||||
public static QrCode encodeBinary(@NonNull byte[] data, @NonNull Ecc ecl) {
|
||||
QrSegment seg = QrSegment.makeBytes(data);
|
||||
return encodeSegments(Arrays.asList(seg), ecl);
|
||||
return encodeSegments(Collections.singletonList(seg), ecl);
|
||||
}
|
||||
|
||||
|
||||
|
@ -691,7 +692,7 @@ public final class QrCode {
|
|||
final int formatBits;
|
||||
|
||||
// Constructor.
|
||||
private Ecc(int fb) {
|
||||
Ecc(int fb) {
|
||||
formatBits = fb;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -254,7 +254,7 @@ public final class QrSegment {
|
|||
|
||||
/*-- Constructor --*/
|
||||
|
||||
private Mode(int mode, int... ccbits) {
|
||||
Mode(int mode, int... ccbits) {
|
||||
this.modeBits = mode;
|
||||
numBitsCharCount = ccbits;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ public class SavedSearchesAdapter extends BaseAdapter {
|
|||
public View getView(final int position, final View convertView, final ViewGroup parent) {
|
||||
final View view = convertView != null ? convertView : mInflater.inflate(
|
||||
android.R.layout.simple_list_item_1, null);
|
||||
final TextView text = (TextView) view.findViewById(android.R.id.text1);
|
||||
final TextView text = view.findViewById(android.R.id.text1);
|
||||
text.setText(getItem(position).getName());
|
||||
return view;
|
||||
}
|
||||
|
|
|
@ -20,8 +20,6 @@ import android.content.Context;
|
|||
import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.IntRange;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.RecyclerView.Adapter;
|
||||
|
@ -114,7 +112,7 @@ public class ExtendedDividerItemDecoration extends RecyclerView.ItemDecoration {
|
|||
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
|
||||
.getLayoutParams();
|
||||
final int top = child.getBottom() + params.bottomMargin +
|
||||
Math.round(ViewCompat.getTranslationY(child));
|
||||
Math.round(child.getTranslationY());
|
||||
final int bottom = top + mDivider.getIntrinsicHeight();
|
||||
if (mPadding != null && mPadding.get(childPos, mPaddingRect)) {
|
||||
mDivider.setBounds(left + mPaddingRect.left, top + mPaddingRect.top, right - mPaddingRect.right,
|
||||
|
@ -145,7 +143,7 @@ public class ExtendedDividerItemDecoration extends RecyclerView.ItemDecoration {
|
|||
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
|
||||
.getLayoutParams();
|
||||
final int left = child.getRight() + params.rightMargin +
|
||||
Math.round(ViewCompat.getTranslationX(child));
|
||||
Math.round(child.getTranslationX());
|
||||
final int right = left + mDivider.getIntrinsicHeight();
|
||||
|
||||
mDivider.setBounds(left + mPaddingRect.left, top + mPaddingRect.top, right - mPaddingRect.right,
|
||||
|
|
|
@ -200,7 +200,7 @@ public final class DataExportImportTypeSelectorDialogFragment extends BaseDialog
|
|||
@Override
|
||||
public View getView(final int position, @Nullable final View convertView, final ViewGroup parent) {
|
||||
final View view = super.getView(position, convertView, parent);
|
||||
final TextView text1 = (TextView) view.findViewById(android.R.id.text1);
|
||||
final TextView text1 = view.findViewById(android.R.id.text1);
|
||||
text1.setText(getItem(position).title);
|
||||
view.setEnabled(isEnabled(position));
|
||||
return view;
|
||||
|
|
|
@ -20,8 +20,6 @@ import android.os.Bundle;
|
|||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.preference.ListPreference;
|
||||
|
||||
import org.mariotaku.twidere.util.TwidereArrayUtils;
|
||||
|
||||
public class ThemedListPreferenceDialogFragmentCompat extends ThemedPreferenceDialogFragmentCompat {
|
||||
private int mClickedDialogEntryIndex;
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.mariotaku.twidere.annotation.AccountType;
|
|||
import org.mariotaku.twidere.model.util.UserKeyCursorFieldConverter;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Accounts;
|
||||
|
||||
@SuppressWarnings("DeprecatedIsStillUsed")
|
||||
@CursorObject
|
||||
@Deprecated
|
||||
public class ParcelableAccount {
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.mariotaku.twidere.provider.TwidereDataStore.Accounts;
|
|||
/**
|
||||
* Created by mariotaku on 15/5/26.
|
||||
*/
|
||||
@SuppressWarnings("DeprecatedIsStillUsed")
|
||||
@CursorObject
|
||||
@Deprecated
|
||||
public class ParcelableCredentials extends ParcelableAccount {
|
||||
|
|
|
@ -21,10 +21,10 @@ package org.mariotaku.twidere.model.pagination;
|
|||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.mariotaku.microblog.library.twitter.model.Paging;
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,10 +21,10 @@ package org.mariotaku.twidere.model.pagination;
|
|||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.mariotaku.microblog.library.twitter.model.Paging;
|
||||
|
||||
/**
|
||||
|
|
|
@ -209,13 +209,13 @@ public class SeekBarDialogPreference extends DialogPreference implements IDialog
|
|||
super.onBindDialogView(view);
|
||||
final SeekBarDialogPreference preference = (SeekBarDialogPreference) getPreference();
|
||||
final CharSequence message = preference.getDialogMessage();
|
||||
final TextView dialogMessageText = (TextView) view.findViewById(R.id.text_dialog_message);
|
||||
final TextView dialogMessageText = view.findViewById(R.id.text_dialog_message);
|
||||
dialogMessageText.setText(message);
|
||||
dialogMessageText.setVisibility(TextUtils.isEmpty(message) ? View.GONE : View.VISIBLE);
|
||||
|
||||
mProgressText = (TextView) view.findViewById(R.id.text_progress);
|
||||
mProgressText = view.findViewById(R.id.text_progress);
|
||||
|
||||
mSeekBar = (SeekBar) view.findViewById(R.id.seek_bar);
|
||||
mSeekBar = view.findViewById(R.id.seek_bar);
|
||||
mSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(final SeekBar seekBar, final int progress, final boolean fromUser) {
|
||||
|
|
|
@ -184,7 +184,7 @@ public class ThemeBackgroundPreference extends DialogPreference implements Const
|
|||
final View view = inflater.inflate(R.layout.dialog_theme_background_preference, listViewParent);
|
||||
((ViewGroup) view.findViewById(R.id.list_container)).addView(listView);
|
||||
mAlphaContainer = view.findViewById(R.id.alpha_container);
|
||||
mAlphaSlider = (SeekBar) view.findViewById(R.id.alpha_slider);
|
||||
mAlphaSlider = view.findViewById(R.id.alpha_slider);
|
||||
mAlphaSlider.setMax(MAX_ALPHA - MIN_ALPHA);
|
||||
mAlphaSlider.setProgress(preferences.getInt(KEY_THEME_BACKGROUND_ALPHA, DEFAULT_THEME_BACKGROUND_ALPHA) - MIN_ALPHA);
|
||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
|
|
|
@ -94,7 +94,7 @@ public class MicroBlogAPIFactory implements TwidereConstants {
|
|||
|
||||
@NonNull
|
||||
public static String getApiBaseUrl(@NonNull String format, @Nullable final String domain) {
|
||||
final Matcher matcher = Pattern.compile("\\[(\\.?)DOMAIN(\\.?)\\]", Pattern.CASE_INSENSITIVE).matcher(format);
|
||||
final Matcher matcher = Pattern.compile("\\[(\\.?)DOMAIN(\\.?)]", Pattern.CASE_INSENSITIVE).matcher(format);
|
||||
final String baseUrl;
|
||||
if (!matcher.find()) {
|
||||
// For backward compatibility
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.mariotaku.twidere.util;
|
|||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.view.MotionEventCompat;
|
||||
import android.view.InputDevice;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
@ -75,7 +74,7 @@ public class MouseScrollDirectionDecider {
|
|||
if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) == 0) {
|
||||
return false;
|
||||
}
|
||||
if (event.getAction() != MotionEventCompat.ACTION_SCROLL) return false;
|
||||
if (event.getAction() != MotionEvent.ACTION_SCROLL) return false;
|
||||
verticalScroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
|
||||
horizontalScroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL);
|
||||
verticalView.onGenericMotionEvent(event);
|
||||
|
|
|
@ -24,7 +24,6 @@ import android.content.Context;
|
|||
import android.content.ContextWrapper;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.mariotaku.twidere.util.net;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -11,12 +13,12 @@ public final class SimpleCookieJar implements CookieJar {
|
|||
private final List<Cookie> allCookies = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public synchronized void saveFromResponse(HttpUrl url, List<Cookie> cookies) {
|
||||
public synchronized void saveFromResponse(@NonNull HttpUrl url, @NonNull List<Cookie> cookies) {
|
||||
allCookies.addAll(cookies);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized List<Cookie> loadForRequest(HttpUrl url) {
|
||||
public synchronized List<Cookie> loadForRequest(@NonNull HttpUrl url) {
|
||||
List<Cookie> result = new ArrayList<>();
|
||||
for (Cookie cookie : allCookies) {
|
||||
if (cookie.matches(url)) {
|
||||
|
|
|
@ -25,7 +25,6 @@ import android.content.res.TypedArray;
|
|||
import android.os.SystemClock;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.support.v4.widget.ScrollerCompat;
|
||||
import android.support.v4.widget.ViewDragHelper;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.GestureDetector;
|
||||
|
@ -34,6 +33,7 @@ import android.view.LayoutInflater;
|
|||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.OverScroller;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.util.TwidereMathUtils;
|
||||
|
@ -46,7 +46,7 @@ import org.mariotaku.twidere.util.TwidereMathUtils;
|
|||
public class HeaderDrawerLayout extends ViewGroup {
|
||||
|
||||
private final ViewDragHelper mDragHelper;
|
||||
private final ScrollerCompat mScroller;
|
||||
private final OverScroller mScroller;
|
||||
private final GestureDetector mGestureDetector;
|
||||
|
||||
private final InternalContainer mContainer;
|
||||
|
@ -70,7 +70,7 @@ public class HeaderDrawerLayout extends ViewGroup {
|
|||
a.recycle();
|
||||
mDragHelper = ViewDragHelper.create(this, mDragCallback = new DragCallback(this));
|
||||
mGestureDetector = new GestureDetector(context, new GestureListener(this));
|
||||
mScroller = ScrollerCompat.create(context);
|
||||
mScroller = new OverScroller(context);
|
||||
}
|
||||
|
||||
public HeaderDrawerLayout(Context context, AttributeSet attrs) {
|
||||
|
|
|
@ -25,7 +25,6 @@ import android.os.Parcel;
|
|||
import android.os.Parcelable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.view.MotionEventCompat;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
|
@ -213,11 +212,11 @@ public class LinePageIndicator extends View implements PagerIndicator {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(@NonNull final android.view.MotionEvent ev) {
|
||||
public boolean onTouchEvent(@NonNull final MotionEvent ev) {
|
||||
if (super.onTouchEvent(ev)) return true;
|
||||
if (mViewPager == null || mViewPager.getAdapter().getCount() == 0) return false;
|
||||
|
||||
final int action = ev.getAction() & MotionEventCompat.ACTION_MASK;
|
||||
final int action = ev.getAction() & MotionEvent.ACTION_MASK;
|
||||
switch (action) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
mActivePointerId = ev.getPointerId(0);
|
||||
|
@ -273,21 +272,21 @@ public class LinePageIndicator extends View implements PagerIndicator {
|
|||
}
|
||||
break;
|
||||
|
||||
case MotionEventCompat.ACTION_POINTER_DOWN: {
|
||||
final int index = MotionEventCompat.getActionIndex(ev);
|
||||
case MotionEvent.ACTION_POINTER_DOWN: {
|
||||
final int index = ev.getActionIndex();
|
||||
mLastMotionX = ev.getX(index);
|
||||
mActivePointerId = ev.getPointerId(index);
|
||||
break;
|
||||
}
|
||||
|
||||
case MotionEventCompat.ACTION_POINTER_UP:
|
||||
final int pointerIndex = MotionEventCompat.getActionIndex(ev);
|
||||
case MotionEvent.ACTION_POINTER_UP:
|
||||
final int pointerIndex = ev.getActionIndex();
|
||||
final int pointerId = ev.getPointerId(pointerIndex);
|
||||
if (pointerId == mActivePointerId) {
|
||||
final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
|
||||
mActivePointerId = ev.getPointerId(newPointerIndex);
|
||||
}
|
||||
mLastMotionX = MotionEventCompat.getX(ev, ev.findPointerIndex(mActivePointerId));
|
||||
mLastMotionX = ev.getX(ev.findPointerIndex(mActivePointerId));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -410,9 +410,9 @@ public class TabPagerIndicator extends RecyclerView implements PagerIndicator, C
|
|||
|
||||
public void addTab(int icon, CharSequence label, int unread, boolean isCurrent) {
|
||||
final ItemLayout layout = (ItemLayout) inflater.inflate(R.layout.layout_tab_item, this, false);
|
||||
final ImageView tabIcon = (ImageView) layout.findViewById(R.id.tab_icon);
|
||||
final BadgeView badgeView = (BadgeView) layout.findViewById(R.id.unread_indicator);
|
||||
final TextView tabLabel = (TextView) layout.findViewById(R.id.tab_label);
|
||||
final ImageView tabIcon = layout.findViewById(R.id.tab_icon);
|
||||
final BadgeView badgeView = layout.findViewById(R.id.unread_indicator);
|
||||
final TextView tabLabel = layout.findViewById(R.id.tab_label);
|
||||
|
||||
layout.setStripColor(stripColor);
|
||||
layout.setStripHeight(stripHeight);
|
||||
|
@ -500,9 +500,9 @@ public class TabPagerIndicator extends RecyclerView implements PagerIndicator, C
|
|||
this.itemView = (ItemLayout) itemView;
|
||||
itemView.setOnClickListener(this);
|
||||
itemView.setOnLongClickListener(this);
|
||||
iconView = (ImageView) itemView.findViewById(R.id.tab_icon);
|
||||
labelView = (TextView) itemView.findViewById(R.id.tab_label);
|
||||
badgeView = (BadgeView) itemView.findViewById(R.id.unread_indicator);
|
||||
iconView = itemView.findViewById(R.id.tab_icon);
|
||||
labelView = itemView.findViewById(R.id.tab_label);
|
||||
badgeView = itemView.findViewById(R.id.unread_indicator);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -60,13 +60,14 @@ class BrowserSignInActivity : BaseActivity() {
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_browser_sign_in)
|
||||
webView.setWebChromeClient(AuthorizationWebChromeClient(this))
|
||||
webView.setWebViewClient(AuthorizationWebViewClient(this))
|
||||
webView.webChromeClient = AuthorizationWebChromeClient(this)
|
||||
webView.webViewClient = AuthorizationWebViewClient(this)
|
||||
webView.isVerticalScrollBarEnabled = false
|
||||
webView.addJavascriptInterface(InjectorJavaScriptInterface(this), "injector")
|
||||
val webSettings = webView.settings
|
||||
webSettings.applyDefault()
|
||||
webSettings.setSupportMultipleWindows(true)
|
||||
webView.settings.apply {
|
||||
applyDefault()
|
||||
setSupportMultipleWindows(true)
|
||||
}
|
||||
|
||||
webView.loadUrl(intent.dataString)
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.mariotaku.twidere.activity
|
|||
import android.accounts.AccountManager
|
||||
import android.animation.AnimatorSet
|
||||
import android.animation.ObjectAnimator
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.app.Dialog
|
||||
import android.content.ActivityNotFoundException
|
||||
|
@ -953,6 +954,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
|||
return false
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun handleMentionIntent(user: ParcelableUser?): Boolean {
|
||||
if (user == null || user.key == null) return false
|
||||
val accountScreenName = DataStoreUtils.getAccountScreenName(this, user.account_key)
|
||||
|
@ -2051,7 +2053,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
|||
|
||||
private class DeleteMediaTask(
|
||||
activity: ComposeActivity,
|
||||
val media: Array<ParcelableMediaUpdate>
|
||||
media: Array<ParcelableMediaUpdate>
|
||||
) : AbsDeleteMediaTask<((BooleanArray) -> Unit)?>(activity, media.mapToArray { Uri.parse(it.uri) }) {
|
||||
|
||||
override fun beforeExecute() {
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.mariotaku.twidere.extension
|
|||
|
||||
import android.net.Uri
|
||||
|
||||
fun Uri.withAppendedPath(path: String) = Uri.withAppendedPath(this, path)
|
||||
fun Uri.withAppendedPath(path: String): Uri = Uri.withAppendedPath(this, path)
|
||||
|
||||
fun Uri.Builder.appendQueryParameterIgnoreNull(key: String, value: String?) {
|
||||
if (value == null) return
|
||||
|
|
|
@ -165,7 +165,7 @@ fun FiltersData.parse(parser: XmlPullParser) {
|
|||
}
|
||||
|
||||
fun FiltersData.addAll(data: FiltersData, ignoreDuplicates: Boolean = false): Boolean {
|
||||
var changed: Boolean = false
|
||||
var changed = false
|
||||
initFields()
|
||||
if (data.users != null) {
|
||||
changed = changed or this.users.addAllEnhanced(collection = data.users, ignoreDuplicates = ignoreDuplicates)
|
||||
|
|
|
@ -39,7 +39,7 @@ fun User.getProfileImageOfSize(size: String): String {
|
|||
if (larger != null) return larger
|
||||
}
|
||||
val profileImage = profileImageUrlHttps ?: profileImageUrl
|
||||
return Utils.getTwitterProfileImageOfSize(profileImage, size) ?: profileImage
|
||||
return Utils.getTwitterProfileImageOfSize(profileImage, size)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,8 +25,9 @@ import org.mariotaku.twidere.util.HtmlEscapeHelper
|
|||
/**
|
||||
* Created by mariotaku on 2017/4/19.
|
||||
*/
|
||||
val Application.sourceHtml: String get() {
|
||||
val name = this.name ?: return ""
|
||||
val website = this.website ?: return name.let(HtmlEscapeHelper::escape).orEmpty()
|
||||
return "<a href='${HtmlEscapeHelper.escape(website)}'>${HtmlEscapeHelper.escape(name)}</a>"
|
||||
}
|
||||
val Application.sourceHtml: String
|
||||
get() {
|
||||
val name = this.name ?: return ""
|
||||
val website = this.website ?: return name.let(HtmlEscapeHelper::escape)
|
||||
return "<a href='${HtmlEscapeHelper.escape(website)}'>${HtmlEscapeHelper.escape(name)}</a>"
|
||||
}
|
|
@ -37,12 +37,13 @@ open class BaseWebViewFragment : BaseFragment() {
|
|||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
val view = webView
|
||||
view!!.setWebViewClient(createWebViewClient())
|
||||
val settings = view.settings
|
||||
settings.builtInZoomControls = true
|
||||
settings.javaScriptEnabled = true
|
||||
WebSettingsSupport.setAllowUniversalAccessFromFileURLs(settings, true)
|
||||
val view = webView!!
|
||||
view.webViewClient = createWebViewClient()
|
||||
view.settings.apply {
|
||||
builtInZoomControls = true
|
||||
javaScriptEnabled = true
|
||||
WebSettingsSupport.setAllowUniversalAccessFromFileURLs(this, true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1723,7 +1723,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
|
|||
|
||||
fun getItemType(position: Int): Int {
|
||||
var typeStart = 0
|
||||
for (type in 0..ITEM_TYPES_SUM - 1) {
|
||||
for (type in 0 until ITEM_TYPES_SUM) {
|
||||
val typeCount = getTypeCount(type)
|
||||
val typeEnd = typeStart + typeCount
|
||||
if (position in typeStart until typeEnd) return type
|
||||
|
@ -1734,7 +1734,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
|
|||
|
||||
fun getItemTypeStart(position: Int): Int {
|
||||
var typeStart = 0
|
||||
for (type in 0..ITEM_TYPES_SUM - 1) {
|
||||
for (type in 0 until ITEM_TYPES_SUM) {
|
||||
val typeCount = getTypeCount(type)
|
||||
val typeEnd = typeStart + typeCount
|
||||
if (position in typeStart until typeEnd) return typeStart
|
||||
|
@ -1814,7 +1814,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
|
|||
|
||||
fun getFirstPositionOfItem(itemIdx: Int): Int {
|
||||
var position = 0
|
||||
for (i in 0..ITEM_TYPES_SUM - 1) {
|
||||
for (i in 0 until ITEM_TYPES_SUM) {
|
||||
if (itemIdx == i) return position
|
||||
position += getTypeCount(i)
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ class TrendsSuggestionsFragment : AbsContentListViewFragment<TrendsAdapter>(), L
|
|||
val uri = CachedTrends.Local.CONTENT_URI
|
||||
val loaderWhere = Expression.and(Expression.equalsArgs(CachedTrends.ACCOUNT_KEY),
|
||||
Expression.equalsArgs(CachedTrends.WOEID)).sql
|
||||
val loaderWhereArgs = arrayOf(accountKey?.toString()?.orEmpty(), woeId.toString())
|
||||
val loaderWhereArgs = arrayOf(accountKey?.toString().orEmpty(), woeId.toString())
|
||||
return CursorLoader(activity, uri, CachedTrends.COLUMNS, loaderWhere, loaderWhereArgs, CachedTrends.TREND_ORDER)
|
||||
}
|
||||
|
||||
|
|
|
@ -325,6 +325,7 @@ class MessageNewConversationFragment : BaseFragment(), LoaderCallbacks<List<Parc
|
|||
Expression.equalsArgs(Conversations.PARTICIPANT_KEYS)).sql
|
||||
val whereArgs = arrayOf(accountKey.toString(), participantKeys.sorted().joinToString(","))
|
||||
val cur = resolver.query(Conversations.CONTENT_URI, Conversations.COLUMNS, where, whereArgs, null) ?: return null
|
||||
@Suppress("ConvertTryFinallyToUseCall")
|
||||
try {
|
||||
if (cur.moveToFirst()) {
|
||||
val indices = ObjectCursor.indicesFrom(cur, ParcelableMessageConversation::class.java)
|
||||
|
|
|
@ -121,6 +121,7 @@ class ParcelableUserLoader(
|
|||
}
|
||||
resolver.query(CachedUsers.CONTENT_URI, CachedUsers.COLUMNS, where.sql,
|
||||
whereArgs, null)?.let { cur ->
|
||||
@Suppress("ConvertTryFinallyToUseCall")
|
||||
try {
|
||||
cur.moveToFirst()
|
||||
val indices = ObjectCursor.indicesFrom(cur, ParcelableUser::class.java)
|
||||
|
|
|
@ -78,12 +78,12 @@ abstract class BaseGroupsLoader(
|
|||
nextPagination = CursorPagination.valueOf(listLoaded.nextCursor)
|
||||
prevPagination = CursorPagination.valueOf(listLoaded.previousCursor)
|
||||
val dataSize = data.size
|
||||
for (i in 0..listSize - 1) {
|
||||
for (i in 0 until listSize) {
|
||||
val group = listLoaded[i]
|
||||
data.add(ParcelableGroupUtils.from(group, accountKey, dataSize + i, isMember(group)))
|
||||
}
|
||||
} else {
|
||||
for (i in 0..listSize - 1) {
|
||||
for (i in 0 until listSize) {
|
||||
val list = listLoaded[i]
|
||||
data.add(ParcelableGroupUtils.from(listLoaded[i], accountKey, i, isMember(list)))
|
||||
}
|
||||
|
|
|
@ -97,13 +97,13 @@ abstract class BaseUserListsLoader(
|
|||
nextPagination = CursorPagination.valueOf(listLoaded.nextCursor)
|
||||
prevPagination = CursorPagination.valueOf(listLoaded.previousCursor)
|
||||
val dataSize = data.size
|
||||
for (i in 0..listSize - 1) {
|
||||
for (i in 0 until listSize) {
|
||||
val list = listLoaded[i]
|
||||
data.add(list.toParcelable(accountKey, (dataSize + i).toLong(),
|
||||
isFollowing(list), profileImageSize))
|
||||
}
|
||||
} else {
|
||||
for (i in 0..listSize - 1) {
|
||||
for (i in 0 until listSize) {
|
||||
val list = listLoaded[i]
|
||||
data.add(listLoaded[i].toParcelable(accountKey, i.toLong(),
|
||||
isFollowing(list), profileImageSize))
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.content.Intent
|
|||
import android.view.ActionProvider
|
||||
import android.view.Menu
|
||||
import android.view.SubMenu
|
||||
import android.view.View
|
||||
import org.mariotaku.twidere.TwidereConstants
|
||||
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_ACCOUNT
|
||||
import org.mariotaku.twidere.model.AccountDetails
|
||||
|
@ -25,10 +24,6 @@ class AccountActionProvider(
|
|||
return true
|
||||
}
|
||||
|
||||
override fun onCreateActionView(): View? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun onPrepareSubMenu(subMenu: SubMenu) {
|
||||
subMenu.removeGroup(MENU_GROUP)
|
||||
if (accounts == null) return
|
||||
|
@ -51,6 +46,9 @@ class AccountActionProvider(
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("OverridingDeprecatedMember")
|
||||
override fun onCreateActionView() = null
|
||||
|
||||
companion object {
|
||||
|
||||
val MENU_GROUP = 201
|
||||
|
|
|
@ -20,7 +20,7 @@ class ItemCounts(counts: Int) {
|
|||
}
|
||||
|
||||
fun getItemStartPosition(countIndex: Int): Int {
|
||||
return (0..countIndex - 1).sumBy { data[it] }
|
||||
return (0 until countIndex).sumBy { data[it] }
|
||||
}
|
||||
|
||||
val itemCount: Int get() = data.sum()
|
||||
|
|
|
@ -12,11 +12,11 @@ import org.mariotaku.twidere.model.UserKey
|
|||
object ParcelableActivityUtils {
|
||||
|
||||
/**
|
||||
* @param activity Activity for processing
|
||||
* @param sources Source users
|
||||
* *
|
||||
* @param filtered Those ids will be removed from source_ids.
|
||||
* *
|
||||
* @param followingOnly Limit following users in sources
|
||||
* @param followingOnly Limit following users in sources
|
||||
* *
|
||||
* @return true if source ids changed, false otherwise
|
||||
*/
|
||||
|
|
|
@ -55,7 +55,7 @@ abstract class ComponentPickerPreference(context: Context, attrs: AttributeSet?
|
|||
val values = arrayOfNulls<CharSequence>(infoListSize + 1)
|
||||
entries[0] = noneEntry
|
||||
values[0] = ""
|
||||
for (i in 0..infoListSize - 1) {
|
||||
for (i in 0 until infoListSize) {
|
||||
val info = infoList[i]
|
||||
entries[i + 1] = info.loadLabel(packageManager)
|
||||
values[i + 1] = getComponentName(info).flattenToString()
|
||||
|
|
|
@ -338,7 +338,7 @@ class LengthyOperationsService : BaseIntentService("lengthy_operations") {
|
|||
val stream = body.stream()
|
||||
var response = upload.initUploadMedia(mediaType, length, null, null)
|
||||
val segments = if (length == 0L) 0 else (length / BULK_SIZE + 1).toInt()
|
||||
for (segmentIndex in 0..segments - 1) {
|
||||
for (segmentIndex in 0 until segments) {
|
||||
val currentBulkSize = Math.min(BULK_SIZE, length - segmentIndex * BULK_SIZE).toInt()
|
||||
val bulk = SimpleBody(ContentType.OCTET_STREAM, null, currentBulkSize.toLong(),
|
||||
stream)
|
||||
|
|
|
@ -404,7 +404,7 @@ class StreamingService : BaseService() {
|
|||
}
|
||||
|
||||
override fun onDisconnectNotice(code: Int, reason: String?): Boolean {
|
||||
disconnect();
|
||||
disconnect()
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
@ -193,7 +193,7 @@ class UpdateStatusTask(
|
|||
}
|
||||
|
||||
val sharedMedia = HashMap<UserKey, MediaUploadResult>()
|
||||
for (i in 0..pending.length - 1) {
|
||||
for (i in 0 until pending.length) {
|
||||
val account = update.accounts[i]
|
||||
// Skip upload if shared media found
|
||||
val accountKey = account.key
|
||||
|
@ -357,7 +357,7 @@ class UpdateStatusTask(
|
|||
val ownerIds = ownersList.map {
|
||||
it.id
|
||||
}.toTypedArray()
|
||||
for (i in 0..pendingUpdate.length - 1) {
|
||||
for (i in 0 until pendingUpdate.length) {
|
||||
val account = update.accounts[i]
|
||||
val mediaIds: Array<String>?
|
||||
when (account.type) {
|
||||
|
@ -472,7 +472,7 @@ class UpdateStatusTask(
|
|||
private fun statusShortenCallback(shortener: StatusShortenerInterface?,
|
||||
pendingUpdate: PendingStatusUpdate, updateResult: UpdateStatusResult) {
|
||||
if (shortener == null || !shortener.waitForService()) return
|
||||
for (i in 0..pendingUpdate.length - 1) {
|
||||
for (i in 0 until pendingUpdate.length) {
|
||||
val shortenResult = pendingUpdate.statusShortenResults[i]
|
||||
val status = updateResult.statuses[i]
|
||||
if (shortenResult == null || status == null) continue
|
||||
|
@ -483,7 +483,7 @@ class UpdateStatusTask(
|
|||
private fun mediaUploadCallback(uploader: MediaUploaderInterface?,
|
||||
pendingUpdate: PendingStatusUpdate, updateResult: UpdateStatusResult) {
|
||||
if (uploader == null || !uploader.waitForService()) return
|
||||
for (i in 0..pendingUpdate.length - 1) {
|
||||
for (i in 0 until pendingUpdate.length) {
|
||||
val uploadResult = pendingUpdate.mediaUploadResults[i]
|
||||
val status = updateResult.statuses[i]
|
||||
if (uploadResult == null || status == null) continue
|
||||
|
@ -845,7 +845,7 @@ class UpdateStatusTask(
|
|||
val stream = body.stream()
|
||||
var response = upload.initUploadMedia(mediaType, length, mediaCategory, ownerIds)
|
||||
val segments = if (length == 0L) 0 else (length / BULK_SIZE + 1).toInt()
|
||||
for (segmentIndex in 0..segments - 1) {
|
||||
for (segmentIndex in 0 until segments) {
|
||||
val currentBulkSize = Math.min(BULK_SIZE.toLong(), length - segmentIndex * BULK_SIZE).toInt()
|
||||
val bulk = SimpleBody(ContentType.OCTET_STREAM, null, currentBulkSize.toLong(),
|
||||
stream)
|
||||
|
|
|
@ -122,6 +122,7 @@ class MarkMessageReadTask(
|
|||
@SuppressLint("Recycle")
|
||||
val cur = query(Messages.CONTENT_URI, Messages.COLUMNS,
|
||||
where, whereArgs, OrderBy(Messages.LOCAL_TIMESTAMP, false).sql) ?: return null
|
||||
@Suppress("ConvertTryFinallyToUseCall")
|
||||
try {
|
||||
if (cur.moveToFirst()) {
|
||||
val indices = ObjectCursor.indicesFrom(cur, ParcelableMessage::class.java)
|
||||
|
|
|
@ -28,11 +28,7 @@ import android.text.style.DynamicDrawableSpan
|
|||
* Created by mariotaku on 15/12/22.
|
||||
*/
|
||||
class EmojiSpan(private val drawable: Drawable) : DynamicDrawableSpan(DynamicDrawableSpan.ALIGN_BOTTOM) {
|
||||
private val fontMetrics: Paint.FontMetrics
|
||||
|
||||
init {
|
||||
this.fontMetrics = Paint.FontMetrics()
|
||||
}
|
||||
private val fontMetrics: Paint.FontMetrics = Paint.FontMetrics()
|
||||
|
||||
override fun getDrawable(): Drawable? {
|
||||
return drawable
|
||||
|
|
|
@ -24,7 +24,9 @@ import org.mariotaku.twidere.provider.TwidereDataStore.Accounts
|
|||
*/
|
||||
@Suppress("deprecation")
|
||||
fun migrateAccounts(am: AccountManager, db: SQLiteDatabase) {
|
||||
val cur = db.query(Accounts.TABLE_NAME, Accounts.COLUMNS, null, null, null, null, null) ?: return
|
||||
val cur = db.query(Accounts.TABLE_NAME, Accounts.COLUMNS, null, null,
|
||||
null, null, null) ?: return
|
||||
@Suppress("ConvertTryFinallyToUseCall")
|
||||
try {
|
||||
val indices = ObjectCursor.indicesFrom(cur, ParcelableCredentials::class.java)
|
||||
cur.moveToFirst()
|
||||
|
|
|
@ -154,7 +154,7 @@ open class ContentScrollHandler<A>(
|
|||
fun post(runnable: Runnable)
|
||||
}
|
||||
|
||||
interface ContentListSupport<A> {
|
||||
interface ContentListSupport<out A> {
|
||||
|
||||
val adapter: A?
|
||||
|
||||
|
|
|
@ -621,6 +621,7 @@ object DataStoreUtils {
|
|||
val where = Expression.equalsArgs(Filters.Users.USER_KEY)
|
||||
val c = cr.query(Filters.Users.CONTENT_URI, arrayOf(SQLFunctions.COUNT()),
|
||||
where.sql, arrayOf(userKey), null) ?: return false
|
||||
@Suppress("ConvertTryFinallyToUseCall")
|
||||
try {
|
||||
if (c.moveToFirst()) {
|
||||
return c.getLong(0) > 0
|
||||
|
@ -812,6 +813,7 @@ object DataStoreUtils {
|
|||
fun queryCount(cr: ContentResolver, uri: Uri, selection: String?, selectionArgs: Array<String>?): Int {
|
||||
val projection = arrayOf(SQLFunctions.COUNT())
|
||||
val cur = cr.query(uri, projection, selection, selectionArgs, null) ?: return -1
|
||||
@Suppress("ConvertTryFinallyToUseCall")
|
||||
try {
|
||||
if (cur.moveToFirst()) {
|
||||
return cur.getInt(0)
|
||||
|
@ -909,6 +911,7 @@ object DataStoreUtils {
|
|||
val whereArgs = arrayOf(accountKey.toString(), statusId)
|
||||
for (uri in DataStoreUtils.STATUSES_URIS) {
|
||||
val cur = resolver.query(uri, Statuses.COLUMNS, where, whereArgs, null) ?: continue
|
||||
@Suppress("ConvertTryFinallyToUseCall")
|
||||
try {
|
||||
if (cur.moveToFirst()) {
|
||||
val indices = ObjectCursor.indicesFrom(cur, ParcelableStatus::class.java)
|
||||
|
@ -956,6 +959,7 @@ object DataStoreUtils {
|
|||
Expression.equalsArgs(Conversations.CONVERSATION_ID)).sql
|
||||
val whereArgs = arrayOf(accountKey.toString(), conversationId)
|
||||
val cur = resolver.query(Conversations.CONTENT_URI, Conversations.COLUMNS, where, whereArgs, null) ?: return null
|
||||
@Suppress("ConvertTryFinallyToUseCall")
|
||||
try {
|
||||
if (cur.moveToFirst()) {
|
||||
val indices = ObjectCursor.indicesFrom(cur, ParcelableMessageConversation::class.java)
|
||||
|
|
|
@ -62,7 +62,7 @@ class HtmlBuilder(
|
|||
val sb = StringBuilder()
|
||||
val linksSize = spanSpecs.size
|
||||
val items = arrayOfNulls<SpanItem>(linksSize)
|
||||
for (i in 0..linksSize - 1) {
|
||||
for (i in 0 until linksSize) {
|
||||
val spec = spanSpecs[i]
|
||||
val start = spec.start
|
||||
val end = spec.end
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.mariotaku.twidere.model.util.ParcelableMediaUtils
|
|||
/**
|
||||
* Created by mariotaku on 15/4/6.
|
||||
*/
|
||||
class StatusAdapterLinkClickHandler<D>(context: Context, preferences: SharedPreferences) :
|
||||
class StatusAdapterLinkClickHandler<out D>(context: Context, preferences: SharedPreferences) :
|
||||
OnLinkClickHandler(context, null, preferences), Constants {
|
||||
|
||||
private var adapter: IStatusesAdapter<D>? = null
|
||||
|
|
|
@ -245,7 +245,7 @@ object Utils {
|
|||
if (projection == null) return AllColumns()
|
||||
val length = projection.size
|
||||
val columns = arrayOfNulls<Column>(length)
|
||||
for (i in 0..length - 1) {
|
||||
for (i in 0 until length) {
|
||||
columns[i] = Column(projection[i])
|
||||
}
|
||||
return Columns(*columns)
|
||||
|
|
|
@ -47,6 +47,7 @@ object FilterQueryBuilder {
|
|||
textPlain, quotedTextPlain, spans, quotedSpans, source, quotedSource, retweetedByKey,
|
||||
quotedUserKey, true)
|
||||
val cur = cr.rawQuery(query.first, query.second) ?: return false
|
||||
@Suppress("ConvertTryFinallyToUseCall")
|
||||
try {
|
||||
return cur.moveToFirst() && cur.getInt(0) != 0
|
||||
} finally {
|
||||
|
|
|
@ -144,7 +144,7 @@ class TwidereDns(context: Context, private val preferences: SharedPreferences) :
|
|||
private fun addLogSplit(logger: TimingLogger, host: String, message: String, depth: Int) {
|
||||
if (BuildConfig.DEBUG) return
|
||||
val sb = StringBuilder()
|
||||
for (i in 0..depth - 1) {
|
||||
for (i in 0 until depth) {
|
||||
sb.append(">")
|
||||
}
|
||||
sb.append(" ")
|
||||
|
|
|
@ -272,6 +272,7 @@ class ContentNotificationManager(
|
|||
val unreadHaving = Expression.greaterThan(Conversations.UNREAD_COUNT, 0)
|
||||
val cur = cr.getUnreadMessagesEntriesCursor(projection, arrayOf(accountKey),
|
||||
extraHaving = unreadHaving) ?: return
|
||||
@Suppress("ConvertTryFinallyToUseCall")
|
||||
try {
|
||||
if (cur.isEmpty) return
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ abstract class FileBasedDraftsSyncAction<RemoteFileInfo>(val context: Context) :
|
|||
|
||||
val localDrafts = run {
|
||||
val cur = context.contentResolver.query(Drafts.CONTENT_URI, Drafts.COLUMNS, null, null, null)!!
|
||||
@Suppress("ConvertTryFinallyToUseCall")
|
||||
try {
|
||||
val indices = ObjectCursor.indicesFrom(cur, Draft::class.java)
|
||||
return@run cur.map(indices)
|
||||
|
@ -157,6 +158,7 @@ abstract class FileBasedDraftsSyncAction<RemoteFileInfo>(val context: Context) :
|
|||
|
||||
snapshotsListFile.writer().use { writer ->
|
||||
val cur = context.contentResolver.query(Drafts.CONTENT_URI, Drafts.COLUMNS, null, null, null)!!
|
||||
@Suppress("ConvertTryFinallyToUseCall")
|
||||
try {
|
||||
val indices = ObjectCursor.indicesFrom(cur, Draft::class.java)
|
||||
cur.map(indices).map { it.unique_id_non_null }.forEach { line ->
|
||||
|
|
|
@ -121,7 +121,7 @@ class CardPollViewController : ContainerView.ViewController() {
|
|||
val hasChoice = selectedChoice != -1
|
||||
val isMyPoll = status.account_key == status.user_key
|
||||
val showResult = countsAreFinal || isMyPoll || hasChoice
|
||||
for (i in 0..choicesCount - 1) {
|
||||
for (i in 0 until choicesCount) {
|
||||
val choiceIndex = i + 1
|
||||
votesSum += card.getAsInteger("choice${choiceIndex}_count", 0)
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ class CardPollViewController : ContainerView.ViewController() {
|
|||
|
||||
val color = ContextCompat.getColor(context, R.color.material_light_blue_a200)
|
||||
val radius = context.resources.getDimension(R.dimen.element_spacing_small)
|
||||
for (i in 0..choicesCount - 1) {
|
||||
for (i in 0 until choicesCount) {
|
||||
val pollItem = view.pollContainer.getChildAt(i)
|
||||
|
||||
val choicePercentView: TextView = pollItem.findViewById(R.id.choice_percent)
|
||||
|
|
|
@ -42,25 +42,17 @@ class UserListViewHolder(
|
|||
private val adapter: IUserListsAdapter<*>
|
||||
) : ViewHolder(itemView), View.OnClickListener, View.OnLongClickListener {
|
||||
|
||||
private val itemContent: ColorLabelRelativeLayout
|
||||
private val profileImageView: ProfileImageView
|
||||
private val nameView: TextView
|
||||
private val createdByView: TextView
|
||||
private val descriptionView: TextView
|
||||
private val membersCountView: TextView
|
||||
private val subscribersCountView: TextView
|
||||
private val itemContent: ColorLabelRelativeLayout = itemView.itemContent
|
||||
private val profileImageView: ProfileImageView = itemView.profileImage
|
||||
private val nameView: TextView = itemView.name
|
||||
private val createdByView: TextView = itemView.createdBy
|
||||
private val descriptionView: TextView = itemView.description
|
||||
private val membersCountView: TextView = itemView.membersCount
|
||||
private val subscribersCountView: TextView = itemView.subscribersCount
|
||||
|
||||
private var userListClickListener: IUserListsAdapter.UserListClickListener? = null
|
||||
|
||||
init {
|
||||
itemContent = itemView.itemContent
|
||||
profileImageView = itemView.profileImage
|
||||
nameView = itemView.name
|
||||
createdByView = itemView.createdBy
|
||||
descriptionView = itemView.description
|
||||
membersCountView = itemView.membersCount
|
||||
subscribersCountView = itemView.subscribersCount
|
||||
|
||||
profileImageView.style = adapter.profileImageStyle
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ class MessageViewHolder(itemView: View, adapter: MessagesConversationAdapter) :
|
|||
var nonSpaceCount = 0
|
||||
var curPos = 0
|
||||
message.spans?.forEach { span ->
|
||||
nonSpaceCount += text.nonSpaceCount(curPos..span.start - 1)
|
||||
nonSpaceCount += text.nonSpaceCount(curPos until span.start)
|
||||
if (message.media?.firstOrNull { media -> span.link == media.url } != null) {
|
||||
// Skip if span is hidden
|
||||
span.type = SpanItem.SpanType.HIDE
|
||||
|
|
Loading…
Reference in New Issue