mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-02-12 01:30:43 +01:00
using dagger to retrive image loader
This commit is contained in:
parent
b5db451c75
commit
1ff43a360d
@ -66,7 +66,6 @@ import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.adapter.support.SupportFixedFragmentStatePagerAdapter;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.fragment.support.BaseSupportFragment;
|
||||
import org.mariotaku.twidere.fragment.support.ViewStatusDialogFragment;
|
||||
import org.mariotaku.twidere.loader.support.TileImageLoader;
|
||||
@ -81,7 +80,6 @@ import org.mariotaku.twidere.util.MenuUtils;
|
||||
import org.mariotaku.twidere.util.SaveFileTask;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.util.VideoLoader;
|
||||
import org.mariotaku.twidere.util.VideoLoader.VideoLoadingListener;
|
||||
|
||||
import java.io.File;
|
||||
@ -584,8 +582,6 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
||||
}
|
||||
}
|
||||
|
||||
private VideoLoader mVideoLoader;
|
||||
|
||||
private TextureVideoView mVideoView;
|
||||
private View mVideoViewOverlay;
|
||||
private SeekBar mVideoViewProgress;
|
||||
@ -734,7 +730,6 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
setHasOptionsMenu(true);
|
||||
mVideoLoader = TwidereApplication.getInstance(getActivity()).getVideoLoader();
|
||||
|
||||
Handler handler = mVideoViewProgress.getHandler();
|
||||
if (handler == null) {
|
||||
|
@ -36,11 +36,6 @@ import android.support.multidex.MultiDexApplication;
|
||||
|
||||
import com.nostra13.universalimageloader.cache.disc.DiskCache;
|
||||
import com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
|
||||
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
|
||||
import com.nostra13.universalimageloader.core.download.ImageDownloader;
|
||||
import com.nostra13.universalimageloader.utils.L;
|
||||
import com.squareup.okhttp.internal.Network;
|
||||
import com.squareup.otto.Bus;
|
||||
|
||||
@ -52,7 +47,6 @@ import org.mariotaku.twidere.activity.MainActivity;
|
||||
import org.mariotaku.twidere.activity.MainHondaJOJOActivity;
|
||||
import org.mariotaku.twidere.service.RefreshService;
|
||||
import org.mariotaku.twidere.util.AbsLogger;
|
||||
import org.mariotaku.twidere.util.AsyncTaskManager;
|
||||
import org.mariotaku.twidere.util.DebugModeUtils;
|
||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler;
|
||||
import org.mariotaku.twidere.util.MathUtils;
|
||||
@ -61,13 +55,11 @@ import org.mariotaku.twidere.util.StrictModeUtils;
|
||||
import org.mariotaku.twidere.util.TwidereLogger;
|
||||
import org.mariotaku.twidere.util.UserColorNameManager;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.util.VideoLoader;
|
||||
import org.mariotaku.twidere.util.content.TwidereSQLiteOpenHelper;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.util.imageloader.ReadOnlyDiskLRUNameCache;
|
||||
import org.mariotaku.twidere.util.imageloader.TwidereImageDownloader;
|
||||
import org.mariotaku.twidere.util.imageloader.URLFileNameGenerator;
|
||||
import org.mariotaku.twidere.util.net.TwidereHostAddressResolver;
|
||||
import org.mariotaku.twidere.util.net.TwidereNetwork;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -89,16 +81,13 @@ public class TwidereApplication extends MultiDexApplication implements Constants
|
||||
private static final String KEY_KEYBOARD_SHORTCUT_INITIALIZED = "keyboard_shortcut_initialized";
|
||||
|
||||
private Handler mHandler;
|
||||
private AsyncTaskManager mAsyncTaskManager;
|
||||
private SharedPreferences mPreferences;
|
||||
private MultiSelectManager mMultiSelectManager;
|
||||
private TwidereImageDownloader mImageDownloader, mFullImageDownloader;
|
||||
private DiskCache mDiskCache, mFullDiskCache;
|
||||
private SQLiteOpenHelper mSQLiteOpenHelper;
|
||||
private Network mNetwork;
|
||||
private SQLiteDatabase mDatabase;
|
||||
private Bus mMessageBus;
|
||||
private VideoLoader mVideoLoader;
|
||||
private KeyboardShortcutsHandler mKeyboardShortcutsHandler;
|
||||
private UserColorNameManager mUserColorNameManager;
|
||||
|
||||
@ -110,11 +99,6 @@ public class TwidereApplication extends MultiDexApplication implements Constants
|
||||
return (TwidereApplication) context.getApplicationContext();
|
||||
}
|
||||
|
||||
public AsyncTaskManager getAsyncTaskManager() {
|
||||
if (mAsyncTaskManager != null) return mAsyncTaskManager;
|
||||
return mAsyncTaskManager = AsyncTaskManager.getInstance();
|
||||
}
|
||||
|
||||
public DiskCache getDiskCache() {
|
||||
if (mDiskCache != null) return mDiskCache;
|
||||
return mDiskCache = createDiskCache(DIR_NAME_IMAGE_CACHE);
|
||||
@ -130,18 +114,13 @@ public class TwidereApplication extends MultiDexApplication implements Constants
|
||||
return mUserColorNameManager = new UserColorNameManager(this);
|
||||
}
|
||||
|
||||
public ImageDownloader getFullImageDownloader() {
|
||||
if (mFullImageDownloader != null) return mFullImageDownloader;
|
||||
return mFullImageDownloader = new TwidereImageDownloader(this, true, true);
|
||||
}
|
||||
|
||||
public Handler getHandler() {
|
||||
return mHandler;
|
||||
}
|
||||
|
||||
public Network getNetwork() {
|
||||
if (mNetwork != null) return mNetwork;
|
||||
return mNetwork = new TwidereHostAddressResolver(this);
|
||||
return mNetwork = new TwidereNetwork(this);
|
||||
}
|
||||
|
||||
public KeyboardShortcutsHandler getKeyboardShortcutsHandler() {
|
||||
@ -155,18 +134,6 @@ public class TwidereApplication extends MultiDexApplication implements Constants
|
||||
return mKeyboardShortcutsHandler;
|
||||
}
|
||||
|
||||
public ImageDownloader getImageDownloader() {
|
||||
if (mImageDownloader != null) return mImageDownloader;
|
||||
return mImageDownloader = new TwidereImageDownloader(this, false, true);
|
||||
}
|
||||
|
||||
|
||||
public VideoLoader getVideoLoader() {
|
||||
if (mVideoLoader != null) return mVideoLoader;
|
||||
final VideoLoader loader = new VideoLoader(this);
|
||||
return mVideoLoader = loader;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Bus getMessageBus() {
|
||||
return mMessageBus;
|
||||
@ -286,12 +253,7 @@ public class TwidereApplication extends MultiDexApplication implements Constants
|
||||
}
|
||||
|
||||
public void reloadConnectivitySettings() {
|
||||
if (mImageDownloader != null) {
|
||||
mImageDownloader.reloadConnectivitySettings();
|
||||
}
|
||||
if (mFullImageDownloader != null) {
|
||||
mFullImageDownloader.reloadConnectivitySettings();
|
||||
}
|
||||
ApplicationModule.get(this).getImageDownloader().reloadConnectivitySettings();
|
||||
}
|
||||
|
||||
private DiskCache createDiskCache(final String dirName) {
|
||||
|
@ -46,6 +46,7 @@ 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.VideoLoader;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.util.dagger.DaggerGeneralComponent;
|
||||
|
||||
@ -59,6 +60,8 @@ public class BaseSupportFragment extends Fragment implements IBaseFragment, Cons
|
||||
protected ReadStateManager mReadStateManager;
|
||||
@Inject
|
||||
protected MediaLoaderWrapper mMediaLoader;
|
||||
@Inject
|
||||
protected VideoLoader mVideoLoader;
|
||||
|
||||
public BaseSupportFragment() {
|
||||
|
||||
|
@ -56,7 +56,6 @@ import org.mariotaku.twidere.api.twitter.Twitter;
|
||||
import org.mariotaku.twidere.api.twitter.TwitterException;
|
||||
import org.mariotaku.twidere.api.twitter.model.ProfileUpdate;
|
||||
import org.mariotaku.twidere.api.twitter.model.User;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.loader.support.ParcelableUserLoader;
|
||||
import org.mariotaku.twidere.model.ParcelableUser;
|
||||
import org.mariotaku.twidere.model.SingleResponse;
|
||||
@ -71,6 +70,7 @@ import org.mariotaku.twidere.util.TwitterAPIFactory;
|
||||
import org.mariotaku.twidere.util.TwitterValidatorMETLengthChecker;
|
||||
import org.mariotaku.twidere.util.TwitterWrapper;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.view.ForegroundColorView;
|
||||
import org.mariotaku.twidere.view.iface.IExtendedView.OnSizeChangedListener;
|
||||
|
||||
@ -221,8 +221,7 @@ public class UserProfileEditorFragment extends BaseSupportFragment implements On
|
||||
public void onActivityCreated(final Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
setHasOptionsMenu(true);
|
||||
final TwidereApplication application = TwidereApplication.getInstance(getActivity());
|
||||
mAsyncTaskManager = application.getAsyncTaskManager();
|
||||
mAsyncTaskManager = ApplicationModule.get(getContext()).getAsyncTaskManager();
|
||||
final Bundle args = getArguments();
|
||||
final long accountId = args.getLong(EXTRA_ACCOUNT_ID, -1);
|
||||
mAccountId = accountId;
|
||||
|
@ -38,7 +38,9 @@ import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.util.BitmapUtils;
|
||||
import org.mariotaku.twidere.util.Exif;
|
||||
import org.mariotaku.twidere.util.ImageValidator;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.util.imageloader.AccountExtra;
|
||||
import org.mariotaku.twidere.util.imageloader.AccountFullImageExtra;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -62,7 +64,7 @@ public class TileImageLoader extends AsyncTaskLoader<TileImageLoader.Result> {
|
||||
mUri = uri;
|
||||
mListener = listener;
|
||||
final TwidereApplication app = TwidereApplication.getInstance(context);
|
||||
mDownloader = app.getFullImageDownloader();
|
||||
mDownloader = ApplicationModule.get(context).getImageDownloader();
|
||||
mDiskCache = app.getFullDiskCache();
|
||||
final Resources res = context.getResources();
|
||||
final DisplayMetrics dm = res.getDisplayMetrics();
|
||||
@ -89,7 +91,7 @@ public class TileImageLoader extends AsyncTaskLoader<TileImageLoader.Result> {
|
||||
}
|
||||
try {
|
||||
// from SD cache
|
||||
final InputStream is = mDownloader.getStream(url, new AccountExtra(mAccountId));
|
||||
final InputStream is = mDownloader.getStream(url, new AccountFullImageExtra(mAccountId));
|
||||
if (is == null) return Result.nullInstance();
|
||||
try {
|
||||
final long length = is.available();
|
||||
|
@ -154,6 +154,7 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
|
||||
ImageLoader mMediaLoader;
|
||||
private SharedPreferencesWrapper mPreferences;
|
||||
private ImagePreloader mImagePreloader;
|
||||
@Inject
|
||||
private Network mNetwork;
|
||||
private Handler mHandler;
|
||||
|
||||
@ -423,10 +424,8 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
|
||||
public boolean onCreate() {
|
||||
final Context context = getContext();
|
||||
DaggerGeneralComponent.builder().applicationModule(ApplicationModule.get(context)).build().inject(this);
|
||||
final TwidereApplication app = TwidereApplication.getInstance(context);
|
||||
mHandler = new Handler(Looper.getMainLooper());
|
||||
mDatabaseWrapper = new SQLiteDatabaseWrapper(this);
|
||||
mNetwork = app.getNetwork();
|
||||
mPreferences = SharedPreferencesWrapper.getInstance(context, SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
mPreferences.registerOnSharedPreferenceChangeListener(this);
|
||||
updatePreferences();
|
||||
|
@ -21,6 +21,7 @@ package org.mariotaku.twidere.util;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
|
||||
import org.mariotaku.twidere.task.ManagedAsyncTask;
|
||||
|
||||
@ -38,7 +39,7 @@ public final class AsyncTaskManager {
|
||||
private static AsyncTaskManager sInstance;
|
||||
|
||||
AsyncTaskManager() {
|
||||
this(new Handler());
|
||||
this(new Handler(Looper.getMainLooper()));
|
||||
}
|
||||
|
||||
AsyncTaskManager(final Handler handler) {
|
||||
|
@ -72,7 +72,8 @@ import org.mariotaku.twidere.model.ParcelableUser;
|
||||
import org.mariotaku.twidere.model.ParcelableUserList;
|
||||
import org.mariotaku.twidere.model.SingleResponse;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.*;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.CachedHashtags;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.CachedRelationships;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.CachedTrends;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.DirectMessages;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.DirectMessages.Inbox;
|
||||
@ -86,6 +87,7 @@ import org.mariotaku.twidere.task.CacheUsersStatusesTask;
|
||||
import org.mariotaku.twidere.task.ManagedAsyncTask;
|
||||
import org.mariotaku.twidere.util.collection.LongSparseMap;
|
||||
import org.mariotaku.twidere.util.content.ContentResolverUtils;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.util.message.FavoriteCreatedEvent;
|
||||
import org.mariotaku.twidere.util.message.FavoriteDestroyedEvent;
|
||||
import org.mariotaku.twidere.util.message.FriendshipUpdatedEvent;
|
||||
@ -130,8 +132,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
public AsyncTwitterWrapper(final Context context) {
|
||||
mContext = context;
|
||||
final TwidereApplication app = TwidereApplication.getInstance(context);
|
||||
mAsyncTaskManager = app.getAsyncTaskManager();
|
||||
mAsyncTaskManager = ApplicationModule.get(context).getAsyncTaskManager();
|
||||
mPreferences = SharedPreferencesWrapper.getInstance(context, SHARED_PREFERENCES_NAME,
|
||||
Context.MODE_PRIVATE, SharedPreferenceConstants.class);
|
||||
mResolver = context.getContentResolver();
|
||||
|
@ -47,6 +47,7 @@ import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.model.ConsumerKeyType;
|
||||
import org.mariotaku.twidere.model.ParcelableCredentials;
|
||||
import org.mariotaku.twidere.model.RequestType;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.util.net.OkHttpRestClient;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
@ -127,7 +128,7 @@ public class TwitterAPIFactory implements TwidereConstants {
|
||||
if (enableProxy) {
|
||||
client.setProxy(getProxy(prefs));
|
||||
}
|
||||
Internal.instance.setNetwork(client, TwidereApplication.getInstance(context).getNetwork());
|
||||
Internal.instance.setNetwork(client, ApplicationModule.get(context).getNetwork());
|
||||
return new OkHttpRestClient(context, client);
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ import com.squareup.otto.Bus;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.model.SingleResponse;
|
||||
import org.mariotaku.twidere.task.ManagedAsyncTask;
|
||||
import org.mariotaku.twidere.util.dagger.ApplicationModule;
|
||||
import org.mariotaku.twidere.util.imageloader.TwidereImageDownloader;
|
||||
import org.mariotaku.twidere.util.message.VideoLoadFinishedEvent;
|
||||
|
||||
@ -53,8 +54,8 @@ public class VideoLoader {
|
||||
final TwidereApplication app = TwidereApplication.getInstance(context);
|
||||
mContext = context;
|
||||
mDiskCache = app.getDiskCache();
|
||||
mImageDownloader = new TwidereImageDownloader(context, false, false);
|
||||
mTaskManager = app.getAsyncTaskManager();
|
||||
mImageDownloader = new TwidereImageDownloader(context, false);
|
||||
mTaskManager = ApplicationModule.get(context).getAsyncTaskManager();
|
||||
mBus = app.getMessageBus();
|
||||
}
|
||||
|
||||
|
@ -25,14 +25,18 @@ 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 com.squareup.okhttp.internal.Network;
|
||||
|
||||
import org.mariotaku.twidere.BuildConfig;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.util.ActivityTracker;
|
||||
import org.mariotaku.twidere.util.AsyncTaskManager;
|
||||
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 org.mariotaku.twidere.util.imageloader.TwidereImageDownloader;
|
||||
import org.mariotaku.twidere.util.net.TwidereNetwork;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
@ -46,23 +50,34 @@ 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;
|
||||
private final ImageLoader imageLoader;
|
||||
private final MediaLoaderWrapper mediaLoaderWrapper;
|
||||
private final TwidereImageDownloader imageDownloader;
|
||||
private final AsyncTaskManager asyncTaskManager;
|
||||
private final Network network;
|
||||
|
||||
public ApplicationModule(TwidereApplication application) {
|
||||
activityTracker = new ActivityTracker();
|
||||
asyncTwitterWrapper = new AsyncTwitterWrapper(application);
|
||||
readStateManager = new ReadStateManager(application);
|
||||
imageLoader = createImageLoader(application);
|
||||
imageDownloader = new TwidereImageDownloader(application, true);
|
||||
imageLoader = createImageLoader(application, imageDownloader);
|
||||
videoLoader = new VideoLoader(application);
|
||||
mediaLoaderWrapper = new MediaLoaderWrapper(imageLoader, videoLoader);
|
||||
asyncTaskManager = AsyncTaskManager.getInstance();
|
||||
network = new TwidereNetwork(application);
|
||||
}
|
||||
|
||||
public static ApplicationModule get(Context context) {
|
||||
return TwidereApplication.getInstance(context).getApplicationModule();
|
||||
}
|
||||
|
||||
@Provides
|
||||
public AsyncTaskManager getAsyncTaskManager() {
|
||||
return asyncTaskManager;
|
||||
}
|
||||
|
||||
@Provides
|
||||
public ImageLoader getImageLoader() {
|
||||
return imageLoader;
|
||||
@ -73,6 +88,11 @@ public class ApplicationModule {
|
||||
return videoLoader;
|
||||
}
|
||||
|
||||
@Provides
|
||||
public TwidereImageDownloader getImageDownloader() {
|
||||
return imageDownloader;
|
||||
}
|
||||
|
||||
@Provides
|
||||
public ActivityTracker getActivityTracker() {
|
||||
return activityTracker;
|
||||
@ -93,7 +113,7 @@ public class ApplicationModule {
|
||||
return mediaLoaderWrapper;
|
||||
}
|
||||
|
||||
private static ImageLoader createImageLoader(TwidereApplication application) {
|
||||
private static ImageLoader createImageLoader(TwidereApplication application, TwidereImageDownloader imageDownloader) {
|
||||
final ImageLoader loader = ImageLoader.getInstance();
|
||||
final ImageLoaderConfiguration.Builder cb = new ImageLoaderConfiguration.Builder(application);
|
||||
cb.threadPriority(Thread.NORM_PRIORITY - 2);
|
||||
@ -101,9 +121,14 @@ public class ApplicationModule {
|
||||
cb.tasksProcessingOrder(QueueProcessingType.LIFO);
|
||||
// cb.memoryCache(new ImageMemoryCache(40));
|
||||
cb.diskCache(application.getDiskCache());
|
||||
cb.imageDownloader(application.getImageDownloader());
|
||||
cb.imageDownloader(imageDownloader);
|
||||
L.writeDebugLogs(BuildConfig.DEBUG);
|
||||
loader.init(cb.build());
|
||||
return loader;
|
||||
}
|
||||
|
||||
@Provides
|
||||
public Network getNetwork() {
|
||||
return network;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.util.imageloader;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/10/5.
|
||||
*/
|
||||
public class AccountFullImageExtra extends AccountExtra implements FullImageExtra {
|
||||
public AccountFullImageExtra(long accountId) {
|
||||
super(accountId);
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.util.imageloader;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/10/5.
|
||||
*/
|
||||
public interface FullImageExtra {
|
||||
}
|
@ -71,15 +71,13 @@ public class TwidereImageDownloader extends BaseImageDownloader implements Const
|
||||
private final String mUserAgent;
|
||||
private Thumbor mThumbor;
|
||||
private RestHttpClient mClient;
|
||||
private final boolean mFullImage;
|
||||
private final String mTwitterProfileImageSize;
|
||||
|
||||
public TwidereImageDownloader(final Context context, final boolean fullImage, final boolean useThumbor) {
|
||||
public TwidereImageDownloader(final Context context, final boolean useThumbor) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
mPreferences = SharedPreferencesWrapper.getInstance(context, SHARED_PREFERENCES_NAME,
|
||||
Context.MODE_PRIVATE, SharedPreferenceConstants.class);
|
||||
mFullImage = fullImage;
|
||||
mTwitterProfileImageSize = context.getString(R.string.profile_image_size);
|
||||
mUseThumbor = useThumbor;
|
||||
mUserAgent = UserAgentUtils.getDefaultUserAgentString(context);
|
||||
@ -109,7 +107,7 @@ public class TwidereImageDownloader extends BaseImageDownloader implements Const
|
||||
@Override
|
||||
protected InputStream getStreamFromNetwork(final String uriString, final Object extras) throws IOException {
|
||||
if (uriString == null) return null;
|
||||
final ParcelableMedia media = MediaPreviewUtils.getAllAvailableImage(uriString, mFullImage, mClient);
|
||||
final ParcelableMedia media = MediaPreviewUtils.getAllAvailableImage(uriString, extras instanceof FullImageExtra, mClient);
|
||||
try {
|
||||
final String mediaUrl = media != null ? media.media_url : uriString;
|
||||
if (isTwitterProfileImage(uriString)) {
|
||||
|
@ -51,7 +51,7 @@ import java.util.Arrays;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class TwidereHostAddressResolver implements Constants, Network {
|
||||
public class TwidereNetwork implements Constants, Network {
|
||||
|
||||
private static final String RESOLVER_LOGTAG = "Twidere.Host";
|
||||
|
||||
@ -64,7 +64,7 @@ public class TwidereHostAddressResolver implements Constants, Network {
|
||||
|
||||
private Resolver mDns;
|
||||
|
||||
public TwidereHostAddressResolver(final Context context) {
|
||||
public TwidereNetwork(final Context context) {
|
||||
mHostMapping = context.getSharedPreferences(HOST_MAPPING_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
mPreferences = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
final String address = mPreferences.getString(KEY_DNS_SERVER, DEFAULT_DNS_SERVER_ADDRESS);
|
Loading…
x
Reference in New Issue
Block a user