本文整理匯總了Java中com.jakewharton.picasso.OkHttp3Downloader類的典型用法代碼示例。如果您正苦於以下問題:Java OkHttp3Downloader類的具體用法?Java OkHttp3Downloader怎麽用?Java OkHttp3Downloader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
OkHttp3Downloader類屬於com.jakewharton.picasso包,在下文中一共展示了OkHttp3Downloader類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import com.jakewharton.picasso.OkHttp3Downloader; //導入依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
if(!FirebaseApp.getApps(this).isEmpty()){
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
}
Picasso.Builder builder = new Picasso.Builder(this);
builder.downloader(new OkHttp3Downloader(this, Integer.MAX_VALUE));
Picasso built = builder.build();
built.setIndicatorsEnabled(false);
built.setLoggingEnabled(true);
Picasso.setSingletonInstance(built);
}
示例2: getDefaultPicassoClient
import com.jakewharton.picasso.OkHttp3Downloader; //導入依賴的package包/類
public static Picasso getDefaultPicassoClient(Context context) {
if (sDefaultPicasso == null) {
final File cacheDir = CacheHelper.getImagesCacheDir(context);
OkHttpClient client = new OkHttpClient.Builder()
.addNetworkInterceptor(chain -> {
Response originalResponse = chain.proceed(chain.request());
return CacheHelper.addCacheControl(originalResponse.newBuilder()).build();
})
.cache(new Cache(cacheDir, CacheHelper.MAX_DISK_CACHE))
.build();
OkHttp3Downloader downloader = new OkHttp3Downloader(client);
sDefaultPicasso = new Picasso.Builder(context.getApplicationContext())
.defaultBitmapConfig(Bitmap.Config.ARGB_8888)
.memoryCache(new LruCache(context))
.downloader(downloader)
.build();
}
return sDefaultPicasso;
}
示例3: ChatroomListAdapter
import com.jakewharton.picasso.OkHttp3Downloader; //導入依賴的package包/類
public ChatroomListAdapter(Context context, List<Chatroom> entries) {
super(context, R.layout.list_item_chat, entries);
RoboGuice.getInjector(context).injectMembers(this);
TypedArray colorArray = context.getTheme().obtainStyledAttributes(new int[]{
R.attr.BackgroundChatTab,
R.attr.BackgroundChatTabActive,
R.attr.BackgroundChatTabAttention,
R.attr.BackgroundChatTabStatus});
standardColor = colorArray.getColor(0, 0);
activeColor = colorArray.getColor(1, 0);
attentionColor = colorArray.getColor(2, 0);
statusColor = colorArray.getColor(3, 0);
colorArray.recycle();
OkHttpClient client = new OkHttpClient();
//client.setProtocols(Collections.singletonList(Protocol.HTTP_1_1));
picasso = new Picasso.Builder(getContext())
.downloader(new OkHttp3Downloader(client))
.build();
}
示例4: FriendListAdapter
import com.jakewharton.picasso.OkHttp3Downloader; //導入依賴的package包/類
public FriendListAdapter(final Context context, List<FCharacter> chars) {
super(context, R.layout.list_item_friend, chars);
if (chars.size() > 1) {
sortList();
}
this.chars = chars;
RoboGuice.getInjector(context).injectMembers(this);
if (picasso == null) {
picasso = new Picasso.Builder(getContext())
.downloader(new OkHttp3Downloader(client))
.build();
}
}
示例5: onCreate
import com.jakewharton.picasso.OkHttp3Downloader; //導入依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
Picasso.Builder builder = new Picasso.Builder(this);
builder.downloader(new OkHttp3Downloader(this, Integer.MAX_VALUE));
Picasso picassoInstance = builder.build();
Picasso.setSingletonInstance(picassoInstance);
CountryFlagsLoader.getInstance().load(this);
historyManager = new HistoryManager(this);
favouriteManager = new FavouriteManager(this);
recordingsManager = new RecordingsManager();
}
示例6: getPicasso
import com.jakewharton.picasso.OkHttp3Downloader; //導入依賴的package包/類
public static Picasso getPicasso(Context context) {
if (sPicasso == null) {
sPicasso = new Picasso.Builder(context)
.downloader(new OkHttp3Downloader(context, ConfigConstants.MAX_DISK_CACHE_SIZE))
.memoryCache(new LruCache(ConfigConstants.MAX_MEMORY_CACHE_SIZE))
.build();
}
return sPicasso;
}
示例7: onCreate
import com.jakewharton.picasso.OkHttp3Downloader; //導入依賴的package包/類
@Override
public void onCreate (){
super.onCreate();
mClient = new OkHttpClient.Builder()
.build();
mDownloader = new Picasso.Builder(this)
.downloader(new OkHttp3Downloader(mClient))
.build();
}
示例8: providePicasso
import com.jakewharton.picasso.OkHttp3Downloader; //導入依賴的package包/類
@Provides @Singleton Picasso providePicasso(OkHttpClient client, Application app) {
Picasso.Builder builder = new Picasso.Builder(app).downloader(new OkHttp3Downloader(client));
builder.listener((picasso, uri, exception) -> {
Timber.e(exception, "Error while loading image %s", uri);
});
return builder.build();
}
示例9: picasso
import com.jakewharton.picasso.OkHttp3Downloader; //導入依賴的package包/類
@AppScope
@Provides
public Picasso picasso(Context context, OkHttpClient okHttpClient) {
return new Picasso.Builder(context)
.downloader(new OkHttp3Downloader(okHttpClient))
.build();
}
示例10: initPicasso
import com.jakewharton.picasso.OkHttp3Downloader; //導入依賴的package包/類
@SuppressWarnings("WeakerAccess")
protected void initPicasso() {
if (mPicasso != null) {
return;
}
mPicasso = new Picasso.Builder(this)
.downloader(new OkHttp3Downloader(mOkHttpClient))
.listener((picasso, uri, exception) -> {
Log.e("Picasso", "Failed to load image: %s", uri);
Log.exception(exception);
})
.build();
}
示例11: onCreate
import com.jakewharton.picasso.OkHttp3Downloader; //導入依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
// Initialize Picasso configuration
Picasso.Builder builder = new Picasso.Builder(this);
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
builder.downloader(new OkHttp3Downloader(OkHttpUtils.getCompatibleClient(preferences)));
if (BuildConfig.DEBUG) {
builder.listener((picasso, uri, exception) -> exception.printStackTrace());
}
try {
Picasso.setSingletonInstance(builder.build());
} catch (IllegalStateException e) {
throw new RuntimeException(e);
}
db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "tuskyDB")
.allowMainThreadQueries()
.addMigrations(AppDatabase.MIGRATION_2_3)
.addMigrations(AppDatabase.MIGRATION_3_4)
.build();
JobManager.create(this).addJobCreator(new NotificationPullJobCreator(this));
//necessary for Android < APi 21
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
示例12: providesPicasso
import com.jakewharton.picasso.OkHttp3Downloader; //導入依賴的package包/類
@Provides
@Singleton
Picasso providesPicasso(Context context, OkHttpClient okHttpClient) {
return new Picasso.Builder(context)
.loggingEnabled(false)
.downloader(new OkHttp3Downloader(okHttpClient))
// .indicatorsEnabled(true)
.build();
}
示例13: getDrawable
import com.jakewharton.picasso.OkHttp3Downloader; //導入依賴的package包/類
@Override
public Drawable getDrawable(String source) {
BitmapDrawablePlaceHolder drawable = new BitmapDrawablePlaceHolder();
if (!source.contains(context.getString(R.string.web_protocol_http))
&& !source.contains(context.getString(R.string.web_protocol_https)))
source = context.getString(R.string.website) + source;
OkHttpClient okHttpClient = new OkHttpClient().newBuilder()
.addInterceptor(new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
final Request original = chain.request();
final Request authorized = original.newBuilder()
.addHeader("Cookie", "jwt=" + accessToken)
.build();
return chain.proceed(authorized);
}
})
.build();
Picasso picasso = new Picasso.Builder(context)
.downloader(new OkHttp3Downloader(okHttpClient))
.build();
picasso.load(source).into(drawable);
return drawable;
}
示例14: onCreate
import com.jakewharton.picasso.OkHttp3Downloader; //導入依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
if (LeakCanary.isInAnalyzerProcess(this)) {
return;
}
refWatcher = LeakCanary.install(this);
instance = this;
Realm.init(this);
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder()
.name(getString(R.string.realm_database_name))
.schemaVersion(Long.parseLong(getString(R.string.realm_database_schemaversion)))
.deleteRealmIfMigrationNeeded()
.build();
Realm.setDefaultConfiguration(realmConfiguration);
if (BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree());
Stetho.initializeWithDefaults(this);
}
Picasso.setSingletonInstance(new Picasso.Builder(this)
.downloader(new OkHttp3Downloader(OkHttpSingleton.getClient()))
.build());
FacebookSdk.sdkInitialize(getApplicationContext());
AppEventsLogger.activateApp(this);
Mapbox.getInstance(this, getResources().getString(R.string.mapbox_token));
Config config = new Config(getResources().getString(R.string.uservoice_site));
config.setTopicId(getResources().getInteger(R.integer.uservoice_topic_id));
config.setShowForum(false);
config.setShowKnowledgeBase(false);
config.setShowPostIdea(false);
if (PreferenceUtils.hasUserId(this) && PreferenceUtils.hasUserFullname(this) && PreferenceUtils.hasUserEmail(this)) {
config.identifyUser(PreferenceUtils.getUserId(this), PreferenceUtils.getUserFullname(this), PreferenceUtils.getUserEmail(this));
}
UserVoice.init(config, this);
Raven.init(this);
Utils.setRavenUser(this);
}
示例15: setup
import com.jakewharton.picasso.OkHttp3Downloader; //導入依賴的package包/類
public static void setup(@NonNull Context context) {
Picasso picasso = new Picasso.Builder(context)
.downloader(new OkHttp3Downloader(context, DISK_CACHE_SIZE))
.memoryCache(new LruCache(MEMORY_CACHE_SIZE))
.build();
Picasso.setSingletonInstance(picasso);
}