mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-02-07 15:28:51 +01:00
code cleanup
This commit is contained in:
parent
9ba87d4d21
commit
76a9088a7b
@ -102,8 +102,8 @@ dependencies {
|
||||
compile project(':twidere.component.nyan')
|
||||
|
||||
// START Non-FOSS component
|
||||
googleCompile 'com.google.android.gms:play-services-maps:10.0.0'
|
||||
googleCompile 'com.google.android.gms:play-services-auth:10.0.0'
|
||||
googleCompile 'com.google.android.gms:play-services-maps:10.0.1'
|
||||
googleCompile 'com.google.android.gms:play-services-auth:10.0.1'
|
||||
googleCompile 'com.google.maps.android:android-maps-utils:0.4.4'
|
||||
googleCompile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') { transitive = true }
|
||||
googleCompile ':YouTubeAndroidPlayerApi:1.2.2@jar'
|
||||
|
@ -52,8 +52,8 @@ Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||||
compile project(':twidere.component.nyan')
|
||||
|
||||
// START Non-FOSS component
|
||||
- googleCompile 'com.google.android.gms:play-services-maps:10.0.0'
|
||||
- googleCompile 'com.google.android.gms:play-services-auth:10.0.0'
|
||||
- googleCompile 'com.google.android.gms:play-services-maps:10.0.1'
|
||||
- googleCompile 'com.google.android.gms:play-services-auth:10.0.1'
|
||||
- googleCompile 'com.google.maps.android:android-maps-utils:0.4.4'
|
||||
- googleCompile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') { transitive = true }
|
||||
- googleCompile ':YouTubeAndroidPlayerApi:1.2.2@jar'
|
||||
|
@ -134,7 +134,7 @@ class GoogleMapFragment : SupportMapFragment(), Constants, IMapFragment, IBaseFr
|
||||
actionHelper.executeAfterFragmentResumed(action)
|
||||
}
|
||||
|
||||
protected fun fitSystemWindows(insets: Rect) {
|
||||
private fun fitSystemWindows(insets: Rect) {
|
||||
val view = view
|
||||
view?.setPadding(insets.left, insets.top, insets.right, insets.bottom)
|
||||
}
|
||||
|
@ -473,7 +473,8 @@
|
||||
android:label="@string/label_background_operation_service"/>
|
||||
<service
|
||||
android:name=".service.AccountAuthenticatorService"
|
||||
android:exported="true">
|
||||
android:exported="true"
|
||||
tools:ignore="ExportedService">
|
||||
<intent-filter>
|
||||
<action android:name="android.accounts.AccountAuthenticator"/>
|
||||
</intent-filter>
|
||||
@ -484,7 +485,8 @@
|
||||
<service
|
||||
android:name=".service.AccountSyncService"
|
||||
android:exported="true"
|
||||
android:process=":sync">
|
||||
android:process=":sync"
|
||||
tools:ignore="ExportedService">
|
||||
<intent-filter>
|
||||
<action android:name="android.content.SyncAdapter"/>
|
||||
</intent-filter>
|
||||
|
@ -12,7 +12,6 @@ import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
|
||||
import com.hannesdorfmann.parcelableplease.annotation.ParcelableThisPlease;
|
||||
|
||||
import org.mariotaku.twidere.annotation.Referral;
|
||||
import org.mariotaku.twidere.fragment.UserFragment;
|
||||
import org.mariotaku.twidere.model.ParcelableUser;
|
||||
|
||||
/**
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package org.mariotaku.microblog.library.twitter;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
@ -169,7 +170,7 @@ public abstract class UserStreamCallback implements RawCallback {
|
||||
|
||||
public abstract void onStatus(Status status) throws IOException;
|
||||
|
||||
public abstract void onDirectMessage(DirectMessage directMessage) throws IOException;
|
||||
public abstract void onDirectMessage(@NonNull DirectMessage directMessage) throws IOException;
|
||||
|
||||
public abstract void onBlock(User source, User blockedUser);
|
||||
|
||||
|
@ -105,5 +105,6 @@ public interface Constants extends TwidereConstants {
|
||||
@Preference(type = STRING, exportable = false)
|
||||
String KEY_DEVICE_SERIAL = "device_serial";
|
||||
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
String GOOGLE_APIS_SERVER_CLIENT_ID = "223623398518-1p34hsndj7couh2c9c2f8909amh9euhf.apps.googleusercontent.com";
|
||||
}
|
||||
|
@ -256,6 +256,7 @@ public class BrowserSignInActivity extends BaseActivity {
|
||||
mActivity.setLoadProgressShown(false);
|
||||
if (result.hasData()) {
|
||||
final OAuthToken token = result.getData();
|
||||
assert token != null;
|
||||
mActivity.setRequestToken(token);
|
||||
final Endpoint endpoint = MicroBlogAPIFactory.getOAuthSignInEndpoint(mAPIUrlFormat, true);
|
||||
mActivity.loadUrl(endpoint.construct("/oauth/authorize", new String[]{"oauth_token", token.getOauthToken()}));
|
||||
|
@ -86,7 +86,7 @@ public class KeyboardShortcutPreferenceCompatActivity extends BaseActivity imple
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) {
|
||||
if (KeyEvent.isModifierKey(keyCode)) {
|
||||
mMetaState |= KeyboardShortcutsHandler.getMetaStateForKeyCode(keyCode);
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ public class UserListSelectorActivity extends BaseActivity implements OnClickLis
|
||||
|
||||
@Override
|
||||
protected SingleResponse<List<ParcelableUserList>> doInBackground(final Object... params) {
|
||||
final MicroBlog twitter = MicroBlogAPIFactory.getInstance(mActivity, mAccountKey, false);
|
||||
final MicroBlog twitter = MicroBlogAPIFactory.getInstance(mActivity, mAccountKey);
|
||||
if (twitter == null) return SingleResponse.Companion.getInstance();
|
||||
try {
|
||||
final ResponseList<UserList> lists = twitter.getUserLists(mScreenName, true);
|
||||
@ -363,7 +363,7 @@ public class UserListSelectorActivity extends BaseActivity implements OnClickLis
|
||||
|
||||
@Override
|
||||
protected SingleResponse<List<ParcelableUser>> doInBackground(final Object... params) {
|
||||
final MicroBlog twitter = MicroBlogAPIFactory.getInstance(mActivity, mAccountKey, false);
|
||||
final MicroBlog twitter = MicroBlogAPIFactory.getInstance(mActivity, mAccountKey);
|
||||
if (twitter == null) return SingleResponse.Companion.getInstance();
|
||||
try {
|
||||
final Paging paging = new Paging();
|
||||
|
@ -41,7 +41,7 @@ public class DestroyUserListDialogFragment extends BaseDialogFragment implements
|
||||
case DialogInterface.BUTTON_POSITIVE:
|
||||
final ParcelableUserList userList = getUserList();
|
||||
final AsyncTwitterWrapper twitter = twitterWrapper;
|
||||
if (userList == null || twitter == null) return;
|
||||
if (userList == null) return;
|
||||
twitter.destroyUserListAsync(userList.account_key, userList.id);
|
||||
break;
|
||||
default:
|
||||
|
@ -168,7 +168,7 @@ public class NetworkDiagnosticsFragment extends BaseSupportFragment {
|
||||
|
||||
for (UserKey accountKey : DataStoreUtils.getAccountKeys(mContext)) {
|
||||
final AccountDetails details = AccountUtils.getAccountDetails(AccountManager.get(mContext), accountKey);
|
||||
final MicroBlog twitter = MicroBlogAPIFactory.getInstance(mContext, accountKey, false);
|
||||
final MicroBlog twitter = MicroBlogAPIFactory.getInstance(mContext, accountKey);
|
||||
if (details == null || twitter == null) continue;
|
||||
publishProgress(new LogText("Testing connection for account " + accountKey));
|
||||
publishProgress(LogText.LINEBREAK);
|
||||
|
@ -22,6 +22,7 @@ import android.graphics.ColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
/**
|
||||
* This drawable that draws a simple white and gray chessboard pattern. It's
|
||||
@ -45,7 +46,7 @@ public class AlphaPatternDrawable extends Drawable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(final Canvas canvas) {
|
||||
public void draw(@NonNull final Canvas canvas) {
|
||||
|
||||
boolean verticalStartWhite = true;
|
||||
for (int i = 0; i <= mNumRectanglesVertical; i++) {
|
||||
|
@ -4,6 +4,7 @@ import android.graphics.Canvas;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
public class EmptyDrawable extends Drawable {
|
||||
|
||||
@ -49,7 +50,7 @@ public class EmptyDrawable extends Drawable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(final Canvas canvas) {
|
||||
public void draw(@NonNull final Canvas canvas) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ import android.graphics.Canvas;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
public class PaddingDrawable extends Drawable {
|
||||
|
||||
@ -46,7 +47,7 @@ public class PaddingDrawable extends Drawable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(final Canvas canvas) {
|
||||
public void draw(@NonNull final Canvas canvas) {
|
||||
mDrawable.draw(canvas);
|
||||
}
|
||||
|
||||
@ -76,7 +77,7 @@ public class PaddingDrawable extends Drawable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBounds(final Rect bounds) {
|
||||
public void setBounds(@NonNull final Rect bounds) {
|
||||
final int left = bounds.left + mPaddingLeft;
|
||||
final int top = bounds.top + mPaddingTop;
|
||||
final int right = bounds.right - mPaddingRight;
|
||||
|
@ -35,6 +35,7 @@ import android.graphics.Path;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.text.Layout;
|
||||
import android.text.StaticLayout;
|
||||
import android.text.TextPaint;
|
||||
@ -153,7 +154,7 @@ public class TextDrawable extends Drawable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(final Canvas canvas) {
|
||||
public void draw(@NonNull final Canvas canvas) {
|
||||
if (mTextPath == null) {
|
||||
// Allow the layout to draw the text
|
||||
mTextLayout.draw(canvas);
|
||||
|
@ -4,6 +4,7 @@ import android.graphics.Canvas;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 16/3/30.
|
||||
@ -17,7 +18,7 @@ public class WindowBackgroundDrawable extends Drawable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
public void draw(@NonNull Canvas canvas) {
|
||||
canvas.drawColor(color);
|
||||
}
|
||||
|
||||
|
@ -203,7 +203,7 @@ public class LikeAnimationDrawable extends Drawable implements Animatable, Drawa
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
public void draw(@NonNull Canvas canvas) {
|
||||
mState.mCircleLayer.draw(canvas);
|
||||
mState.mParticleLayer.draw(canvas);
|
||||
mState.mIconDrawable.draw(canvas);
|
||||
@ -231,17 +231,17 @@ public class LikeAnimationDrawable extends Drawable implements Animatable, Drawa
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidateDrawable(Drawable who) {
|
||||
public void invalidateDrawable(@NonNull Drawable who) {
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduleDrawable(Drawable who, Runnable what, long when) {
|
||||
public void scheduleDrawable(@NonNull Drawable who, @NonNull Runnable what, long when) {
|
||||
scheduleSelf(what, when);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unscheduleDrawable(Drawable who, Runnable what) {
|
||||
public void unscheduleDrawable(@NonNull Drawable who, @NonNull Runnable what) {
|
||||
unscheduleSelf(what);
|
||||
}
|
||||
|
||||
@ -255,6 +255,7 @@ public class LikeAnimationDrawable extends Drawable implements Animatable, Drawa
|
||||
return super.getChangingConfigurations() | mState.getChangingConfigurations();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Drawable mutate() {
|
||||
if (!mMutated && super.mutate() == this) {
|
||||
|
@ -3,6 +3,7 @@ package org.mariotaku.twidere.graphic.like.layer;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import org.mariotaku.twidere.graphic.like.LikeAnimationDrawable;
|
||||
|
||||
@ -61,6 +62,7 @@ public abstract class AnimationLayerDrawable extends Drawable implements LikeAni
|
||||
return mState;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Drawable mutate() {
|
||||
if (!mMutated && super.mutate() == this) {
|
||||
|
@ -26,7 +26,7 @@ public class CircleLayerDrawable extends AnimationLayerDrawable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(final Canvas canvas) {
|
||||
public void draw(@NonNull final Canvas canvas) {
|
||||
final CircleState state = (CircleState) mState;
|
||||
final float progress = getProgress();
|
||||
final Rect bounds = getBounds();
|
||||
|
@ -28,7 +28,7 @@ public class ParticleLayerDrawable extends AnimationLayerDrawable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(final Canvas canvas) {
|
||||
public void draw(@NonNull final Canvas canvas) {
|
||||
final ParticleLayerState state = (ParticleLayerState) mState;
|
||||
final float progress = getProgress();
|
||||
if (progress < 0) return;
|
||||
|
@ -33,21 +33,21 @@ public class ScalableDrawable extends Drawable implements Drawable.Callback {
|
||||
|
||||
// overrides from Drawable.Callback
|
||||
@Override
|
||||
public void invalidateDrawable(Drawable who) {
|
||||
public void invalidateDrawable(@NonNull Drawable who) {
|
||||
if (getCallback() != null) {
|
||||
getCallback().invalidateDrawable(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduleDrawable(Drawable who, Runnable what, long when) {
|
||||
public void scheduleDrawable(@NonNull Drawable who, @NonNull Runnable what, long when) {
|
||||
if (getCallback() != null) {
|
||||
getCallback().scheduleDrawable(this, what, when);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unscheduleDrawable(Drawable who, Runnable what) {
|
||||
public void unscheduleDrawable(@NonNull Drawable who, @NonNull Runnable what) {
|
||||
if (getCallback() != null) {
|
||||
getCallback().unscheduleDrawable(this, what);
|
||||
}
|
||||
@ -55,7 +55,7 @@ public class ScalableDrawable extends Drawable implements Drawable.Callback {
|
||||
|
||||
// overrides from Drawable
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
public void draw(@NonNull Canvas canvas) {
|
||||
if (mState.getScale() <= 0) return;
|
||||
mState.mDrawable.draw(canvas);
|
||||
}
|
||||
@ -126,6 +126,7 @@ public class ScalableDrawable extends Drawable implements Drawable.Callback {
|
||||
return mState.mDrawable.getIntrinsicHeight();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Drawable mutate() {
|
||||
if (!mMutated && super.mutate() == this) {
|
||||
|
@ -20,7 +20,7 @@ public class ShineLayerDrawable extends AnimationLayerDrawable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
public void draw(@NonNull Canvas canvas) {
|
||||
final ShineLayerState state = (ShineLayerState) mState;
|
||||
final float progress = getProgress();
|
||||
if (progress < 0) return;
|
||||
|
@ -78,7 +78,7 @@ public abstract class BaseGroupsLoader extends AsyncTaskLoader<List<ParcelableGr
|
||||
|
||||
@Override
|
||||
public List<ParcelableGroup> loadInBackground() {
|
||||
final MicroBlog twitter = MicroBlogAPIFactory.getInstance(getContext(), mAccountId, true);
|
||||
final MicroBlog twitter = MicroBlogAPIFactory.getInstance(getContext(), mAccountId);
|
||||
List<Group> listLoaded = null;
|
||||
try {
|
||||
listLoaded = getGroups(twitter);
|
||||
|
@ -78,7 +78,7 @@ public abstract class BaseUserListsLoader extends AsyncTaskLoader<List<Parcelabl
|
||||
|
||||
@Override
|
||||
public List<ParcelableUserList> loadInBackground() {
|
||||
final MicroBlog twitter = MicroBlogAPIFactory.getInstance(getContext(), mAccountId, true);
|
||||
final MicroBlog twitter = MicroBlogAPIFactory.getInstance(getContext(), mAccountId);
|
||||
List<UserList> listLoaded = null;
|
||||
try {
|
||||
listLoaded = getUserLists(twitter);
|
||||
|
@ -3,6 +3,7 @@ package org.mariotaku.twidere.menu;
|
||||
import android.content.Context;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.view.ActionProvider;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
@ -89,21 +90,21 @@ public class FavoriteItemProvider extends ActionProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidateDrawable(Drawable who) {
|
||||
public void invalidateDrawable(@NonNull Drawable who) {
|
||||
final View view = mViewRef.get();
|
||||
if (view == null) return;
|
||||
view.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduleDrawable(Drawable who, Runnable what, long when) {
|
||||
public void scheduleDrawable(@NonNull Drawable who, @NonNull Runnable what, long when) {
|
||||
final View view = mViewRef.get();
|
||||
if (view == null) return;
|
||||
view.postDelayed(what, when);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unscheduleDrawable(Drawable who, Runnable what) {
|
||||
public void unscheduleDrawable(@NonNull Drawable who, @NonNull Runnable what) {
|
||||
final View view = mViewRef.get();
|
||||
if (view == null) return;
|
||||
view.post(what);
|
||||
|
@ -20,7 +20,6 @@
|
||||
package org.mariotaku.twidere.model;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import org.mariotaku.twidere.util.TwidereArrayUtils;
|
||||
|
||||
|
@ -81,6 +81,7 @@ public class AccountUtils {
|
||||
details.activated = AccountExtensionsKt.isActivated(account, am);
|
||||
details.type = AccountExtensionsKt.getAccountType(account, am);
|
||||
details.credentials_type = AccountExtensionsKt.getCredentialsType(account, am);
|
||||
details.extras = AccountExtensionsKt.getAccountExtras(account, am);
|
||||
|
||||
details.user.color = details.color;
|
||||
return details;
|
||||
|
@ -259,9 +259,10 @@ public class ParcelableMediaUtils {
|
||||
case ParcelableMedia.Type.CARD_ANIMATED_GIF:
|
||||
case ParcelableMedia.Type.EXTERNAL_PLAYER:
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static ParcelableMedia findByUrl(@Nullable ParcelableMedia[] media, @Nullable String url) {
|
||||
if (media == null || url == null) return null;
|
||||
|
@ -22,6 +22,7 @@ package org.mariotaku.twidere.preference;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
@ -73,7 +74,7 @@ public class CardPreviewPreference extends Preference implements OnSharedPrefere
|
||||
mHolder.displaySampleStatus();
|
||||
mHolder.setStatusClickListener(new IStatusViewHolder.SimpleStatusClickListener() {
|
||||
@Override
|
||||
public void onItemActionClick(RecyclerView.ViewHolder holder, int id, int position) {
|
||||
public void onItemActionClick(@NonNull RecyclerView.ViewHolder holder, int id, int position) {
|
||||
if (id == R.id.favorite) {
|
||||
((StatusViewHolder) holder).playLikeAnimation(new LikeAnimationDrawable.OnLikedListener() {
|
||||
@Override
|
||||
|
@ -25,6 +25,7 @@ import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnCancelListener;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.text.TextUtils;
|
||||
@ -125,8 +126,9 @@ public class TranslationDestinationPreference extends Preference implements OnCl
|
||||
return -1;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public View getView(final int position, final View convertView, final ViewGroup parent) {
|
||||
public View getView(final int position, final View convertView, @NonNull final ViewGroup parent) {
|
||||
final View view = super.getView(position, convertView, parent);
|
||||
final TextView text = (TextView) (view instanceof TextView ? view : view.findViewById(android.R.id.text1));
|
||||
final Language item = getItem(position);
|
||||
|
@ -139,7 +139,6 @@ import org.mariotaku.twidere.util.UriExtraUtils;
|
||||
import org.mariotaku.twidere.util.UserColorNameManager;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.util.collection.CompactHashSet;
|
||||
import org.mariotaku.twidere.util.content.TwidereSQLiteOpenHelper;
|
||||
import org.mariotaku.twidere.util.dagger.GeneralComponentHelper;
|
||||
import org.mariotaku.twidere.util.media.preview.PreviewMediaExtractor;
|
||||
import org.mariotaku.twidere.util.net.TwidereDns;
|
||||
|
@ -261,7 +261,7 @@ public class RefreshService extends Service implements Constants {
|
||||
screenFilter.addAction(Intent.ACTION_USER_PRESENT);
|
||||
registerReceiver(mPowerStateReceiver, batteryFilter);
|
||||
registerReceiver(mScreenStateReceiver, screenFilter);
|
||||
PowerStateReceiver.setServiceReceiverStarted(true);
|
||||
PowerStateReceiver.Companion.setServiceReceiverStarted(true);
|
||||
if (Utils.hasAutoRefreshAccounts(this)) {
|
||||
startAutoRefresh();
|
||||
} else {
|
||||
@ -271,7 +271,7 @@ public class RefreshService extends Service implements Constants {
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
PowerStateReceiver.setServiceReceiverStarted(false);
|
||||
PowerStateReceiver.Companion.setServiceReceiverStarted(false);
|
||||
unregisterReceiver(mScreenStateReceiver);
|
||||
unregisterReceiver(mPowerStateReceiver);
|
||||
unregisterReceiver(mStateReceiver);
|
||||
|
@ -70,6 +70,7 @@ public abstract class AbsFriendshipOperationTask extends AbstractTask<AbsFriends
|
||||
event.setFinished(true);
|
||||
if (result.hasData()) {
|
||||
final ParcelableUser user = result.getData();
|
||||
assert user != null;
|
||||
showSucceededMessage(params, user);
|
||||
event.setSucceeded(true);
|
||||
event.setUser(result.getData());
|
||||
|
@ -71,7 +71,7 @@ public abstract class GetDirectMessagesTask extends AbstractTask<RefreshTaskPara
|
||||
int idx = 0;
|
||||
final int loadItemLimit = preferences.getInt(KEY_LOAD_ITEM_LIMIT, DEFAULT_LOAD_ITEM_LIMIT);
|
||||
for (final UserKey accountKey : accountKeys) {
|
||||
final MicroBlog twitter = MicroBlogAPIFactory.getInstance(context, accountKey, true);
|
||||
final MicroBlog twitter = MicroBlogAPIFactory.getInstance(context, accountKey);
|
||||
if (twitter == null) continue;
|
||||
try {
|
||||
final Paging paging = new Paging();
|
||||
|
@ -36,7 +36,7 @@ public class GetSavedSearchesTask extends AbstractTask<UserKey[], SingleResponse
|
||||
public SingleResponse<Object> doLongOperation(UserKey[] params) {
|
||||
final ContentResolver cr = mContext.getContentResolver();
|
||||
for (UserKey accountKey : params) {
|
||||
final MicroBlog twitter = MicroBlogAPIFactory.getInstance(mContext, accountKey, true);
|
||||
final MicroBlog twitter = MicroBlogAPIFactory.getInstance(mContext, accountKey);
|
||||
if (twitter == null) continue;
|
||||
try {
|
||||
final ResponseList<SavedSearch> searches = twitter.getSavedSearches();
|
||||
|
@ -46,7 +46,7 @@ public abstract class GetTrendsTask extends AbstractTask<Object, Object, Object>
|
||||
|
||||
@Override
|
||||
public Object doLongOperation(final Object param) {
|
||||
final MicroBlog twitter = MicroBlogAPIFactory.getInstance(mContext, mAccountId, false);
|
||||
final MicroBlog twitter = MicroBlogAPIFactory.getInstance(mContext, mAccountId);
|
||||
if (twitter == null) return null;
|
||||
try {
|
||||
final List<Trends> trends = getTrends(twitter);
|
||||
|
@ -69,8 +69,8 @@ public class UpdateProfileBackgroundImageTask<ResultHandler> extends AbstractTas
|
||||
@Override
|
||||
protected SingleResponse<ParcelableUser> doLongOperation(final Object params) {
|
||||
try {
|
||||
final MicroBlog twitter = MicroBlogAPIFactory.getInstance(mContext, mAccountKey,
|
||||
true);
|
||||
final MicroBlog twitter = MicroBlogAPIFactory.getInstance(mContext, mAccountKey
|
||||
);
|
||||
TwitterWrapper.updateProfileBackgroundImage(mContext, twitter, mImageUri, mTile,
|
||||
mDeleteImage);
|
||||
// Wait for 5 seconds, see
|
||||
|
@ -65,8 +65,8 @@ public class UpdateProfileBannerImageTask<ResultHandler> extends AbstractTask<Ob
|
||||
@Override
|
||||
protected SingleResponse<ParcelableUser> doLongOperation(final Object params) {
|
||||
try {
|
||||
final MicroBlog twitter = MicroBlogAPIFactory.getInstance(mContext, mAccountKey,
|
||||
true);
|
||||
final MicroBlog twitter = MicroBlogAPIFactory.getInstance(mContext, mAccountKey
|
||||
);
|
||||
TwitterWrapper.updateProfileBannerImage(mContext, twitter, mImageUri, mDeleteImage);
|
||||
// Wait for 5 seconds, see
|
||||
// https://dev.twitter.com/docs/api/1.1/post/account/update_profile_image
|
||||
|
@ -337,8 +337,8 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void getLocalTrendsAsync(final UserKey accountId, final int woeid) {
|
||||
final GetLocalTrendsTask task = new GetLocalTrendsTask(context, accountId, woeid);
|
||||
public void getLocalTrendsAsync(final UserKey accountId, final int woeId) {
|
||||
final GetLocalTrendsTask task = new GetLocalTrendsTask(context, accountId, woeId);
|
||||
TaskStarter.execute(task);
|
||||
}
|
||||
|
||||
@ -520,7 +520,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
TaskStarter.execute(new AbstractTask<Object, SingleResponse<Relationship>, Bus>() {
|
||||
@Override
|
||||
public SingleResponse<Relationship> doLongOperation(Object param) {
|
||||
final MicroBlog microBlog = MicroBlogAPIFactory.getInstance(context, accountKey, true);
|
||||
final MicroBlog microBlog = MicroBlogAPIFactory.getInstance(context, accountKey);
|
||||
try {
|
||||
final Relationship relationship = microBlog.updateFriendship(userKey.getId(), update);
|
||||
if (!relationship.isSourceWantRetweetsFromTarget()) {
|
||||
@ -563,7 +563,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
@Override
|
||||
public Object doLongOperation(Object o) {
|
||||
for (UserKey accountId : accountKeys) {
|
||||
MicroBlog microBlog = MicroBlogAPIFactory.getInstance(context, accountId, false);
|
||||
MicroBlog microBlog = MicroBlogAPIFactory.getInstance(context, accountId);
|
||||
if (!Utils.isOfficialCredentials(context, accountId)) continue;
|
||||
try {
|
||||
microBlog.setActivitiesAboutMeUnread(cursor);
|
||||
@ -615,7 +615,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
@Override
|
||||
protected SingleResponse<ParcelableUser> doLongOperation(final Object params) {
|
||||
try {
|
||||
final MicroBlog microBlog = MicroBlogAPIFactory.getInstance(mContext, mAccountKey, true);
|
||||
final MicroBlog microBlog = MicroBlogAPIFactory.getInstance(mContext, mAccountKey);
|
||||
TwitterWrapper.updateProfileImage(mContext, microBlog, mImageUri, mDeleteImage);
|
||||
// Wait for 5 seconds, see
|
||||
// https://dev.twitter.com/rest/reference/post/account/update_profile_image
|
||||
@ -651,7 +651,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
@NonNull
|
||||
private final ParcelableUser[] mUsers;
|
||||
|
||||
public AddUserListMembersTask(@NonNull final UserKey accountKey,
|
||||
AddUserListMembersTask(@NonNull final UserKey accountKey,
|
||||
final String listId,
|
||||
@NonNull final ParcelableUser[] users) {
|
||||
super(context);
|
||||
@ -662,7 +662,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
@Override
|
||||
protected SingleResponse<ParcelableUserList> doInBackground(final Object... params) {
|
||||
final MicroBlog microBlog = MicroBlogAPIFactory.getInstance(context, mAccountKey, false);
|
||||
final MicroBlog microBlog = MicroBlogAPIFactory.getInstance(context, mAccountKey);
|
||||
if (microBlog == null) return SingleResponse.Companion.getInstance();
|
||||
try {
|
||||
final UserKey[] userIds = new UserKey[mUsers.length];
|
||||
@ -880,7 +880,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
@Override
|
||||
protected ListResponse<String> doInBackground(final Object... params) {
|
||||
final List<String> blockedUsers = new ArrayList<>();
|
||||
final MicroBlog microBlog = MicroBlogAPIFactory.getInstance(context, mAccountKey, false);
|
||||
final MicroBlog microBlog = MicroBlogAPIFactory.getInstance(context, mAccountKey);
|
||||
if (microBlog != null) {
|
||||
for (final String userId : mUserIds) {
|
||||
try {
|
||||
@ -923,7 +923,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
@Override
|
||||
protected SingleResponse<SavedSearch> doInBackground(final Object... params) {
|
||||
final MicroBlog microBlog = MicroBlogAPIFactory.getInstance(context, mAccountKey, false);
|
||||
final MicroBlog microBlog = MicroBlogAPIFactory.getInstance(context, mAccountKey);
|
||||
if (microBlog == null) return null;
|
||||
try {
|
||||
return SingleResponse.Companion.getInstance(microBlog.createSavedSearch(mQuery));
|
||||
@ -965,7 +965,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
@Override
|
||||
protected SingleResponse<ParcelableUserList> doInBackground(final Object... params) {
|
||||
final MicroBlog microBlog = MicroBlogAPIFactory.getInstance(context, mAccountKey, false);
|
||||
final MicroBlog microBlog = MicroBlogAPIFactory.getInstance(context, mAccountKey);
|
||||
if (microBlog == null) return SingleResponse.Companion.getInstance();
|
||||
try {
|
||||
final UserList userList = microBlog.createUserListSubscription(mListId);
|
||||
@ -1009,8 +1009,8 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
@Override
|
||||
protected SingleResponse<ParcelableUserList> doInBackground(final Object... params) {
|
||||
final MicroBlog microBlog = MicroBlogAPIFactory.getInstance(getContext(), mAccountKey,
|
||||
false);
|
||||
final MicroBlog microBlog = MicroBlogAPIFactory.getInstance(getContext(), mAccountKey
|
||||
);
|
||||
if (microBlog == null || mListName == null)
|
||||
return SingleResponse.Companion.getInstance();
|
||||
try {
|
||||
@ -1056,7 +1056,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
@Override
|
||||
protected SingleResponse<ParcelableUserList> doInBackground(final Object... params) {
|
||||
final MicroBlog microBlog = MicroBlogAPIFactory.getInstance(context, mAccountKey, false);
|
||||
final MicroBlog microBlog = MicroBlogAPIFactory.getInstance(context, mAccountKey);
|
||||
if (microBlog == null) return SingleResponse.Companion.getInstance();
|
||||
try {
|
||||
final UserKey[] userIds = new UserKey[users.length];
|
||||
@ -1128,7 +1128,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
@Override
|
||||
protected SingleResponse<DirectMessage> doInBackground(final Object... args) {
|
||||
final MicroBlog microBlog = MicroBlogAPIFactory.getInstance(context, mAccountKey, false);
|
||||
final MicroBlog microBlog = MicroBlogAPIFactory.getInstance(context, mAccountKey);
|
||||
if (microBlog == null) return SingleResponse.Companion.getInstance();
|
||||
try {
|
||||
final DirectMessage message = microBlog.destroyDirectMessage(mMessageId);
|
||||
@ -1190,7 +1190,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
@Override
|
||||
protected SingleResponse<Void> doInBackground(final Object... args) {
|
||||
final MicroBlog microBlog = MicroBlogAPIFactory.getInstance(context, mAccountKey, false);
|
||||
final MicroBlog microBlog = MicroBlogAPIFactory.getInstance(context, mAccountKey);
|
||||
if (microBlog == null) return SingleResponse.Companion.getInstance();
|
||||
try {
|
||||
microBlog.destroyDirectMessagesConversation(mAccountKey.getId(), mUserId);
|
||||
@ -1339,7 +1339,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
@Override
|
||||
protected SingleResponse<SavedSearch> doInBackground(final Object... params) {
|
||||
final MicroBlog microBlog = MicroBlogAPIFactory.getInstance(context, mAccountKey, false);
|
||||
final MicroBlog microBlog = MicroBlogAPIFactory.getInstance(context, mAccountKey);
|
||||
if (microBlog == null) return SingleResponse.Companion.getInstance();
|
||||
try {
|
||||
return SingleResponse.Companion.getInstance(microBlog.destroySavedSearch(mSearchId));
|
||||
@ -1441,7 +1441,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
@Override
|
||||
protected SingleResponse<ParcelableUserList> doInBackground(final Object... params) {
|
||||
|
||||
final MicroBlog microBlog = MicroBlogAPIFactory.getInstance(context, mAccountKey, false);
|
||||
final MicroBlog microBlog = MicroBlogAPIFactory.getInstance(context, mAccountKey);
|
||||
if (microBlog == null) return SingleResponse.Companion.getInstance();
|
||||
try {
|
||||
final UserList userList = microBlog.destroyUserListSubscription(mListId);
|
||||
@ -1481,8 +1481,8 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
@Override
|
||||
protected SingleResponse<ParcelableUserList> doInBackground(final Object... params) {
|
||||
final MicroBlog microBlog = MicroBlogAPIFactory.getInstance(getContext(), mAccountKey,
|
||||
false);
|
||||
final MicroBlog microBlog = MicroBlogAPIFactory.getInstance(getContext(), mAccountKey
|
||||
);
|
||||
if (microBlog == null) return SingleResponse.Companion.getInstance();
|
||||
try {
|
||||
final UserList userList = microBlog.destroyUserList(mListId);
|
||||
@ -1700,7 +1700,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
@Override
|
||||
protected SingleResponse<ParcelableUserList> doInBackground(final Object... params) {
|
||||
|
||||
final MicroBlog microBlog = MicroBlogAPIFactory.getInstance(mContext, mAccountKey, false);
|
||||
final MicroBlog microBlog = MicroBlogAPIFactory.getInstance(mContext, mAccountKey);
|
||||
if (microBlog != null) {
|
||||
try {
|
||||
final UserList list = microBlog.updateUserList(listId, update);
|
||||
@ -1726,7 +1726,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
public interface GetAccountKeysClosure {
|
||||
interface GetAccountKeysClosure {
|
||||
UserKey[] getAccountKeys();
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ import org.mariotaku.twidere.activity.MediaViewerActivity;
|
||||
import org.mariotaku.twidere.annotation.Referral;
|
||||
import org.mariotaku.twidere.constant.SharedPreferenceConstants;
|
||||
import org.mariotaku.twidere.fragment.SensitiveContentWarningDialogFragment;
|
||||
import org.mariotaku.twidere.fragment.UserFragment;
|
||||
import org.mariotaku.twidere.model.ParcelableDirectMessage;
|
||||
import org.mariotaku.twidere.model.ParcelableGroup;
|
||||
import org.mariotaku.twidere.model.ParcelableMedia;
|
||||
@ -80,11 +79,7 @@ public class IntentUtils implements Constants {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && newDocument) {
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
||||
}
|
||||
if (context instanceof Activity) {
|
||||
ActivityCompat.startActivity((Activity) context, intent, activityOptions);
|
||||
} else {
|
||||
context.startActivity(intent);
|
||||
}
|
||||
ActivityCompat.startActivity(context, intent, activityOptions);
|
||||
}
|
||||
|
||||
public static void openUserProfile(@NonNull final Context context, @Nullable final UserKey accountKey,
|
||||
@ -96,11 +91,7 @@ public class IntentUtils implements Constants {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && newDocument) {
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
||||
}
|
||||
if (context instanceof Activity) {
|
||||
ActivityCompat.startActivity((Activity) context, intent, activityOptions);
|
||||
} else {
|
||||
context.startActivity(intent);
|
||||
}
|
||||
ActivityCompat.startActivity(context, intent, activityOptions);
|
||||
}
|
||||
|
||||
public static Intent userProfile(@Nullable UserKey accountKey, UserKey userKey, String screenName,
|
||||
@ -266,11 +257,7 @@ public class IntentUtils implements Constants {
|
||||
if (newDocument && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
||||
}
|
||||
if (context instanceof Activity) {
|
||||
ActivityCompat.startActivity((Activity) context, intent, options);
|
||||
} else {
|
||||
context.startActivity(intent);
|
||||
}
|
||||
ActivityCompat.startActivity(context, intent, options);
|
||||
}
|
||||
|
||||
public static Uri getMediaViewerUri(@NonNull final String type, final String id,
|
||||
@ -412,11 +399,7 @@ public class IntentUtils implements Constants {
|
||||
final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());
|
||||
intent.setExtrasClassLoader(context.getClassLoader());
|
||||
intent.putExtras(extras);
|
||||
if (context instanceof Activity) {
|
||||
ActivityCompat.startActivity((Activity) context, intent, activityOptions);
|
||||
} else {
|
||||
context.startActivity(intent);
|
||||
}
|
||||
ActivityCompat.startActivity(context, intent, activityOptions);
|
||||
}
|
||||
|
||||
public static void openStatusFavoriters(@NonNull final Context context, @Nullable final UserKey accountKey,
|
||||
@ -429,7 +412,7 @@ public class IntentUtils implements Constants {
|
||||
}
|
||||
builder.appendQueryParameter(QUERY_PARAM_STATUS_ID, statusId);
|
||||
final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());
|
||||
context.startActivity(intent);
|
||||
ActivityCompat.startActivity(context, intent, null);
|
||||
}
|
||||
|
||||
public static void openStatusRetweeters(@NonNull final Context context, @Nullable final UserKey accountKey,
|
||||
@ -442,7 +425,7 @@ public class IntentUtils implements Constants {
|
||||
}
|
||||
builder.appendQueryParameter(QUERY_PARAM_STATUS_ID, statusId);
|
||||
final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());
|
||||
context.startActivity(intent);
|
||||
ActivityCompat.startActivity(context, intent, null);
|
||||
}
|
||||
|
||||
public static void openTweetSearch(@NonNull final Context context, @Nullable final UserKey accountKey,
|
||||
|
@ -82,22 +82,14 @@ public class MicroBlogAPIFactory implements TwidereConstants {
|
||||
@WorkerThread
|
||||
public static MicroBlog getDefaultTwitterInstance(final Context context, final boolean includeEntities) {
|
||||
if (context == null) return null;
|
||||
return getDefaultTwitterInstance(context, includeEntities, true);
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
public static MicroBlog getDefaultTwitterInstance(final Context context, final boolean includeEntities,
|
||||
final boolean includeRetweets) {
|
||||
if (context == null) return null;
|
||||
final UserKey accountKey = Utils.getDefaultAccountKey(context);
|
||||
if (accountKey == null) return null;
|
||||
return getInstance(context, accountKey, includeEntities, includeRetweets);
|
||||
return getInstance(context, accountKey, includeEntities, true);
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
public static MicroBlog getInstance(@NonNull final Context context,
|
||||
@NonNull final UserKey accountKey,
|
||||
final boolean includeEntities) {
|
||||
@NonNull final UserKey accountKey) {
|
||||
AccountManager am = AccountManager.get(context);
|
||||
Account account = AccountUtils.findByAccountKey(am, accountKey);
|
||||
if (account == null) return null;
|
||||
|
@ -65,12 +65,12 @@ public class TwidereStringUtils {
|
||||
private static class ZeroWidthSpan extends ReplacementSpan {
|
||||
|
||||
@Override
|
||||
public int getSize(Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fm) {
|
||||
public int getSize(@NonNull Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fm) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) {
|
||||
public void draw(@NonNull Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, @NonNull Paint paint) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public class TwitterWrapper implements Constants {
|
||||
|
||||
public static SingleResponse<Boolean> deleteProfileBannerImage(final Context context,
|
||||
final UserKey accountKey) {
|
||||
final MicroBlog twitter = MicroBlogAPIFactory.getInstance(context, accountKey, false);
|
||||
final MicroBlog twitter = MicroBlogAPIFactory.getInstance(context, accountKey);
|
||||
if (twitter == null) return SingleResponse.Companion.getInstance(false);
|
||||
try {
|
||||
twitter.removeProfileBannerImage();
|
||||
|
@ -20,6 +20,7 @@
|
||||
package org.mariotaku.twidere.util;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
@ -33,8 +34,7 @@ public class UriExtraUtils {
|
||||
private UriExtraUtils() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static void addExtra(Uri.Builder builder, String key, Object value) {
|
||||
public static void addExtra(@NonNull Uri.Builder builder, String key, Object value) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_EXTRA, key + "=" + String.valueOf(value));
|
||||
}
|
||||
|
||||
|
@ -439,7 +439,7 @@ public final class Utils implements Constants {
|
||||
throws MicroBlogException {
|
||||
final ParcelableStatus cached = findStatusInDatabases(context, accountKey, statusId);
|
||||
if (cached != null) return cached;
|
||||
final MicroBlog twitter = MicroBlogAPIFactory.getInstance(context, accountKey, true);
|
||||
final MicroBlog twitter = MicroBlogAPIFactory.getInstance(context, accountKey);
|
||||
if (twitter == null) throw new MicroBlogException("Account does not exist");
|
||||
final Status result = twitter.showStatus(statusId);
|
||||
final String where = Expression.and(Expression.equalsArgs(Statuses.ACCOUNT_KEY),
|
||||
|
@ -26,6 +26,7 @@ import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Shader;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.nostra13.universalimageloader.core.assist.LoadedFrom;
|
||||
import com.nostra13.universalimageloader.core.display.BitmapDisplayer;
|
||||
@ -102,7 +103,7 @@ public class OvalBitmapDisplayer implements BitmapDisplayer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
public void draw(@NonNull Canvas canvas) {
|
||||
canvas.drawOval(mRect, paint);
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
@ -145,7 +146,7 @@ public class ForegroundColorView extends View implements IForegroundView {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean verifyDrawable(final Drawable who) {
|
||||
protected boolean verifyDrawable(@NonNull final Drawable who) {
|
||||
return super.verifyDrawable(who) || (mForegroundViewHelper != null && mForegroundViewHelper.verifyDrawable(who));
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ public class ForegroundImageView extends ImageView implements IForegroundView {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean verifyDrawable(final Drawable who) {
|
||||
protected boolean verifyDrawable(@NonNull final Drawable who) {
|
||||
return super.verifyDrawable(who) || (mForegroundViewHelper != null && mForegroundViewHelper.verifyDrawable(who));
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ public class MediaPreviewImageView extends ImageView {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean verifyDrawable(final Drawable who) {
|
||||
protected boolean verifyDrawable(@NonNull final Drawable who) {
|
||||
return super.verifyDrawable(who) || (mForegroundViewHelper != null && mForegroundViewHelper.verifyDrawable(who));
|
||||
}
|
||||
|
||||
|
@ -302,9 +302,7 @@ public class ShapedImageView extends ImageView {
|
||||
BitmapDrawable bitmapDrawable = null;
|
||||
// support state list drawable by getting the current state
|
||||
if (drawable instanceof StateListDrawable) {
|
||||
if (drawable.getCurrent() != null) {
|
||||
bitmapDrawable = (BitmapDrawable) drawable.getCurrent();
|
||||
}
|
||||
} else if (drawable instanceof BitmapDrawable) {
|
||||
bitmapDrawable = (BitmapDrawable) drawable;
|
||||
} else if (drawable instanceof ColorDrawable) {
|
||||
|
@ -167,8 +167,7 @@ public class TabPagerIndicator extends RecyclerView implements PagerIndicator, C
|
||||
mIndicatorAdapter.setStripColor(color);
|
||||
}
|
||||
|
||||
@DisplayOption
|
||||
public void setTabDisplayOption(int flags) {
|
||||
public void setTabDisplayOption(@DisplayOption int flags) {
|
||||
mOption = flags;
|
||||
}
|
||||
|
||||
|
@ -116,8 +116,8 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
private val backTimeoutRunnable = Runnable { navigateBackPressed = false }
|
||||
|
||||
// Adapters
|
||||
private var mediaPreviewAdapter: MediaPreviewAdapter? = null
|
||||
private var accountsAdapter: AccountIconsAdapter? = null
|
||||
private lateinit var mediaPreviewAdapter: MediaPreviewAdapter
|
||||
private lateinit var accountsAdapter: AccountIconsAdapter
|
||||
|
||||
// Data fields
|
||||
private var recentLocation: ParcelableLocation? = null
|
||||
@ -197,12 +197,12 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
protected fun discardTweet() {
|
||||
private fun discardTweet() {
|
||||
if (isFinishing || currentTask != null && currentTask!!.status == AsyncTask.Status.RUNNING) return
|
||||
currentTask = AsyncTaskUtils.executeTask(DiscardTweetTask(this))
|
||||
}
|
||||
|
||||
protected fun hasComposingStatus(): Boolean {
|
||||
private fun hasComposingStatus(): Boolean {
|
||||
val text = if (editText != null) ParseUtils.parseString(editText.text) else null
|
||||
val textChanged = text != null && !text.isEmpty() && text != originalText
|
||||
val isEditingDraft = INTENT_ACTION_EDIT_DRAFT == intent.action
|
||||
@ -210,7 +210,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
}
|
||||
|
||||
public override fun onSaveInstanceState(outState: Bundle) {
|
||||
outState.putParcelableArray(EXTRA_ACCOUNT_KEYS, accountsAdapter!!.selectedAccountKeys)
|
||||
outState.putParcelableArray(EXTRA_ACCOUNT_KEYS, accountsAdapter.selectedAccountKeys)
|
||||
outState.putParcelableArrayList(EXTRA_MEDIA, ArrayList<Parcelable>(mediaList))
|
||||
outState.putBoolean(EXTRA_IS_POSSIBLY_SENSITIVE, possiblySensitive)
|
||||
outState.putParcelable(EXTRA_STATUS, inReplyToStatus)
|
||||
@ -336,11 +336,11 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
try {
|
||||
val action = intent.action
|
||||
if (INTENT_ACTION_EXTENSION_COMPOSE == action) {
|
||||
val accountKeys = accountsAdapter!!.selectedAccountKeys
|
||||
val accountKeys = accountsAdapter.selectedAccountKeys
|
||||
intent.putExtra(EXTRA_TEXT, ParseUtils.parseString(editText.text))
|
||||
intent.putExtra(EXTRA_ACCOUNT_KEYS, accountKeys)
|
||||
if (accountKeys.size > 0) {
|
||||
val accountKey = accountKeys[0]
|
||||
if (accountKeys.isNotEmpty()) {
|
||||
val accountKey = accountKeys.first()
|
||||
intent.putExtra(EXTRA_NAME, DataStoreUtils.getAccountName(this, accountKey))
|
||||
intent.putExtra(EXTRA_SCREEN_NAME, DataStoreUtils.getAccountScreenName(this, accountKey))
|
||||
}
|
||||
@ -420,7 +420,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
}
|
||||
|
||||
fun removeAllMedia(list: List<ParcelableMediaUpdate>) {
|
||||
mediaPreviewAdapter!!.removeAll(list)
|
||||
mediaPreviewAdapter.removeAll(list)
|
||||
}
|
||||
|
||||
fun saveToDrafts(): Uri {
|
||||
@ -428,7 +428,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
val draft = Draft()
|
||||
|
||||
draft.action_type = getDraftAction(intent.action)
|
||||
draft.account_keys = accountsAdapter!!.selectedAccountKeys
|
||||
draft.account_keys = accountsAdapter.selectedAccountKeys
|
||||
draft.text = text
|
||||
draft.media = media
|
||||
draft.location = recentLocation
|
||||
@ -537,7 +537,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
accountSelector.itemAnimator = DefaultItemAnimator()
|
||||
accountsAdapter = AccountIconsAdapter(this)
|
||||
accountSelector.adapter = accountsAdapter
|
||||
accountsAdapter!!.setAccounts(accounts)
|
||||
accountsAdapter.setAccounts(accounts)
|
||||
|
||||
|
||||
val adapter = MediaPreviewAdapter(this, PreviewGridOnStartDragListener(this))
|
||||
@ -557,7 +557,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
if (savedInstanceState != null) {
|
||||
// Restore from previous saved state
|
||||
val selected = savedInstanceState.getParcelableArray(EXTRA_ACCOUNT_KEYS).toTypedArray(UserKey.CREATOR)
|
||||
accountsAdapter!!.setSelectedAccountIds(*selected)
|
||||
accountsAdapter.setSelectedAccountIds(*selected)
|
||||
possiblySensitive = savedInstanceState.getBoolean(EXTRA_IS_POSSIBLY_SENSITIVE)
|
||||
val mediaList = savedInstanceState.getParcelableArrayList<ParcelableMediaUpdate>(EXTRA_MEDIA)
|
||||
if (mediaList != null) {
|
||||
@ -580,15 +580,15 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
handleDefaultIntent(intent)
|
||||
}
|
||||
setLabel(intent)
|
||||
val selectedAccountIds = accountsAdapter!!.selectedAccountKeys
|
||||
val selectedAccountIds = accountsAdapter.selectedAccountKeys
|
||||
if (ArrayUtils.isEmpty(selectedAccountIds)) {
|
||||
val idsInPrefs: Array<UserKey> = UserKey.arrayOf(preferences.getString(KEY_COMPOSE_ACCOUNTS, null)) ?: emptyArray()
|
||||
val intersection: Array<UserKey> = defaultAccountIds.intersect(listOf(*idsInPrefs)).toTypedArray()
|
||||
|
||||
if (intersection.isEmpty()) {
|
||||
accountsAdapter!!.setSelectedAccountIds(*defaultAccountIds)
|
||||
accountsAdapter.setSelectedAccountIds(*defaultAccountIds)
|
||||
} else {
|
||||
accountsAdapter!!.setSelectedAccountIds(*intersection)
|
||||
accountsAdapter.setSelectedAccountIds(*intersection)
|
||||
}
|
||||
}
|
||||
originalText = ParseUtils.parseString(editText.text)
|
||||
@ -642,7 +642,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
when (menuInfo.recyclerViewId) {
|
||||
R.id.attachedMediaPreview -> {
|
||||
val position = menuInfo.position
|
||||
val mediaUpdate = mediaPreviewAdapter!!.getItem(position)
|
||||
val mediaUpdate = mediaPreviewAdapter.getItem(position)
|
||||
val args = Bundle()
|
||||
args.putString(EXTRA_TEXT, mediaUpdate.alt_text)
|
||||
args.putInt(EXTRA_POSITION, position)
|
||||
@ -684,7 +684,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
}
|
||||
|
||||
override fun afterTextChanged(s: Editable) {
|
||||
textChanged = s.length == 0
|
||||
textChanged = s.isEmpty()
|
||||
val deletes = s.getSpans(0, s.length, MarkForDeleteSpan::class.java)
|
||||
for (delete in deletes) {
|
||||
s.delete(s.getSpanStart(delete), s.getSpanEnd(delete))
|
||||
@ -730,17 +730,17 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
}
|
||||
|
||||
private fun addMedia(media: ParcelableMediaUpdate) {
|
||||
mediaPreviewAdapter!!.add(media)
|
||||
mediaPreviewAdapter.add(media)
|
||||
updateAttachedMediaView()
|
||||
}
|
||||
|
||||
private fun addMedia(media: List<ParcelableMediaUpdate>) {
|
||||
mediaPreviewAdapter!!.addAll(media)
|
||||
mediaPreviewAdapter.addAll(media)
|
||||
updateAttachedMediaView()
|
||||
}
|
||||
|
||||
private fun clearMedia() {
|
||||
mediaPreviewAdapter!!.clear()
|
||||
mediaPreviewAdapter.clear()
|
||||
updateAttachedMediaView()
|
||||
}
|
||||
|
||||
@ -770,7 +770,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
get() = mediaList.toTypedArray()
|
||||
|
||||
private val mediaList: List<ParcelableMediaUpdate>
|
||||
get() = mediaPreviewAdapter!!.asList
|
||||
get() = mediaPreviewAdapter.asList
|
||||
|
||||
private fun handleDefaultIntent(intent: Intent?): Boolean {
|
||||
if (intent == null) return false
|
||||
@ -778,11 +778,11 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
val hasAccountIds: Boolean
|
||||
if (intent.hasExtra(EXTRA_ACCOUNT_KEYS)) {
|
||||
val accountKeys = intent.getParcelableArrayExtra(EXTRA_ACCOUNT_KEYS).toTypedArray(UserKey.CREATOR)
|
||||
accountsAdapter!!.setSelectedAccountIds(*accountKeys)
|
||||
accountsAdapter.setSelectedAccountIds(*accountKeys)
|
||||
hasAccountIds = true
|
||||
} else if (intent.hasExtra(EXTRA_ACCOUNT_KEY)) {
|
||||
val accountKey = intent.getParcelableExtra<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||
accountsAdapter!!.setSelectedAccountIds(accountKey)
|
||||
accountsAdapter.setSelectedAccountIds(accountKey)
|
||||
hasAccountIds = true
|
||||
} else {
|
||||
hasAccountIds = false
|
||||
@ -833,7 +833,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
editText.setText(draft.text)
|
||||
val selectionEnd = editText.length()
|
||||
editText.setSelection(selectionEnd)
|
||||
accountsAdapter!!.setSelectedAccountIds(*draft.account_keys ?: emptyArray())
|
||||
accountsAdapter.setSelectedAccountIds(*draft.account_keys ?: emptyArray())
|
||||
if (draft.media != null) {
|
||||
addMedia(Arrays.asList(*draft.media))
|
||||
}
|
||||
@ -942,7 +942,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
editText.setText(String.format("@%s ", user.screen_name))
|
||||
val selection_end = editText.length()
|
||||
editText.setSelection(selection_end)
|
||||
accountsAdapter!!.setSelectedAccountIds(user.account_key)
|
||||
accountsAdapter.setSelectedAccountIds(user.account_key)
|
||||
return true
|
||||
}
|
||||
|
||||
@ -950,7 +950,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
if (status == null) return false
|
||||
editText.setText(Utils.getQuoteStatus(this, status))
|
||||
editText.setSelection(0)
|
||||
accountsAdapter!!.setSelectedAccountIds(status.account_key)
|
||||
accountsAdapter.setSelectedAccountIds(status.account_key)
|
||||
showQuoteLabel(status)
|
||||
return true
|
||||
}
|
||||
@ -999,12 +999,9 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
mentions.add(status.quoted_user_screen_name)
|
||||
}
|
||||
if (!ArrayUtils.isEmpty(status.mentions)) {
|
||||
for (mention in status.mentions) {
|
||||
if (mention.key == status.account_key || TextUtils.isEmpty(mention.screen_name)) {
|
||||
continue
|
||||
}
|
||||
mentions.add(mention.screen_name)
|
||||
}
|
||||
status.mentions
|
||||
.filterNot { it.key == status.account_key || it.screen_name.isNullOrEmpty() }
|
||||
.mapTo(mentions) { it.screen_name }
|
||||
mentions.addAll(extractor.extractMentionedScreennames(status.quoted_text_plain))
|
||||
} else if (USER_TYPE_FANFOU_COM == status.account_key.host) {
|
||||
addFanfouHtmlToMentions(status.text_unescaped, status.spans, mentions)
|
||||
@ -1018,15 +1015,11 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
}
|
||||
}
|
||||
|
||||
for (mention in mentions) {
|
||||
if (mention.equals(status.user_screen_name, ignoreCase = true) || mention.equals(account.user.screen_name, ignoreCase = true)) {
|
||||
continue
|
||||
}
|
||||
editText.append("@$mention ")
|
||||
}
|
||||
mentions.filterNot { it.equals(status.user_screen_name, ignoreCase = true) || it.equals(account.user.screen_name, ignoreCase = true) }
|
||||
.forEach { editText.append("@$it ") }
|
||||
val selectionEnd = editText.length()
|
||||
editText.setSelection(selectionStart, selectionEnd)
|
||||
accountsAdapter!!.setSelectedAccountIds(status.account_key)
|
||||
accountsAdapter.setSelectedAccountIds(status.account_key)
|
||||
showReplyLabel(status)
|
||||
return true
|
||||
}
|
||||
@ -1046,23 +1039,19 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
|
||||
private fun handleReplyMultipleIntent(screenNames: Array<String>?, accountId: UserKey?,
|
||||
inReplyToStatus: ParcelableStatus): Boolean {
|
||||
if (screenNames == null || screenNames.size == 0 || accountId == null) return false
|
||||
if (screenNames == null || screenNames.isEmpty() || accountId == null) return false
|
||||
val myScreenName = DataStoreUtils.getAccountScreenName(this, accountId)
|
||||
if (TextUtils.isEmpty(myScreenName)) return false
|
||||
for (screenName in screenNames) {
|
||||
if (screenName.equals(myScreenName, ignoreCase = true)) {
|
||||
continue
|
||||
}
|
||||
editText.append("@$screenName ")
|
||||
}
|
||||
screenNames.filterNot { it.equals(myScreenName, ignoreCase = true) }
|
||||
.forEach { editText.append("@$it ") }
|
||||
editText.setSelection(editText.length())
|
||||
accountsAdapter!!.setSelectedAccountIds(accountId)
|
||||
accountsAdapter.setSelectedAccountIds(accountId)
|
||||
this.inReplyToStatus = inReplyToStatus
|
||||
return true
|
||||
}
|
||||
|
||||
private fun hasMedia(): Boolean {
|
||||
return mediaPreviewAdapter!!.itemCount > 0
|
||||
return mediaPreviewAdapter.itemCount > 0
|
||||
}
|
||||
|
||||
private val isQuote: Boolean
|
||||
@ -1083,7 +1072,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
}
|
||||
|
||||
private fun notifyAccountSelectionChanged() {
|
||||
val accounts = accountsAdapter!!.selectedAccounts
|
||||
val accounts = accountsAdapter.selectedAccounts
|
||||
setSelectedAccounts(*accounts)
|
||||
if (ArrayUtils.isEmpty(accounts)) {
|
||||
editText.accountKey = Utils.getDefaultAccountKey(this)
|
||||
@ -1104,7 +1093,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
if (!shouldSaveAccounts) return
|
||||
val editor = preferences.edit()
|
||||
|
||||
editor.putString(KEY_COMPOSE_ACCOUNTS, accountsAdapter!!.selectedAccountKeys.joinToString(","))
|
||||
editor.putString(KEY_COMPOSE_ACCOUNTS, accountsAdapter.selectedAccountKeys.joinToString(","))
|
||||
editor.apply()
|
||||
}
|
||||
|
||||
@ -1132,7 +1121,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
|
||||
private val scheduleSupported: Boolean
|
||||
get() {
|
||||
val accounts = accountsAdapter!!.selectedAccounts
|
||||
val accounts = accountsAdapter.selectedAccounts
|
||||
if (ArrayUtils.isEmpty(accounts)) return false
|
||||
return false
|
||||
}
|
||||
@ -1265,7 +1254,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
val text = if (editText != null) ParseUtils.parseString(editText.text) else null
|
||||
val tweetLength = validator.getTweetLength(text)
|
||||
val maxLength = statusTextCount.maxLength
|
||||
if (accountsAdapter!!.isSelectionEmpty) {
|
||||
if (accountsAdapter.isSelectionEmpty) {
|
||||
editText.error = getString(R.string.no_account_selected)
|
||||
return
|
||||
} else if (!hasMedia && (TextUtils.isEmpty(text) || noReplyContent(text))) {
|
||||
@ -1279,7 +1268,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
}
|
||||
val attachLocation = preferences.getBoolean(KEY_ATTACH_LOCATION)
|
||||
val attachPreciseLocation = preferences.getBoolean(KEY_ATTACH_PRECISE_LOCATION)
|
||||
val accountKeys = accountsAdapter!!.selectedAccountKeys
|
||||
val accountKeys = accountsAdapter.selectedAccountKeys
|
||||
val isPossiblySensitive = hasMedia && possiblySensitive
|
||||
val update = ParcelableStatusUpdate()
|
||||
@Draft.Action val action = draft?.action_type ?: getDraftAction(intent.action)
|
||||
@ -1573,18 +1562,14 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
this.media = activity.mediaList
|
||||
}
|
||||
|
||||
override fun doInBackground(vararg params: Any): Unit {
|
||||
for (item in media) {
|
||||
val uri = Uri.parse(item.uri)
|
||||
if (ContentResolver.SCHEME_FILE == uri.scheme) {
|
||||
override fun doInBackground(vararg params: Any) {
|
||||
media.map { Uri.parse(it.uri) }.filter { ContentResolver.SCHEME_FILE == it.scheme }.forEach { uri ->
|
||||
val file = File(uri.path)
|
||||
if (!file.delete()) {
|
||||
Log.d(LOGTAG, String.format("Unable to delete %s", file))
|
||||
}
|
||||
}
|
||||
}
|
||||
return Unit
|
||||
}
|
||||
|
||||
override fun onPostExecute(result: Unit) {
|
||||
val activity = activityRef.get() ?: return
|
||||
@ -1794,7 +1779,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
}
|
||||
|
||||
private fun setMediaAltText(position: Int, altText: String?) {
|
||||
mediaPreviewAdapter!!.setAltText(position, altText)
|
||||
mediaPreviewAdapter.setAltText(position, altText)
|
||||
}
|
||||
|
||||
class RetweetProtectedStatusWarnFragment : BaseDialogFragment(), DialogInterface.OnClickListener {
|
||||
|
@ -61,7 +61,7 @@ class MediaViewerActivity : BaseActivity(), IExtendedActivity, ATEToolbarCustomi
|
||||
@Inject
|
||||
lateinit var mMediaDownloader: MediaDownloader
|
||||
|
||||
private var mSaveToStoragePosition = -1
|
||||
private var saveToStoragePosition = -1
|
||||
private var mShareMediaPosition = -1
|
||||
|
||||
|
||||
@ -120,8 +120,7 @@ class MediaViewerActivity : BaseActivity(), IExtendedActivity, ATEToolbarCustomi
|
||||
val adapter = viewPager.adapter
|
||||
val currentItem = viewPager.currentItem
|
||||
if (currentItem < 0 || currentItem >= adapter.count) return false
|
||||
val obj = adapter.instantiateItem(viewPager, currentItem)
|
||||
if (obj !is MediaViewerFragment) return false
|
||||
val obj = adapter.instantiateItem(viewPager, currentItem) as? MediaViewerFragment ?: return false
|
||||
when (item.itemId) {
|
||||
R.id.refresh -> {
|
||||
if (obj is CacheDownloadMediaViewerFragment) {
|
||||
@ -288,14 +287,14 @@ class MediaViewerActivity : BaseActivity(), IExtendedActivity, ATEToolbarCustomi
|
||||
intent.getParcelableArrayExtra(EXTRA_MEDIA).toTypedArray(ParcelableMedia.CREATOR)
|
||||
}
|
||||
|
||||
protected fun processShareIntent(intent: Intent) {
|
||||
private fun processShareIntent(intent: Intent) {
|
||||
val status = status ?: return
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, IntentUtils.getStatusShareSubject(this, status))
|
||||
intent.putExtra(Intent.EXTRA_TEXT, IntentUtils.getStatusShareText(this, status))
|
||||
}
|
||||
|
||||
protected fun requestAndSaveToStorage(position: Int) {
|
||||
mSaveToStoragePosition = position
|
||||
private fun requestAndSaveToStorage(position: Int) {
|
||||
saveToStoragePosition = position
|
||||
if (PermissionUtils.hasPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
saveToStorage()
|
||||
} else {
|
||||
@ -309,7 +308,7 @@ class MediaViewerActivity : BaseActivity(), IExtendedActivity, ATEToolbarCustomi
|
||||
}
|
||||
}
|
||||
|
||||
protected fun requestAndShareMedia(position: Int) {
|
||||
private fun requestAndShareMedia(position: Int) {
|
||||
mShareMediaPosition = position
|
||||
if (PermissionUtils.hasPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
shareMedia()
|
||||
@ -324,12 +323,11 @@ class MediaViewerActivity : BaseActivity(), IExtendedActivity, ATEToolbarCustomi
|
||||
}
|
||||
}
|
||||
|
||||
protected fun shareMedia() {
|
||||
private fun shareMedia() {
|
||||
if (mShareMediaPosition == -1) return
|
||||
val viewPager = findViewPager()
|
||||
val adapter = viewPager.adapter
|
||||
val f = adapter.instantiateItem(viewPager, mShareMediaPosition)
|
||||
if (f !is CacheDownloadMediaViewerFragment) return
|
||||
val f = adapter.instantiateItem(viewPager, mShareMediaPosition) as? CacheDownloadMediaViewerFragment ?: return
|
||||
val result = f.downloadResult
|
||||
if (result == null || result.cacheUri == null) {
|
||||
// TODO show error
|
||||
@ -393,12 +391,11 @@ class MediaViewerActivity : BaseActivity(), IExtendedActivity, ATEToolbarCustomi
|
||||
AsyncTaskUtils.executeTask<SaveFileTask, Any>(task)
|
||||
}
|
||||
|
||||
protected fun saveToStorage() {
|
||||
if (mSaveToStoragePosition == -1) return
|
||||
private fun saveToStorage() {
|
||||
if (saveToStoragePosition == -1) return
|
||||
val viewPager = findViewPager()
|
||||
val adapter = viewPager.adapter
|
||||
val f = adapter.instantiateItem(viewPager, mSaveToStoragePosition)
|
||||
if (f !is CacheDownloadMediaViewerFragment) return
|
||||
val f = adapter.instantiateItem(viewPager, saveToStoragePosition) as? CacheDownloadMediaViewerFragment ?: return
|
||||
val result = f.downloadResult ?: return
|
||||
val cacheUri = result.cacheUri
|
||||
val hasMedia = cacheUri != null
|
||||
|
@ -218,7 +218,7 @@ class SettingsActivity : BaseActivity(), OnItemClickListener, OnPreferenceStartF
|
||||
openDetails(position)
|
||||
}
|
||||
|
||||
protected fun openDetails(position: Int) {
|
||||
private fun openDetails(position: Int) {
|
||||
if (isFinishing) return
|
||||
val entry = mEntriesAdapter!!.getItem(position) as? PreferenceEntry ?: return
|
||||
val fm = supportFragmentManager
|
||||
@ -252,38 +252,38 @@ class SettingsActivity : BaseActivity(), OnItemClickListener, OnPreferenceStartF
|
||||
return false
|
||||
}
|
||||
|
||||
internal class EntriesAdapter(private val mContext: Context) : BaseAdapter() {
|
||||
private val mInflater: LayoutInflater
|
||||
private val mEntries: MutableList<Entry>
|
||||
internal class EntriesAdapter(context: Context) : BaseAdapter() {
|
||||
private val inflater: LayoutInflater
|
||||
private val entries: MutableList<Entry>
|
||||
|
||||
init {
|
||||
mInflater = LayoutInflater.from(mContext)
|
||||
mEntries = ArrayList<Entry>()
|
||||
inflater = LayoutInflater.from(context)
|
||||
entries = ArrayList<Entry>()
|
||||
}
|
||||
|
||||
fun addPreference(tag: String, @DrawableRes icon: Int, title: String, @XmlRes preference: Int) {
|
||||
mEntries.add(PreferenceEntry(tag, icon, title, preference, null, null))
|
||||
entries.add(PreferenceEntry(tag, icon, title, preference, null, null))
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
|
||||
@JvmOverloads fun addPreference(tag: String, @DrawableRes icon: Int, title: String, cls: Class<out Fragment>,
|
||||
fun addPreference(tag: String, @DrawableRes icon: Int, title: String, cls: Class<out Fragment>,
|
||||
args: Bundle? = null) {
|
||||
mEntries.add(PreferenceEntry(tag, icon, title, 0, cls.name, args))
|
||||
entries.add(PreferenceEntry(tag, icon, title, 0, cls.name, args))
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
fun addHeader(title: String) {
|
||||
mEntries.add(HeaderEntry(title))
|
||||
entries.add(HeaderEntry(title))
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun getCount(): Int {
|
||||
return mEntries.size
|
||||
return entries.size
|
||||
}
|
||||
|
||||
override fun getItem(position: Int): Entry {
|
||||
return mEntries[position]
|
||||
return entries[position]
|
||||
}
|
||||
|
||||
override fun getItemId(position: Int): Long {
|
||||
@ -311,16 +311,13 @@ class SettingsActivity : BaseActivity(), OnItemClickListener, OnPreferenceStartF
|
||||
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
|
||||
val viewType = getItemViewType(position)
|
||||
val entry = getItem(position)
|
||||
val view: View
|
||||
if (convertView != null) {
|
||||
view = convertView
|
||||
} else {
|
||||
val view: View = convertView ?: let {
|
||||
when (viewType) {
|
||||
VIEW_TYPE_PREFERENCE_ENTRY -> {
|
||||
view = mInflater.inflate(R.layout.list_item_preference_header_item, parent, false)
|
||||
return@let inflater.inflate(R.layout.list_item_preference_header_item, parent, false)
|
||||
}
|
||||
VIEW_TYPE_HEADER_ENTRY -> {
|
||||
view = mInflater.inflate(R.layout.list_item_preference_header_category, parent, false)
|
||||
return@let inflater.inflate(R.layout.list_item_preference_header_category, parent, false)
|
||||
}
|
||||
else -> {
|
||||
throw UnsupportedOperationException()
|
||||
|
@ -26,7 +26,6 @@ import android.widget.CompoundButton
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.adapter.iface.IBaseAdapter
|
||||
import org.mariotaku.twidere.model.AccountDetails
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
import org.mariotaku.twidere.model.util.AccountUtils
|
||||
import org.mariotaku.twidere.util.MediaLoaderWrapper
|
||||
import org.mariotaku.twidere.util.dagger.GeneralComponentHelper
|
||||
|
@ -157,7 +157,7 @@ class ParcelableActivitiesAdapter(
|
||||
return data!!.size
|
||||
}
|
||||
|
||||
protected fun bindTitleSummaryViewHolder(holder: ActivityTitleSummaryViewHolder, position: Int) {
|
||||
private fun bindTitleSummaryViewHolder(holder: ActivityTitleSummaryViewHolder, position: Int) {
|
||||
holder.displayActivity(getActivity(position)!!, byFriends)
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ class ParcelableGroupsAdapter(context: Context) : LoadMoreSupportAdapter<Recycle
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
protected fun bindGroup(holder: GroupViewHolder, position: Int) {
|
||||
private fun bindGroup(holder: GroupViewHolder, position: Int) {
|
||||
holder.displayGroup(getGroup(position))
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ class ParcelableUserListsAdapter(context: Context) : LoadMoreSupportAdapter<Recy
|
||||
return true
|
||||
}
|
||||
|
||||
protected fun bindUserList(holder: UserListViewHolder, position: Int) {
|
||||
private fun bindUserList(holder: UserListViewHolder, position: Int) {
|
||||
holder.displayUserList(getUserList(position))
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ class ParcelableUsersAdapter(context: Context) : LoadMoreSupportAdapter<Recycler
|
||||
return true
|
||||
}
|
||||
|
||||
protected fun bindUser(holder: UserViewHolder, position: Int) {
|
||||
private fun bindUser(holder: UserViewHolder, position: Int) {
|
||||
holder.displayUser(getUser(position)!!)
|
||||
}
|
||||
|
||||
@ -111,8 +111,7 @@ class ParcelableUsersAdapter(context: Context) : LoadMoreSupportAdapter<Recycler
|
||||
}
|
||||
|
||||
fun removeUserAt(position: Int): Boolean {
|
||||
val data = this.data
|
||||
if (data !is MutableList) return false
|
||||
val data = this.data as? MutableList ?: return false
|
||||
val dataPosition = position - userStartIndex
|
||||
if (dataPosition < 0 || dataPosition >= userCount) return false
|
||||
data.removeAt(dataPosition)
|
||||
@ -121,8 +120,7 @@ class ParcelableUsersAdapter(context: Context) : LoadMoreSupportAdapter<Recycler
|
||||
}
|
||||
|
||||
fun setUserAt(position: Int, user: ParcelableUser): Boolean {
|
||||
val data = this.data
|
||||
if (data !is MutableList) return false
|
||||
val data = this.data as? MutableList ?: return false
|
||||
val dataPosition = position - userStartIndex
|
||||
if (dataPosition < 0 || dataPosition >= userCount) return false
|
||||
data[dataPosition] = user
|
||||
|
@ -71,7 +71,7 @@ class VariousItemsAdapter(context: Context) : LoadMoreSupportAdapter<RecyclerVie
|
||||
return getItemViewType(getItem(position))
|
||||
}
|
||||
|
||||
protected fun getItemViewType(obj: Any): Int {
|
||||
private fun getItemViewType(obj: Any): Int {
|
||||
if (obj is ParcelableStatus) {
|
||||
return VIEW_TYPE_STATUS
|
||||
} else if (obj is ParcelableUser) {
|
||||
|
@ -26,7 +26,7 @@ import org.mariotaku.twidere.view.holder.ActivityTitleSummaryViewHolder
|
||||
/**
|
||||
* Created by mariotaku on 14/11/18.
|
||||
*/
|
||||
interface IActivitiesAdapter<Data> : IContentCardAdapter, IGapSupportedAdapter {
|
||||
interface IActivitiesAdapter<in Data> : IContentCardAdapter, IGapSupportedAdapter {
|
||||
|
||||
val activityCount: Int
|
||||
|
||||
|
@ -25,7 +25,7 @@ import org.mariotaku.twidere.view.holder.GroupViewHolder
|
||||
/**
|
||||
* Created by mariotaku on 15/4/16.
|
||||
*/
|
||||
interface IGroupsAdapter<Data> : IContentCardAdapter {
|
||||
interface IGroupsAdapter<in Data> : IContentCardAdapter {
|
||||
|
||||
val groupsCount: Int
|
||||
|
||||
|
@ -10,7 +10,7 @@ import org.mariotaku.twidere.view.holder.iface.IStatusViewHolder
|
||||
/**
|
||||
* Created by mariotaku on 14/11/18.
|
||||
*/
|
||||
interface IStatusesAdapter<Data> : IContentCardAdapter, IGapSupportedAdapter {
|
||||
interface IStatusesAdapter<in Data> : IContentCardAdapter, IGapSupportedAdapter {
|
||||
|
||||
@TwidereLinkify.HighlightStyle
|
||||
val linkHighlightingStyle: Int
|
||||
|
@ -25,7 +25,7 @@ import org.mariotaku.twidere.view.holder.UserListViewHolder
|
||||
/**
|
||||
* Created by mariotaku on 15/4/16.
|
||||
*/
|
||||
interface IUserListsAdapter<Data> : IContentCardAdapter {
|
||||
interface IUserListsAdapter<in Data> : IContentCardAdapter {
|
||||
|
||||
val userListsCount: Int
|
||||
|
||||
|
@ -25,7 +25,7 @@ import org.mariotaku.twidere.view.holder.UserViewHolder
|
||||
/**
|
||||
* Created by mariotaku on 15/4/16.
|
||||
*/
|
||||
interface IUsersAdapter<Data> : IContentCardAdapter {
|
||||
interface IUsersAdapter<in Data> : IContentCardAdapter {
|
||||
|
||||
val userCount: Int
|
||||
|
||||
|
@ -104,7 +104,7 @@ fun <T> Credentials.newMicroBlogInstance(context: Context,
|
||||
extraRequestParams: Map<String, String>? = null,
|
||||
cls: Class<T>): T {
|
||||
return newMicroBlogInstance(context, getAuthorization(), getEndpoint(cls),
|
||||
twitterExtraQueries, extraRequestParams, cls);
|
||||
twitterExtraQueries, extraRequestParams, cls)
|
||||
}
|
||||
|
||||
fun <T> newMicroBlogInstance(context: Context,
|
||||
|
@ -15,7 +15,7 @@ fun AccountDetails.isOfficial(context: Context): Boolean {
|
||||
val credentials = this.credentials
|
||||
if (credentials is OAuthCredentials) {
|
||||
return TwitterContentUtils.isOfficialKey(context,
|
||||
credentials.consumer_key, credentials.consumer_secret);
|
||||
credentials.consumer_key, credentials.consumer_secret)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ abstract class AbsActivitiesFragment protected constructor() : AbsContentListRec
|
||||
val lastItemIndex = Math.min(activityEndIndex, lastVisiblePos)
|
||||
lastReadId = adapter.getTimestamp(lastItemIndex)
|
||||
val positionView = layoutManager.findViewByPosition(lastItemIndex)
|
||||
lastVisibleTop = if (positionView != null) positionView.top else 0
|
||||
lastVisibleTop = positionView?.top ?: 0
|
||||
} else if (rememberPosition && tag != null) {
|
||||
lastReadId = readStateManager.getPosition(tag)
|
||||
lastVisibleTop = 0
|
||||
@ -269,7 +269,7 @@ abstract class AbsActivitiesFragment protected constructor() : AbsContentListRec
|
||||
if (loader !is IExtendedLoader || loader.fromUser) {
|
||||
adapter.loadMoreSupportedPosition = if (hasMoreData(data)) ILoadMoreSupportAdapter.END else ILoadMoreSupportAdapter.NONE
|
||||
var pos = -1
|
||||
for (i in activityStartIndex..activityEndExclusiveIndex - 1) {
|
||||
for (i in activityStartIndex until activityEndExclusiveIndex) {
|
||||
if (lastReadId != -1L && adapter.getTimestamp(i) <= lastReadId) {
|
||||
pos = i
|
||||
break
|
||||
|
@ -515,10 +515,8 @@ abstract class AbsStatusesFragment protected constructor() :
|
||||
val status = adapter.getStatus(position) ?: return
|
||||
val positionKey = if (status.position_key > 0) status.position_key else status.timestamp
|
||||
readPositionTagWithArguments?.let {
|
||||
for (accountKey in accountKeys) {
|
||||
val tag = Utils.getReadPositionTagWithAccount(it, accountKey)
|
||||
readStateManager.setPosition(tag, positionKey)
|
||||
}
|
||||
accountKeys.map { accountKey -> Utils.getReadPositionTagWithAccount(it, accountKey) }
|
||||
.forEach { readStateManager.setPosition(it, positionKey) }
|
||||
}
|
||||
currentReadPositionTag?.let {
|
||||
readStateManager.setPosition(it, positionKey, true)
|
||||
|
@ -56,7 +56,7 @@ abstract class AbsToolbarTabPagesFragment : BaseSupportFragment(), RefreshScroll
|
||||
val pageLimit = viewPager.offscreenPageLimit
|
||||
val currentItem = viewPager.currentItem
|
||||
val count = pagerAdapter!!.count
|
||||
for (i in 0..count - 1) {
|
||||
for (i in 0 until count) {
|
||||
if (i > currentItem - pageLimit - 1 || i < currentItem + pageLimit) {
|
||||
val obj = pagerAdapter!!.instantiateItem(viewPager, i)
|
||||
if (obj is IBaseFragment) {
|
||||
@ -105,8 +105,7 @@ abstract class AbsToolbarTabPagesFragment : BaseSupportFragment(), RefreshScroll
|
||||
}
|
||||
|
||||
override fun scrollToStart(): Boolean {
|
||||
val fragment = currentVisibleFragment
|
||||
if (fragment !is RefreshScrollTopInterface) return false
|
||||
val fragment = currentVisibleFragment as? RefreshScrollTopInterface ?: return false
|
||||
fragment.scrollToStart()
|
||||
return true
|
||||
}
|
||||
|
@ -267,13 +267,7 @@ class AccountsDashboardFragment : BaseSupportFragment(), LoaderCallbacks<Account
|
||||
noAccountContainer.visibility = View.VISIBLE
|
||||
profileContainer.visibility = View.INVISIBLE
|
||||
}
|
||||
var defaultId: UserKey? = null
|
||||
for (account in accounts) {
|
||||
if (account.activated) {
|
||||
defaultId = account.key
|
||||
break
|
||||
}
|
||||
}
|
||||
val defaultId: UserKey? = accounts.firstOrNull { it.activated }?.convert { it.key }
|
||||
useStarsForLikes = preferences.getBoolean(KEY_I_WANT_MY_STARS_BACK)
|
||||
|
||||
accountsAdapter!!.accounts = accounts
|
||||
@ -496,7 +490,7 @@ class AccountsDashboardFragment : BaseSupportFragment(), LoaderCallbacks<Account
|
||||
|
||||
}
|
||||
|
||||
protected fun displayAccountBanner(account: AccountDetails) {
|
||||
private fun displayAccountBanner(account: AccountDetails) {
|
||||
val bannerWidth = accountProfileBanner.width
|
||||
val res = resources
|
||||
val defWidth = res.displayMetrics.widthPixels
|
||||
|
@ -259,7 +259,7 @@ abstract class BaseFiltersFragment : AbsContentListViewFragment<SimpleCursorAdap
|
||||
mUserAutoCompleteAdapter = SourceAutoCompleteAdapter(activity)
|
||||
} else {
|
||||
val adapter = ComposeAutoCompleteAdapter(activity)
|
||||
adapter.setAccountKey(Utils.getDefaultAccountKey(activity))
|
||||
adapter.accountKey = Utils.getDefaultAccountKey(activity)
|
||||
mUserAutoCompleteAdapter = adapter
|
||||
}
|
||||
editText.setAdapter(mUserAutoCompleteAdapter)
|
||||
@ -269,7 +269,7 @@ abstract class BaseFiltersFragment : AbsContentListViewFragment<SimpleCursorAdap
|
||||
return dialog
|
||||
}
|
||||
|
||||
protected val text: String
|
||||
private val text: String
|
||||
get() {
|
||||
val alertDialog = dialog as AlertDialog
|
||||
val editText = (alertDialog.findViewById(R.id.edit_text) as AutoCompleteTextView?)!!
|
||||
|
@ -78,8 +78,7 @@ open class BaseListFragment : ListFragment(), OnScrollListener, RefreshScrollTop
|
||||
|
||||
val tabPosition: Int
|
||||
get() {
|
||||
val args = arguments
|
||||
return if (args != null) args.getInt(EXTRA_TAB_POSITION, -1) else -1
|
||||
return arguments?.getInt(EXTRA_TAB_POSITION, -1) ?: -1
|
||||
}
|
||||
|
||||
fun invalidateOptionsMenu() {
|
||||
|
@ -89,7 +89,7 @@ abstract class BasePreferenceFragment : PreferenceFragmentCompat() {
|
||||
|
||||
val existingValue = preference.value // TODO
|
||||
if (existingValue != null) {
|
||||
if (existingValue.length == 0) {
|
||||
if (existingValue.isEmpty()) {
|
||||
// Select "Silent"
|
||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, null as Uri)
|
||||
} else {
|
||||
|
@ -55,7 +55,7 @@ abstract class CursorActivitiesFragment : AbsActivitiesFragment() {
|
||||
val adapter = adapter
|
||||
if (adapter!!.itemCount > 0) {
|
||||
showContent()
|
||||
} else if (accountKeys.size > 0) {
|
||||
} else if (accountKeys.isNotEmpty()) {
|
||||
val errorInfo = ErrorInfoStore.getErrorInfo(context,
|
||||
errorInfoStore.get(errorInfoKey, accountKeys[0]))
|
||||
if (errorInfo != null) {
|
||||
@ -158,7 +158,7 @@ abstract class CursorActivitiesFragment : AbsActivitiesFragment() {
|
||||
override fun onLoadMoreContents(@IndicatorPosition position: Long) {
|
||||
// Only supports load from end, skip START flag
|
||||
if (position and ILoadMoreSupportAdapter.START !== 0L || refreshing) return
|
||||
super.onLoadMoreContents(position.toLong())
|
||||
super.onLoadMoreContents(position)
|
||||
if (position == 0L) return
|
||||
getActivities(object : SimpleRefreshTaskParam() {
|
||||
override fun getAccountKeysWorker(): Array<UserKey> {
|
||||
@ -268,9 +268,8 @@ abstract class CursorActivitiesFragment : AbsActivitiesFragment() {
|
||||
continue@loop
|
||||
}
|
||||
val statusesMatrix = arrayOf(activity.target_statuses, activity.target_object_statuses)
|
||||
for (statusesArray in statusesMatrix) {
|
||||
if (statusesArray == null) continue
|
||||
for (status in statusesArray) {
|
||||
statusesMatrix.filterNotNull().forEach { statuses ->
|
||||
for (status in statuses) {
|
||||
if (result.id == status.id || result.id == status.retweet_id
|
||||
|| result.id == status.my_retweet_id) {
|
||||
status.is_favorite = result.is_favorite
|
||||
|
@ -102,10 +102,10 @@ abstract class CursorStatusesFragment : AbsStatusesFragment() {
|
||||
|
||||
private fun showContentOrError() {
|
||||
val accountKeys = accountKeys
|
||||
val adapter = adapter
|
||||
if (adapter!!.itemCount > 0) {
|
||||
val adapter = adapter!!
|
||||
if (adapter.itemCount > 0) {
|
||||
showContent()
|
||||
} else if (accountKeys.size > 0) {
|
||||
} else if (accountKeys.isNotEmpty()) {
|
||||
val errorInfo = ErrorInfoStore.getErrorInfo(context,
|
||||
errorInfoStore.get(errorInfoKey, accountKeys[0]))
|
||||
if (errorInfo != null) {
|
||||
@ -173,7 +173,7 @@ abstract class CursorStatusesFragment : AbsStatusesFragment() {
|
||||
override fun onLoadMoreContents(@IndicatorPosition position: Long) {
|
||||
// Only supports load from end, skip START flag
|
||||
if (position and ILoadMoreSupportAdapter.START !== 0L) return
|
||||
super.onLoadMoreContents(position.toLong())
|
||||
super.onLoadMoreContents(position)
|
||||
if (position == 0L) return
|
||||
getStatuses(object : SimpleRefreshTaskParam() {
|
||||
override fun getAccountKeysWorker(): Array<UserKey> {
|
||||
|
@ -65,7 +65,7 @@ abstract class CursorSupportUsersListFragment : ParcelableUsersFragment() {
|
||||
override fun onLoadMoreContents(@IndicatorPosition position: Long) {
|
||||
// Only supports load from end, skip START flag
|
||||
if (position and ILoadMoreSupportAdapter.START !== 0L) return
|
||||
super.onLoadMoreContents(position.toLong())
|
||||
super.onLoadMoreContents(position)
|
||||
if (position == 0L) return
|
||||
val loaderArgs = Bundle(arguments)
|
||||
loaderArgs.putBoolean(EXTRA_FROM_USER, true)
|
||||
|
@ -43,7 +43,6 @@ import android.widget.AdapterView.OnItemClickListener
|
||||
import com.afollestad.appthemeengine.ATEActivity
|
||||
import com.afollestad.appthemeengine.Config
|
||||
import com.mobeta.android.dslv.SimpleDragSortCursorAdapter
|
||||
import kotlinx.android.synthetic.main.layout_actionbar_message_user_picker.view.*
|
||||
import kotlinx.android.synthetic.main.layout_draggable_list_with_empty_view.*
|
||||
import kotlinx.android.synthetic.main.list_item_section_header.view.*
|
||||
import org.mariotaku.ktextension.Bundle
|
||||
|
@ -137,7 +137,7 @@ class DirectMessagesFragment : AbsContentListRecyclerViewFragment<MessageEntries
|
||||
adapter.setShowAccountsColor(accountIds.size > 1)
|
||||
refreshEnabled = true
|
||||
|
||||
if (accountIds.size > 0) {
|
||||
if (accountIds.isNotEmpty()) {
|
||||
val errorInfo = ErrorInfoStore.getErrorInfo(context,
|
||||
errorInfoStore.get(ErrorInfoStore.KEY_DIRECT_MESSAGES, accountIds[0]))
|
||||
if (isEmpty && errorInfo != null) {
|
||||
@ -150,7 +150,7 @@ class DirectMessagesFragment : AbsContentListRecyclerViewFragment<MessageEntries
|
||||
}
|
||||
}
|
||||
|
||||
protected fun hasMoreData(cursor: Cursor?): Boolean {
|
||||
private fun hasMoreData(cursor: Cursor?): Boolean {
|
||||
return cursor != null && cursor.count != 0
|
||||
}
|
||||
|
||||
@ -265,7 +265,7 @@ class DirectMessagesFragment : AbsContentListRecyclerViewFragment<MessageEntries
|
||||
super.setUserVisibleHint(isVisibleToUser)
|
||||
val context = context
|
||||
if (isVisibleToUser && context != null) {
|
||||
for (accountKey in accountKeys) {
|
||||
accountKeys.forEach { accountKey ->
|
||||
val tag = "messages_" + accountKey
|
||||
notificationManager.cancel(tag, NOTIFICATION_ID_DIRECT_MESSAGES)
|
||||
}
|
||||
@ -282,7 +282,7 @@ class DirectMessagesFragment : AbsContentListRecyclerViewFragment<MessageEntries
|
||||
return itemDecoration
|
||||
}
|
||||
|
||||
protected val accountKeys: Array<UserKey>
|
||||
private val accountKeys: Array<UserKey>
|
||||
get() {
|
||||
val args = arguments
|
||||
val accountKeys = Utils.getAccountKeys(context, args)
|
||||
|
@ -214,7 +214,7 @@ class DraftsFragment : BaseSupportFragment(), LoaderCallbacks<Cursor?>, OnItemCl
|
||||
continue@loop
|
||||
}
|
||||
val accountId = item.account_keys!![0]
|
||||
val imageUri = if (item.media != null && item.media.size > 0) item.media[0].uri else null
|
||||
val imageUri = item.media?.firstOrNull()?.uri
|
||||
twitterWrapper.sendDirectMessageAsync(accountId, recipientId, item.text, imageUri)
|
||||
}
|
||||
}
|
||||
@ -307,7 +307,7 @@ class DraftsFragment : BaseSupportFragment(), LoaderCallbacks<Cursor?>, OnItemCl
|
||||
f.dismiss()
|
||||
}
|
||||
}
|
||||
for (id in ids) {
|
||||
ids.forEach { id ->
|
||||
val tag = Uri.withAppendedPath(Drafts.CONTENT_URI, id.toString()).toString()
|
||||
notificationManager.cancel(tag, NOTIFICATION_ID_DRAFTS)
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ class GifPageFragment : CacheDownloadMediaViewerFragment() {
|
||||
super.onDownloadFinished(nonce)
|
||||
if (mediaDownloadEvent != null && mediaDownloadEvent!!.nonce == nonce) {
|
||||
mediaDownloadEvent!!.markEnd()
|
||||
HotMobiLogger.getInstance(context).log<MediaDownloadEvent>(accountKey, mediaDownloadEvent!!)
|
||||
HotMobiLogger.getInstance(context).log(accountKey, mediaDownloadEvent!!)
|
||||
mediaDownloadEvent = null
|
||||
}
|
||||
}
|
||||
|
@ -104,8 +104,8 @@ class GroupFragment : AbsToolbarTabPagesFragment(), LoaderCallbacks<SingleRespon
|
||||
val cache = extras.getParcelable<ParcelableGroup>(EXTRA_GROUP)
|
||||
if (cache != null) return SingleResponse.getInstance(cache)
|
||||
}
|
||||
val twitter = MicroBlogAPIFactory.getInstance(context, accountKey,
|
||||
true) ?: return SingleResponse.getInstance<ParcelableGroup>()
|
||||
val twitter = MicroBlogAPIFactory.getInstance(context, accountKey
|
||||
) ?: return SingleResponse.getInstance<ParcelableGroup>()
|
||||
try {
|
||||
val group: Group
|
||||
if (groupId != null) {
|
||||
|
@ -129,7 +129,7 @@ class ImagePageFragment : SubsampleImageViewerFragment() {
|
||||
super.onDownloadFinished(nonce)
|
||||
if (mediaDownloadEvent != null && mediaDownloadEvent!!.nonce == nonce) {
|
||||
mediaDownloadEvent!!.markEnd()
|
||||
HotMobiLogger.getInstance(context).log<MediaDownloadEvent>(accountKey, mediaDownloadEvent!!)
|
||||
HotMobiLogger.getInstance(context).log(accountKey, mediaDownloadEvent!!)
|
||||
mediaDownloadEvent = null
|
||||
}
|
||||
}
|
||||
|
@ -561,14 +561,12 @@ class MessagesConversationFragment : BaseSupportFragment(), LoaderCallbacks<Curs
|
||||
private fun setupEditQuery() {
|
||||
val queryEnterHandler = EditTextEnterHandler.attach(actionBarCustomView.editUserQuery, object : EnterListener {
|
||||
override fun shouldCallListener(): Boolean {
|
||||
val activity = activity
|
||||
if (activity !is BaseActivity) return false
|
||||
val activity = activity as? BaseActivity ?: return false
|
||||
return activity.keyMetaState == 0
|
||||
}
|
||||
|
||||
override fun onHitEnter(): Boolean {
|
||||
val activity = activity
|
||||
if (activity !is BaseActivity) return false
|
||||
val activity = activity as? BaseActivity ?: return false
|
||||
if (activity.keyMetaState != 0) return false
|
||||
val account = actionBarCustomView.accountSpinner.selectedItem as AccountDetails
|
||||
editText.accountKey = account.key
|
||||
@ -619,7 +617,7 @@ class MessagesConversationFragment : BaseSupportFragment(), LoaderCallbacks<Curs
|
||||
editText.addTextChangedListener(object : TextWatcher {
|
||||
|
||||
override fun afterTextChanged(s: Editable) {
|
||||
textChanged = s.length == 0
|
||||
textChanged = s.isEmpty()
|
||||
}
|
||||
|
||||
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {
|
||||
|
@ -94,7 +94,7 @@ abstract class ParcelableGroupsFragment : AbsContentListRecyclerViewFragment<Par
|
||||
override fun onLoadMoreContents(@IndicatorPosition position: Long) {
|
||||
// Only supports load from end, skip START flag
|
||||
if (position and ILoadMoreSupportAdapter.START !== 0L) return
|
||||
super.onLoadMoreContents(position.toLong())
|
||||
super.onLoadMoreContents(position)
|
||||
if (position == 0L) return
|
||||
val loaderArgs = Bundle(arguments)
|
||||
loaderArgs.putBoolean(EXTRA_FROM_USER, true)
|
||||
|
@ -147,7 +147,7 @@ abstract class ParcelableStatusesFragment : AbsStatusesFragment() {
|
||||
override fun onLoadMoreContents(position: Long) {
|
||||
// Only supports load from end, skip START flag
|
||||
if (position and ILoadMoreSupportAdapter.START !== 0L || refreshing) return
|
||||
super.onLoadMoreContents(position.toLong())
|
||||
super.onLoadMoreContents(position)
|
||||
if (position == 0L) return
|
||||
val adapter = adapter
|
||||
// Load the last item
|
||||
|
@ -100,7 +100,7 @@ abstract class ParcelableUserListsFragment : AbsContentListRecyclerViewFragment<
|
||||
override fun onLoadMoreContents(@IndicatorPosition position: Long) {
|
||||
// Only supports load from end, skip START flag
|
||||
if (position and ILoadMoreSupportAdapter.START !== 0L) return
|
||||
super.onLoadMoreContents(position.toLong())
|
||||
super.onLoadMoreContents(position)
|
||||
if (position == 0L) return
|
||||
val loaderArgs = Bundle(arguments)
|
||||
loaderArgs.putBoolean(EXTRA_FROM_USER, true)
|
||||
|
@ -49,7 +49,7 @@ import org.mariotaku.twidere.util.KeyboardShortcutsHandler.KeyboardShortcutCallb
|
||||
import org.mariotaku.twidere.util.RecyclerViewNavigationHelper
|
||||
import org.mariotaku.twidere.view.holder.UserViewHolder
|
||||
|
||||
abstract class ParcelableUsersFragment : AbsContentListRecyclerViewFragment<ParcelableUsersAdapter>,
|
||||
abstract class ParcelableUsersFragment : AbsContentListRecyclerViewFragment<ParcelableUsersAdapter>(),
|
||||
LoaderCallbacks<List<ParcelableUser>?>, UserClickListener, KeyboardShortcutCallback,
|
||||
IUsersAdapter.FriendshipClickListener {
|
||||
|
||||
@ -57,7 +57,7 @@ abstract class ParcelableUsersFragment : AbsContentListRecyclerViewFragment<Parc
|
||||
|
||||
private var navigationHelper: RecyclerViewNavigationHelper? = null
|
||||
|
||||
protected constructor() {
|
||||
init {
|
||||
usersBusCallback = createMessageBusCallback()
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ class SearchUsersFragment : ParcelableUsersFragment() {
|
||||
override fun onLoadMoreContents(@IndicatorPosition position: Long) {
|
||||
// Only supports load from end, skip START flag
|
||||
if (position and ILoadMoreSupportAdapter.START !== 0L) return
|
||||
super.onLoadMoreContents(position.toLong())
|
||||
super.onLoadMoreContents(position)
|
||||
if (position == 0L) return
|
||||
val loaderArgs = Bundle(arguments)
|
||||
loaderArgs.putBoolean(EXTRA_FROM_USER, true)
|
||||
|
@ -136,25 +136,26 @@ class StatusFragment : BaseSupportFragment(), LoaderCallbacks<SingleResponse<Par
|
||||
// Listeners
|
||||
private val conversationsLoaderCallback = object : LoaderCallbacks<List<ParcelableStatus>> {
|
||||
override fun onCreateLoader(id: Int, args: Bundle): Loader<List<ParcelableStatus>> {
|
||||
adapter!!.isRepliesLoading = true
|
||||
adapter!!.isConversationsLoading = true
|
||||
adapter!!.updateItemDecoration()
|
||||
val status = args.getParcelable<ParcelableStatus>(EXTRA_STATUS)
|
||||
val adapter = this@StatusFragment.adapter!!
|
||||
adapter.isRepliesLoading = true
|
||||
adapter.isConversationsLoading = true
|
||||
adapter.updateItemDecoration()
|
||||
val status: ParcelableStatus = args.getParcelable(EXTRA_STATUS)
|
||||
val maxId = args.getString(EXTRA_MAX_ID)
|
||||
val sinceId = args.getString(EXTRA_SINCE_ID)
|
||||
val maxSortId = args.getLong(EXTRA_MAX_SORT_ID)
|
||||
val sinceSortId = args.getLong(EXTRA_SINCE_SORT_ID)
|
||||
val loadingMore = args.getBoolean(EXTRA_LOADING_MORE, false)
|
||||
assert(status != null)
|
||||
val loader = ConversationLoader(activity, status!!, sinceId,
|
||||
maxId, sinceSortId, maxSortId, adapter!!.getData(), true, loadingMore)
|
||||
val loader = ConversationLoader(activity, status, sinceId, maxId, sinceSortId, maxSortId,
|
||||
adapter.getData(), true, loadingMore)
|
||||
// Setting comparator to null lets statuses sort ascending
|
||||
loader.comparator = null
|
||||
return loader
|
||||
}
|
||||
|
||||
override fun onLoadFinished(loader: Loader<List<ParcelableStatus>>, data: List<ParcelableStatus>?) {
|
||||
adapter!!.updateItemDecoration()
|
||||
val adapter = this@StatusFragment.adapter!!
|
||||
adapter.updateItemDecoration()
|
||||
val conversationLoader = loader as ConversationLoader
|
||||
var supportedPositions: Long = 0
|
||||
if (data != null && !data.isEmpty()) {
|
||||
@ -171,21 +172,16 @@ class StatusFragment : BaseSupportFragment(), LoaderCallbacks<SingleResponse<Par
|
||||
supportedPositions = supportedPositions or ILoadMoreSupportAdapter.START
|
||||
}
|
||||
}
|
||||
adapter!!.loadMoreSupportedPosition = supportedPositions
|
||||
adapter.loadMoreSupportedPosition = supportedPositions
|
||||
setConversation(data)
|
||||
val canLoadAllReplies = loader.canLoadAllReplies()
|
||||
if (canLoadAllReplies) {
|
||||
adapter!!.setReplyError(null)
|
||||
adapter.setReplyError(null)
|
||||
} else {
|
||||
val error = SpannableStringBuilder.valueOf(
|
||||
HtmlSpanBuilder.fromHtml(getString(R.string.cant_load_all_replies_message)))
|
||||
var dialogSpan: ClickableSpan? = null
|
||||
for (span in error.getSpans(0, error.length, URLSpan::class.java)) {
|
||||
if ("#dialog" == span.url) {
|
||||
dialogSpan = span
|
||||
break
|
||||
}
|
||||
}
|
||||
val dialogSpan: ClickableSpan? = error.getSpans(0, error.length, URLSpan::class.java)
|
||||
.firstOrNull { "#dialog" == it.url }
|
||||
if (dialogSpan != null) {
|
||||
val spanStart = error.getSpanStart(dialogSpan)
|
||||
val spanEnd = error.getSpanEnd(dialogSpan)
|
||||
@ -200,10 +196,10 @@ class StatusFragment : BaseSupportFragment(), LoaderCallbacks<SingleResponse<Par
|
||||
}
|
||||
}, spanStart, spanEnd, Spanned.SPAN_INCLUSIVE_INCLUSIVE)
|
||||
}
|
||||
adapter!!.setReplyError(error)
|
||||
adapter.setReplyError(error)
|
||||
}
|
||||
adapter!!.isConversationsLoading = false
|
||||
adapter!!.isRepliesLoading = false
|
||||
adapter.isConversationsLoading = false
|
||||
adapter.isRepliesLoading = false
|
||||
}
|
||||
|
||||
override fun onLoaderReset(loader: Loader<List<ParcelableStatus>>) {
|
||||
@ -564,7 +560,7 @@ class StatusFragment : BaseSupportFragment(), LoaderCallbacks<SingleResponse<Par
|
||||
val context = this.context ?: return
|
||||
if (status != null) {
|
||||
val event = TranslateEvent.create(context, status, translation.translatedLang)
|
||||
HotMobiLogger.getInstance(context).log(status.account_key, event);
|
||||
HotMobiLogger.getInstance(context).log(status.account_key, event)
|
||||
}
|
||||
}
|
||||
|
||||
@ -706,8 +702,8 @@ class StatusFragment : BaseSupportFragment(), LoaderCallbacks<SingleResponse<Par
|
||||
|
||||
override fun doInBackground(vararg params: ParcelableStatus): SingleResponse<TranslationResult> {
|
||||
val status = params[0]
|
||||
val twitter = MicroBlogAPIFactory.getInstance(context, status.account_key,
|
||||
true)
|
||||
val twitter = MicroBlogAPIFactory.getInstance(context, status.account_key
|
||||
)
|
||||
val prefs = context.getSharedPreferences(SHARED_PREFERENCES_NAME,
|
||||
Context.MODE_PRIVATE)
|
||||
if (twitter == null) return SingleResponse.Companion.getInstance<TranslationResult>()
|
||||
@ -1260,7 +1256,7 @@ class StatusFragment : BaseSupportFragment(), LoaderCallbacks<SingleResponse<Par
|
||||
return counts!!.size
|
||||
}
|
||||
|
||||
protected val usersCount: Int
|
||||
private val usersCount: Int
|
||||
get() {
|
||||
if (users == null) return 0
|
||||
return users!!.size
|
||||
@ -1546,7 +1542,7 @@ class StatusFragment : BaseSupportFragment(), LoaderCallbacks<SingleResponse<Par
|
||||
|
||||
override fun getStatusTimestamp(position: Int): Long {
|
||||
val status = getStatus(position)
|
||||
return if (status != null) status.timestamp else -1
|
||||
return status?.timestamp ?: -1
|
||||
}
|
||||
|
||||
override fun getStatusPositionKey(position: Int): Long {
|
||||
@ -1563,11 +1559,7 @@ class StatusFragment : BaseSupportFragment(), LoaderCallbacks<SingleResponse<Par
|
||||
if (status != null && accountKey == status!!.account_key && TextUtils.equals(statusId, status!!.id)) {
|
||||
return status
|
||||
}
|
||||
for (status in Nullables.list(data)) {
|
||||
if (accountKey == status.account_key && TextUtils.equals(status.id, statusId))
|
||||
return status
|
||||
}
|
||||
return null
|
||||
return data?.firstOrNull { accountKey == it.account_key && TextUtils.equals(it.id, statusId) }
|
||||
}
|
||||
|
||||
override val statusCount: Int
|
||||
@ -2071,7 +2063,7 @@ class StatusFragment : BaseSupportFragment(), LoaderCallbacks<SingleResponse<Par
|
||||
if (AccountType.TWITTER != details.type) {
|
||||
return null
|
||||
}
|
||||
val twitter = MicroBlogAPIFactory.getInstance(context, mAccountKey, false) ?: return null
|
||||
val twitter = MicroBlogAPIFactory.getInstance(context, mAccountKey) ?: return null
|
||||
val paging = Paging()
|
||||
paging.setCount(10)
|
||||
val activitySummary = StatusActivity(mStatusId, emptyList())
|
||||
|
@ -311,7 +311,7 @@ class UserFragment : BaseSupportFragment(), OnClickListener, OnLinkClickListener
|
||||
followingYouIndicator.visibility = if (userRelationship.followed_by) View.VISIBLE else View.GONE
|
||||
|
||||
task {
|
||||
val resolver = contentResolver;
|
||||
val resolver = contentResolver
|
||||
resolver.insert(CachedUsers.CONTENT_URI, ParcelableUserValuesCreator.create(user))
|
||||
resolver.insert(CachedRelationships.CONTENT_URI, ParcelableRelationshipValuesCreator.create(userRelationship))
|
||||
}
|
||||
@ -727,7 +727,7 @@ class UserFragment : BaseSupportFragment(), OnClickListener, OnLinkClickListener
|
||||
if (userEvent != null && context != null && user != null) {
|
||||
userEvent!!.setUser(user!!)
|
||||
userEvent!!.markEnd()
|
||||
HotMobiLogger.getInstance(context).log<UserEvent>(userEvent!!)
|
||||
HotMobiLogger.getInstance(context).log(userEvent!!)
|
||||
}
|
||||
bus.unregister(this)
|
||||
super.onStop()
|
||||
@ -912,7 +912,7 @@ class UserFragment : BaseSupportFragment(), OnClickListener, OnLinkClickListener
|
||||
ProgressDialogFragment.show(fragmentManager, "get_list_progress")
|
||||
}
|
||||
}.then {
|
||||
val microBlog = MicroBlogAPIFactory.getInstance(context, user.account_key, true)
|
||||
val microBlog = MicroBlogAPIFactory.getInstance(context, user.account_key)
|
||||
val paging = Paging()
|
||||
val ownedLists = microBlog.getUserListOwnerships(paging)
|
||||
var nextCursor = ownedLists.nextCursor
|
||||
@ -1241,15 +1241,13 @@ class UserFragment : BaseSupportFragment(), OnClickListener, OnLinkClickListener
|
||||
}
|
||||
|
||||
override fun scrollToStart(): Boolean {
|
||||
val fragment = currentVisibleFragment
|
||||
if (fragment !is RefreshScrollTopInterface) return false
|
||||
val fragment = currentVisibleFragment as? RefreshScrollTopInterface ?: return false
|
||||
fragment.scrollToStart()
|
||||
return true
|
||||
}
|
||||
|
||||
override fun triggerRefresh(): Boolean {
|
||||
val fragment = currentVisibleFragment
|
||||
if (fragment !is RefreshScrollTopInterface) return false
|
||||
val fragment = currentVisibleFragment as? RefreshScrollTopInterface ?: return false
|
||||
fragment.triggerRefresh()
|
||||
return true
|
||||
}
|
||||
@ -1322,8 +1320,7 @@ class UserFragment : BaseSupportFragment(), OnClickListener, OnLinkClickListener
|
||||
}
|
||||
|
||||
private fun setupBaseActionBar() {
|
||||
val activity = activity
|
||||
if (activity !is LinkHandlerActivity) return
|
||||
val activity = activity as? LinkHandlerActivity ?: return
|
||||
val actionBar = activity.supportActionBar ?: return
|
||||
val shadow = ResourcesCompat.getDrawable(activity.getResources(), R.drawable.shadow_user_banner_action_bar, null)
|
||||
mActionBarBackground = ActionBarDrawable(shadow!!)
|
||||
@ -1544,7 +1541,7 @@ class UserFragment : BaseSupportFragment(), OnClickListener, OnLinkClickListener
|
||||
return SingleResponse.getInstance(ParcelableRelationshipUtils.create(user, isFiltering))
|
||||
}
|
||||
}
|
||||
val twitter = MicroBlogAPIFactory.getInstance(context, accountKey, false) ?: return SingleResponse.Companion.getInstance<ParcelableRelationship>(MicroBlogException("No Account"))
|
||||
val twitter = MicroBlogAPIFactory.getInstance(context, accountKey) ?: return SingleResponse.Companion.getInstance<ParcelableRelationship>(MicroBlogException("No Account"))
|
||||
try {
|
||||
val relationship = twitter.showFriendship(user.key.id)
|
||||
if (relationship.isSourceBlockingTarget || relationship.isSourceBlockedByTarget) {
|
||||
@ -1607,7 +1604,7 @@ class UserFragment : BaseSupportFragment(), OnClickListener, OnLinkClickListener
|
||||
ProgressDialogFragment.show(fragmentManager, "update_lists_progress")
|
||||
}
|
||||
}.then {
|
||||
val twitter = MicroBlogAPIFactory.getInstance(context, accountKey, false)
|
||||
val twitter = MicroBlogAPIFactory.getInstance(context, accountKey)
|
||||
val successfulStates = SparseBooleanArray()
|
||||
try {
|
||||
for (i in 0 until checkedPositions.size()) {
|
||||
|
@ -414,8 +414,8 @@ class UserListFragment : AbsToolbarTabPagesFragment(), OnClickListener, LoaderCa
|
||||
val cache = extras.getParcelable<ParcelableUserList>(EXTRA_USER_LIST)
|
||||
if (cache != null) return SingleResponse.Companion.getInstance(cache)
|
||||
}
|
||||
val twitter = MicroBlogAPIFactory.getInstance(context, accountKey,
|
||||
true) ?: return SingleResponse.Companion.getInstance<ParcelableUserList>()
|
||||
val twitter = MicroBlogAPIFactory.getInstance(context, accountKey
|
||||
) ?: return SingleResponse.Companion.getInstance<ParcelableUserList>()
|
||||
try {
|
||||
val list: UserList
|
||||
when {
|
||||
|
@ -136,7 +136,7 @@ class UserMediaTimelineFragment : AbsContentRecyclerViewFragment<StaggeredGridPa
|
||||
override fun onLoadMoreContents(position: Long) {
|
||||
// Only supports load from end, skip START flag
|
||||
if (position and ILoadMoreSupportAdapter.START != 0L) return
|
||||
super.onLoadMoreContents(position.toLong())
|
||||
super.onLoadMoreContents(position)
|
||||
if (position == 0L) return
|
||||
val adapter = adapter ?: return
|
||||
val maxId = adapter.getStatusId(adapter.statusCount - 1)
|
||||
|
@ -176,13 +176,10 @@ class VideoPageFragment : CacheDownloadMediaViewerFragment(), MediaPlayer.OnPrep
|
||||
if (media.video_info == null) {
|
||||
return Pair.create<String, String>(media.media_url, null)
|
||||
}
|
||||
for (supportedType in supportedTypes) {
|
||||
for (variant in media.video_info.variants) {
|
||||
if (supportedType.equals(variant.content_type, ignoreCase = true))
|
||||
return Pair.create(variant.url, variant.content_type)
|
||||
}
|
||||
}
|
||||
return null
|
||||
val firstMatch = media.video_info.variants.first { variant ->
|
||||
supportedTypes.any { it.equals(variant.content_type, ignoreCase = true) }
|
||||
} ?: return null
|
||||
return Pair.create(firstMatch.url, firstMatch.content_type)
|
||||
}
|
||||
ParcelableMedia.Type.CARD_ANIMATED_GIF -> {
|
||||
return Pair.create<String, String>(media.media_url, "video/mp4")
|
||||
@ -265,7 +262,7 @@ class VideoPageFragment : CacheDownloadMediaViewerFragment(), MediaPlayer.OnPrep
|
||||
super.onDownloadFinished(nonce)
|
||||
if (mediaDownloadEvent != null && mediaDownloadEvent!!.nonce == nonce) {
|
||||
mediaDownloadEvent!!.markEnd()
|
||||
HotMobiLogger.getInstance(context).log<MediaDownloadEvent>(accountKey, mediaDownloadEvent!!)
|
||||
HotMobiLogger.getInstance(context).log(accountKey, mediaDownloadEvent!!)
|
||||
mediaDownloadEvent = null
|
||||
}
|
||||
}
|
||||
|
@ -46,10 +46,7 @@ abstract class ParcelableStatusesLoader(
|
||||
}
|
||||
|
||||
protected fun containsStatus(statusId: String): Boolean {
|
||||
for (status in this.data) {
|
||||
if (TextUtils.equals(status.id, statusId)) return true
|
||||
}
|
||||
return false
|
||||
return data.any { TextUtils.equals(it.id, statusId) }
|
||||
}
|
||||
|
||||
protected fun deleteStatus(statuses: MutableList<ParcelableStatus>?, statusId: String): Boolean {
|
||||
|
@ -47,10 +47,7 @@ abstract class ParcelableUsersLoader(
|
||||
}
|
||||
|
||||
protected fun hasId(id: String): Boolean {
|
||||
for (i in this.data.indices) {
|
||||
if (TextUtils.equals(this.data[i].key.id, id)) return true
|
||||
}
|
||||
return false
|
||||
return data.indices.any { TextUtils.equals(data[it].key.id, id) }
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,8 +36,8 @@ class SavedSearchesLoader(
|
||||
) : AsyncTaskLoader<ResponseList<SavedSearch>>(context), Constants {
|
||||
|
||||
override fun loadInBackground(): ResponseList<SavedSearch>? {
|
||||
val twitter = MicroBlogAPIFactory.getInstance(context, accountId,
|
||||
false) ?: return null
|
||||
val twitter = MicroBlogAPIFactory.getInstance(context, accountId
|
||||
) ?: return null
|
||||
try {
|
||||
return twitter.savedSearches
|
||||
} catch (e: MicroBlogException) {
|
||||
|
@ -24,7 +24,7 @@ import android.os.Bundle
|
||||
/**
|
||||
* Created by mariotaku on 15/10/11.
|
||||
*/
|
||||
interface Response<Data> {
|
||||
interface Response<out Data> {
|
||||
val data: Data?
|
||||
|
||||
val exception: Exception?
|
||||
|
@ -38,11 +38,11 @@ data class SingleResponse<Data>(
|
||||
companion object {
|
||||
|
||||
fun <T> getInstance(): SingleResponse<T> {
|
||||
return SingleResponse<T>(null, null)
|
||||
return SingleResponse(null, null)
|
||||
}
|
||||
|
||||
fun <T> getInstance(exception: Exception): SingleResponse<T> {
|
||||
return SingleResponse<T>(null, exception)
|
||||
return SingleResponse(null, exception)
|
||||
}
|
||||
|
||||
fun <T> getInstance(data: T): SingleResponse<T> {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user