using dagger to retrive image loader
This commit is contained in:
parent
ce3f4f1710
commit
b5db451c75
|
@ -48,6 +48,7 @@ import org.mariotaku.twidere.util.StrictModeUtils;
|
|||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.TwidereColorUtils;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.util.dagger.DaggerGeneralComponent;
|
||||
import org.mariotaku.twidere.util.support.ViewSupport;
|
||||
import org.mariotaku.twidere.view.ShapedImageView.ShapeStyle;
|
||||
|
@ -163,7 +164,7 @@ public abstract class BasePreferenceActivity extends AppCompatPreferenceActivity
|
|||
}
|
||||
setupWindow();
|
||||
super.onCreate(savedInstanceState);
|
||||
DaggerGeneralComponent.builder().applicationModule(TwidereApplication.getModule(this)).build().inject(this);
|
||||
DaggerGeneralComponent.builder().applicationModule(ApplicationModule.get(this)).build().inject(this);
|
||||
mKeyboardShortcutsHandler = TwidereApplication.getInstance(this).getKeyboardShortcutsHandler();
|
||||
}
|
||||
|
||||
|
|
|
@ -26,11 +26,11 @@ import android.support.annotation.NonNull;
|
|||
|
||||
import org.mariotaku.twidere.BuildConfig;
|
||||
import org.mariotaku.twidere.activity.iface.IThemedActivity;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.util.ActivityTracker;
|
||||
import org.mariotaku.twidere.util.StrictModeUtils;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.util.dagger.DaggerGeneralComponent;
|
||||
import org.mariotaku.twidere.view.ShapedImageView;
|
||||
|
||||
|
@ -119,7 +119,7 @@ public abstract class BaseThemedActivity extends Activity implements IThemedActi
|
|||
StrictModeUtils.detectAllThreadPolicy();
|
||||
}
|
||||
super.onCreate(savedInstanceState);
|
||||
DaggerGeneralComponent.builder().applicationModule(TwidereApplication.getModule(this)).build().inject(this);
|
||||
DaggerGeneralComponent.builder().applicationModule(ApplicationModule.get(this)).build().inject(this);
|
||||
setActionBarBackground();
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.mariotaku.twidere.util.KeyboardShortcutsHandler;
|
|||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler.KeyboardShortcutCallback;
|
||||
import org.mariotaku.twidere.util.ReadStateManager;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.util.dagger.DaggerGeneralComponent;
|
||||
import org.mariotaku.twidere.view.iface.IExtendedView.OnFitSystemWindowsListener;
|
||||
|
||||
|
@ -149,7 +150,7 @@ public class BaseAppCompatActivity extends ThemedAppCompatActivity implements Co
|
|||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
DaggerGeneralComponent.builder().applicationModule(TwidereApplication.getModule(this)).build().inject(this);
|
||||
DaggerGeneralComponent.builder().applicationModule(ApplicationModule.get(this)).build().inject(this);
|
||||
mKeyboardShortcutsHandler = TwidereApplication.getInstance(this).getKeyboardShortcutsHandler();
|
||||
}
|
||||
|
||||
|
|
|
@ -180,7 +180,6 @@ public class ComposeActivity extends ThemedFragmentActivity implements LocationL
|
|||
private ShapedImageView mProfileImageView;
|
||||
private BadgeView mCountView;
|
||||
private View mAccountSelectorButton;
|
||||
private MediaLoaderWrapper mImageLoader;
|
||||
private View mLocationContainer;
|
||||
private ActionIconView mLocationIcon;
|
||||
private TextView mLocationText;
|
||||
|
@ -589,7 +588,6 @@ public class ComposeActivity extends ThemedFragmentActivity implements LocationL
|
|||
final TwidereApplication app = TwidereApplication.getInstance(this);
|
||||
mResolver = getContentResolver();
|
||||
mValidator = new TwidereValidator(this);
|
||||
mImageLoader = app.getMediaLoaderWrapper();
|
||||
setContentView(R.layout.activity_compose);
|
||||
setFinishOnTouchOutside(false);
|
||||
final long[] defaultAccountIds = Utils.getAccountIds(this);
|
||||
|
@ -1339,7 +1337,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements LocationL
|
|||
setHasStableIds(true);
|
||||
mActivity = activity;
|
||||
mInflater = activity.getLayoutInflater();
|
||||
mImageLoader = TwidereApplication.getInstance(activity).getMediaLoaderWrapper();
|
||||
mImageLoader = activity.mImageLoader;
|
||||
mSelection = new LongSparseArray<>();
|
||||
final SharedPreferencesWrapper preferences = SharedPreferencesWrapper.getInstance(activity,
|
||||
SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE, SharedPreferenceConstants.class);
|
||||
|
@ -1606,9 +1604,9 @@ public class ComposeActivity extends ThemedFragmentActivity implements LocationL
|
|||
|
||||
private final MediaLoaderWrapper mImageLoader;
|
||||
|
||||
public MediaPreviewAdapter(final Context context) {
|
||||
super(context, R.layout.grid_item_media_editor);
|
||||
mImageLoader = TwidereApplication.getInstance(context).getMediaLoaderWrapper();
|
||||
public MediaPreviewAdapter(final ComposeActivity activity) {
|
||||
super(activity, R.layout.grid_item_media_editor);
|
||||
mImageLoader = activity.mImageLoader;
|
||||
}
|
||||
|
||||
public List<ParcelableMediaUpdate> getAsList() {
|
||||
|
|
|
@ -74,7 +74,6 @@ import static org.mariotaku.twidere.util.CustomTabUtils.getTabTypeName;
|
|||
|
||||
public class CustomTabEditorActivity extends BaseSupportDialogActivity implements OnClickListener {
|
||||
|
||||
private MediaLoaderWrapper mImageLoader;
|
||||
private SharedPreferences mPreferences;
|
||||
|
||||
private AccountsSpinnerAdapter mAccountsAdapter;
|
||||
|
@ -269,7 +268,6 @@ public class CustomTabEditorActivity extends BaseSupportDialogActivity implement
|
|||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, MODE_PRIVATE);
|
||||
mImageLoader = TwidereApplication.getInstance(this).getMediaLoaderWrapper();
|
||||
final Intent intent = getIntent();
|
||||
final String type = mTabType = intent.getStringExtra(EXTRA_TYPE);
|
||||
final CustomTabConfiguration conf = getTabConfiguration(type);
|
||||
|
|
|
@ -127,8 +127,6 @@ import static org.mariotaku.twidere.util.Utils.showMenuItemToast;
|
|||
|
||||
public class HomeActivity extends BaseAppCompatActivity implements OnClickListener, OnPageChangeListener,
|
||||
SupportFragmentCallback, OnLongClickListener {
|
||||
|
||||
private static final String EXTRA_SESSION_EVENT = "session_event";
|
||||
private final Handler mHandler = new Handler();
|
||||
|
||||
private final ContentObserver mAccountChangeObserver = new AccountChangeObserver(this, mHandler);
|
||||
|
|
|
@ -421,9 +421,9 @@ public class QuickSearchBarActivity extends ThemedFragmentActivity implements On
|
|||
|
||||
SuggestionsAdapter(QuickSearchBarActivity activity) {
|
||||
mActivity = activity;
|
||||
mImageLoader = activity.mImageLoader;
|
||||
mInflater = LayoutInflater.from(activity);
|
||||
final TwidereApplication application = TwidereApplication.getInstance(activity);
|
||||
mImageLoader = application.getMediaLoaderWrapper();
|
||||
mUserColorNameManager = application.getUserColorNameManager();
|
||||
}
|
||||
|
||||
|
|
|
@ -39,10 +39,12 @@ import org.mariotaku.twidere.util.ActivityTracker;
|
|||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler;
|
||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler.KeyboardShortcutCallback;
|
||||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.StrictModeUtils;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.ThemedLayoutInflaterFactory;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.util.dagger.DaggerGeneralComponent;
|
||||
import org.mariotaku.twidere.view.ShapedImageView.ShapeStyle;
|
||||
|
||||
|
@ -57,6 +59,8 @@ public abstract class ThemedFragmentActivity extends FragmentActivity implements
|
|||
protected AsyncTwitterWrapper mTwitterWrapper;
|
||||
@Inject
|
||||
protected ActivityTracker mActivityTracker;
|
||||
@Inject
|
||||
protected MediaLoaderWrapper mImageLoader;
|
||||
|
||||
// Data fields
|
||||
private int mCurrentThemeResource, mCurrentThemeColor, mCurrentThemeBackgroundAlpha;
|
||||
|
@ -138,7 +142,7 @@ public abstract class ThemedFragmentActivity extends FragmentActivity implements
|
|||
StrictModeUtils.detectAllThreadPolicy();
|
||||
}
|
||||
super.onCreate(savedInstanceState);
|
||||
DaggerGeneralComponent.builder().applicationModule(TwidereApplication.getModule(this)).build().inject(this);
|
||||
DaggerGeneralComponent.builder().applicationModule(ApplicationModule.get(this)).build().inject(this);
|
||||
mKeyboardShortcutsHandler = TwidereApplication.getInstance(this).getKeyboardShortcutsHandler();
|
||||
}
|
||||
|
||||
|
|
|
@ -56,8 +56,6 @@ import org.mariotaku.twidere.view.holder.StatusViewHolder;
|
|||
import org.mariotaku.twidere.view.holder.StatusViewHolder.DummyStatusHolderAdapter;
|
||||
import org.mariotaku.twidere.view.holder.StatusViewHolder.StatusClickListener;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/1/3.
|
||||
*/
|
||||
|
@ -72,7 +70,6 @@ public abstract class AbsActivitiesAdapter<Data> extends LoadMoreSupportAdapter<
|
|||
|
||||
private final Context mContext;
|
||||
private final LayoutInflater mInflater;
|
||||
private final MediaLoaderWrapper mImageLoader;
|
||||
private final MediaLoadingHandler mLoadingHandler;
|
||||
private final int mCardBackgroundColor;
|
||||
private final int mTextSize;
|
||||
|
@ -92,7 +89,6 @@ public abstract class AbsActivitiesAdapter<Data> extends LoadMoreSupportAdapter<
|
|||
final TwidereApplication app = TwidereApplication.getInstance(context);
|
||||
mCardBackgroundColor = ThemeUtils.getCardBackgroundColor(context, ThemeUtils.getThemeBackgroundOption(context), ThemeUtils.getUserThemeBackgroundAlpha(context));
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mImageLoader = app.getMediaLoaderWrapper();
|
||||
mLoadingHandler = new MediaLoadingHandler(R.id.media_preview_progress);
|
||||
mUserColorNameManager = app.getUserColorNameManager();
|
||||
final SharedPreferencesWrapper preferences = SharedPreferencesWrapper.getInstance(context,
|
||||
|
@ -123,7 +119,7 @@ public abstract class AbsActivitiesAdapter<Data> extends LoadMoreSupportAdapter<
|
|||
@NonNull
|
||||
@Override
|
||||
public MediaLoaderWrapper getMediaLoader() {
|
||||
return mImageLoader;
|
||||
return mMediaLoader;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
|
|
@ -30,8 +30,6 @@ import org.mariotaku.twidere.view.holder.GapViewHolder;
|
|||
import org.mariotaku.twidere.view.holder.LoadIndicatorViewHolder;
|
||||
import org.mariotaku.twidere.view.holder.StatusViewHolder;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 14/11/19.
|
||||
*/
|
||||
|
@ -42,7 +40,6 @@ public abstract class AbsStatusesAdapter<D> extends LoadMoreSupportAdapter<ViewH
|
|||
|
||||
private final Context mContext;
|
||||
private final LayoutInflater mInflater;
|
||||
private final MediaLoaderWrapper mMediaLoader;
|
||||
private final MediaLoadingHandler mLoadingHandler;
|
||||
private final TwidereLinkify mLinkify;
|
||||
private final UserColorNameManager mUserColorNameManager;
|
||||
|
@ -74,7 +71,6 @@ public abstract class AbsStatusesAdapter<D> extends LoadMoreSupportAdapter<ViewH
|
|||
final TwidereApplication app = TwidereApplication.getInstance(context);
|
||||
mCardBackgroundColor = ThemeUtils.getCardBackgroundColor(context, ThemeUtils.getThemeBackgroundOption(context), ThemeUtils.getUserThemeBackgroundAlpha(context));
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mMediaLoader = app.getMediaLoaderWrapper();
|
||||
mUserColorNameManager = app.getUserColorNameManager();
|
||||
mLoadingHandler = new MediaLoadingHandler(R.id.media_preview_progress);
|
||||
final SharedPreferencesWrapper preferences = SharedPreferencesWrapper.getInstance(context,
|
||||
|
|
|
@ -40,8 +40,6 @@ import org.mariotaku.twidere.util.Utils;
|
|||
import org.mariotaku.twidere.view.holder.LoadIndicatorViewHolder;
|
||||
import org.mariotaku.twidere.view.holder.UserListViewHolder;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public abstract class AbsUserListsAdapter<D> extends LoadMoreSupportAdapter<ViewHolder> implements Constants,
|
||||
IUserListsAdapter<D> {
|
||||
|
||||
|
@ -49,7 +47,6 @@ public abstract class AbsUserListsAdapter<D> extends LoadMoreSupportAdapter<View
|
|||
|
||||
private final Context mContext;
|
||||
private final LayoutInflater mInflater;
|
||||
private final MediaLoaderWrapper mMediaLoader;
|
||||
|
||||
private final int mCardBackgroundColor;
|
||||
private final boolean mCompactCards;
|
||||
|
@ -66,7 +63,6 @@ public abstract class AbsUserListsAdapter<D> extends LoadMoreSupportAdapter<View
|
|||
mContext = context;
|
||||
mCardBackgroundColor = ThemeUtils.getCardBackgroundColor(context, ThemeUtils.getThemeBackgroundOption(context), ThemeUtils.getUserThemeBackgroundAlpha(context));
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mMediaLoader = app.getMediaLoaderWrapper();
|
||||
mUserColorNameManager = app.getUserColorNameManager();
|
||||
final SharedPreferencesWrapper preferences = SharedPreferencesWrapper.getInstance(context,
|
||||
SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
|
|
|
@ -40,8 +40,6 @@ import org.mariotaku.twidere.util.Utils;
|
|||
import org.mariotaku.twidere.view.holder.LoadIndicatorViewHolder;
|
||||
import org.mariotaku.twidere.view.holder.UserViewHolder;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public abstract class AbsUsersAdapter<D> extends LoadMoreSupportAdapter<ViewHolder> implements Constants,
|
||||
IUsersAdapter<D> {
|
||||
|
||||
|
@ -49,7 +47,6 @@ public abstract class AbsUsersAdapter<D> extends LoadMoreSupportAdapter<ViewHold
|
|||
|
||||
private final Context mContext;
|
||||
private final LayoutInflater mInflater;
|
||||
private final MediaLoaderWrapper mMediaLoader;
|
||||
|
||||
private final int mCardBackgroundColor;
|
||||
private final boolean mCompactCards;
|
||||
|
@ -65,7 +62,6 @@ public abstract class AbsUsersAdapter<D> extends LoadMoreSupportAdapter<ViewHold
|
|||
mContext = context;
|
||||
mCardBackgroundColor = ThemeUtils.getCardBackgroundColor(context, ThemeUtils.getThemeBackgroundOption(context), ThemeUtils.getUserThemeBackgroundAlpha(context));
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mMediaLoader = app.getMediaLoaderWrapper();
|
||||
mUserColorNameManager = app.getUserColorNameManager();
|
||||
final SharedPreferencesWrapper preferences = SharedPreferencesWrapper.getInstance(context,
|
||||
SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
|
|
|
@ -31,16 +31,20 @@ import com.mobeta.android.dslv.SimpleDragSortCursorAdapter;
|
|||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.adapter.iface.IBaseAdapter;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.model.ParcelableAccount;
|
||||
import org.mariotaku.twidere.model.ParcelableAccount.Indices;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Accounts;
|
||||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.util.dagger.DaggerGeneralComponent;
|
||||
import org.mariotaku.twidere.view.holder.AccountViewHolder;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class AccountsAdapter extends SimpleDragSortCursorAdapter implements Constants, IBaseAdapter {
|
||||
|
||||
private final MediaLoaderWrapper mImageLoader;
|
||||
@Inject
|
||||
MediaLoaderWrapper mImageLoader;
|
||||
private final SharedPreferences mPreferences;
|
||||
|
||||
private boolean mDisplayProfileImage;
|
||||
|
@ -62,8 +66,7 @@ public class AccountsAdapter extends SimpleDragSortCursorAdapter implements Cons
|
|||
public AccountsAdapter(final Context context) {
|
||||
super(context, R.layout.list_item_account, null, new String[]{Accounts.NAME},
|
||||
new int[]{android.R.id.text1}, 0);
|
||||
final TwidereApplication application = TwidereApplication.getInstance(context);
|
||||
mImageLoader = application.getMediaLoaderWrapper();
|
||||
DaggerGeneralComponent.builder().applicationModule(ApplicationModule.get(context)).build().inject(this);
|
||||
mPreferences = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,16 +26,20 @@ import android.widget.ImageView;
|
|||
import android.widget.TextView;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.fragment.support.MessagesConversationFragment;
|
||||
import org.mariotaku.twidere.model.ParcelableCredentials;
|
||||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.util.dagger.DaggerGeneralComponent;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class AccountsSpinnerAdapter extends ArrayAdapter<ParcelableCredentials> {
|
||||
|
||||
private final MediaLoaderWrapper mImageLoader;
|
||||
@Inject
|
||||
MediaLoaderWrapper mImageLoader;
|
||||
private final boolean mDisplayProfileImage;
|
||||
private final Context mContext;
|
||||
private String mDummyItemText;
|
||||
|
@ -46,8 +50,8 @@ public class AccountsSpinnerAdapter extends ArrayAdapter<ParcelableCredentials>
|
|||
|
||||
public AccountsSpinnerAdapter(final Context context, int itemViewResource) {
|
||||
super(context, itemViewResource);
|
||||
DaggerGeneralComponent.builder().applicationModule(ApplicationModule.get(context)).build().inject(this);
|
||||
mContext = context;
|
||||
mImageLoader = TwidereApplication.getInstance(context).getMediaLoaderWrapper();
|
||||
mDisplayProfileImage = context.getSharedPreferences(MessagesConversationFragment.SHARED_PREFERENCES_NAME,
|
||||
Context.MODE_PRIVATE).getBoolean(MessagesConversationFragment.KEY_DISPLAY_PROFILE_IMAGE, true);
|
||||
}
|
||||
|
|
|
@ -22,9 +22,10 @@ package org.mariotaku.twidere.adapter;
|
|||
import android.content.Context;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.ReadStateManager;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.util.dagger.DaggerGeneralComponent;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -37,11 +38,13 @@ public abstract class BaseAdapter<VH extends RecyclerView.ViewHolder> extends Re
|
|||
protected AsyncTwitterWrapper mTwitterWrapper;
|
||||
@Inject
|
||||
protected ReadStateManager mReadStateManager;
|
||||
@Inject
|
||||
protected MediaLoaderWrapper mMediaLoader;
|
||||
|
||||
public BaseAdapter(Context context) {
|
||||
//noinspection unchecked
|
||||
DaggerGeneralComponent.builder()
|
||||
.applicationModule(TwidereApplication.getModule(context))
|
||||
.applicationModule(ApplicationModule.get(context))
|
||||
.build()
|
||||
.inject((BaseAdapter<RecyclerView.ViewHolder>) this);
|
||||
}
|
||||
|
|
|
@ -29,9 +29,13 @@ import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
|||
import org.mariotaku.twidere.util.OnLinkClickHandler;
|
||||
import org.mariotaku.twidere.util.TwidereLinkify;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.util.dagger.DaggerGeneralComponent;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class BaseArrayAdapter<T> extends ArrayAdapter<T> implements IBaseAdapter, OnSharedPreferenceChangeListener {
|
||||
|
||||
private final TwidereLinkify mLinkify;
|
||||
|
@ -42,7 +46,8 @@ public class BaseArrayAdapter<T> extends ArrayAdapter<T> implements IBaseAdapter
|
|||
private boolean mDisplayProfileImage, mDisplayNameFirst, mShowAccountColor;
|
||||
|
||||
private final SharedPreferences mNicknamePrefs, mColorPrefs;
|
||||
private final MediaLoaderWrapper mImageLoader;
|
||||
@Inject
|
||||
protected MediaLoaderWrapper mImageLoader;
|
||||
|
||||
public BaseArrayAdapter(final Context context, final int layoutRes) {
|
||||
this(context, layoutRes, null);
|
||||
|
@ -50,9 +55,10 @@ public class BaseArrayAdapter<T> extends ArrayAdapter<T> implements IBaseAdapter
|
|||
|
||||
public BaseArrayAdapter(final Context context, final int layoutRes, final Collection<? extends T> collection) {
|
||||
super(context, layoutRes, collection);
|
||||
//noinspection unchecked
|
||||
DaggerGeneralComponent.builder().applicationModule(ApplicationModule.get(context)).build().inject((BaseArrayAdapter<Object>) this);
|
||||
final TwidereApplication app = TwidereApplication.getInstance(context);
|
||||
mLinkify = new TwidereLinkify(new OnLinkClickHandler(context, app.getMultiSelectManager()));
|
||||
mImageLoader = app.getMediaLoaderWrapper();
|
||||
mNicknamePrefs = context.getSharedPreferences(USER_NICKNAME_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
mColorPrefs = context.getSharedPreferences(USER_COLOR_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
mNicknamePrefs.registerOnSharedPreferenceChangeListener(this);
|
||||
|
|
|
@ -29,23 +29,27 @@ import android.view.ViewGroup;
|
|||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.model.DraftItem;
|
||||
import org.mariotaku.twidere.model.ParcelableMedia;
|
||||
import org.mariotaku.twidere.model.ParcelableMediaUpdate;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Drafts;
|
||||
import org.mariotaku.twidere.util.MediaLoadingHandler;
|
||||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.MediaLoadingHandler;
|
||||
import org.mariotaku.twidere.util.SharedPreferencesWrapper;
|
||||
import org.mariotaku.twidere.util.TwidereArrayUtils;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.util.dagger.DaggerGeneralComponent;
|
||||
import org.mariotaku.twidere.view.holder.DraftViewHolder;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static org.mariotaku.twidere.util.Utils.getAccountColors;
|
||||
|
||||
public class DraftsAdapter extends SimpleCursorAdapter implements Constants {
|
||||
|
||||
private final MediaLoaderWrapper mImageLoader;
|
||||
@Inject
|
||||
MediaLoaderWrapper mImageLoader;
|
||||
private final MediaLoadingHandler mMediaLoadingHandler;
|
||||
private final int mMediaPreviewStyle;
|
||||
|
||||
|
@ -54,7 +58,7 @@ public class DraftsAdapter extends SimpleCursorAdapter implements Constants {
|
|||
|
||||
public DraftsAdapter(final Context context) {
|
||||
super(context, R.layout.list_item_draft, null, new String[0], new int[0], 0);
|
||||
mImageLoader = TwidereApplication.getInstance(context).getMediaLoaderWrapper();
|
||||
DaggerGeneralComponent.builder().applicationModule(ApplicationModule.get(context)).build().inject(this);
|
||||
mMediaLoadingHandler = new MediaLoadingHandler(R.id.media_preview_progress);
|
||||
final SharedPreferencesWrapper preferences = SharedPreferencesWrapper.getInstance(context,
|
||||
SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.mariotaku.twidere.adapter;
|
|||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.RecyclerView.Adapter;
|
||||
import android.support.v7.widget.RecyclerView.ViewHolder;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -47,7 +46,7 @@ import org.mariotaku.twidere.view.ShapedImageView;
|
|||
import org.mariotaku.twidere.view.holder.IncomingMessageViewHolder;
|
||||
import org.mariotaku.twidere.view.holder.MessageViewHolder;
|
||||
|
||||
public class MessageConversationAdapter extends Adapter<ViewHolder> implements Constants,
|
||||
public class MessageConversationAdapter extends BaseAdapter<ViewHolder> implements Constants,
|
||||
IDirectMessagesAdapter, OnClickListener {
|
||||
|
||||
private static final int ITEM_VIEW_TYPE_MESSAGE_OUTGOING = 1;
|
||||
|
@ -62,7 +61,6 @@ public class MessageConversationAdapter extends Adapter<ViewHolder> implements C
|
|||
|
||||
private final Context mContext;
|
||||
private final LayoutInflater mInflater;
|
||||
private final MediaLoaderWrapper mMediaLoader;
|
||||
private final MultiSelectManager mMultiSelectManager;
|
||||
private final MediaLoadingHandler mMediaLoadingHandler;
|
||||
|
||||
|
@ -71,12 +69,12 @@ public class MessageConversationAdapter extends Adapter<ViewHolder> implements C
|
|||
private TwidereLinkify mLinkify;
|
||||
|
||||
public MessageConversationAdapter(final Context context) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
final TwidereApplication app = TwidereApplication.getInstance(context);
|
||||
mLinkify = new TwidereLinkify(new DirectMessageOnLinkClickHandler(context, null));
|
||||
mMultiSelectManager = app.getMultiSelectManager();
|
||||
mMediaLoader = app.getMediaLoaderWrapper();
|
||||
final SharedPreferencesWrapper preferences = SharedPreferencesWrapper.getInstance(context,
|
||||
SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
mDisplayProfileImage = preferences.getBoolean(KEY_DISPLAY_PROFILE_IMAGE, true);
|
||||
|
|
|
@ -39,7 +39,6 @@ import org.mariotaku.twidere.provider.TwidereDataStore.DirectMessages.Conversati
|
|||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.MultiSelectManager;
|
||||
import org.mariotaku.twidere.util.ReadStateManager;
|
||||
import org.mariotaku.twidere.util.ReadStateManager.OnReadStateChangeListener;
|
||||
import org.mariotaku.twidere.util.SharedPreferencesWrapper;
|
||||
import org.mariotaku.twidere.util.UserColorNameManager;
|
||||
|
@ -47,8 +46,6 @@ import org.mariotaku.twidere.util.Utils;
|
|||
import org.mariotaku.twidere.view.holder.LoadIndicatorViewHolder;
|
||||
import org.mariotaku.twidere.view.holder.MessageEntryViewHolder;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class MessageEntriesAdapter extends LoadMoreSupportAdapter<ViewHolder> implements Constants,
|
||||
IContentCardAdapter, OnClickListener, OnReadStateChangeListener {
|
||||
|
||||
|
@ -57,7 +54,6 @@ public class MessageEntriesAdapter extends LoadMoreSupportAdapter<ViewHolder> im
|
|||
|
||||
private final Context mContext;
|
||||
private final LayoutInflater mInflater;
|
||||
private final MediaLoaderWrapper mImageLoader;
|
||||
private final MultiSelectManager mMultiSelectManager;
|
||||
private final int mTextSize;
|
||||
private final int mProfileImageStyle;
|
||||
|
@ -77,7 +73,6 @@ public class MessageEntriesAdapter extends LoadMoreSupportAdapter<ViewHolder> im
|
|||
mInflater = LayoutInflater.from(context);
|
||||
final TwidereApplication app = TwidereApplication.getInstance(context);
|
||||
mMultiSelectManager = app.getMultiSelectManager();
|
||||
mImageLoader = app.getMediaLoaderWrapper();
|
||||
final SharedPreferencesWrapper preferences = SharedPreferencesWrapper.getInstance(context,
|
||||
SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
mProfileImageStyle = Utils.getProfileImageStyle(preferences.getString(KEY_PROFILE_IMAGE_STYLE, null));
|
||||
|
@ -130,7 +125,7 @@ public class MessageEntriesAdapter extends LoadMoreSupportAdapter<ViewHolder> im
|
|||
@NonNull
|
||||
@Override
|
||||
public MediaLoaderWrapper getMediaLoader() {
|
||||
return mImageLoader;
|
||||
return mMediaLoader;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
|
|
@ -30,7 +30,6 @@ import org.mariotaku.twidere.R;
|
|||
import org.mariotaku.twidere.adapter.iface.IBaseCardAdapter;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.model.ParcelableUserList;
|
||||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.MultiSelectManager;
|
||||
import org.mariotaku.twidere.util.UserColorNameManager;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
|
@ -47,7 +46,6 @@ public class ParcelableUserListsListAdapter extends BaseArrayAdapter<ParcelableU
|
|||
OnClickListener {
|
||||
|
||||
private final Context mContext;
|
||||
private final MediaLoaderWrapper mImageLoader;
|
||||
private final MultiSelectManager mMultiSelectManager;
|
||||
private final Locale mLocale;
|
||||
private final UserColorNameManager mUserColorNameManager;
|
||||
|
@ -61,7 +59,6 @@ public class ParcelableUserListsListAdapter extends BaseArrayAdapter<ParcelableU
|
|||
mContext = context;
|
||||
mLocale = context.getResources().getConfiguration().locale;
|
||||
final TwidereApplication app = TwidereApplication.getInstance(context);
|
||||
mImageLoader = app.getMediaLoaderWrapper();
|
||||
mMultiSelectManager = app.getMultiSelectManager();
|
||||
mUserColorNameManager = app.getUserColorNameManager();
|
||||
configBaseCardAdapter(context, this);
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.mariotaku.twidere.R;
|
|||
import org.mariotaku.twidere.adapter.iface.IBaseAdapter;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.model.ParcelableUserList;
|
||||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.UserColorNameManager;
|
||||
import org.mariotaku.twidere.view.holder.TwoLineWithIconViewHolder;
|
||||
|
||||
|
@ -38,14 +37,12 @@ import static org.mariotaku.twidere.util.Utils.configBaseAdapter;
|
|||
public class SimpleParcelableUserListsAdapter extends BaseArrayAdapter<ParcelableUserList> implements IBaseAdapter {
|
||||
|
||||
private final Context mContext;
|
||||
private final MediaLoaderWrapper mImageLoader;
|
||||
private UserColorNameManager mUserColorNameManager;
|
||||
|
||||
public SimpleParcelableUserListsAdapter(final Context context) {
|
||||
super(context, R.layout.list_item_two_line);
|
||||
mContext = context;
|
||||
final TwidereApplication app = TwidereApplication.getInstance(context);
|
||||
mImageLoader = app.getMediaLoaderWrapper();
|
||||
mUserColorNameManager = app.getUserColorNameManager();
|
||||
configBaseAdapter(context, this);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.mariotaku.twidere.R;
|
|||
import org.mariotaku.twidere.adapter.iface.IBaseAdapter;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.model.ParcelableUser;
|
||||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.UserColorNameManager;
|
||||
import org.mariotaku.twidere.view.holder.TwoLineWithIconViewHolder;
|
||||
|
||||
|
@ -38,7 +37,6 @@ import static org.mariotaku.twidere.util.Utils.getUserTypeIconRes;
|
|||
|
||||
public class SimpleParcelableUsersAdapter extends BaseArrayAdapter<ParcelableUser> implements IBaseAdapter {
|
||||
|
||||
private final MediaLoaderWrapper mImageLoader;
|
||||
private final Context mContext;
|
||||
private final UserColorNameManager mUserColorNameManager;
|
||||
|
||||
|
@ -50,7 +48,6 @@ public class SimpleParcelableUsersAdapter extends BaseArrayAdapter<ParcelableUse
|
|||
super(context, layoutRes);
|
||||
mContext = context;
|
||||
final TwidereApplication app = TwidereApplication.getInstance(context);
|
||||
mImageLoader = app.getMediaLoaderWrapper();
|
||||
mUserColorNameManager = app.getUserColorNameManager();
|
||||
configBaseAdapter(context, this);
|
||||
}
|
||||
|
|
|
@ -48,8 +48,12 @@ import org.mariotaku.twidere.util.ParseUtils;
|
|||
import org.mariotaku.twidere.util.SharedPreferencesWrapper;
|
||||
import org.mariotaku.twidere.util.UserColorNameManager;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.util.dagger.DaggerGeneralComponent;
|
||||
import org.mariotaku.twidere.view.ProfileImageView;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
|
||||
public class UserHashtagAutoCompleteAdapter extends SimpleCursorAdapter implements Constants {
|
||||
|
||||
|
@ -60,8 +64,8 @@ public class UserHashtagAutoCompleteAdapter extends SimpleCursorAdapter implemen
|
|||
private final ContentResolver mResolver;
|
||||
@NonNull
|
||||
private final SQLiteDatabase mDatabase;
|
||||
@NonNull
|
||||
private final MediaLoaderWrapper mProfileImageLoader;
|
||||
@Inject
|
||||
MediaLoaderWrapper mProfileImageLoader;
|
||||
@NonNull
|
||||
private final SharedPreferencesWrapper mPreferences;
|
||||
@NonNull
|
||||
|
@ -81,12 +85,12 @@ public class UserHashtagAutoCompleteAdapter extends SimpleCursorAdapter implemen
|
|||
|
||||
public UserHashtagAutoCompleteAdapter(final Context context, final EditText view) {
|
||||
super(context, R.layout.list_item_auto_complete, null, FROM, TO, 0);
|
||||
DaggerGeneralComponent.builder().applicationModule(ApplicationModule.get(context)).build().inject(this);
|
||||
mEditText = view;
|
||||
final TwidereApplication app = TwidereApplication.getInstance(context);
|
||||
mPreferences = SharedPreferencesWrapper.getInstance(context, SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
mUserColorNameManager = app.getUserColorNameManager();
|
||||
mResolver = context.getContentResolver();
|
||||
mProfileImageLoader = app.getMediaLoaderWrapper();
|
||||
mDatabase = app.getSQLiteDatabase();
|
||||
mDisplayProfileImage = mPreferences.getBoolean(KEY_DISPLAY_PROFILE_IMAGE, true);
|
||||
}
|
||||
|
|
|
@ -56,7 +56,6 @@ import org.mariotaku.twidere.util.AsyncTaskManager;
|
|||
import org.mariotaku.twidere.util.DebugModeUtils;
|
||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler;
|
||||
import org.mariotaku.twidere.util.MathUtils;
|
||||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.MultiSelectManager;
|
||||
import org.mariotaku.twidere.util.StrictModeUtils;
|
||||
import org.mariotaku.twidere.util.TwidereLogger;
|
||||
|
@ -90,8 +89,6 @@ public class TwidereApplication extends MultiDexApplication implements Constants
|
|||
private static final String KEY_KEYBOARD_SHORTCUT_INITIALIZED = "keyboard_shortcut_initialized";
|
||||
|
||||
private Handler mHandler;
|
||||
private MediaLoaderWrapper mMediaLoaderWrapper;
|
||||
private ImageLoader mImageLoader;
|
||||
private AsyncTaskManager mAsyncTaskManager;
|
||||
private SharedPreferences mPreferences;
|
||||
private MultiSelectManager mMultiSelectManager;
|
||||
|
@ -163,20 +160,6 @@ public class TwidereApplication extends MultiDexApplication implements Constants
|
|||
return mImageDownloader = new TwidereImageDownloader(this, false, true);
|
||||
}
|
||||
|
||||
public ImageLoader getImageLoader() {
|
||||
if (mImageLoader != null) return mImageLoader;
|
||||
final ImageLoader loader = ImageLoader.getInstance();
|
||||
final ImageLoaderConfiguration.Builder cb = new ImageLoaderConfiguration.Builder(this);
|
||||
cb.threadPriority(Thread.NORM_PRIORITY - 2);
|
||||
cb.denyCacheImageMultipleSizesInMemory();
|
||||
cb.tasksProcessingOrder(QueueProcessingType.LIFO);
|
||||
// cb.memoryCache(new ImageMemoryCache(40));
|
||||
cb.diskCache(getDiskCache());
|
||||
cb.imageDownloader(getImageDownloader());
|
||||
L.writeDebugLogs(BuildConfig.DEBUG);
|
||||
loader.init(cb.build());
|
||||
return mImageLoader = loader;
|
||||
}
|
||||
|
||||
public VideoLoader getVideoLoader() {
|
||||
if (mVideoLoader != null) return mVideoLoader;
|
||||
|
@ -184,11 +167,6 @@ public class TwidereApplication extends MultiDexApplication implements Constants
|
|||
return mVideoLoader = loader;
|
||||
}
|
||||
|
||||
public MediaLoaderWrapper getMediaLoaderWrapper() {
|
||||
if (mMediaLoaderWrapper != null) return mMediaLoaderWrapper;
|
||||
return mMediaLoaderWrapper = new MediaLoaderWrapper(getImageLoader(), getVideoLoader());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Bus getMessageBus() {
|
||||
return mMessageBus;
|
||||
|
@ -285,9 +263,8 @@ public class TwidereApplication extends MultiDexApplication implements Constants
|
|||
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
if (mMediaLoaderWrapper != null) {
|
||||
mMediaLoaderWrapper.clearMemoryCache();
|
||||
}
|
||||
final ApplicationModule module = getApplicationModule();
|
||||
module.getMediaLoaderWrapper().clearMemoryCache();
|
||||
super.onLowMemory();
|
||||
}
|
||||
|
||||
|
@ -346,11 +323,7 @@ public class TwidereApplication extends MultiDexApplication implements Constants
|
|||
return mHotMobiLogger = new HotMobiLogger(this);
|
||||
}
|
||||
|
||||
public static ApplicationModule getModule(Context context) {
|
||||
return getInstance(context).getApplicationModule();
|
||||
}
|
||||
|
||||
private ApplicationModule getApplicationModule() {
|
||||
public ApplicationModule getApplicationModule() {
|
||||
if (mApplicationModule != null) return mApplicationModule;
|
||||
return mApplicationModule = new ApplicationModule(this);
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.mariotaku.twidere.activity.support.BaseAppCompatActivity;
|
|||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.MultiSelectManager;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.util.dagger.DaggerGeneralComponent;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -44,7 +45,7 @@ public class BaseFragment extends Fragment implements Constants {
|
|||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
DaggerGeneralComponent.builder().applicationModule(TwidereApplication.getModule(context)).build().inject(this);
|
||||
DaggerGeneralComponent.builder().applicationModule(ApplicationModule.get(context)).build().inject(this);
|
||||
}
|
||||
|
||||
public TwidereApplication getApplication() {
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.mariotaku.twidere.fragment.iface.RefreshScrollTopInterface;
|
|||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.MultiSelectManager;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.util.dagger.DaggerGeneralComponent;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -112,7 +113,7 @@ public class BaseListFragment extends ListFragment implements Constants, OnScrol
|
|||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
DaggerGeneralComponent.builder().applicationModule(TwidereApplication.getModule(context)).build().inject(this);
|
||||
DaggerGeneralComponent.builder().applicationModule(ApplicationModule.get(context)).build().inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -132,7 +132,6 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
|
|||
private View mNoAccountContainer;
|
||||
|
||||
private Context mThemedContext;
|
||||
private MediaLoaderWrapper mImageLoader;
|
||||
private AccountToggleProvider mAccountActionProvider;
|
||||
private final SupportFragmentReloadCursorObserver mReloadContentObserver = new SupportFragmentReloadCursorObserver(
|
||||
this, 0, this) {
|
||||
|
@ -410,7 +409,6 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
|
|||
if (view == null) throw new AssertionError();
|
||||
final Context context = view.getContext();
|
||||
final TwidereApplication application = TwidereApplication.getInstance(context);
|
||||
mImageLoader = application.getMediaLoaderWrapper();
|
||||
mListView.setItemsCanFocus(true);
|
||||
mAdapter = new MergeAdapter();
|
||||
final LayoutInflater inflater = getLayoutInflater(savedInstanceState);
|
||||
|
@ -587,9 +585,9 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
|
|||
clickedDrawable = clickedImageView.getDrawable();
|
||||
clickedColors = clickedImageView.getBorderColors();
|
||||
final ParcelableAccount oldSelectedAccount = mAccountsAdapter.getSelectedAccount();
|
||||
mImageLoader.displayDashboardProfileImage(clickedImageView,
|
||||
mMediaLoader.displayDashboardProfileImage(clickedImageView,
|
||||
oldSelectedAccount.profile_image_url, profileDrawable);
|
||||
// mImageLoader.displayDashboardProfileImage(profileImageView,
|
||||
// mMediaLoader.displayDashboardProfileImage(profileImageView,
|
||||
// account.profile_image_url, clickedDrawable);
|
||||
clickedImageView.setBorderColors(profileImageView.getBorderColors());
|
||||
mSwitchAccountAnimationPlaying = true;
|
||||
|
@ -638,7 +636,7 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
|
|||
}
|
||||
mAccountProfileNameView.setText(account.name);
|
||||
mAccountProfileScreenNameView.setText("@" + account.screen_name);
|
||||
mImageLoader.displayDashboardProfileImage(mAccountProfileImageView,
|
||||
mMediaLoader.displayDashboardProfileImage(mAccountProfileImageView,
|
||||
account.profile_image_url, profileImageSnapshot);
|
||||
mAccountProfileImageView.setBorderColors(account.color);
|
||||
final int bannerWidth = mAccountProfileBannerView.getWidth();
|
||||
|
@ -648,9 +646,9 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
|
|||
final String bannerUrl = Utils.getBestBannerUrl(account.profile_banner_url, width);
|
||||
final ImageView bannerView = mAccountProfileBannerView;
|
||||
if (bannerView.getDrawable() == null || !CompareUtils.objectEquals(bannerUrl, bannerView.getTag())) {
|
||||
mImageLoader.displayProfileBanner(mAccountProfileBannerView, bannerUrl, this);
|
||||
mMediaLoader.displayProfileBanner(mAccountProfileBannerView, bannerUrl, this);
|
||||
} else {
|
||||
mImageLoader.cancelDisplayTask(mAccountProfileBannerView);
|
||||
mMediaLoader.cancelDisplayTask(mAccountProfileBannerView);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -727,7 +725,7 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
|
|||
|
||||
AccountSelectorAdapter(Context context, LayoutInflater inflater, AccountsDashboardFragment fragment) {
|
||||
mInflater = inflater;
|
||||
mImageLoader = TwidereApplication.getInstance(context).getMediaLoaderWrapper();
|
||||
mImageLoader = fragment.mMediaLoader;
|
||||
mFragment = fragment;
|
||||
setHasStableIds(true);
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import android.support.v4.app.DialogFragment;
|
|||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.util.dagger.DaggerGeneralComponent;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -70,7 +71,7 @@ public class BaseSupportDialogFragment extends DialogFragment implements Constan
|
|||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
DaggerGeneralComponent.builder().applicationModule(TwidereApplication.getModule(context)).build().inject(this);
|
||||
DaggerGeneralComponent.builder().applicationModule(ApplicationModule.get(context)).build().inject(this);
|
||||
}
|
||||
|
||||
public void registerReceiver(final BroadcastReceiver receiver, final IntentFilter filter) {
|
||||
|
|
|
@ -42,9 +42,11 @@ import org.mariotaku.twidere.activity.support.BaseAppCompatActivity;
|
|||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.fragment.iface.IBaseFragment;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.MultiSelectManager;
|
||||
import org.mariotaku.twidere.util.ReadStateManager;
|
||||
import org.mariotaku.twidere.util.ThemedLayoutInflaterFactory;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.util.dagger.DaggerGeneralComponent;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -55,6 +57,8 @@ public class BaseSupportFragment extends Fragment implements IBaseFragment, Cons
|
|||
protected AsyncTwitterWrapper mTwitterWrapper;
|
||||
@Inject
|
||||
protected ReadStateManager mReadStateManager;
|
||||
@Inject
|
||||
protected MediaLoaderWrapper mMediaLoader;
|
||||
|
||||
public BaseSupportFragment() {
|
||||
|
||||
|
@ -70,7 +74,7 @@ public class BaseSupportFragment extends Fragment implements IBaseFragment, Cons
|
|||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
DaggerGeneralComponent.builder().applicationModule(TwidereApplication.getModule(context)).build().inject(this);
|
||||
DaggerGeneralComponent.builder().applicationModule(ApplicationModule.get(context)).build().inject(this);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -111,6 +111,7 @@ import org.mariotaku.twidere.util.SharedPreferencesWrapper;
|
|||
import org.mariotaku.twidere.util.TwidereValidator;
|
||||
import org.mariotaku.twidere.util.UserColorNameManager;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.util.message.TaskStateChangedEvent;
|
||||
import org.mariotaku.twidere.view.ComposeEditText;
|
||||
|
||||
|
@ -167,7 +168,6 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
|||
private TwidereValidator mValidator;
|
||||
private SharedPreferencesWrapper mPreferences;
|
||||
private SharedPreferences mMessageDrafts;
|
||||
private MediaLoaderWrapper mImageLoader;
|
||||
private UserColorNameManager mUserColorNameManager;
|
||||
private EffectViewHelper mEffectHelper;
|
||||
|
||||
|
@ -236,7 +236,6 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
|||
Context.MODE_PRIVATE, SharedPreferenceConstants.class);
|
||||
mUserColorNameManager = UserColorNameManager.getInstance(activity);
|
||||
mMessageDrafts = getSharedPreferences(MESSAGE_DRAFTS_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
mImageLoader = TwidereApplication.getInstance(activity).getMediaLoaderWrapper();
|
||||
mValidator = new TwidereValidator(activity);
|
||||
|
||||
final View view = getView();
|
||||
|
@ -911,7 +910,7 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
|||
private final ParcelableUser mRecipient;
|
||||
|
||||
public SetReadStateTask(Context context, ParcelableCredentials account, ParcelableUser recipient) {
|
||||
mReadStateManager = TwidereApplication.getModule(context).getReadStateManager();
|
||||
mReadStateManager = ApplicationModule.get(context).getReadStateManager();
|
||||
mContext = context;
|
||||
mAccount = account;
|
||||
mRecipient = recipient;
|
||||
|
|
|
@ -51,7 +51,6 @@ import android.support.v7.widget.LinearLayoutManager;
|
|||
import android.support.v7.widget.PopupMenu;
|
||||
import android.support.v7.widget.PopupMenu.OnMenuItemClickListener;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.RecyclerView.Adapter;
|
||||
import android.support.v7.widget.RecyclerView.LayoutParams;
|
||||
import android.support.v7.widget.RecyclerView.ViewHolder;
|
||||
import android.text.Html;
|
||||
|
@ -74,6 +73,7 @@ import org.apache.commons.lang3.ArrayUtils;
|
|||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.activity.support.ColorPickerDialogActivity;
|
||||
import org.mariotaku.twidere.adapter.AbsStatusesAdapter.StatusAdapterListener;
|
||||
import org.mariotaku.twidere.adapter.BaseAdapter;
|
||||
import org.mariotaku.twidere.adapter.decorator.DividerItemDecoration;
|
||||
import org.mariotaku.twidere.adapter.iface.IStatusesAdapter;
|
||||
import org.mariotaku.twidere.api.twitter.Twitter;
|
||||
|
@ -1038,7 +1038,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
}
|
||||
}
|
||||
|
||||
private static class StatusAdapter extends Adapter<ViewHolder> implements IStatusesAdapter<List<ParcelableStatus>> {
|
||||
private static class StatusAdapter extends BaseAdapter<ViewHolder> implements IStatusesAdapter<List<ParcelableStatus>> {
|
||||
|
||||
private static final int VIEW_TYPE_LIST_STATUS = 0;
|
||||
private static final int VIEW_TYPE_DETAIL_STATUS = 1;
|
||||
|
@ -1049,7 +1049,6 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
private final Context mContext;
|
||||
private final StatusFragment mFragment;
|
||||
private final LayoutInflater mInflater;
|
||||
private final MediaLoaderWrapper mImageLoader;
|
||||
private final MediaLoadingHandler mMediaLoadingHandler;
|
||||
private final TwidereLinkify mTwidereLinkify;
|
||||
|
||||
|
@ -1089,6 +1088,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
private DetailStatusViewHolder mStatusViewHolder;
|
||||
|
||||
public StatusAdapter(StatusFragment fragment, boolean compact) {
|
||||
super(fragment.getContext());
|
||||
setHasStableIds(true);
|
||||
final Context context = fragment.getActivity();
|
||||
final Resources res = context.getResources();
|
||||
|
@ -1100,7 +1100,6 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
mFragment = fragment;
|
||||
mContext = context;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mImageLoader = TwidereApplication.getInstance(context).getMediaLoaderWrapper();
|
||||
mUserColorNameManager = TwidereApplication.getInstance(context).getUserColorNameManager();
|
||||
mMediaLoadingHandler = new MediaLoadingHandler(R.id.media_preview_progress);
|
||||
mCardBackgroundColor = ThemeUtils.getCardBackgroundColor(context, ThemeUtils.getThemeBackgroundOption(context), ThemeUtils.getUserThemeBackgroundAlpha(context));
|
||||
|
@ -1169,7 +1168,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
@NonNull
|
||||
@Override
|
||||
public MediaLoaderWrapper getMediaLoader() {
|
||||
return mImageLoader;
|
||||
return mMediaLoader;
|
||||
}
|
||||
|
||||
public StatusFragment getFragment() {
|
||||
|
|
|
@ -121,7 +121,6 @@ import org.mariotaku.twidere.util.KeyboardShortcutsHandler;
|
|||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler.KeyboardShortcutCallback;
|
||||
import org.mariotaku.twidere.util.LinkCreator;
|
||||
import org.mariotaku.twidere.util.MathUtils;
|
||||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.MenuUtils;
|
||||
import org.mariotaku.twidere.util.ParseUtils;
|
||||
import org.mariotaku.twidere.util.SharedPreferencesWrapper;
|
||||
|
@ -175,7 +174,6 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
|
|||
private static final String TAB_TYPE_MEDIA = "media";
|
||||
private static final String TAB_TYPE_FAVORITES = "favorites";
|
||||
|
||||
private MediaLoaderWrapper mMediaLoader;
|
||||
private UserColorNameManager mUserColorNameManager;
|
||||
private SharedPreferencesWrapper mPreferences;
|
||||
|
||||
|
@ -693,7 +691,6 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
|
|||
ThemeUtils.getUserThemeBackgroundAlpha(activity));
|
||||
mActionBarShadowColor = 0xA0000000;
|
||||
final TwidereApplication app = TwidereApplication.getInstance(activity);
|
||||
mMediaLoader = app.getMediaLoaderWrapper();
|
||||
final Bundle args = getArguments();
|
||||
long accountId = -1, userId = -1;
|
||||
String screenName = null;
|
||||
|
|
|
@ -75,7 +75,6 @@ import org.mariotaku.twidere.model.SingleResponse;
|
|||
import org.mariotaku.twidere.text.validator.UserListNameValidator;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.LinkCreator;
|
||||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.OnLinkClickHandler;
|
||||
import org.mariotaku.twidere.util.ParseUtils;
|
||||
import org.mariotaku.twidere.util.SharedPreferencesWrapper;
|
||||
|
@ -95,9 +94,6 @@ public class UserListFragment extends BaseSupportFragment implements OnClickList
|
|||
LoaderCallbacks<SingleResponse<ParcelableUserList>>, SystemWindowsInsetsCallback,
|
||||
SupportFragmentCallback {
|
||||
|
||||
private MediaLoaderWrapper mProfileImageLoader;
|
||||
private AsyncTwitterWrapper mTwitterWrapper;
|
||||
|
||||
private ViewPager mViewPager;
|
||||
private TabPagerIndicator mPagerIndicator;
|
||||
private View mPagerOverlay;
|
||||
|
@ -213,7 +209,6 @@ public class UserListFragment extends BaseSupportFragment implements OnClickList
|
|||
super.onActivityCreated(savedInstanceState);
|
||||
final FragmentActivity activity = getActivity();
|
||||
final TwidereApplication application = TwidereApplication.getInstance(activity);
|
||||
mProfileImageLoader = application.getMediaLoaderWrapper();
|
||||
mUserColorNameManager = application.getUserColorNameManager();
|
||||
mPreferences = SharedPreferencesWrapper.getInstance(activity, SHARED_PREFERENCES_NAME,
|
||||
Context.MODE_PRIVATE, SharedPreferenceConstants.class);
|
||||
|
|
|
@ -7,7 +7,6 @@ import android.support.annotation.Nullable;
|
|||
import android.support.v4.app.LoaderManager.LoaderCallbacks;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.RecyclerView.Adapter;
|
||||
import android.support.v7.widget.RecyclerView.OnScrollListener;
|
||||
import android.support.v7.widget.RecyclerView.ViewHolder;
|
||||
import android.support.v7.widget.StaggeredGridLayoutManager;
|
||||
|
@ -18,12 +17,12 @@ import android.widget.ImageView;
|
|||
import android.widget.TextView;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.adapter.BaseAdapter;
|
||||
import org.mariotaku.twidere.loader.support.MediaTimelineLoader;
|
||||
import org.mariotaku.twidere.model.ParcelableMedia;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
import org.mariotaku.twidere.util.MediaLoadingHandler;
|
||||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.MediaLoadingHandler;
|
||||
import org.mariotaku.twidere.util.SimpleDrawerCallback;
|
||||
import org.mariotaku.twidere.view.HeaderDrawerLayout.DrawerCallback;
|
||||
import org.mariotaku.twidere.view.MediaSizeImageView;
|
||||
|
@ -157,16 +156,15 @@ public class UserMediaTimelineFragment extends BaseSupportFragment
|
|||
mAdapter.setData(null);
|
||||
}
|
||||
|
||||
private static class MediaTimelineAdapter extends Adapter<MediaTimelineViewHolder> {
|
||||
private static class MediaTimelineAdapter extends BaseAdapter<MediaTimelineViewHolder> {
|
||||
|
||||
private final LayoutInflater mInflater;
|
||||
private final MediaLoaderWrapper mImageLoader;
|
||||
private final MediaLoadingHandler mLoadingHandler;
|
||||
private List<ParcelableStatus> mData;
|
||||
|
||||
MediaTimelineAdapter(Context context) {
|
||||
super(context);
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mImageLoader = TwidereApplication.getInstance(context).getMediaLoaderWrapper();
|
||||
mLoadingHandler = new MediaLoadingHandler(R.id.media_image_progress);
|
||||
}
|
||||
|
||||
|
@ -179,7 +177,7 @@ public class UserMediaTimelineFragment extends BaseSupportFragment
|
|||
@Override
|
||||
public void onBindViewHolder(MediaTimelineViewHolder holder, int position) {
|
||||
if (mData == null) return;
|
||||
holder.setMedia(mImageLoader, mLoadingHandler, mData.get(position));
|
||||
holder.setMedia(mMediaLoader, mLoadingHandler, mData.get(position));
|
||||
}
|
||||
|
||||
public void setData(List<ParcelableStatus> data) {
|
||||
|
|
|
@ -90,7 +90,7 @@ public class UserProfileEditorFragment extends BaseSupportFragment implements On
|
|||
private static final int RESULT_REMOVE_BANNER = 101;
|
||||
private static final String UPDATE_PROFILE_DIALOG_FRAGMENT_TAG = "update_profile";
|
||||
|
||||
private MediaLoaderWrapper mLazyImageLoader;
|
||||
private MediaLoaderWrapper mMediaLoader;
|
||||
private AsyncTaskManager mAsyncTaskManager;
|
||||
private AsyncTask<Object, Object, ?> mTask;
|
||||
private ImageView mProfileImageView;
|
||||
|
@ -223,7 +223,6 @@ public class UserProfileEditorFragment extends BaseSupportFragment implements On
|
|||
setHasOptionsMenu(true);
|
||||
final TwidereApplication application = TwidereApplication.getInstance(getActivity());
|
||||
mAsyncTaskManager = application.getAsyncTaskManager();
|
||||
mLazyImageLoader = application.getMediaLoaderWrapper();
|
||||
final Bundle args = getArguments();
|
||||
final long accountId = args.getLong(EXTRA_ACCOUNT_ID, -1);
|
||||
mAccountId = accountId;
|
||||
|
@ -346,9 +345,9 @@ public class UserProfileEditorFragment extends BaseSupportFragment implements On
|
|||
mEditDescription.setText(user.description_expanded);
|
||||
mEditLocation.setText(user.location);
|
||||
mEditUrl.setText(isEmpty(user.url_expanded) ? user.url : user.url_expanded);
|
||||
mLazyImageLoader.displayProfileImage(mProfileImageView, user.profile_image_url);
|
||||
mMediaLoader.displayProfileImage(mProfileImageView, user.profile_image_url);
|
||||
final int def_width = getResources().getDisplayMetrics().widthPixels;
|
||||
mLazyImageLoader.displayProfileBanner(mProfileBannerView, user.profile_banner_url, def_width);
|
||||
mMediaLoader.displayProfileBanner(mProfileBannerView, user.profile_banner_url, def_width);
|
||||
mLinkColor.setColor(user.link_color);
|
||||
mBackgroundColor.setColor(user.background_color);
|
||||
} else {
|
||||
|
|
|
@ -40,11 +40,11 @@ import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
|
|||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.model.ParcelableAccount;
|
||||
import org.mariotaku.twidere.util.AsyncTaskUtils;
|
||||
import org.mariotaku.twidere.util.BitmapUtils;
|
||||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -105,8 +105,7 @@ public abstract class AccountsListPreference extends PreferenceCategory implemen
|
|||
final String switchPreferenceName = ACCOUNT_PREFERENCES_NAME_PREFIX + account.account_id;
|
||||
mAccount = account;
|
||||
mSwitchPreference = context.getSharedPreferences(switchPreferenceName, Context.MODE_PRIVATE);
|
||||
final TwidereApplication app = TwidereApplication.getInstance(context);
|
||||
mImageLoader = app.getMediaLoaderWrapper();
|
||||
mImageLoader = ApplicationModule.get(context).getMediaLoaderWrapper();
|
||||
mSwitchPreference.registerOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,10 +29,10 @@ import android.net.Uri;
|
|||
import android.support.annotation.NonNull;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.provider.TwidereCommands.Refresh;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.PermissionsManager;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.util.dagger.DaggerGeneralComponent;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -75,7 +75,7 @@ public class TwidereCommandProvider extends ContentProvider implements Constants
|
|||
@Override
|
||||
public boolean onCreate() {
|
||||
mContext = getContext();
|
||||
DaggerGeneralComponent.builder().applicationModule(TwidereApplication.getModule(mContext)).build().inject(this);
|
||||
DaggerGeneralComponent.builder().applicationModule(ApplicationModule.get(mContext)).build().inject(this);
|
||||
mPermissionsManager = new PermissionsManager(mContext);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ import android.text.SpannableStringBuilder;
|
|||
import android.text.style.StyleSpan;
|
||||
import android.util.Log;
|
||||
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.squareup.okhttp.internal.Network;
|
||||
import com.squareup.otto.Bus;
|
||||
|
||||
|
@ -109,6 +110,7 @@ import org.mariotaku.twidere.util.TwidereQueryBuilder.ConversationQueryBuilder;
|
|||
import org.mariotaku.twidere.util.UserColorNameManager;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.util.collection.CompactHashSet;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.util.dagger.DaggerGeneralComponent;
|
||||
import org.mariotaku.twidere.util.message.UnreadCountUpdatedEvent;
|
||||
|
||||
|
@ -148,6 +150,8 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
|
|||
ReadStateManager mReadStateManager;
|
||||
@Inject
|
||||
AsyncTwitterWrapper mTwitterWrapper;
|
||||
@Inject
|
||||
ImageLoader mMediaLoader;
|
||||
private SharedPreferencesWrapper mPreferences;
|
||||
private ImagePreloader mImagePreloader;
|
||||
private Network mNetwork;
|
||||
|
@ -418,7 +422,7 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
|
|||
@Override
|
||||
public boolean onCreate() {
|
||||
final Context context = getContext();
|
||||
DaggerGeneralComponent.builder().applicationModule(TwidereApplication.getModule(context)).build().inject(this);
|
||||
DaggerGeneralComponent.builder().applicationModule(ApplicationModule.get(context)).build().inject(this);
|
||||
final TwidereApplication app = TwidereApplication.getInstance(context);
|
||||
mHandler = new Handler(Looper.getMainLooper());
|
||||
mDatabaseWrapper = new SQLiteDatabaseWrapper(this);
|
||||
|
@ -427,7 +431,7 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
|
|||
mPreferences.registerOnSharedPreferenceChangeListener(this);
|
||||
updatePreferences();
|
||||
mPermissionsManager = new PermissionsManager(context);
|
||||
mImagePreloader = new ImagePreloader(context, app.getImageLoader());
|
||||
mImagePreloader = new ImagePreloader(context, mMediaLoader);
|
||||
final IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(BROADCAST_HOME_ACTIVITY_ONSTART);
|
||||
filter.addAction(BROADCAST_HOME_ACTIVITY_ONSTOP);
|
||||
|
|
|
@ -27,11 +27,11 @@ import android.support.annotation.NonNull;
|
|||
import android.text.TextUtils;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.model.StringLongPair;
|
||||
import org.mariotaku.twidere.util.ParseUtils;
|
||||
import org.mariotaku.twidere.util.ReadStateManager;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/4/4.
|
||||
|
@ -48,7 +48,7 @@ public class NotificationReceiver extends BroadcastReceiver implements Constants
|
|||
final String tag = getPositionTag(uri.getLastPathSegment());
|
||||
if (tag == null) return;
|
||||
final long accountId = ParseUtils.parseLong(uri.getQueryParameter(QUERY_PARAM_ACCOUNT_ID), -1);
|
||||
final ReadStateManager manager = TwidereApplication.getModule(context).getReadStateManager();
|
||||
final ReadStateManager manager = ApplicationModule.get(context).getReadStateManager();
|
||||
final String paramReadPosition, paramReadPositions;
|
||||
if (!TextUtils.isEmpty(paramReadPosition = uri.getQueryParameter(QUERY_PARAM_READ_POSITION))) {
|
||||
manager.setPosition(Utils.getReadPositionTagWithAccounts(tag, accountId),
|
||||
|
|
|
@ -85,6 +85,7 @@ import org.mariotaku.twidere.util.StatusShortenerInterface;
|
|||
import org.mariotaku.twidere.util.TwidereValidator;
|
||||
import org.mariotaku.twidere.util.TwitterAPIFactory;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.util.dagger.DaggerGeneralComponent;
|
||||
import org.mariotaku.twidere.util.io.ContentLengthInputStream;
|
||||
import org.mariotaku.twidere.util.io.ContentLengthInputStream.ReadListener;
|
||||
|
@ -132,7 +133,7 @@ public class BackgroundOperationService extends IntentService implements Constan
|
|||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
DaggerGeneralComponent.builder().applicationModule(TwidereApplication.getModule(this)).build().inject(this);
|
||||
DaggerGeneralComponent.builder().applicationModule(ApplicationModule.get(this)).build().inject(this);
|
||||
final TwidereApplication app = TwidereApplication.getInstance(this);
|
||||
mHandler = new Handler();
|
||||
mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, MODE_PRIVATE);
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.mariotaku.twidere.provider.TwidereDataStore.Statuses;
|
|||
import org.mariotaku.twidere.receiver.PowerStateReceiver;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.SharedPreferencesWrapper;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.util.dagger.DaggerGeneralComponent;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
@ -152,7 +153,7 @@ public class RefreshService extends Service implements Constants {
|
|||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
DaggerGeneralComponent.builder().applicationModule(TwidereApplication.getModule(this)).build().inject(this);
|
||||
DaggerGeneralComponent.builder().applicationModule(ApplicationModule.get(this)).build().inject(this);
|
||||
mAlarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
|
||||
final TwidereApplication app = TwidereApplication.getInstance(this);
|
||||
mPreferences = SharedPreferencesWrapper.getInstance(app, SHARED_PREFERENCES_NAME, MODE_PRIVATE);
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.mariotaku.twidere.model.ParcelableAccount;
|
|||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
import org.mariotaku.twidere.model.ParcelableUser;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Filters;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.util.dagger.DaggerGeneralComponent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -75,7 +76,7 @@ public class MultiSelectEventHandler implements Constants, ActionMode.Callback,
|
|||
public static final int MENU_GROUP = 201;
|
||||
|
||||
public MultiSelectEventHandler(final BaseAppCompatActivity activity) {
|
||||
DaggerGeneralComponent.builder().applicationModule(TwidereApplication.getModule(activity)).build().inject(this);
|
||||
DaggerGeneralComponent.builder().applicationModule(ApplicationModule.get(activity)).build().inject(this);
|
||||
mActivity = activity;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,10 +19,20 @@
|
|||
|
||||
package org.mariotaku.twidere.util.dagger;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
|
||||
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
|
||||
import com.nostra13.universalimageloader.utils.L;
|
||||
|
||||
import org.mariotaku.twidere.BuildConfig;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.util.ActivityTracker;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.ReadStateManager;
|
||||
import org.mariotaku.twidere.util.VideoLoader;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
@ -36,37 +46,64 @@ public class ApplicationModule {
|
|||
private final ActivityTracker activityTracker;
|
||||
private final AsyncTwitterWrapper asyncTwitterWrapper;
|
||||
private final ReadStateManager readStateManager;
|
||||
private final MediaLoaderWrapper mediaLoaderWrapper;
|
||||
private final ImageLoader imageLoader;
|
||||
private final VideoLoader videoLoader;
|
||||
|
||||
public ApplicationModule(TwidereApplication application) {
|
||||
activityTracker = new ActivityTracker();
|
||||
asyncTwitterWrapper = new AsyncTwitterWrapper(application);
|
||||
readStateManager = new ReadStateManager(application);
|
||||
imageLoader = createImageLoader(application);
|
||||
videoLoader = new VideoLoader(application);
|
||||
mediaLoaderWrapper = new MediaLoaderWrapper(imageLoader, videoLoader);
|
||||
}
|
||||
|
||||
public static ApplicationModule get(Context context) {
|
||||
return TwidereApplication.getInstance(context).getApplicationModule();
|
||||
}
|
||||
|
||||
@Provides
|
||||
ActivityTracker provideActivityStack() {
|
||||
return activityTracker;
|
||||
public ImageLoader getImageLoader() {
|
||||
return imageLoader;
|
||||
}
|
||||
|
||||
@Provides
|
||||
AsyncTwitterWrapper provideAsyncTwitterWrapper() {
|
||||
return asyncTwitterWrapper;
|
||||
public VideoLoader getVideoLoader() {
|
||||
return videoLoader;
|
||||
}
|
||||
|
||||
@Provides
|
||||
ReadStateManager provideReadStateManager() {
|
||||
return readStateManager;
|
||||
}
|
||||
|
||||
public ActivityTracker getActivityTracker() {
|
||||
return activityTracker;
|
||||
}
|
||||
|
||||
@Provides
|
||||
public AsyncTwitterWrapper getAsyncTwitterWrapper() {
|
||||
return asyncTwitterWrapper;
|
||||
}
|
||||
|
||||
@Provides
|
||||
public ReadStateManager getReadStateManager() {
|
||||
return readStateManager;
|
||||
}
|
||||
|
||||
@Provides
|
||||
public MediaLoaderWrapper getMediaLoaderWrapper() {
|
||||
return mediaLoaderWrapper;
|
||||
}
|
||||
|
||||
private static ImageLoader createImageLoader(TwidereApplication application) {
|
||||
final ImageLoader loader = ImageLoader.getInstance();
|
||||
final ImageLoaderConfiguration.Builder cb = new ImageLoaderConfiguration.Builder(application);
|
||||
cb.threadPriority(Thread.NORM_PRIORITY - 2);
|
||||
cb.denyCacheImageMultipleSizesInMemory();
|
||||
cb.tasksProcessingOrder(QueueProcessingType.LIFO);
|
||||
// cb.memoryCache(new ImageMemoryCache(40));
|
||||
cb.diskCache(application.getDiskCache());
|
||||
cb.imageDownloader(application.getImageDownloader());
|
||||
L.writeDebugLogs(BuildConfig.DEBUG);
|
||||
loader.init(cb.build());
|
||||
return loader;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,12 @@ import org.mariotaku.twidere.activity.BasePreferenceActivity;
|
|||
import org.mariotaku.twidere.activity.BaseThemedActivity;
|
||||
import org.mariotaku.twidere.activity.support.BaseAppCompatActivity;
|
||||
import org.mariotaku.twidere.activity.support.ThemedFragmentActivity;
|
||||
import org.mariotaku.twidere.adapter.AccountsAdapter;
|
||||
import org.mariotaku.twidere.adapter.AccountsSpinnerAdapter;
|
||||
import org.mariotaku.twidere.adapter.BaseAdapter;
|
||||
import org.mariotaku.twidere.adapter.BaseArrayAdapter;
|
||||
import org.mariotaku.twidere.adapter.DraftsAdapter;
|
||||
import org.mariotaku.twidere.adapter.UserHashtagAutoCompleteAdapter;
|
||||
import org.mariotaku.twidere.fragment.BaseFragment;
|
||||
import org.mariotaku.twidere.fragment.BaseListFragment;
|
||||
import org.mariotaku.twidere.fragment.support.BaseSupportDialogFragment;
|
||||
|
@ -73,4 +78,14 @@ public interface GeneralComponent {
|
|||
void inject(BackgroundOperationService object);
|
||||
|
||||
void inject(BaseAdapter<RecyclerView.ViewHolder> object);
|
||||
|
||||
void inject(AccountsAdapter object);
|
||||
|
||||
void inject(UserHashtagAutoCompleteAdapter object);
|
||||
|
||||
void inject(AccountsSpinnerAdapter object);
|
||||
|
||||
void inject(BaseArrayAdapter<Object> object);
|
||||
|
||||
void inject(DraftsAdapter object);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.mariotaku.twidere.util.TwidereLinkify;
|
|||
import org.mariotaku.twidere.util.TwitterCardUtils;
|
||||
import org.mariotaku.twidere.util.UserColorNameManager;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.util.dagger.DaggerGeneralComponent;
|
||||
import org.mariotaku.twidere.view.CardMediaContainer;
|
||||
import org.mariotaku.twidere.view.CardMediaContainer.OnMediaClickListener;
|
||||
|
@ -452,7 +453,8 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi
|
|||
|
||||
private final Context context;
|
||||
private final SharedPreferencesWrapper preferences;
|
||||
private final MediaLoaderWrapper loader;
|
||||
@Inject
|
||||
MediaLoaderWrapper loader;
|
||||
private final MediaLoadingHandler handler;
|
||||
@Inject
|
||||
AsyncTwitterWrapper twitter;
|
||||
|
@ -471,11 +473,10 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi
|
|||
private boolean shouldShowAccountsColor;
|
||||
|
||||
public DummyStatusHolderAdapter(Context context) {
|
||||
DaggerGeneralComponent.builder().applicationModule(TwidereApplication.getModule(context)).build().inject(this);
|
||||
DaggerGeneralComponent.builder().applicationModule(ApplicationModule.get(context)).build().inject(this);
|
||||
this.context = context;
|
||||
preferences = SharedPreferencesWrapper.getInstance(context, SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
final TwidereApplication app = TwidereApplication.getInstance(context);
|
||||
loader = app.getMediaLoaderWrapper();
|
||||
handler = new MediaLoadingHandler(R.id.media_preview_progress);
|
||||
manager = app.getUserColorNameManager();
|
||||
linkify = new TwidereLinkify(null);
|
||||
|
|
Loading…
Reference in New Issue