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 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 interface IDrawingHelper {
public void dispatchOnDraw(final Canvas canvas); 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 { public static final class TileBitmapDrawable extends BitmapDrawable {
@ -477,7 +477,7 @@ public class NyanDrawingHelper {
0, 0, 0, 0, 0, 0, 0 0, 0, 0, 0, 0, 0, 0
} }
}; };
static final byte[][] FRAME2 = { byte[][] FRAME2 = {
{ {
0, 0, 0, 0, 0, 0, 0 0, 0, 0, 0, 0, 0, 0
}, },
@ -500,7 +500,7 @@ public class NyanDrawingHelper {
0, 0, 0, 0, 0, 0, 0 0, 0, 0, 0, 0, 0, 0
} }
}; };
static final byte[][] FRAME3 = { byte[][] FRAME3 = {
{ {
0, 0, 0, 0, 0, 0, 0 0, 0, 0, 0, 0, 0, 0
}, },
@ -523,7 +523,7 @@ public class NyanDrawingHelper {
0, 0, 0, 0, 0, 0, 0 0, 0, 0, 0, 0, 0, 0
} }
}; };
static final byte[][] FRAME4 = { byte[][] FRAME4 = {
{ {
0, 0, 0, 1, 0, 0, 0 0, 0, 0, 1, 0, 0, 0
}, },
@ -546,7 +546,7 @@ public class NyanDrawingHelper {
0, 0, 0, 1, 0, 0, 0 0, 0, 0, 1, 0, 0, 0
} }
}; };
static final byte[][] FRAME5 = { byte[][] FRAME5 = {
{ {
0, 0, 0, 1, 0, 0, 0 0, 0, 0, 1, 0, 0, 0
}, },
@ -569,7 +569,7 @@ public class NyanDrawingHelper {
0, 0, 0, 1, 0, 0, 0 0, 0, 0, 1, 0, 0, 0
} }
}; };
static final byte[][] FRAME6 = { byte[][] FRAME6 = {
{ {
0, 0, 0, 1, 0, 0, 0 0, 0, 0, 1, 0, 0, 0
}, },

View File

@ -17,7 +17,9 @@ public class TwidereArrayUtilsTest {
String[] array2 = {"1", "2"}; String[] array2 = {"1", "2"};
String[] array3 = null; String[] array3 = null;
//noinspection ConstantConditions
String[] merged = new String[TwidereArrayUtils.arraysLength(array1, array2, array3)]; String[] merged = new String[TwidereArrayUtils.arraysLength(array1, array2, array3)];
//noinspection ConstantConditions
TwidereArrayUtils.mergeArray(merged, array1, array2, array3); TwidereArrayUtils.mergeArray(merged, array1, array2, array3);
String[] expected = {"1", "2", "1", "2"}; String[] expected = {"1", "2", "1", "2"};
assertArrayEquals(expected, merged); assertArrayEquals(expected, merged);
@ -28,6 +30,7 @@ public class TwidereArrayUtilsTest {
String[] array1 = {"1", "2"}; String[] array1 = {"1", "2"};
String[] array2 = {"1", "2"}; String[] array2 = {"1", "2"};
String[] array3 = null; String[] array3 = null;
//noinspection ConstantConditions
assertEquals(4, TwidereArrayUtils.arraysLength(array1, array2, array3)); assertEquals(4, TwidereArrayUtils.arraysLength(array1, array2, array3));
assertEquals(6, TwidereArrayUtils.arraysLength(array1, array2, array2)); 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.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap; 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.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions; 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)) if (args == null || !args.containsKey(EXTRA_LATITUDE) || !args.containsKey(EXTRA_LONGITUDE))
return; return;
final double lat = args.getDouble(EXTRA_LATITUDE, 0.0), lng = args.getDouble(EXTRA_LONGITUDE, 0.0); final double lat = args.getDouble(EXTRA_LATITUDE, 0.0), lng = args.getDouble(EXTRA_LONGITUDE, 0.0);
mMapView = getMap(); getMapAsync(new OnMapReadyCallback() {
final MarkerOptions marker = new MarkerOptions(); @Override
marker.position(new LatLng(lat, lng)); public void onMapReady(GoogleMap googleMap) {
mMapView.addMarker(marker); mMapView = googleMap;
center(false); final MarkerOptions marker = new MarkerOptions();
marker.position(new LatLng(lat, lng));
mMapView.addMarker(marker);
center(false);
}
});
} }
@Override @Override

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -236,7 +236,7 @@ public class ThemeUtils implements Constants {
if (!context.getTheme().resolveAttribute(attr, outValue, true)) if (!context.getTheme().resolveAttribute(attr, outValue, true))
return def; return def;
if (outValue.type == TypedValue.TYPE_REFERENCE) if (outValue.type == TypedValue.TYPE_REFERENCE)
return context.getResources().getColor(attr); return ContextCompat.getColor(context, attr);
return outValue.data; 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); final String fontFamily = pref.getString(KEY_THEME_FONT_FAMILY, VALUE_THEME_FONT_FAMILY_REGULAR);
if (!TextUtils.isEmpty(fontFamily)) return fontFamily; if (!TextUtils.isEmpty(fontFamily)) return fontFamily;
return VALUE_THEME_FONT_FAMILY_REGULAR; return VALUE_THEME_FONT_FAMILY_REGULAR;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?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"> android:title="@string/other_settings">
<Preference <Preference
@ -7,19 +9,19 @@
android:title="@string/usage_statistics"> android:title="@string/usage_statistics">
<extra <extra
android:name="resid" android:name="resid"
android:value="@xml/preferences_usage_statistics" /> android:value="@xml/preferences_usage_statistics"/>
</Preference> </Preference>
<org.mariotaku.twidere.preference.SettingsImportExportPreference <org.mariotaku.twidere.preference.SettingsImportExportPreference
android:key="import_export_settings" android:key="import_export_settings"
android:title="@string/import_export_settings" /> android:title="@string/import_export_settings"/>
<Preference <Preference
android:fragment="org.mariotaku.twidere.fragment.SettingsDetailsFragment" android:fragment="org.mariotaku.twidere.fragment.SettingsDetailsFragment"
android:title="@string/scrapyard"> android:title="@string/scrapyard">
<extra <extra
android:name="resid" android:name="resid"
android:value="@xml/preferences_scrapyard" /> android:value="@xml/preferences_scrapyard"/>
</Preference> </Preference>
<SwitchPreferenceCompat <SwitchPreferenceCompat

View File

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

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!--suppress AndroidElementNotAllowed -->
<PreferenceScreen <PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" 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/>. ~ along with this program. If not, see <http://www.gnu.org/licenses/>.
--> -->
<!--suppress AndroidElementNotAllowed -->
<PreferenceScreen <PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/thumbor_integration"> android:title="@string/thumbor_integration">

View File

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

View File

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