fixed lint problems

This commit is contained in:
Mariotaku Lee 2016-03-25 12:14:29 +08:00
parent a3c0750a29
commit 5fe409ebc0
33 changed files with 155 additions and 121 deletions

View File

@ -24,7 +24,7 @@ package org.mariotaku.twidere.nyan;
*/
public interface NyanConstants {
public static final String SHARED_PREFERENCES_NAME = "nyan_preferences";
String SHARED_PREFERENCES_NAME = "nyan_preferences";
public static final String KEY_LIVE_WALLPAPER_SCALE = "live_wallpaper_scale";
String KEY_LIVE_WALLPAPER_SCALE = "live_wallpaper_scale";
}

View File

@ -248,10 +248,10 @@ public class NyanDrawingHelper {
}
public static interface IDrawingHelper {
public void dispatchOnDraw(final Canvas canvas);
public interface IDrawingHelper {
void dispatchOnDraw(final Canvas canvas);
public void dispatchSizeChanged(final int w, final int h);
void dispatchSizeChanged(final int w, final int h);
}
public static final class TileBitmapDrawable extends BitmapDrawable {
@ -477,7 +477,7 @@ public class NyanDrawingHelper {
0, 0, 0, 0, 0, 0, 0
}
};
static final byte[][] FRAME2 = {
byte[][] FRAME2 = {
{
0, 0, 0, 0, 0, 0, 0
},
@ -500,7 +500,7 @@ public class NyanDrawingHelper {
0, 0, 0, 0, 0, 0, 0
}
};
static final byte[][] FRAME3 = {
byte[][] FRAME3 = {
{
0, 0, 0, 0, 0, 0, 0
},
@ -523,7 +523,7 @@ public class NyanDrawingHelper {
0, 0, 0, 0, 0, 0, 0
}
};
static final byte[][] FRAME4 = {
byte[][] FRAME4 = {
{
0, 0, 0, 1, 0, 0, 0
},
@ -546,7 +546,7 @@ public class NyanDrawingHelper {
0, 0, 0, 1, 0, 0, 0
}
};
static final byte[][] FRAME5 = {
byte[][] FRAME5 = {
{
0, 0, 0, 1, 0, 0, 0
},
@ -569,7 +569,7 @@ public class NyanDrawingHelper {
0, 0, 0, 1, 0, 0, 0
}
};
static final byte[][] FRAME6 = {
byte[][] FRAME6 = {
{
0, 0, 0, 1, 0, 0, 0
},

View File

@ -17,7 +17,9 @@ public class TwidereArrayUtilsTest {
String[] array2 = {"1", "2"};
String[] array3 = null;
//noinspection ConstantConditions
String[] merged = new String[TwidereArrayUtils.arraysLength(array1, array2, array3)];
//noinspection ConstantConditions
TwidereArrayUtils.mergeArray(merged, array1, array2, array3);
String[] expected = {"1", "2", "1", "2"};
assertArrayEquals(expected, merged);
@ -28,6 +30,7 @@ public class TwidereArrayUtilsTest {
String[] array1 = {"1", "2"};
String[] array2 = {"1", "2"};
String[] array3 = null;
//noinspection ConstantConditions
assertEquals(4, TwidereArrayUtils.arraysLength(array1, array2, array3));
assertEquals(6, TwidereArrayUtils.arraysLength(array1, array2, array2));
}

View File

@ -31,6 +31,7 @@ import android.view.View;
import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
@ -53,11 +54,16 @@ public class GoogleMapFragment extends SupportMapFragment implements Constants,
if (args == null || !args.containsKey(EXTRA_LATITUDE) || !args.containsKey(EXTRA_LONGITUDE))
return;
final double lat = args.getDouble(EXTRA_LATITUDE, 0.0), lng = args.getDouble(EXTRA_LONGITUDE, 0.0);
mMapView = getMap();
final MarkerOptions marker = new MarkerOptions();
marker.position(new LatLng(lat, lng));
mMapView.addMarker(marker);
center(false);
getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap googleMap) {
mMapView = googleMap;
final MarkerOptions marker = new MarkerOptions();
marker.position(new LatLng(lat, lng));
mMapView.addMarker(marker);
center(false);
}
});
}
@Override

View File

@ -540,7 +540,7 @@ public class ComposeActivity extends BaseActivity implements OnMenuItemClickList
mAttachedMediaPreview = (RecyclerView) findViewById(R.id.attached_media_preview);
mMenuBar = (ActionMenuView) findViewById(R.id.menu_bar);
mSendView = findViewById(R.id.send);
mSendTextCountView = (StatusTextCountView) mSendView.findViewById(R.id.status_text_count);
mSendTextCountView = (StatusTextCountView) findViewById(R.id.status_text_count);
mLocationSwitch = (MultiValueSwitch) findViewById(R.id.location_switch);
mAccountSelector = (RecyclerView) findViewById(R.id.account_selector);
mAccountSelectorContainer = findViewById(R.id.account_selector_container);

View File

@ -27,7 +27,6 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Color;
import android.net.Uri;
import android.os.AsyncTask;
@ -39,6 +38,7 @@ import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewCompat;
import android.support.v7.app.AlertDialog;
import android.text.Editable;
@ -87,6 +87,7 @@ import org.mariotaku.twidere.model.util.ParcelableUserUtils;
import org.mariotaku.twidere.model.util.UserKeyUtils;
import org.mariotaku.twidere.provider.TwidereDataStore.Accounts;
import org.mariotaku.twidere.util.AsyncTaskUtils;
import org.mariotaku.twidere.util.DataStoreUtils;
import org.mariotaku.twidere.util.JsonSerializer;
import org.mariotaku.twidere.util.OAuthPasswordAuthenticator;
import org.mariotaku.twidere.util.OAuthPasswordAuthenticator.AuthenticationException;
@ -104,13 +105,6 @@ import org.mariotaku.twidere.util.view.ConsumerKeySecretValidator;
import java.lang.ref.WeakReference;
import static android.text.TextUtils.isEmpty;
import static org.mariotaku.twidere.util.DataStoreUtils.getActivatedAccountKeys;
import static org.mariotaku.twidere.util.Utils.getNonEmptyString;
import static org.mariotaku.twidere.util.Utils.isUserLoggedIn;
import static org.mariotaku.twidere.util.Utils.showErrorMessage;
import static org.mariotaku.twidere.util.Utils.trim;
public class SignInActivity extends BaseActivity implements OnClickListener, TextWatcher {
public static final String FRAGMENT_TAG_SIGN_IN_PROGRESS = "sign_in_progress";
@ -218,7 +212,7 @@ public class SignInActivity extends BaseActivity implements OnClickListener, Tex
public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home: {
final UserKey[] accountKeys = getActivatedAccountKeys(this);
final UserKey[] accountKeys = DataStoreUtils.getActivatedAccountKeys(this);
if (accountKeys.length > 0) {
onBackPressed();
}
@ -303,8 +297,8 @@ public class SignInActivity extends BaseActivity implements OnClickListener, Tex
mAPIUrlFormat = savedInstanceState.getString(Accounts.API_URL_FORMAT);
mAuthType = savedInstanceState.getInt(Accounts.AUTH_TYPE);
mSameOAuthSigningUrl = savedInstanceState.getBoolean(Accounts.SAME_OAUTH_SIGNING_URL);
mConsumerKey = trim(savedInstanceState.getString(Accounts.CONSUMER_KEY));
mConsumerSecret = trim(savedInstanceState.getString(Accounts.CONSUMER_SECRET));
mConsumerKey = Utils.trim(savedInstanceState.getString(Accounts.CONSUMER_KEY));
mConsumerSecret = Utils.trim(savedInstanceState.getString(Accounts.CONSUMER_SECRET));
mUsername = savedInstanceState.getString(Accounts.SCREEN_NAME);
mPassword = savedInstanceState.getString(Accounts.PASSWORD);
mAPIChangeTimestamp = savedInstanceState.getLong(EXTRA_API_LAST_CHANGE);
@ -321,8 +315,8 @@ public class SignInActivity extends BaseActivity implements OnClickListener, Tex
mSignUpButton.setOnClickListener(this);
final Resources resources = getResources();
final ColorStateList color = ColorStateList.valueOf(resources.getColor(R.color.material_light_green));
final ColorStateList color = ColorStateList.valueOf(ContextCompat.getColor(this,
R.color.material_light_green));
ViewCompat.setBackgroundTintList(mSignInButton, color);
setSignInButton();
@ -378,13 +372,13 @@ public class SignInActivity extends BaseActivity implements OnClickListener, Tex
private void setDefaultAPI() {
final long apiLastChange = mPreferences.getLong(KEY_API_LAST_CHANGE, mAPIChangeTimestamp);
final boolean defaultApiChanged = apiLastChange != mAPIChangeTimestamp;
final String apiUrlFormat = getNonEmptyString(mPreferences, KEY_API_URL_FORMAT, DEFAULT_TWITTER_API_URL_FORMAT);
final String apiUrlFormat = Utils.getNonEmptyString(mPreferences, KEY_API_URL_FORMAT, DEFAULT_TWITTER_API_URL_FORMAT);
final int authType = mPreferences.getInt(KEY_AUTH_TYPE, ParcelableCredentials.AUTH_TYPE_OAUTH);
final boolean sameOAuthSigningUrl = mPreferences.getBoolean(KEY_SAME_OAUTH_SIGNING_URL, false);
final boolean noVersionSuffix = mPreferences.getBoolean(KEY_NO_VERSION_SUFFIX, false);
final String consumerKey = getNonEmptyString(mPreferences, KEY_CONSUMER_KEY, TWITTER_CONSUMER_KEY);
final String consumerSecret = getNonEmptyString(mPreferences, KEY_CONSUMER_SECRET, TWITTER_CONSUMER_SECRET);
if (isEmpty(mAPIUrlFormat) || defaultApiChanged) {
final String consumerKey = Utils.getNonEmptyString(mPreferences, KEY_CONSUMER_KEY, TWITTER_CONSUMER_KEY);
final String consumerSecret = Utils.getNonEmptyString(mPreferences, KEY_CONSUMER_SECRET, TWITTER_CONSUMER_SECRET);
if (TextUtils.isEmpty(mAPIUrlFormat) || defaultApiChanged) {
mAPIUrlFormat = apiUrlFormat;
}
if (defaultApiChanged) {
@ -396,10 +390,10 @@ public class SignInActivity extends BaseActivity implements OnClickListener, Tex
if (defaultApiChanged) {
mNoVersionSuffix = noVersionSuffix;
}
if (isEmpty(mConsumerKey) || defaultApiChanged) {
if (TextUtils.isEmpty(mConsumerKey) || defaultApiChanged) {
mConsumerKey = consumerKey;
}
if (isEmpty(mConsumerSecret) || defaultApiChanged) {
if (TextUtils.isEmpty(mConsumerSecret) || defaultApiChanged) {
mConsumerSecret = consumerSecret;
}
if (defaultApiChanged) {
@ -448,9 +442,9 @@ public class SignInActivity extends BaseActivity implements OnClickListener, Tex
} else if (result.exception instanceof LoginVerificationException) {
Toast.makeText(this, R.string.login_verification_failed, Toast.LENGTH_SHORT).show();
} else if (result.exception instanceof AuthenticationException) {
showErrorMessage(this, getString(R.string.action_signing_in), result.exception.getCause(), true);
Utils.showErrorMessage(this, getString(R.string.action_signing_in), result.exception.getCause(), true);
} else {
showErrorMessage(this, getString(R.string.action_signing_in), result.exception, true);
Utils.showErrorMessage(this, getString(R.string.action_signing_in), result.exception, true);
}
}
}
@ -610,7 +604,7 @@ public class SignInActivity extends BaseActivity implements OnClickListener, Tex
Twitter.class);
final User user = twitter.verifyCredentials();
final int color = analyseUserProfileColor(user);
return new SignInResponse(isUserLoggedIn(context, user.getId()), auth, user,
return new SignInResponse(Utils.isUserLoggedIn(context, user.getId()), auth, user,
ParcelableCredentials.AUTH_TYPE_OAUTH, color, apiUrlFormat, sameOauthSigningUrl,
noVersionSuffix, detectAccountType(twitter, user));
} catch (final TwitterException e) {
@ -735,7 +729,7 @@ public class SignInActivity extends BaseActivity implements OnClickListener, Tex
final String userId = user.getId();
if (userId == null) return new SignInResponse(false, false, null);
final int color = analyseUserProfileColor(user);
return new SignInResponse(isUserLoggedIn(activity, userId), username, password, user,
return new SignInResponse(Utils.isUserLoggedIn(activity, userId), username, password, user,
color, apiUrlFormat, noVersionSuffix, detectAccountType(twitter, user));
}
@ -751,7 +745,7 @@ public class SignInActivity extends BaseActivity implements OnClickListener, Tex
final String userId = user.getId();
if (userId == null) return new SignInResponse(false, false, null);
final int color = analyseUserProfileColor(user);
return new SignInResponse(isUserLoggedIn(activity, userId), user, color, apiUrlFormat,
return new SignInResponse(Utils.isUserLoggedIn(activity, userId), user, color, apiUrlFormat,
noVersionSuffix, detectAccountType(twitter, user));
}
@ -762,7 +756,7 @@ public class SignInActivity extends BaseActivity implements OnClickListener, Tex
final Twitter twitter = TwitterAPIFactory.getInstance(activity, endpoint, auth, Twitter.class);
final User user = twitter.verifyCredentials();
final int color = analyseUserProfileColor(user);
return new SignInResponse(isUserLoggedIn(activity, userId), auth, user, authType, color,
return new SignInResponse(Utils.isUserLoggedIn(activity, userId), auth, user, authType, color,
apiUrlFormat, sameOAuthSigningUrl, noVersionSuffix, detectAccountType(twitter, user));
}
@ -874,6 +868,7 @@ public class SignInActivity extends BaseActivity implements OnClickListener, Tex
case DialogInterface.BUTTON_POSITIVE: {
final AlertDialog alertDialog = (AlertDialog) dialog;
final EditText editVerification = (EditText) alertDialog.findViewById(R.id.edit_verification_code);
assert editVerification != null;
callback.setChallengeResponse(ParseUtils.parseString(editVerification.getText()));
break;
}

View File

@ -25,6 +25,7 @@ import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
@ -298,19 +299,19 @@ public class UserListSelectorActivity extends BaseActivity implements OnClickLis
try {
final ResponseList<UserList> lists = twitter.getUserLists(mScreenName, true);
final List<ParcelableUserList> data = new ArrayList<>();
boolean is_my_account = mScreenName.equalsIgnoreCase(getAccountScreenName(mActivity,
boolean isMyAccount = mScreenName.equalsIgnoreCase(getAccountScreenName(mActivity,
mAccountKey));
for (final UserList item : lists) {
final User user = item.getUser();
if (user != null && mScreenName.equalsIgnoreCase(user.getScreenName())) {
if (!is_my_account && user.getId() == mAccountKey.getId()) {
is_my_account = true;
if (!isMyAccount && TextUtils.equals(user.getId(), mAccountKey.getId())) {
isMyAccount = true;
}
data.add(ParcelableUserListUtils.from(item, mAccountKey));
}
}
final SingleResponse<List<ParcelableUserList>> result = SingleResponse.getInstance(data);
result.getExtras().putBoolean(EXTRA_IS_MY_ACCOUNT, is_my_account);
result.getExtras().putBoolean(EXTRA_IS_MY_ACCOUNT, isMyAccount);
return result;
} catch (final TwitterException e) {
Log.w(LOGTAG, e);

View File

@ -33,55 +33,55 @@ import org.mariotaku.twidere.util.HtmlEscapeHelper;
public class SourceAutoCompleteAdapter extends SimpleCursorAdapter implements Constants {
private static final String[] COLUMNS = new String[] { CachedStatuses._ID, CachedStatuses.SOURCE };
private static final String[] FROM = new String[0];
private static final int[] TO = new int[0];
private static final String[] COLUMNS = new String[]{CachedStatuses._ID, CachedStatuses.SOURCE};
private static final String[] FROM = new String[0];
private static final int[] TO = new int[0];
private final SQLiteDatabase mDatabase;
private final SQLiteDatabase mDatabase;
private int mSourceIdx;
private int mSourceIdx;
public SourceAutoCompleteAdapter(final Context context) {
super(context, android.R.layout.simple_list_item_1, null, FROM, TO, 0);
final TwidereApplication app = TwidereApplication.getInstance(context);
mDatabase = app != null ? app.getSQLiteDatabase() : null;
}
public SourceAutoCompleteAdapter(final Context context) {
super(context, android.R.layout.simple_list_item_1, null, FROM, TO, 0);
final TwidereApplication app = TwidereApplication.getInstance(context);
mDatabase = app.getSQLiteDatabase();
}
@Override
public void bindView(final View view, final Context context, final Cursor cursor) {
if (isCursorClosed()) return;
final TextView text1 = (TextView) view.findViewById(android.R.id.text1);
text1.setText(convertToString(cursor));
super.bindView(view, context, cursor);
}
@Override
public void bindView(final View view, final Context context, final Cursor cursor) {
if (isCursorClosed()) return;
final TextView text1 = (TextView) view.findViewById(android.R.id.text1);
text1.setText(convertToString(cursor));
super.bindView(view, context, cursor);
}
@Override
public CharSequence convertToString(final Cursor cursor) {
if (isCursorClosed() || mSourceIdx == -1) return null;
return HtmlEscapeHelper.toPlainText(cursor.getString(mSourceIdx));
}
@Override
public CharSequence convertToString(final Cursor cursor) {
if (isCursorClosed() || mSourceIdx == -1) return null;
return HtmlEscapeHelper.toPlainText(cursor.getString(mSourceIdx));
}
public boolean isCursorClosed() {
final Cursor cursor = getCursor();
return cursor == null || cursor.isClosed();
}
public boolean isCursorClosed() {
final Cursor cursor = getCursor();
return cursor == null || cursor.isClosed();
}
@Override
public Cursor runQueryOnBackgroundThread(final CharSequence constraint) {
final String constraint_escaped = constraint != null ? constraint.toString().replaceAll("_", "^_") : null;
final String selection = constraint != null ? CachedStatuses.SOURCE + " LIKE '%\">'||?||'%</a>' ESCAPE '^'"
: null;
final String[] selectionArgs = constraint != null ? new String[] { constraint_escaped } : null;
return mDatabase.query(true, CachedStatuses.TABLE_NAME, COLUMNS, selection, selectionArgs,
CachedStatuses.SOURCE, null, null, null);
}
@Override
public Cursor runQueryOnBackgroundThread(final CharSequence constraint) {
final String constraint_escaped = constraint != null ? constraint.toString().replaceAll("_", "^_") : null;
final String selection = constraint != null ? CachedStatuses.SOURCE + " LIKE '%\">'||?||'%</a>' ESCAPE '^'"
: null;
final String[] selectionArgs = constraint != null ? new String[]{constraint_escaped} : null;
return mDatabase.query(true, CachedStatuses.TABLE_NAME, COLUMNS, selection, selectionArgs,
CachedStatuses.SOURCE, null, null, null);
}
@Override
public Cursor swapCursor(final Cursor cursor) {
if (cursor != null) {
mSourceIdx = cursor.getColumnIndex(CachedStatuses.SOURCE);
}
return super.swapCursor(cursor);
}
@Override
public Cursor swapCursor(final Cursor cursor) {
if (cursor != null) {
mSourceIdx = cursor.getColumnIndex(CachedStatuses.SOURCE);
}
return super.swapCursor(cursor);
}
}

View File

@ -295,6 +295,7 @@ public abstract class BaseFiltersFragment extends AbsContentListViewFragment<Sim
public void onShow(DialogInterface dialog) {
AlertDialog alertDialog = (AlertDialog) dialog;
final AutoCompleteTextView editText = (AutoCompleteTextView) alertDialog.findViewById(R.id.edit_text);
assert editText != null;
final Bundle args = getArguments();
final int autoCompleteType;
autoCompleteType = args.getInt(EXTRA_AUTO_COMPLETE_TYPE, 0);
@ -318,6 +319,7 @@ public abstract class BaseFiltersFragment extends AbsContentListViewFragment<Sim
protected String getText() {
AlertDialog alertDialog = (AlertDialog) getDialog();
final AutoCompleteTextView editText = (AutoCompleteTextView) alertDialog.findViewById(R.id.edit_text);
assert editText != null;
return ParseUtils.parseString(editText.getText());
}

View File

@ -43,12 +43,13 @@ public class CreateUserListDialogFragment extends BaseSupportDialogFragment impl
final AlertDialog alertDialog = (AlertDialog) dialog;
final Bundle args = getArguments();
final UserKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY);
final MaterialEditText mEditName = (MaterialEditText) alertDialog.findViewById(R.id.name);
final MaterialEditText mEditDescription = (MaterialEditText) alertDialog.findViewById(R.id.description);
final CheckBox mPublicCheckBox = (CheckBox) alertDialog.findViewById(R.id.is_public);
final String name = ParseUtils.parseString(mEditName.getText());
final String description = ParseUtils.parseString(mEditDescription.getText());
final boolean isPublic = mPublicCheckBox.isChecked();
final MaterialEditText editName = (MaterialEditText) alertDialog.findViewById(R.id.name);
final MaterialEditText editDescription = (MaterialEditText) alertDialog.findViewById(R.id.description);
final CheckBox editPublic = (CheckBox) alertDialog.findViewById(R.id.is_public);
assert editName != null && editDescription != null && editPublic != null;
final String name = ParseUtils.parseString(editName.getText());
final String description = ParseUtils.parseString(editDescription.getText());
final boolean isPublic = editPublic.isChecked();
if (TextUtils.isEmpty(name)) return;
mTwitterWrapper.createUserListAsync(accountKey, name, isPublic, description);
break;

View File

@ -232,6 +232,7 @@ public class FileSelectorDialogFragment extends BaseSupportDialogFragment implem
text.setPadding(mPadding, mPadding, position, mPadding);
final Drawable icon = ResourcesCompat.getDrawable(mResources,
file.isDirectory() ? R.drawable.ic_folder : R.drawable.ic_file, null);
assert icon != null;
icon.mutate();
icon.setColorFilter(mActionIconColor, PorterDuff.Mode.SRC_ATOP);
text.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);

View File

@ -425,18 +425,18 @@ public class UserListFragment extends AbsToolbarTabPagesFragment implements OnCl
public void onShow(DialogInterface dialog) {
AlertDialog alertDialog = (AlertDialog) dialog;
MaterialEditText mEditName = (MaterialEditText) alertDialog.findViewById(R.id.name);
MaterialEditText mEditDescription = (MaterialEditText) alertDialog.findViewById(R.id.description);
CheckBox mPublicCheckBox = (CheckBox) alertDialog.findViewById(R.id.is_public);
mEditName.addValidator(new UserListNameValidator(getString(R.string.invalid_list_name)));
MaterialEditText editName = (MaterialEditText) alertDialog.findViewById(R.id.name);
MaterialEditText editDescription = (MaterialEditText) alertDialog.findViewById(R.id.description);
CheckBox editPublic = (CheckBox) alertDialog.findViewById(R.id.is_public);
assert editName != null && editDescription != null && editPublic != null;
editName.addValidator(new UserListNameValidator(getString(R.string.invalid_list_name)));
if (mName != null) {
mEditName.setText(mName);
editName.setText(mName);
}
if (mDescription != null) {
mEditDescription.setText(mDescription);
editDescription.setText(mDescription);
}
mPublicCheckBox.setChecked(mIsPublic);
editPublic.setChecked(mIsPublic);
}
});
return dialog;

View File

@ -354,6 +354,7 @@ public class LikeAnimationDrawable extends Drawable implements Animatable, Drawa
mIconDrawable.setBounds(left, top, right, bottom);
}
@NonNull
@Override
public Drawable newDrawable() {
return new LikeAnimationDrawable(this);

View File

@ -4,6 +4,7 @@ import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import org.mariotaku.twidere.graphic.like.LikeAnimationDrawable;
@ -67,6 +68,7 @@ public class CircleLayerDrawable extends AnimationLayerDrawable {
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
}
@NonNull
@Override
public Drawable newDrawable() {
return new CircleLayerDrawable(mIntrinsicWidth, mIntrinsicHeight, mPalette);

View File

@ -4,6 +4,7 @@ import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import org.mariotaku.twidere.graphic.like.LikeAnimationDrawable;
@ -98,6 +99,7 @@ public class ParticleLayerDrawable extends AnimationLayerDrawable {
setProgress(-1);
}
@NonNull
@Override
public Drawable newDrawable() {
return new ParticleLayerDrawable(mIntrinsicWidth, mIntrinsicHeight, mPalette);

View File

@ -168,6 +168,7 @@ public class ScalableDrawable extends Drawable implements Drawable.Callback {
mScale = state.getScale();
}
@NonNull
@Override
public Drawable newDrawable() {
return new ScalableDrawable(this);

View File

@ -4,6 +4,7 @@ import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import org.mariotaku.twidere.graphic.like.LikeAnimationDrawable;
@ -118,6 +119,7 @@ public class ShineLayerDrawable extends AnimationLayerDrawable {
return mPaint;
}
@NonNull
@Override
public Drawable newDrawable() {
return new ShineLayerDrawable(mIntrinsicWidth, mIntrinsicHeight, mPalette);

View File

@ -65,7 +65,7 @@ public class MultiSelectManager implements Constants {
return mSelectedItems.contains(object);
}
public boolean isStatusSelected(final long statusId) {
public boolean isStatusSelected(final String statusId) {
return mSelectedStatusIds.contains(statusId);
}

View File

@ -236,7 +236,7 @@ public class ThemeUtils implements Constants {
if (!context.getTheme().resolveAttribute(attr, outValue, true))
return def;
if (outValue.type == TypedValue.TYPE_REFERENCE)
return context.getResources().getColor(attr);
return ContextCompat.getColor(context, attr);
return outValue.data;
}
@ -290,7 +290,7 @@ public class ThemeUtils implements Constants {
}
}
public static String getThemeFontFamily(@NonNull final SharedPreferences pref) {
public static String getThemeFontFamily(@NonNull final SharedPreferences pref) {
final String fontFamily = pref.getString(KEY_THEME_FONT_FAMILY, VALUE_THEME_FONT_FAMILY_REGULAR);
if (!TextUtils.isEmpty(fontFamily)) return fontFamily;
return VALUE_THEME_FONT_FAMILY_REGULAR;

View File

@ -244,6 +244,7 @@ public class TwidereMediaDownloader implements MediaDownloader, Constants {
return mBody.length();
}
@NonNull
@Override
public InputStream getStream() throws IOException {
return mBody.stream();

View File

@ -1,6 +1,7 @@
package org.mariotaku.twidere.util.media;
import android.net.Uri;
import android.support.annotation.NonNull;
import com.nostra13.universalimageloader.cache.disc.DiskCache;
import com.nostra13.universalimageloader.utils.IoUtils;
@ -25,17 +26,17 @@ public class UILFileCache implements FileCache {
}
@Override
public File get(final String key) {
public File get(@NonNull final String key) {
return cache.get(key);
}
@Override
public void remove(final String key) {
public void remove(@NonNull final String key) {
cache.remove(key);
}
@Override
public void save(final String key, final InputStream is, byte[] extra,
public void save(@NonNull final String key, @NonNull final InputStream is, byte[] extra,
final CopyListener listener) throws IOException {
cache.save(key, is, new IoUtils.CopyListener() {
@Override
@ -48,13 +49,15 @@ public class UILFileCache implements FileCache {
}
}
@NonNull
@Override
public Uri toUri(final String key) {
public Uri toUri(@NonNull final String key) {
return CacheProvider.getCacheUri(key, null);
}
@NonNull
@Override
public String fromUri(final Uri uri) {
public String fromUri(@NonNull final Uri uri) {
return CacheProvider.getCacheKey(uri);
}
}

View File

@ -174,12 +174,12 @@ public class LinePageIndicator extends View implements PagerIndicator {
if (mViewPager == viewPager) return;
if (mViewPager != null) {
// Clear us from the old pager.
mViewPager.setOnPageChangeListener(null);
mViewPager.removeOnPageChangeListener(this);
}
if (viewPager.getAdapter() == null)
throw new IllegalStateException("ViewPager does not have adapter instance.");
mViewPager = viewPager;
mViewPager.setOnPageChangeListener(this);
mViewPager.addOnPageChangeListener(this);
invalidate();
}

View File

@ -366,7 +366,7 @@ public class ShapedImageView extends ImageView {
public void setBackground(Drawable background) {
}
@Deprecated
@SuppressWarnings("deprecation")
@Override
public void setBackgroundDrawable(Drawable background) {
// No-op

View File

@ -218,7 +218,7 @@ public class TabPagerIndicator extends RecyclerView implements PagerIndicator, C
}
mViewPager = view;
mPagerProvider = adapter;
view.setOnPageChangeListener(this);
view.addOnPageChangeListener(this);
mIndicatorAdapter.setTabProvider((TabProvider) adapter);
}

View File

@ -31,6 +31,8 @@ import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import org.mariotaku.twidere.R;
public interface IForegroundView {
/**
@ -75,12 +77,11 @@ public interface IForegroundView {
public ForegroundViewHelper(final View view, final Context context, final AttributeSet attrs, final int defStyle) {
mView = view;
final TypedArray a = context.obtainStyledAttributes(attrs, new int[]{android.R.attr.foreground,
android.R.attr.foregroundGravity}, defStyle, 0);
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ForegroundView, defStyle, 0);
mForegroundGravity = a.getInt(1, mForegroundGravity);
mForegroundGravity = a.getInt(R.styleable.ForegroundView_android_foregroundGravity, mForegroundGravity);
final Drawable d = a.getDrawable(0);
final Drawable d = a.getDrawable(R.styleable.ForegroundView_android_foreground);
if (d != null) {
setForeground(d);
}

View File

@ -123,6 +123,10 @@
<attr name="android:showDefault"/>
<attr name="android:showSilent"/>
</declare-styleable>
<declare-styleable name="ForegroundView">
<attr name="android:foreground"/>
<attr name="android:foregroundGravity"/>
</declare-styleable>
<attr name="notificationType">
<flag name="none" value="0"/>
<flag name="ringtone" value="1"/>

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!--suppress AndroidElementNotAllowed -->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"

View File

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
<!--suppress AndroidElementNotAllowed -->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/other_settings">
<Preference
@ -7,19 +9,19 @@
android:title="@string/usage_statistics">
<extra
android:name="resid"
android:value="@xml/preferences_usage_statistics" />
android:value="@xml/preferences_usage_statistics"/>
</Preference>
<org.mariotaku.twidere.preference.SettingsImportExportPreference
android:key="import_export_settings"
android:title="@string/import_export_settings" />
android:title="@string/import_export_settings"/>
<Preference
android:fragment="org.mariotaku.twidere.fragment.SettingsDetailsFragment"
android:title="@string/scrapyard">
<extra
android:name="resid"
android:value="@xml/preferences_scrapyard" />
android:value="@xml/preferences_scrapyard"/>
</Preference>
<SwitchPreferenceCompat

View File

@ -18,6 +18,7 @@
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<!--suppress AndroidElementNotAllowed -->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<org.mariotaku.twidere.preference.EntrySummaryListPreference

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!--suppress AndroidElementNotAllowed -->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"

View File

@ -18,6 +18,7 @@
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<!--suppress AndroidElementNotAllowed -->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/thumbor_integration">

View File

@ -17,6 +17,7 @@
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<!--suppress AndroidElementNotAllowed -->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<SwitchPreferenceCompat

View File

@ -18,6 +18,7 @@
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<!--suppress AndroidElementNotAllowed -->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/usage_statistics">