當前位置: 首頁>>代碼示例>>Java>>正文


Java OkHttp3Downloader類代碼示例

本文整理匯總了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);
}
 
開發者ID:Socialate,項目名稱:furry-sniffle,代碼行數:16,代碼來源:Socialate.java

示例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;
}
 
開發者ID:jruesga,項目名稱:rview,代碼行數:20,代碼來源:PicassoHelper.java

示例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();
}
 
開發者ID:AndFChat,項目名稱:AndFChat,代碼行數:26,代碼來源:ChatroomListAdapter.java

示例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();
    }
}
 
開發者ID:AndFChat,項目名稱:AndFChat,代碼行數:18,代碼來源:FriendListAdapter.java

示例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();
}
 
開發者ID:segler-alex,項目名稱:RadioDroid,代碼行數:18,代碼來源:RadioDroidApp.java

示例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;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:SamplePicassoFactory.java

示例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();
}
 
開發者ID:approov,項目名稱:hands-on-api-proxy,代碼行數:11,代碼來源:App.java

示例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();
}
 
開發者ID:rogues-dev,項目名稱:superglue,代碼行數:8,代碼來源:DebugDataModule.java

示例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();
}
 
開發者ID:jimandreas,項目名稱:android-rxmvp-sandbox,代碼行數:8,代碼來源:NetworkModule.java

示例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();
}
 
開發者ID:TryGhost,項目名稱:Ghost-Android,代碼行數:14,代碼來源:SpectreApplication.java

示例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);
}
 
開發者ID:Vavassor,項目名稱:Tusky,代碼行數:29,代碼來源:TuskyApplication.java

示例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();
    }
 
開發者ID:jam01,項目名稱:LittleLight,代碼行數:10,代碼來源:AdapterModule.java

示例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;
}
 
開發者ID:schul-cloud,項目名稱:schulcloud-mobile-android,代碼行數:30,代碼來源:PicassoImageGetter.java

示例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);
}
 
開發者ID:Turistforeningen,項目名稱:SjekkUT,代碼行數:38,代碼來源:SjekkUTApplication.java

示例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);
}
 
開發者ID:ArturVasilov,項目名稱:AndroidArchitecture,代碼行數:8,代碼來源:PicassoUtils.java


注:本文中的com.jakewharton.picasso.OkHttp3Downloader類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。