mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-02-02 17:56:56 +01:00
fixed video playback
added keep screen on while playing video
This commit is contained in:
parent
8910b80338
commit
27a1660336
@ -47,7 +47,7 @@ android {
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven { url 'https://repo.commonsware.com.s3.amazonaws.com' }
|
||||
maven { url 'https://s3.amazonaws.com/repo.commonsware.com' }
|
||||
}
|
||||
|
||||
configurations {
|
||||
|
@ -27,6 +27,8 @@ import android.support.annotation.NonNull;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.squareup.otto.Bus;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.activity.iface.IControlBarActivity;
|
||||
@ -59,6 +61,8 @@ public class BaseAppCompatActivity extends ThemedAppCompatActivity implements Co
|
||||
protected AsyncTwitterWrapper mTwitterWrapper;
|
||||
@Inject
|
||||
protected ReadStateManager mReadStateManager;
|
||||
@Inject
|
||||
protected Bus mBus;
|
||||
|
||||
// Registered listeners
|
||||
private ArrayList<ControlBarOffsetListener> mControlBarOffsetListeners = new ArrayList<>();
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package org.mariotaku.twidere.activity.support;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.SearchManager;
|
||||
@ -62,7 +61,6 @@ import android.widget.FrameLayout.LayoutParams;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.meizu.flyme.reflect.StatusBarProxy;
|
||||
import com.squareup.otto.Bus;
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
@ -113,9 +111,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import edu.tsinghua.hotmobi.HotMobiLogger;
|
||||
import edu.tsinghua.hotmobi.model.SessionEvent;
|
||||
|
||||
import static org.mariotaku.twidere.util.CompareUtils.classEquals;
|
||||
import static org.mariotaku.twidere.util.Utils.cleanDatabasesByItemLimit;
|
||||
import static org.mariotaku.twidere.util.Utils.getDefaultAccountId;
|
||||
@ -435,9 +430,7 @@ public class HomeActivity extends BaseAppCompatActivity implements OnClickListen
|
||||
sendBroadcast(new Intent(BROADCAST_HOME_ACTIVITY_ONSTART));
|
||||
final ContentResolver resolver = getContentResolver();
|
||||
resolver.registerContentObserver(Accounts.CONTENT_URI, true, mAccountChangeObserver);
|
||||
final Bus bus = TwidereApplication.getInstance(this).getMessageBus();
|
||||
assert bus != null;
|
||||
bus.register(this);
|
||||
mBus.register(this);
|
||||
|
||||
mReadStateManager.registerOnSharedPreferenceChangeListener(mReadStateChangeListener);
|
||||
updateUnreadCount();
|
||||
@ -463,9 +456,7 @@ public class HomeActivity extends BaseAppCompatActivity implements OnClickListen
|
||||
protected void onStop() {
|
||||
mMultiSelectHandler.dispatchOnStop();
|
||||
mReadStateManager.unregisterOnSharedPreferenceChangeListener(mReadStateChangeListener);
|
||||
final Bus bus = TwidereApplication.getInstance(this).getMessageBus();
|
||||
assert bus != null;
|
||||
bus.unregister(this);
|
||||
mBus.unregister(this);
|
||||
final ContentResolver resolver = getContentResolver();
|
||||
resolver.unregisterContentObserver(mAccountChangeObserver);
|
||||
mPreferences.edit().putInt(KEY_SAVED_TAB_POSITION, mViewPager.getCurrentItem()).apply();
|
||||
|
@ -52,7 +52,6 @@ import android.webkit.MimeTypeMap;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.MediaController;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.davemorrissey.labs.subscaleview.ImageSource;
|
||||
@ -584,7 +583,7 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
||||
|
||||
private TextureVideoView mVideoView;
|
||||
private View mVideoViewOverlay;
|
||||
private SeekBar mVideoViewProgress;
|
||||
private ProgressBar mVideoViewProgress;
|
||||
private TextView mDurationLabel, mPositionLabel;
|
||||
private ImageButton mPlayPauseButton, mVolumeButton;
|
||||
private ProgressWheel mProgressBar;
|
||||
@ -596,16 +595,17 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
||||
private File mVideoFile;
|
||||
private Pair<String, String> mVideoUrlAndType;
|
||||
private MediaPlayer mMediaPlayer;
|
||||
private int mMediaPlayerError;
|
||||
|
||||
public boolean isLoopEnabled() {
|
||||
return getArguments().getBoolean(EXTRA_LOOP, false);
|
||||
}
|
||||
|
||||
public void loadVideo() {
|
||||
public void loadVideo(boolean forceReload) {
|
||||
Pair<String, String> urlAndType = getBestVideoUrlAndType(getMedia());
|
||||
if (urlAndType == null) return;
|
||||
mVideoUrlAndType = urlAndType;
|
||||
mVideoLoader.loadVideo(urlAndType.first, this);
|
||||
mVideoLoader.loadVideo(urlAndType.first, forceReload, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -630,6 +630,8 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
||||
mMediaPlayer = null;
|
||||
mVideoViewProgress.removeCallbacks(mVideoProgressRunnable);
|
||||
mVideoViewProgress.setVisibility(View.GONE);
|
||||
mMediaPlayerError = what;
|
||||
invalidateOptionsMenu();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -637,7 +639,9 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
||||
public void onPrepared(MediaPlayer mp) {
|
||||
if (getUserVisibleHint()) {
|
||||
mMediaPlayer = mp;
|
||||
mMediaPlayerError = 0;
|
||||
mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
|
||||
mp.setScreenOnWhilePlaying(true);
|
||||
updateVolume();
|
||||
mp.setLooping(isLoopEnabled());
|
||||
mp.start();
|
||||
@ -645,6 +649,7 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
||||
mVideoViewProgress.post(mVideoProgressRunnable);
|
||||
updatePlayerState();
|
||||
mVideoControl.setVisibility(View.VISIBLE);
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
}
|
||||
|
||||
@ -674,7 +679,7 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
||||
super.onBaseViewCreated(view, savedInstanceState);
|
||||
mVideoView = (TextureVideoView) view.findViewById(R.id.video_view);
|
||||
mVideoViewOverlay = view.findViewById(R.id.video_view_overlay);
|
||||
mVideoViewProgress = (SeekBar) view.findViewById(R.id.video_view_progress);
|
||||
mVideoViewProgress = (ProgressBar) view.findViewById(R.id.video_view_progress);
|
||||
mProgressBar = (ProgressWheel) view.findViewById(R.id.load_progress);
|
||||
mDurationLabel = (TextView) view.findViewById(R.id.duration_label);
|
||||
mPositionLabel = (TextView) view.findViewById(R.id.position_label);
|
||||
@ -746,7 +751,7 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
||||
|
||||
mPlayPauseButton.setOnClickListener(this);
|
||||
mVolumeButton.setOnClickListener(this);
|
||||
loadVideo();
|
||||
loadVideo(false);
|
||||
updateVolume();
|
||||
}
|
||||
|
||||
@ -879,7 +884,7 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
||||
final File file = mVideoFile;
|
||||
final Pair<String, String> linkAndType = mVideoUrlAndType;
|
||||
final boolean isLoading = linkAndType != null && mVideoLoader.isLoading(linkAndType.first);
|
||||
final boolean hasVideo = file != null && file.exists() && linkAndType != null;
|
||||
final boolean hasVideo = file != null && file.exists() && linkAndType != null && mMediaPlayerError == 0;
|
||||
MenuUtils.setMenuItemAvailability(menu, R.id.refresh, !hasVideo && !isLoading);
|
||||
MenuUtils.setMenuItemAvailability(menu, R.id.share, hasVideo && !isLoading);
|
||||
MenuUtils.setMenuItemAvailability(menu, R.id.save, hasVideo && !isLoading);
|
||||
@ -913,7 +918,7 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
||||
return true;
|
||||
}
|
||||
case R.id.refresh: {
|
||||
loadVideo();
|
||||
loadVideo(true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -309,6 +309,7 @@ public abstract class AbsActivitiesAdapter<Data> extends LoadMoreSupportAdapter<
|
||||
case Activity.ACTION_RETWEETED_RETWEET:
|
||||
case Activity.ACTION_RETWEETED_MENTION:
|
||||
case Activity.ACTION_FAVORITED_MENTION:
|
||||
case Activity.ACTION_LIST_CREATED:
|
||||
case Activity.ACTION_LIST_MEMBER_ADDED: {
|
||||
return ITEM_VIEW_TYPE_TITLE_SUMMARY;
|
||||
}
|
||||
|
@ -82,11 +82,7 @@ public class ParcelableActivitiesAdapter extends AbsActivitiesAdapter<List<Parce
|
||||
|
||||
@Override
|
||||
protected void bindTitleSummaryViewHolder(ActivityTitleSummaryViewHolder holder, int position) {
|
||||
if (mIsByFriends) {
|
||||
holder.displayActivitiesByFriends(getActivity(position));
|
||||
} else {
|
||||
holder.displayActivityAboutMe(getActivity(position));
|
||||
}
|
||||
holder.displayActivity(getActivity(position), mIsByFriends);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -31,13 +31,11 @@ import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.multidex.MultiDexApplication;
|
||||
|
||||
import com.nostra13.universalimageloader.cache.disc.DiskCache;
|
||||
import com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache;
|
||||
import com.squareup.okhttp.internal.Network;
|
||||
import com.squareup.otto.Bus;
|
||||
|
||||
import org.acra.annotation.ReportsCrashes;
|
||||
import org.mariotaku.twidere.BuildConfig;
|
||||
@ -87,7 +85,6 @@ public class TwidereApplication extends MultiDexApplication implements Constants
|
||||
private SQLiteOpenHelper mSQLiteOpenHelper;
|
||||
private Network mNetwork;
|
||||
private SQLiteDatabase mDatabase;
|
||||
private Bus mMessageBus;
|
||||
private KeyboardShortcutsHandler mKeyboardShortcutsHandler;
|
||||
private UserColorNameManager mUserColorNameManager;
|
||||
|
||||
@ -134,11 +131,6 @@ public class TwidereApplication extends MultiDexApplication implements Constants
|
||||
return mKeyboardShortcutsHandler;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Bus getMessageBus() {
|
||||
return mMessageBus;
|
||||
}
|
||||
|
||||
public MultiSelectManager getMultiSelectManager() {
|
||||
if (mMultiSelectManager != null) return mMultiSelectManager;
|
||||
return mMultiSelectManager = new MultiSelectManager();
|
||||
@ -164,7 +156,6 @@ public class TwidereApplication extends MultiDexApplication implements Constants
|
||||
initDebugMode();
|
||||
initBugReport();
|
||||
mHandler = new Handler();
|
||||
mMessageBus = new Bus();
|
||||
initializeAsyncTask();
|
||||
initAccountColor(this);
|
||||
|
||||
|
@ -32,12 +32,9 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.squareup.otto.Bus;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.adapter.AbsActivitiesAdapter;
|
||||
import org.mariotaku.twidere.adapter.AbsActivitiesAdapter.ActivityAdapterListener;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.fragment.iface.RefreshScrollTopInterface;
|
||||
import org.mariotaku.twidere.model.ParcelableActivity;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
@ -119,16 +116,12 @@ public abstract class AbsActivitiesFragment<Data> extends AbsContentRecyclerView
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
final Bus bus = TwidereApplication.getInstance(getActivity()).getMessageBus();
|
||||
assert bus != null;
|
||||
bus.register(mStatusesBusCallback);
|
||||
mBus.register(mStatusesBusCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
final Bus bus = TwidereApplication.getInstance(getActivity()).getMessageBus();
|
||||
assert bus != null;
|
||||
bus.unregister(mStatusesBusCallback);
|
||||
mBus.unregister(mStatusesBusCallback);
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
|
@ -23,20 +23,17 @@ import android.view.View;
|
||||
|
||||
import com.desmond.asyncmanager.AsyncManager;
|
||||
import com.desmond.asyncmanager.TaskRunnable;
|
||||
import com.squareup.otto.Bus;
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.adapter.AbsStatusesAdapter;
|
||||
import org.mariotaku.twidere.adapter.AbsStatusesAdapter.StatusAdapterListener;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.loader.iface.IExtendedLoader;
|
||||
import org.mariotaku.twidere.model.ParcelableMedia;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler;
|
||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler.KeyboardShortcutCallback;
|
||||
import org.mariotaku.twidere.util.ReadStateManager;
|
||||
import org.mariotaku.twidere.util.RecyclerViewNavigationHelper;
|
||||
import org.mariotaku.twidere.util.RecyclerViewUtils;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
@ -425,16 +422,12 @@ public abstract class AbsStatusesFragment<Data> extends AbsContentRecyclerViewFr
|
||||
};
|
||||
task.setResultHandler(recyclerView);
|
||||
AsyncManager.runBackgroundTask(task);
|
||||
final Bus bus = TwidereApplication.getInstance(getActivity()).getMessageBus();
|
||||
assert bus != null;
|
||||
bus.register(mStatusesBusCallback);
|
||||
mBus.register(mStatusesBusCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
final Bus bus = TwidereApplication.getInstance(getActivity()).getMessageBus();
|
||||
assert bus != null;
|
||||
bus.unregister(mStatusesBusCallback);
|
||||
mBus.unregister(mStatusesBusCallback);
|
||||
final RecyclerView recyclerView = getRecyclerView();
|
||||
if (mActiveHotMobiScrollTracker != null) {
|
||||
recyclerView.removeOnScrollListener(mActiveHotMobiScrollTracker);
|
||||
|
@ -36,6 +36,8 @@ import android.support.v4.view.LayoutInflaterFactory;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
import com.squareup.otto.Bus;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.activity.iface.IThemedActivity;
|
||||
import org.mariotaku.twidere.activity.support.BaseAppCompatActivity;
|
||||
@ -62,6 +64,8 @@ public class BaseSupportFragment extends Fragment implements IBaseFragment, Cons
|
||||
protected MediaLoaderWrapper mMediaLoader;
|
||||
@Inject
|
||||
protected VideoLoader mVideoLoader;
|
||||
@Inject
|
||||
protected Bus mBus;
|
||||
|
||||
public BaseSupportFragment() {
|
||||
|
||||
|
@ -39,7 +39,6 @@ import android.view.KeyEvent;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
||||
import com.squareup.otto.Bus;
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.mariotaku.sqliteqb.library.Columns.Column;
|
||||
@ -52,7 +51,6 @@ import org.mariotaku.twidere.adapter.MessageEntriesAdapter;
|
||||
import org.mariotaku.twidere.adapter.MessageEntriesAdapter.DirectMessageEntry;
|
||||
import org.mariotaku.twidere.adapter.MessageEntriesAdapter.MessageEntriesAdapterListener;
|
||||
import org.mariotaku.twidere.adapter.decorator.DividerItemDecoration;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Accounts;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.DirectMessages;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.DirectMessages.Inbox;
|
||||
@ -274,8 +272,7 @@ public class DirectMessagesFragment extends AbsContentRecyclerViewFragment<Messa
|
||||
super.onStart();
|
||||
final ContentResolver resolver = getContentResolver();
|
||||
resolver.registerContentObserver(Accounts.CONTENT_URI, true, mReloadContentObserver);
|
||||
final Bus bus = TwidereApplication.getInstance(getActivity()).getMessageBus();
|
||||
bus.register(this);
|
||||
mBus.register(this);
|
||||
final MessageEntriesAdapter adapter = getAdapter();
|
||||
adapter.updateReadState();
|
||||
updateRefreshState();
|
||||
@ -283,8 +280,7 @@ public class DirectMessagesFragment extends AbsContentRecyclerViewFragment<Messa
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
final Bus bus = TwidereApplication.getInstance(getActivity()).getMessageBus();
|
||||
bus.unregister(this);
|
||||
mBus.unregister(this);
|
||||
final ContentResolver resolver = getContentResolver();
|
||||
resolver.unregisterContentObserver(mReloadContentObserver);
|
||||
super.onStop();
|
||||
|
@ -68,7 +68,6 @@ import android.widget.TextView;
|
||||
import com.github.johnpersano.supertoasts.SuperToast;
|
||||
import com.github.johnpersano.supertoasts.SuperToast.Duration;
|
||||
import com.github.johnpersano.supertoasts.SuperToast.OnDismissListener;
|
||||
import com.squareup.otto.Bus;
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.mariotaku.sqliteqb.library.Columns.Column;
|
||||
@ -82,7 +81,6 @@ import org.mariotaku.twidere.adapter.AccountsSpinnerAdapter;
|
||||
import org.mariotaku.twidere.adapter.MessageConversationAdapter;
|
||||
import org.mariotaku.twidere.adapter.SimpleParcelableUsersAdapter;
|
||||
import org.mariotaku.twidere.adapter.iface.IBaseCardAdapter.MenuButtonClickListener;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.constant.SharedPreferenceConstants;
|
||||
import org.mariotaku.twidere.loader.support.UserSearchLoader;
|
||||
import org.mariotaku.twidere.model.ParcelableAccount;
|
||||
@ -103,7 +101,6 @@ import org.mariotaku.twidere.util.EditTextEnterHandler.EnterListener;
|
||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler;
|
||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler.KeyboardShortcutCallback;
|
||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler.TakeAllKeyboardShortcut;
|
||||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.MenuUtils;
|
||||
import org.mariotaku.twidere.util.ParseUtils;
|
||||
import org.mariotaku.twidere.util.ReadStateManager;
|
||||
@ -353,9 +350,7 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
final Bus bus = TwidereApplication.getInstance(getActivity()).getMessageBus();
|
||||
assert bus != null;
|
||||
bus.register(this);
|
||||
mBus.register(this);
|
||||
updateEmptyText();
|
||||
mMessagesListView.addOnScrollListener(mScrollListener);
|
||||
mScrollListener.reset();
|
||||
@ -381,9 +376,7 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
||||
@Override
|
||||
public void onStop() {
|
||||
mMessagesListView.removeOnScrollListener(mScrollListener);
|
||||
final Bus bus = TwidereApplication.getInstance(getActivity()).getMessageBus();
|
||||
assert bus != null;
|
||||
bus.unregister(this);
|
||||
mBus.unregister(this);
|
||||
if (mPopupMenu != null) {
|
||||
mPopupMenu.dismiss();
|
||||
}
|
||||
|
@ -23,11 +23,8 @@ import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.squareup.otto.Bus;
|
||||
|
||||
import org.mariotaku.twidere.adapter.ParcelableActivitiesAdapter;
|
||||
import org.mariotaku.twidere.adapter.iface.IActivitiesAdapter;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.model.ParcelableActivity;
|
||||
|
||||
import java.util.List;
|
||||
@ -50,14 +47,12 @@ public abstract class ParcelableActivitiesFragment extends AbsActivitiesFragment
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
final Bus bus = TwidereApplication.getInstance(getActivity()).getMessageBus();
|
||||
bus.register(this);
|
||||
mBus.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
final Bus bus = TwidereApplication.getInstance(getActivity()).getMessageBus();
|
||||
bus.unregister(this);
|
||||
mBus.unregister(this);
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
|
@ -24,12 +24,10 @@ import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
|
||||
import com.squareup.otto.Bus;
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.mariotaku.twidere.adapter.ParcelableStatusesAdapter;
|
||||
import org.mariotaku.twidere.adapter.iface.IStatusesAdapter;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
import org.mariotaku.twidere.util.message.FavoriteCreatedEvent;
|
||||
import org.mariotaku.twidere.util.message.FavoriteDestroyedEvent;
|
||||
@ -82,16 +80,12 @@ public abstract class ParcelableStatusesFragment extends AbsStatusesFragment<Lis
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
final Bus bus = TwidereApplication.getInstance(getActivity()).getMessageBus();
|
||||
assert bus != null;
|
||||
bus.register(this);
|
||||
mBus.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
final Bus bus = TwidereApplication.getInstance(getActivity()).getMessageBus();
|
||||
assert bus != null;
|
||||
bus.unregister(this);
|
||||
mBus.unregister(this);
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
|
@ -32,11 +32,9 @@ import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.squareup.otto.Bus;
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.mariotaku.twidere.adapter.TrendsAdapter;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.CachedTrends;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.MultiSelectManager;
|
||||
@ -123,16 +121,12 @@ public class TrendsSuggestionsFragment extends AbsContentListViewFragment<Trends
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
getLoaderManager().restartLoader(0, null, this);
|
||||
final Bus bus = TwidereApplication.getInstance(getActivity()).getMessageBus();
|
||||
assert bus != null;
|
||||
bus.register(this);
|
||||
mBus.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
final Bus bus = TwidereApplication.getInstance(getActivity()).getMessageBus();
|
||||
assert bus != null;
|
||||
bus.unregister(this);
|
||||
mBus.unregister(this);
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,6 @@ import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.meizu.flyme.reflect.StatusBarProxy;
|
||||
import com.squareup.otto.Bus;
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.mariotaku.sqliteqb.library.Expression;
|
||||
@ -798,9 +797,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
final Bus bus = TwidereApplication.getInstance(getActivity()).getMessageBus();
|
||||
assert bus != null;
|
||||
bus.register(this);
|
||||
mBus.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -811,9 +808,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
final Bus bus = TwidereApplication.getInstance(getActivity()).getMessageBus();
|
||||
assert bus != null;
|
||||
bus.unregister(this);
|
||||
mBus.unregister(this);
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
|
@ -546,7 +546,7 @@ public class UserProfileEditorFragment extends BaseSupportFragment implements On
|
||||
|
||||
public UpdateProfileImageTaskInternal(final Context context, final AsyncTaskManager manager,
|
||||
final long account_id, final Uri image_uri, final boolean delete_image) {
|
||||
super(context, manager, account_id, image_uri, delete_image);
|
||||
super(context, account_id, image_uri, delete_image);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -157,6 +157,8 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
|
||||
private ImagePreloader mImagePreloader;
|
||||
@Inject
|
||||
Network mNetwork;
|
||||
@Inject
|
||||
Bus mBus;
|
||||
private Handler mHandler;
|
||||
|
||||
private boolean mHomeActivityInBackground;
|
||||
@ -1008,15 +1010,12 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
|
||||
|
||||
private void notifyUnreadCountChanged(final int position) {
|
||||
final Context context = getContext();
|
||||
final Bus bus = TwidereApplication.getInstance(context).getMessageBus();
|
||||
if (bus != null) {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
bus.post(new UnreadCountUpdatedEvent(position));
|
||||
}
|
||||
});
|
||||
}
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mBus.post(new UnreadCountUpdatedEvent(position));
|
||||
}
|
||||
});
|
||||
notifyContentObserver(UnreadCounts.CONTENT_URI);
|
||||
}
|
||||
|
||||
|
@ -25,23 +25,33 @@ import android.os.AsyncTask;
|
||||
import com.squareup.otto.Bus;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.util.AsyncTaskManager;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.util.dagger.DaggerGeneralComponent;
|
||||
import org.mariotaku.twidere.util.message.TaskStateChangedEvent;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public abstract class ManagedAsyncTask<Params, Progress, Result> extends AsyncTask<Params, Progress, Result> implements
|
||||
Constants {
|
||||
|
||||
private final AsyncTaskManager manager;
|
||||
@Inject
|
||||
protected AsyncTaskManager manager;
|
||||
@Inject
|
||||
protected Bus bus;
|
||||
private final Context context;
|
||||
private final String tag;
|
||||
|
||||
public ManagedAsyncTask(final Context context, final AsyncTaskManager manager) {
|
||||
this(context, manager, null);
|
||||
public ManagedAsyncTask(final Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public ManagedAsyncTask(final Context context, final AsyncTaskManager manager, final String tag) {
|
||||
this.manager = manager;
|
||||
public ManagedAsyncTask(final Context context, final String tag) {
|
||||
//noinspection unchecked
|
||||
DaggerGeneralComponent.builder()
|
||||
.applicationModule(ApplicationModule.get(context))
|
||||
.build()
|
||||
.inject((ManagedAsyncTask<Object, Object, Object>) this);
|
||||
this.context = context;
|
||||
this.tag = tag;
|
||||
}
|
||||
@ -63,21 +73,18 @@ public abstract class ManagedAsyncTask<Params, Progress, Result> extends AsyncTa
|
||||
@Override
|
||||
protected void onCancelled() {
|
||||
super.onCancelled();
|
||||
final Bus bus = TwidereApplication.getInstance(context).getMessageBus();
|
||||
bus.post(new TaskStateChangedEvent());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final Result result) {
|
||||
super.onPostExecute(result);
|
||||
final Bus bus = TwidereApplication.getInstance(context).getMessageBus();
|
||||
bus.post(new TaskStateChangedEvent());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
final Bus bus = TwidereApplication.getInstance(context).getMessageBus();
|
||||
bus.post(new TaskStateChangedEvent());
|
||||
}
|
||||
|
||||
|
@ -117,6 +117,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final AsyncTaskManager mAsyncTaskManager;
|
||||
private final SharedPreferencesWrapper mPreferences;
|
||||
private final ContentResolver mResolver;
|
||||
private final Bus mBus;
|
||||
|
||||
private int mGetHomeTimelineTaskId, mGetMentionsTaskId;
|
||||
private int mGetReceivedDirectMessagesTaskId, mGetSentDirectMessagesTaskId;
|
||||
@ -129,12 +130,13 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
private CopyOnWriteArraySet<Long> mSendingDraftIds = new CopyOnWriteArraySet<>();
|
||||
|
||||
public AsyncTwitterWrapper(final Context context, final AsyncTaskManager manager) {
|
||||
public AsyncTwitterWrapper(final Context context, final AsyncTaskManager manager, Bus bus) {
|
||||
mContext = context;
|
||||
mAsyncTaskManager = manager;
|
||||
mPreferences = SharedPreferencesWrapper.getInstance(context, SHARED_PREFERENCES_NAME,
|
||||
Context.MODE_PRIVATE, SharedPreferenceConstants.class);
|
||||
mResolver = context.getContentResolver();
|
||||
mBus = bus;
|
||||
}
|
||||
|
||||
public int acceptFriendshipAsync(final long accountId, final long userId) {
|
||||
@ -507,7 +509,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
public BackgroundTask updateFriendship(final long accountId, final long userId, final FriendshipUpdate update) {
|
||||
final Bus bus = TwidereApplication.getInstance(mContext).getMessageBus();
|
||||
final Bus bus = mBus;
|
||||
if (bus == null) return null;
|
||||
return AsyncManager.runBackgroundTask(new TaskRunnable<Object, SingleResponse<Relationship>, Bus>() {
|
||||
@Override
|
||||
@ -538,7 +540,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final Context mContext;
|
||||
|
||||
GetSavedSearchesTask(AsyncTwitterWrapper twitter) {
|
||||
super(twitter.getContext(), twitter.getTaskManager());
|
||||
super(twitter.getContext());
|
||||
this.mContext = twitter.getContext();
|
||||
}
|
||||
|
||||
@ -571,7 +573,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
public UpdateProfileBannerImageTask(final Context context, final AsyncTaskManager manager,
|
||||
final long account_id, final Uri image_uri, final boolean delete_image) {
|
||||
super(context, manager);
|
||||
super(context);
|
||||
mContext = context;
|
||||
mAccountId = account_id;
|
||||
mImageUri = image_uri;
|
||||
@ -583,8 +585,8 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
super.onPostExecute(result);
|
||||
if (result.hasData()) {
|
||||
Utils.showOkMessage(mContext, R.string.profile_banner_image_updated, false);
|
||||
final Bus bus = TwidereApplication.getInstance(mContext).getMessageBus();
|
||||
assert bus != null;
|
||||
|
||||
|
||||
bus.post(new ProfileUpdatedEvent(result.getData()));
|
||||
} else {
|
||||
Utils.showErrorMessage(mContext, R.string.action_updating_profile_banner_image, result.getException(),
|
||||
@ -621,9 +623,9 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final boolean mDeleteImage;
|
||||
private final Context mContext;
|
||||
|
||||
public UpdateProfileImageTask(final Context context, final AsyncTaskManager manager, final long account_id,
|
||||
public UpdateProfileImageTask(final Context context, final long account_id,
|
||||
final Uri image_uri, final boolean delete_image) {
|
||||
super(context, manager);
|
||||
super(context);
|
||||
this.mContext = context;
|
||||
this.mAccountId = account_id;
|
||||
this.mImageUri = image_uri;
|
||||
@ -654,8 +656,6 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
super.onPostExecute(result);
|
||||
if (result.hasData()) {
|
||||
Utils.showOkMessage(mContext, R.string.profile_image_updated, false);
|
||||
final Bus bus = TwidereApplication.getInstance(mContext).getMessageBus();
|
||||
assert bus != null;
|
||||
bus.post(new ProfileUpdatedEvent(result.getData()));
|
||||
} else {
|
||||
Utils.showErrorMessage(mContext, R.string.action_updating_profile_image, result.getException(), true);
|
||||
@ -670,7 +670,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final long mUserId;
|
||||
|
||||
public AcceptFriendshipTask(final long account_id, final long user_id) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
super(mContext);
|
||||
mAccountId = account_id;
|
||||
mUserId = user_id;
|
||||
}
|
||||
@ -725,7 +725,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final ParcelableUser[] users;
|
||||
|
||||
public AddUserListMembersTask(final long accountId, final long listId, final ParcelableUser[] users) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
super(mContext);
|
||||
this.accountId = accountId;
|
||||
this.listId = listId;
|
||||
this.users = users;
|
||||
@ -813,7 +813,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final long account_id, user_id;
|
||||
|
||||
public CreateBlockTask(final long account_id, final long user_id) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
super(mContext);
|
||||
this.account_id = account_id;
|
||||
this.user_id = user_id;
|
||||
}
|
||||
@ -852,8 +852,8 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
final String message = mContext.getString(R.string.blocked_user,
|
||||
manager.getDisplayName(result.getData(), nameFirst, true));
|
||||
Utils.showInfoMessage(mContext, message, false);
|
||||
final Bus bus = application.getMessageBus();
|
||||
assert bus != null;
|
||||
|
||||
|
||||
bus.post(new FriendshipUserUpdatedEvent(result.getData()));
|
||||
} else {
|
||||
Utils.showErrorMessage(mContext, R.string.action_blocking, result.getException(), true);
|
||||
@ -868,7 +868,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final long account_id, status_id;
|
||||
|
||||
public CreateFavoriteTask(final long account_id, final long status_id) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
super(mContext);
|
||||
this.account_id = account_id;
|
||||
this.status_id = status_id;
|
||||
}
|
||||
@ -905,8 +905,8 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
mCreatingFavoriteIds.put(account_id, status_id);
|
||||
final Bus bus = TwidereApplication.getInstance(mContext).getMessageBus();
|
||||
assert bus != null;
|
||||
|
||||
|
||||
bus.post(new StatusListChangedEvent());
|
||||
}
|
||||
|
||||
@ -924,8 +924,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
// END HotMobi
|
||||
|
||||
final Bus bus = TwidereApplication.getInstance(mContext).getMessageBus();
|
||||
assert bus != null;
|
||||
|
||||
bus.post(new FavoriteCreatedEvent(status));
|
||||
Utils.showOkMessage(mContext, R.string.status_favorited, false);
|
||||
} else {
|
||||
@ -942,7 +941,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final long user_id;
|
||||
|
||||
public CreateFriendshipTask(final long accountId, final long user_id) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
super(mContext);
|
||||
this.mAccountId = accountId;
|
||||
this.user_id = user_id;
|
||||
}
|
||||
@ -985,8 +984,8 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
manager.getDisplayName(user, nameFirst, true));
|
||||
}
|
||||
Utils.showOkMessage(mContext, message, false);
|
||||
final Bus bus = application.getMessageBus();
|
||||
assert bus != null;
|
||||
|
||||
|
||||
bus.post(new FriendshipUserUpdatedEvent(result.getData()));
|
||||
} else {
|
||||
Utils.showErrorMessage(mContext, R.string.action_following, result.getException(), false);
|
||||
@ -1002,7 +1001,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final long[] user_ids;
|
||||
|
||||
public CreateMultiBlockTask(final long account_id, final long[] user_ids) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
super(mContext);
|
||||
this.account_id = account_id;
|
||||
this.user_ids = user_ids;
|
||||
}
|
||||
@ -1059,7 +1058,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final long mAccountId, mUserId;
|
||||
|
||||
public CreateMuteTask(final long accountId, final long userId) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
super(mContext);
|
||||
this.mAccountId = accountId;
|
||||
this.mUserId = userId;
|
||||
}
|
||||
@ -1090,8 +1089,8 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
final String message = mContext.getString(R.string.muted_user,
|
||||
manager.getDisplayName(result.getData(), nameFirst, true));
|
||||
Utils.showInfoMessage(mContext, message, false);
|
||||
final Bus bus = application.getMessageBus();
|
||||
assert bus != null;
|
||||
|
||||
|
||||
bus.post(new FriendshipUserUpdatedEvent(result.getData()));
|
||||
} else {
|
||||
Utils.showErrorMessage(mContext, R.string.action_muting, result.getException(), true);
|
||||
@ -1107,7 +1106,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final String mQuery;
|
||||
|
||||
CreateSavedSearchTask(final long accountId, final String query) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
super(mContext);
|
||||
mAccountId = accountId;
|
||||
mQuery = query;
|
||||
}
|
||||
@ -1142,7 +1141,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final long listId;
|
||||
|
||||
public CreateUserListSubscriptionTask(final long accountId, final long listId) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
super(mContext);
|
||||
this.accountId = accountId;
|
||||
this.listId = listId;
|
||||
}
|
||||
@ -1186,7 +1185,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
public CreateUserListTask(final long account_id, final String list_name, final boolean is_public,
|
||||
final String description) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
super(mContext);
|
||||
this.account_id = account_id;
|
||||
this.list_name = list_name;
|
||||
this.description = description;
|
||||
@ -1233,7 +1232,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final ParcelableUser[] users;
|
||||
|
||||
public DeleteUserListMembersTask(final long accountId, final long userListId, final ParcelableUser[] users) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
super(mContext);
|
||||
mAccountId = accountId;
|
||||
mUserListId = userListId;
|
||||
this.users = users;
|
||||
@ -1292,7 +1291,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final long mUserId;
|
||||
|
||||
public DenyFriendshipTask(final long account_id, final long user_id) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
super(mContext);
|
||||
mAccountId = account_id;
|
||||
mUserId = user_id;
|
||||
}
|
||||
@ -1345,7 +1344,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final long mUserId;
|
||||
|
||||
public DestroyBlockTask(final long accountId, final long userId) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
super(mContext);
|
||||
mAccountId = accountId;
|
||||
mUserId = userId;
|
||||
}
|
||||
@ -1373,8 +1372,8 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
final String message = mContext.getString(R.string.unblocked_user,
|
||||
manager.getDisplayName(result.getData(), nameFirst, true));
|
||||
Utils.showInfoMessage(mContext, message, false);
|
||||
final Bus bus = application.getMessageBus();
|
||||
assert bus != null;
|
||||
|
||||
|
||||
bus.post(new FriendshipUserUpdatedEvent(result.getData()));
|
||||
} else {
|
||||
Utils.showErrorMessage(mContext, R.string.action_unblocking, result.getException(), true);
|
||||
@ -1390,7 +1389,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final long account_id;
|
||||
|
||||
public DestroyDirectMessageTask(final long account_id, final long message_id) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
super(mContext);
|
||||
|
||||
this.account_id = account_id;
|
||||
this.message_id = message_id;
|
||||
@ -1447,7 +1446,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final long accountId;
|
||||
|
||||
public DestroyMessageConversationTask(final long accountId, final long userId) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
super(mContext);
|
||||
|
||||
this.accountId = accountId;
|
||||
this.userId = userId;
|
||||
@ -1506,7 +1505,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final long status_id;
|
||||
|
||||
public DestroyFavoriteTask(final long account_id, final long status_id) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
super(mContext);
|
||||
this.account_id = account_id;
|
||||
this.status_id = status_id;
|
||||
}
|
||||
@ -1542,8 +1541,8 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
mDestroyingFavoriteIds.put(account_id, status_id);
|
||||
final Bus bus = TwidereApplication.getInstance(mContext).getMessageBus();
|
||||
assert bus != null;
|
||||
|
||||
|
||||
bus.post(new StatusListChangedEvent());
|
||||
}
|
||||
|
||||
@ -1559,9 +1558,6 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
HotMobiLogger.getInstance(getContext()).log(account_id, event);
|
||||
|
||||
// END HotMobi
|
||||
|
||||
final Bus bus = TwidereApplication.getInstance(mContext).getMessageBus();
|
||||
assert bus != null;
|
||||
bus.post(new FavoriteDestroyedEvent(status));
|
||||
Utils.showInfoMessage(mContext, R.string.status_unfavorited, false);
|
||||
} else {
|
||||
@ -1578,7 +1574,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final long user_id;
|
||||
|
||||
public DestroyFriendshipTask(final long accountId, final long user_id) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
super(mContext);
|
||||
mAccountId = accountId;
|
||||
this.user_id = user_id;
|
||||
}
|
||||
@ -1621,8 +1617,6 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
final String message = mContext.getString(R.string.unfollowed_user,
|
||||
manager.getDisplayName(result.getData(), nameFirst, true));
|
||||
Utils.showInfoMessage(mContext, message, false);
|
||||
final Bus bus = application.getMessageBus();
|
||||
assert bus != null;
|
||||
bus.post(new FriendshipUserUpdatedEvent(result.getData()));
|
||||
} else {
|
||||
Utils.showErrorMessage(mContext, R.string.action_unfollowing, result.getException(), true);
|
||||
@ -1638,7 +1632,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final long mUserId;
|
||||
|
||||
public DestroyMuteTask(final long accountId, final long userId) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
super(mContext);
|
||||
mAccountId = accountId;
|
||||
mUserId = userId;
|
||||
}
|
||||
@ -1666,8 +1660,8 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
final String message = mContext.getString(R.string.unmuted_user,
|
||||
manager.getDisplayName(result.getData(), nameFirst, true));
|
||||
Utils.showInfoMessage(mContext, message, false);
|
||||
final Bus bus = application.getMessageBus();
|
||||
assert bus != null;
|
||||
|
||||
|
||||
bus.post(new FriendshipUserUpdatedEvent(result.getData()));
|
||||
} else {
|
||||
Utils.showErrorMessage(mContext, R.string.action_unmuting, result.getException(), true);
|
||||
@ -1683,7 +1677,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final int mSearchId;
|
||||
|
||||
DestroySavedSearchTask(final long accountId, final int searchId) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
super(mContext);
|
||||
mAccountId = accountId;
|
||||
mSearchId = searchId;
|
||||
}
|
||||
@ -1719,7 +1713,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final long status_id;
|
||||
|
||||
public DestroyStatusTask(final long account_id, final long status_id) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
super(mContext);
|
||||
this.account_id = account_id;
|
||||
this.status_id = status_id;
|
||||
}
|
||||
@ -1750,8 +1744,6 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
mDestroyingStatusIds.put(account_id, status_id);
|
||||
final Bus bus = TwidereApplication.getInstance(mContext).getMessageBus();
|
||||
assert bus != null;
|
||||
bus.post(new StatusListChangedEvent());
|
||||
}
|
||||
|
||||
@ -1765,8 +1757,6 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
} else {
|
||||
Utils.showInfoMessage(mContext, R.string.status_deleted, false);
|
||||
}
|
||||
final Bus bus = TwidereApplication.getInstance(mContext).getMessageBus();
|
||||
assert bus != null;
|
||||
bus.post(new StatusDestroyedEvent(status));
|
||||
} else {
|
||||
Utils.showErrorMessage(mContext, R.string.action_deleting, result.getException(), true);
|
||||
@ -1782,7 +1772,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final long mListId;
|
||||
|
||||
public DestroyUserListSubscriptionTask(final long accountId, final long listId) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
super(mContext);
|
||||
mAccountId = accountId;
|
||||
mListId = listId;
|
||||
}
|
||||
@ -1826,7 +1816,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final long mListId;
|
||||
|
||||
public DestroyUserListTask(final long accountId, final long listId) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
super(mContext);
|
||||
mAccountId = accountId;
|
||||
mListId = listId;
|
||||
}
|
||||
@ -1872,7 +1862,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
public GetDirectMessagesTask(final long[] account_ids, final long[] max_ids, final long[] since_ids,
|
||||
final String tag) {
|
||||
super(mContext, mAsyncTaskManager, tag);
|
||||
super(mContext, tag);
|
||||
this.account_ids = account_ids;
|
||||
this.max_ids = max_ids;
|
||||
this.since_ids = since_ids;
|
||||
@ -1962,16 +1952,12 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
final Bus bus = TwidereApplication.getInstance(getContext()).getMessageBus();
|
||||
assert bus != null;
|
||||
bus.post(new GetMessagesTaskEvent(getDatabaseUri(), true, null));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final List<MessageListResponse> result) {
|
||||
super.onPostExecute(result);
|
||||
final Bus bus = TwidereApplication.getInstance(getContext()).getMessageBus();
|
||||
assert bus != null;
|
||||
bus.post(new GetMessagesTaskEvent(getDatabaseUri(), false, getException(result)));
|
||||
}
|
||||
|
||||
@ -2155,7 +2141,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final long[] mAccountIds, mMaxIds, mSinceIds;
|
||||
|
||||
public GetStatusesTask(final long[] account_ids, final long[] max_ids, final long[] since_ids, final String tag) {
|
||||
super(mContext, mAsyncTaskManager, tag);
|
||||
super(mContext, tag);
|
||||
mAccountIds = account_ids;
|
||||
mMaxIds = max_ids;
|
||||
mSinceIds = since_ids;
|
||||
@ -2240,16 +2226,12 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
@Override
|
||||
protected void onPostExecute(List<StatusListResponse> result) {
|
||||
super.onPostExecute(result);
|
||||
final Bus bus = TwidereApplication.getInstance(mContext).getMessageBus();
|
||||
assert bus != null;
|
||||
bus.post(new GetStatusesTaskEvent(getDatabaseUri(), false, getException(result)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
final Bus bus = TwidereApplication.getInstance(mContext).getMessageBus();
|
||||
assert bus != null;
|
||||
bus.post(new GetStatusesTaskEvent(getDatabaseUri(), true, null));
|
||||
}
|
||||
|
||||
@ -2299,7 +2281,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final long[] mAccountIds, mMaxIds, mSinceIds;
|
||||
|
||||
public GetActivitiesTask(final long[] account_ids, final long[] max_ids, final long[] since_ids, final String tag) {
|
||||
super(mContext, mAsyncTaskManager, tag);
|
||||
super(mContext, tag);
|
||||
mAccountIds = account_ids;
|
||||
mMaxIds = max_ids;
|
||||
mSinceIds = since_ids;
|
||||
@ -2379,16 +2361,16 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
@Override
|
||||
protected void onPostExecute(List<ActivityListResponse> result) {
|
||||
super.onPostExecute(result);
|
||||
final Bus bus = TwidereApplication.getInstance(mContext).getMessageBus();
|
||||
assert bus != null;
|
||||
|
||||
|
||||
bus.post(new GetStatusesTaskEvent(getDatabaseUri(), false, getException(result)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
final Bus bus = TwidereApplication.getInstance(mContext).getMessageBus();
|
||||
assert bus != null;
|
||||
|
||||
|
||||
bus.post(new GetStatusesTaskEvent(getDatabaseUri(), true, null));
|
||||
}
|
||||
|
||||
@ -2444,7 +2426,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final long account_id;
|
||||
|
||||
public GetTrendsTask(final long account_id) {
|
||||
super(mContext, mAsyncTaskManager, TASK_TAG_GET_TRENDS);
|
||||
super(mContext, TASK_TAG_GET_TRENDS);
|
||||
this.account_id = account_id;
|
||||
}
|
||||
|
||||
@ -2489,7 +2471,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final long[] user_ids;
|
||||
|
||||
public ReportMultiSpamTask(final long account_id, final long[] user_ids) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
super(mContext);
|
||||
this.account_id = account_id;
|
||||
this.user_ids = user_ids;
|
||||
}
|
||||
@ -2543,7 +2525,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final long user_id;
|
||||
|
||||
public ReportSpamTask(final long accountId, final long user_id) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
super(mContext);
|
||||
this.mAccountId = accountId;
|
||||
this.user_id = user_id;
|
||||
}
|
||||
@ -2571,8 +2553,8 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
mResolver.delete(uri, where, null);
|
||||
}
|
||||
Utils.showInfoMessage(mContext, R.string.reported_user_for_spam, false);
|
||||
final Bus bus = TwidereApplication.getInstance(mContext).getMessageBus();
|
||||
assert bus != null;
|
||||
|
||||
|
||||
bus.post(new FriendshipUserUpdatedEvent(result.getData()));
|
||||
} else {
|
||||
Utils.showErrorMessage(mContext, R.string.action_reporting_for_spam, result.getException(), true);
|
||||
@ -2589,7 +2571,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final long status_id;
|
||||
|
||||
public RetweetStatusTask(final long account_id, final long status_id) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
super(mContext);
|
||||
this.account_id = account_id;
|
||||
this.status_id = status_id;
|
||||
}
|
||||
@ -2614,8 +2596,8 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
mCreatingRetweetIds.put(account_id, status_id);
|
||||
final Bus bus = TwidereApplication.getInstance(mContext).getMessageBus();
|
||||
assert bus != null;
|
||||
|
||||
|
||||
bus.post(new StatusListChangedEvent());
|
||||
}
|
||||
|
||||
@ -2642,8 +2624,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
// END HotMobi
|
||||
|
||||
final Bus bus = TwidereApplication.getInstance(mContext).getMessageBus();
|
||||
assert bus != null;
|
||||
|
||||
bus.post(new StatusRetweetedEvent(status));
|
||||
Utils.showOkMessage(mContext, R.string.status_retweeted, false);
|
||||
} else {
|
||||
@ -2669,7 +2650,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final Uri uri;
|
||||
|
||||
public StoreTrendsTask(final ListResponse<Trends> result, final Uri uri) {
|
||||
super(mContext, mAsyncTaskManager, TASK_TAG_STORE_TRENDS);
|
||||
super(mContext, TASK_TAG_STORE_TRENDS);
|
||||
response = result;
|
||||
this.uri = uri;
|
||||
}
|
||||
@ -2721,7 +2702,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
private final UserListUpdate update;
|
||||
|
||||
public UpdateUserListDetailsTask(final long accountId, final long listId, UserListUpdate update) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
super(mContext);
|
||||
this.accountId = accountId;
|
||||
this.listId = listId;
|
||||
this.update = update;
|
||||
|
@ -133,9 +133,13 @@ public class TwitterAPIFactory implements TwidereConstants {
|
||||
|
||||
}
|
||||
client.setSslSocketFactory(sslSocketFactory);
|
||||
} else {
|
||||
client.setSslSocketFactory(null);
|
||||
}
|
||||
if (enableProxy) {
|
||||
client.setProxy(getProxy(prefs));
|
||||
} else {
|
||||
client.setProxy(Proxy.NO_PROXY);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,9 +27,11 @@ import com.nostra13.universalimageloader.core.download.ImageDownloader;
|
||||
import com.nostra13.universalimageloader.utils.IoUtils;
|
||||
import com.squareup.otto.Bus;
|
||||
|
||||
import org.mariotaku.restfu.http.RestHttpClient;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.model.SingleResponse;
|
||||
import org.mariotaku.twidere.task.ManagedAsyncTask;
|
||||
import org.mariotaku.twidere.util.imageloader.TwidereImageDownloader;
|
||||
import org.mariotaku.twidere.util.message.VideoLoadFinishedEvent;
|
||||
|
||||
import java.io.File;
|
||||
@ -48,13 +50,13 @@ public class VideoLoader {
|
||||
private final AsyncTaskManager mTaskManager;
|
||||
private final Bus mBus;
|
||||
|
||||
public VideoLoader(Context context, ImageDownloader downloader, AsyncTaskManager manager) {
|
||||
public VideoLoader(Context context, RestHttpClient client, AsyncTaskManager manager, Bus bus) {
|
||||
final TwidereApplication app = TwidereApplication.getInstance(context);
|
||||
mContext = context;
|
||||
mDiskCache = app.getDiskCache();
|
||||
mImageDownloader = downloader;
|
||||
mImageDownloader = new TwidereImageDownloader(context, client, false);
|
||||
mTaskManager = manager;
|
||||
mBus = app.getMessageBus();
|
||||
mBus = bus;
|
||||
}
|
||||
|
||||
public File getCachedVideoFile(final String url, boolean loadIfNotFound) {
|
||||
@ -74,10 +76,14 @@ public class VideoLoader {
|
||||
|
||||
|
||||
public int loadVideo(String uri, VideoLoadingListener listener) {
|
||||
return loadVideo(uri, false, listener);
|
||||
}
|
||||
|
||||
public int loadVideo(String uri, boolean forceReload, VideoLoadingListener listener) {
|
||||
if (mTaskManager.hasRunningTasksForTag(uri)) {
|
||||
return 0;
|
||||
}
|
||||
return mTaskManager.add(new PreLoadVideoTask(mContext, this, listener, uri), true);
|
||||
return mTaskManager.add(new PreLoadVideoTask(mContext, this, listener, uri, forceReload), true);
|
||||
}
|
||||
|
||||
private void notifyTaskFinish(String uri, boolean succeeded) {
|
||||
@ -102,12 +108,16 @@ public class VideoLoader {
|
||||
private final VideoLoader mPreLoader;
|
||||
private final VideoLoadingListener mListener;
|
||||
private final String mUri;
|
||||
private final boolean mForceReload;
|
||||
|
||||
private PreLoadVideoTask(final Context context, final VideoLoader preLoader, VideoLoadingListener listener, final String uri) {
|
||||
super(context, preLoader.mTaskManager, uri);
|
||||
private PreLoadVideoTask(final Context context, final VideoLoader preLoader,
|
||||
final VideoLoadingListener listener, final String uri,
|
||||
boolean forceReload) {
|
||||
super(context, uri);
|
||||
mPreLoader = preLoader;
|
||||
mListener = listener;
|
||||
mUri = uri;
|
||||
mForceReload = forceReload;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -121,7 +131,7 @@ public class VideoLoader {
|
||||
protected SingleResponse<File> doInBackground(Object... params) {
|
||||
final DiskCache diskCache = mPreLoader.mDiskCache;
|
||||
final File cachedFile = diskCache.get(mUri);
|
||||
if (cachedFile != null && cachedFile.isFile() && cachedFile.length() > 0)
|
||||
if (!mForceReload && cachedFile != null && cachedFile.isFile() && cachedFile.length() > 0)
|
||||
return SingleResponse.getInstance(cachedFile);
|
||||
InputStream is = null;
|
||||
try {
|
||||
|
@ -20,6 +20,7 @@
|
||||
package org.mariotaku.twidere.util.dagger;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Looper;
|
||||
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
|
||||
@ -27,6 +28,8 @@ import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
|
||||
import com.nostra13.universalimageloader.utils.L;
|
||||
import com.squareup.okhttp.OkHttpClient;
|
||||
import com.squareup.okhttp.internal.Network;
|
||||
import com.squareup.otto.Bus;
|
||||
import com.squareup.otto.ThreadEnforcer;
|
||||
|
||||
import org.mariotaku.restfu.http.RestHttpClient;
|
||||
import org.mariotaku.twidere.BuildConfig;
|
||||
@ -65,18 +68,25 @@ public class ApplicationModule {
|
||||
private final AsyncTaskManager asyncTaskManager;
|
||||
private final Network network;
|
||||
private final RestHttpClient restHttpClient;
|
||||
private final Bus bus;
|
||||
|
||||
public ApplicationModule(TwidereApplication application) {
|
||||
if (Thread.currentThread() != Looper.getMainLooper().getThread()) {
|
||||
throw new RuntimeException("Module must be created inside main thread");
|
||||
}
|
||||
sharedPreferences = SharedPreferencesWrapper.getInstance(application, Constants.SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
activityTracker = new ActivityTracker();
|
||||
bus = new Bus(ThreadEnforcer.MAIN);
|
||||
asyncTaskManager = AsyncTaskManager.getInstance();
|
||||
asyncTwitterWrapper = new AsyncTwitterWrapper(application, asyncTaskManager);
|
||||
readStateManager = new ReadStateManager(application);
|
||||
network = new TwidereNetwork(application);
|
||||
|
||||
|
||||
asyncTwitterWrapper = new AsyncTwitterWrapper(application, asyncTaskManager, bus);
|
||||
restHttpClient = TwitterAPIFactory.getDefaultHttpClient(application, network);
|
||||
imageDownloader = new TwidereImageDownloader(application, restHttpClient, true);
|
||||
imageLoader = createImageLoader(application, imageDownloader);
|
||||
videoLoader = new VideoLoader(application, imageDownloader, asyncTaskManager);
|
||||
videoLoader = new VideoLoader(application, restHttpClient, asyncTaskManager, bus);
|
||||
mediaLoaderWrapper = new MediaLoaderWrapper(imageLoader, videoLoader);
|
||||
}
|
||||
|
||||
@ -103,6 +113,11 @@ public class ApplicationModule {
|
||||
return restHttpClient;
|
||||
}
|
||||
|
||||
@Provides
|
||||
public Bus getBus() {
|
||||
return bus;
|
||||
}
|
||||
|
||||
@Provides
|
||||
public AsyncTaskManager getAsyncTaskManager() {
|
||||
return asyncTaskManager;
|
||||
|
@ -39,6 +39,7 @@ import org.mariotaku.twidere.provider.TwidereCommandProvider;
|
||||
import org.mariotaku.twidere.provider.TwidereDataProvider;
|
||||
import org.mariotaku.twidere.service.BackgroundOperationService;
|
||||
import org.mariotaku.twidere.service.RefreshService;
|
||||
import org.mariotaku.twidere.task.ManagedAsyncTask;
|
||||
import org.mariotaku.twidere.util.MultiSelectEventHandler;
|
||||
import org.mariotaku.twidere.view.holder.StatusViewHolder;
|
||||
|
||||
@ -88,4 +89,6 @@ public interface GeneralComponent {
|
||||
void inject(BaseArrayAdapter<Object> object);
|
||||
|
||||
void inject(DraftsAdapter object);
|
||||
|
||||
void inject(ManagedAsyncTask<Object, Object, Object> object);
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ import org.mariotaku.twidere.api.twitter.model.Activity;
|
||||
import org.mariotaku.twidere.model.ParcelableActivity;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
import org.mariotaku.twidere.model.ParcelableUser;
|
||||
import org.mariotaku.twidere.model.ParcelableUserList;
|
||||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.UserColorNameManager;
|
||||
import org.mariotaku.twidere.view.ActionIconView;
|
||||
@ -82,15 +83,20 @@ public class ActivityTitleSummaryViewHolder extends ViewHolder implements View.O
|
||||
profileImageMoreNumber = (TextView) itemView.findViewById(R.id.activity_profile_image_more_number);
|
||||
}
|
||||
|
||||
public void displayActivityAboutMe(ParcelableActivity activity) {
|
||||
public void displayActivity(ParcelableActivity activity, boolean byFriends) {
|
||||
final Context context = adapter.getContext();
|
||||
final Resources resources = adapter.getContext().getResources();
|
||||
switch (activity.action) {
|
||||
case Activity.ACTION_FOLLOW: {
|
||||
activityTypeView.setImageResource(R.drawable.ic_activity_action_follow);
|
||||
activityTypeView.setColorFilter(ContextCompat.getColor(context, R.color.highlight_follow), Mode.SRC_ATOP);
|
||||
titleView.setText(getTitleStringAboutMe(R.string.activity_about_me_follow,
|
||||
R.string.activity_about_me_follow_multi, activity.sources));
|
||||
if (byFriends) {
|
||||
titleView.setText(getTitleStringByFriends(R.string.activity_by_friends_follow,
|
||||
R.string.activity_by_friends_follow_multi, activity.sources, activity.target_users));
|
||||
} else {
|
||||
titleView.setText(getTitleStringAboutMe(R.string.activity_about_me_follow,
|
||||
R.string.activity_about_me_follow_multi, activity.sources));
|
||||
}
|
||||
displayUserProfileImages(activity.sources);
|
||||
summaryView.setVisibility(View.GONE);
|
||||
break;
|
||||
@ -98,8 +104,13 @@ public class ActivityTitleSummaryViewHolder extends ViewHolder implements View.O
|
||||
case Activity.ACTION_FAVORITE: {
|
||||
activityTypeView.setImageResource(R.drawable.ic_activity_action_favorite);
|
||||
activityTypeView.setColorFilter(ContextCompat.getColor(context, R.color.highlight_favorite), Mode.SRC_ATOP);
|
||||
titleView.setText(getTitleStringAboutMe(R.string.activity_about_me_favorite,
|
||||
R.string.activity_about_me_favorite_multi, activity.sources));
|
||||
if (byFriends) {
|
||||
titleView.setText(getTitleStringByFriends(R.string.activity_by_friends_favorite,
|
||||
R.string.activity_by_friends_favorite_multi, activity.sources, activity.target_statuses));
|
||||
} else {
|
||||
titleView.setText(getTitleStringAboutMe(R.string.activity_about_me_favorite,
|
||||
R.string.activity_about_me_favorite_multi, activity.sources));
|
||||
}
|
||||
displayUserProfileImages(activity.sources);
|
||||
summaryView.setText(activity.target_statuses[0].text_unescaped);
|
||||
summaryView.setVisibility(View.VISIBLE);
|
||||
@ -108,14 +119,22 @@ public class ActivityTitleSummaryViewHolder extends ViewHolder implements View.O
|
||||
case Activity.ACTION_RETWEET: {
|
||||
activityTypeView.setImageResource(R.drawable.ic_activity_action_retweet);
|
||||
activityTypeView.setColorFilter(ContextCompat.getColor(context, R.color.highlight_retweet), Mode.SRC_ATOP);
|
||||
titleView.setText(getTitleStringAboutMe(R.string.activity_about_me_retweet,
|
||||
R.string.activity_about_me_retweet_multi, activity.sources));
|
||||
if (byFriends) {
|
||||
titleView.setText(getTitleStringByFriends(R.string.activity_by_friends_retweet,
|
||||
R.string.activity_by_friends_retweet_multi, activity.sources, activity.target_statuses));
|
||||
} else
|
||||
titleView.setText(getTitleStringAboutMe(R.string.activity_about_me_retweet,
|
||||
R.string.activity_about_me_retweet_multi, activity.sources));
|
||||
displayUserProfileImages(activity.sources);
|
||||
summaryView.setText(activity.target_statuses[0].text_unescaped);
|
||||
summaryView.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
}
|
||||
case Activity.ACTION_FAVORITED_RETWEET: {
|
||||
if (byFriends) {
|
||||
showNotSupported();
|
||||
return;
|
||||
}
|
||||
activityTypeView.setImageResource(R.drawable.ic_activity_action_favorite);
|
||||
activityTypeView.setColorFilter(ContextCompat.getColor(context, R.color.highlight_favorite), Mode.SRC_ATOP);
|
||||
titleView.setText(getTitleStringAboutMe(R.string.activity_about_me_favorited_retweet,
|
||||
@ -126,6 +145,10 @@ public class ActivityTitleSummaryViewHolder extends ViewHolder implements View.O
|
||||
break;
|
||||
}
|
||||
case Activity.ACTION_RETWEETED_RETWEET: {
|
||||
if (byFriends) {
|
||||
showNotSupported();
|
||||
return;
|
||||
}
|
||||
activityTypeView.setImageResource(R.drawable.ic_activity_action_retweet);
|
||||
activityTypeView.setColorFilter(ContextCompat.getColor(context, R.color.highlight_retweet), Mode.SRC_ATOP);
|
||||
titleView.setText(getTitleStringAboutMe(R.string.activity_about_me_retweeted_retweet,
|
||||
@ -136,6 +159,10 @@ public class ActivityTitleSummaryViewHolder extends ViewHolder implements View.O
|
||||
break;
|
||||
}
|
||||
case Activity.ACTION_RETWEETED_MENTION: {
|
||||
if (byFriends) {
|
||||
showNotSupported();
|
||||
return;
|
||||
}
|
||||
activityTypeView.setImageResource(R.drawable.ic_activity_action_retweet);
|
||||
activityTypeView.setColorFilter(ContextCompat.getColor(context, R.color.highlight_retweet), Mode.SRC_ATOP);
|
||||
titleView.setText(getTitleStringAboutMe(R.string.activity_about_me_retweeted_mention,
|
||||
@ -146,6 +173,10 @@ public class ActivityTitleSummaryViewHolder extends ViewHolder implements View.O
|
||||
break;
|
||||
}
|
||||
case Activity.ACTION_FAVORITED_MENTION: {
|
||||
if (byFriends) {
|
||||
showNotSupported();
|
||||
return;
|
||||
}
|
||||
activityTypeView.setImageResource(R.drawable.ic_activity_action_favorite);
|
||||
activityTypeView.setColorFilter(ContextCompat.getColor(context, R.color.highlight_favorite), Mode.SRC_ATOP);
|
||||
titleView.setText(getTitleStringAboutMe(R.string.activity_about_me_favorited_mention,
|
||||
@ -155,7 +186,34 @@ public class ActivityTitleSummaryViewHolder extends ViewHolder implements View.O
|
||||
summaryView.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
}
|
||||
case Activity.ACTION_LIST_CREATED: {
|
||||
if (!byFriends) {
|
||||
showNotSupported();
|
||||
return;
|
||||
}
|
||||
activityTypeView.setImageResource(R.drawable.ic_activity_action_list_added);
|
||||
activityTypeView.setColorFilter(activityTypeView.getDefaultColor(), Mode.SRC_ATOP);
|
||||
titleView.setText(getTitleStringByFriends(R.string.activity_by_friends_list_created,
|
||||
R.string.activity_by_friends_list_created_multi, activity.sources,
|
||||
activity.target_object_user_lists));
|
||||
displayUserProfileImages(activity.sources);
|
||||
boolean firstLine = true;
|
||||
summaryView.setText("");
|
||||
for (ParcelableUserList item : activity.target_object_user_lists) {
|
||||
if (!firstLine) {
|
||||
summaryView.append("\n");
|
||||
}
|
||||
summaryView.append(item.description);
|
||||
firstLine = false;
|
||||
}
|
||||
summaryView.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
}
|
||||
case Activity.ACTION_LIST_MEMBER_ADDED: {
|
||||
if (byFriends) {
|
||||
showNotSupported();
|
||||
return;
|
||||
}
|
||||
activityTypeView.setImageResource(R.drawable.ic_activity_action_list_added);
|
||||
activityTypeView.setColorFilter(activityTypeView.getDefaultColor(), Mode.SRC_ATOP);
|
||||
if (activity.sources.length == 1 && activity.target_object_user_lists != null
|
||||
@ -181,34 +239,8 @@ public class ActivityTitleSummaryViewHolder extends ViewHolder implements View.O
|
||||
}
|
||||
}
|
||||
|
||||
public void displayActivitiesByFriends(ParcelableActivity activity) {
|
||||
final Context context = adapter.getContext();
|
||||
switch (activity.action) {
|
||||
case Activity.ACTION_FOLLOW: {
|
||||
activityTypeView.setImageResource(R.drawable.ic_activity_action_follow);
|
||||
activityTypeView.setColorFilter(ContextCompat.getColor(context, R.color.highlight_follow), Mode.SRC_ATOP);
|
||||
titleView.setText(getTitleStringByFriends(R.string.activity_by_friends_follow,
|
||||
R.string.activity_by_friends_follow_multi, activity.sources, activity.target_users));
|
||||
displayUserProfileImages(activity.sources);
|
||||
summaryView.setVisibility(View.GONE);
|
||||
break;
|
||||
}
|
||||
case Activity.ACTION_FAVORITE: {
|
||||
activityTypeView.setImageResource(R.drawable.ic_activity_action_favorite);
|
||||
activityTypeView.setColorFilter(ContextCompat.getColor(context, R.color.highlight_favorite), Mode.SRC_ATOP);
|
||||
titleView.setText(getTitleStringByFriends(R.string.activity_by_friends_favorite,
|
||||
R.string.activity_by_friends_favorite_multi, activity.sources, activity.target_statuses));
|
||||
displayUserProfileImages(activity.sources);
|
||||
summaryView.setText(activity.target_statuses[0].text_unescaped);
|
||||
summaryView.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
activityTypeView.setImageDrawable(null);
|
||||
activityTypeView.clearColorFilter();
|
||||
break;
|
||||
}
|
||||
}
|
||||
private void showNotSupported() {
|
||||
|
||||
}
|
||||
|
||||
public void setTextSize(float textSize) {
|
||||
|
@ -78,11 +78,13 @@
|
||||
android:textColor="?android:textColorPrimary"
|
||||
tools:text="12:34" />
|
||||
|
||||
<SeekBar
|
||||
<ProgressBar
|
||||
android:id="@+id/video_view_progress"
|
||||
style="?android:progressBarStyleHorizontal"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
||||
android:layout_weight="1"
|
||||
android:indeterminate="false" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/duration_label"
|
||||
|
@ -290,7 +290,9 @@
|
||||
<string name="activity_by_friends_follow"><xliff:g id="user">%1$s</xliff:g> is following <xliff:g id="target">%2$s</xliff:g>.</string>
|
||||
<string name="activity_by_friends_follow_multi"><xliff:g id="user">%1$s</xliff:g> is following <xliff:g id="target">%2$s</xliff:g> and <xliff:g id="other">%3$s</xliff:g>.</string>
|
||||
<string name="activity_by_friends_retweet"><xliff:g id="user">%1$s</xliff:g> retweeted <xliff:g id="target">%2$s</xliff:g>\'s tweet.</string>
|
||||
<string name="activity_by_friends_retweet_multi"><xliff:g id="user">%1$s</xliff:g> retweeted <xliff:g id="target">%2$s</xliff:g> and <xliff:g id="other">%3$s</xliff:g>\'s tweet.</string>
|
||||
<string name="activity_by_friends_list_member_added"><xliff:g id="user">%1$s</xliff:g> added <xliff:g id="target">%2$s</xliff:g> to list.</string>
|
||||
<string name="activity_by_friends_list_member_added_multi"><xliff:g id="user">%1$s</xliff:g> added <xliff:g id="target">%2$s</xliff:g> and <xliff:g id="other">%1$s</xliff:g> to list.</string>
|
||||
<string name="activity_by_friends_list_created"><xliff:g id="user">%1$s</xliff:g> created list <xliff:g id="target">%2$s</xliff:g>.</string>
|
||||
<string name="activity_by_friends_list_created_multi"><xliff:g id="user">%1$s</xliff:g> created list <xliff:g id="target">%2$s</xliff:g> and <xliff:g id="other">%1$s</xliff:g>.</string>
|
||||
<string name="status_not_updated">Tweet not sent.</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user