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


Java GlideUrl類代碼示例

本文整理匯總了Java中com.bumptech.glide.load.model.GlideUrl的典型用法代碼示例。如果您正苦於以下問題:Java GlideUrl類的具體用法?Java GlideUrl怎麽用?Java GlideUrl使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


GlideUrl類屬於com.bumptech.glide.load.model包,在下文中一共展示了GlideUrl類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testBuildsNewUrlIfNotPresentInCache

import com.bumptech.glide.load.model.GlideUrl; //導入依賴的package包/類
@Test
public void testBuildsNewUrlIfNotPresentInCache() {
  int width = 10;
  int height = 11;

  urlLoader.resultUrl = "fakeUrl";
  when(wrapped.buildLoadData(any(GlideUrl.class), eq(width), eq(height), eq(options)))
      .thenAnswer(new Answer<ModelLoader.LoadData<InputStream>>() {
        @Override
        public ModelLoader.LoadData<InputStream> answer(InvocationOnMock invocationOnMock)
            throws Throwable {
          GlideUrl glideUrl = (GlideUrl) invocationOnMock.getArguments()[0];
          assertEquals(urlLoader.resultUrl, glideUrl.toStringUrl());
          return new ModelLoader.LoadData<>(mock(Key.class), fetcher);

        }
      });
  assertEquals(fetcher,
      urlLoader.buildLoadData(new GlideUrl(urlLoader.resultUrl), width, height, options).fetcher);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:BaseGlideUrlLoaderTest.java

示例2: buildLoadData

import com.bumptech.glide.load.model.GlideUrl; //導入依賴的package包/類
@Override
public LoadData<InputStream> buildLoadData(GlideUrl model, int width, int height,
    Options options) {
  // GlideUrls memoize parsed URLs so caching them saves a few object instantiations and time
  // spent parsing urls.
  GlideUrl url = model;
  if (modelCache != null) {
    url = modelCache.get(model, 0, 0);
    if (url == null) {
      modelCache.put(model, 0, 0, model);
      url = model;
    }
  }
  int timeout = options.get(TIMEOUT);
  return new LoadData<>(url, new HttpUrlFetcher(url, timeout));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:HttpGlideUrlLoader.java

示例3: testBuildsNewUrlIfNotPresentInCache

import com.bumptech.glide.load.model.GlideUrl; //導入依賴的package包/類
@Test
public void testBuildsNewUrlIfNotPresentInCache() {
  int width = 10;
  int height = 11;

  urlLoader.resultUrl = "fakeUrl";
  when(wrapped.buildLoadData(any(GlideUrl.class), eq(width), eq(height), eq(options)))
      .thenAnswer(new Answer<ModelLoader.LoadData<InputStream>>() {
        @Override
        public ModelLoader.LoadData<InputStream> answer(InvocationOnMock invocationOnMock)
            throws Throwable {
          GlideUrl glideUrl = (GlideUrl) invocationOnMock.getArguments()[0];
          assertEquals(urlLoader.resultUrl, glideUrl.toStringUrl());
          return new ModelLoader.LoadData<>(mock(Key.class), fetcher);

        }
      });
  assertEquals(
      fetcher,
      Preconditions.checkNotNull(
          urlLoader.buildLoadData(
              new GlideUrl(urlLoader.resultUrl), width, height, options)).fetcher);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:24,代碼來源:BaseGlideUrlLoaderTest.java

示例4: testAddsNewUrlToCacheIfNotPresentInCache

import com.bumptech.glide.load.model.GlideUrl; //導入依賴的package包/類
@Test
public void testAddsNewUrlToCacheIfNotPresentInCache() {
  urlLoader.resultUrl = "fakeUrl";
  Object model = new Object();
  int width = 400;
  int height = 500;

  doAnswer(new Answer<Void>() {
    @Override
    public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
      GlideUrl glideUrl = (GlideUrl) invocationOnMock.getArguments()[3];
      assertEquals(urlLoader.resultUrl, glideUrl.toStringUrl());
      return null;
    }
  }).when(modelCache).put(eq(model), eq(width), eq(height), any(GlideUrl.class));

  urlLoader.buildLoadData(model, width, height, options);

  verify(modelCache).put(eq(model), eq(width), eq(height), any(GlideUrl.class));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:BaseGlideUrlLoaderTest.java

示例5: testDoesNotInteractWithModelCacheIfNull

import com.bumptech.glide.load.model.GlideUrl; //導入依賴的package包/類
@Test
public void testDoesNotInteractWithModelCacheIfNull() {
  TestLoader urlLoader = new TestLoader(wrapped, null);
  urlLoader.resultUrl = "fakeUrl";

  int width = 456;
  int height = 789;

  when(wrapped.buildLoadData(any(GlideUrl.class), eq(width), eq(height), eq(options)))
      .thenReturn(new ModelLoader.LoadData<>(mock(Key.class), fetcher));

  assertEquals(
      fetcher,
      Preconditions.checkNotNull(
          urlLoader.buildLoadData(new Object(), width, height, options)).fetcher);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:BaseGlideUrlLoaderTest.java

示例6: registerComponents

import com.bumptech.glide.load.model.GlideUrl; //導入依賴的package包/類
@Override
public void registerComponents(Context context, Glide glide) {
    OkHttpClient client = new OkHttpClient
            .Builder()
            .addInterceptor(createInterceptor(new DispatchingProgressListener()))
            .build();
    glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(client));
}
 
開發者ID:DylanVann,項目名稱:react-native-fast-image,代碼行數:9,代碼來源:OkHttpProgressGlideModule.java

示例7: getGlideUrlByUser

import com.bumptech.glide.load.model.GlideUrl; //導入依賴的package包/類
public static GlideUrl getGlideUrlByUser(String url) {
    if (AccountHelper.isLogin()) {
        return new GlideUrl(url,
                new LazyHeaders
                        .Builder()
                        .addHeader("Cookie", AccountHelper.getCookie())
                        .build());
    } else {
        return new GlideUrl(url);
    }
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:12,代碼來源:AppOperator.java

示例8: displayImageReferer

import com.bumptech.glide.load.model.GlideUrl; //導入依賴的package包/類
public static void displayImageReferer(String url,ImageView imageView,String referer) {
    if(url==null){
        return;
    }
    LazyHeaders.Builder builder=new LazyHeaders.Builder().addHeader("User-Agent", UserAgent);
    if(referer!=null){
        builder.addHeader("Referer", referer);
    }

    /*
            .addHeader("key2", new LazyHeaderFactory() {
                @Override
                public String buildHeader() {
                    String expensiveAuthHeader = computeExpensiveAuthHeader();
                    return expensiveAuthHeader;
                }
            })
            */

    GlideUrl glideUrl = new GlideUrl(url,builder.build());

    Glide.with(MainApp.getContext())
            .load(glideUrl)
            .placeholder(R.drawable.pictures_no)
            .thumbnail(0.2f)
            .diskCacheStrategy(DiskCacheStrategy.SOURCE)
            .into(imageView);

}
 
開發者ID:Louis19910615,項目名稱:youkes_browser,代碼行數:30,代碼來源:GlideUtil.java

示例9: registerComponents

import com.bumptech.glide.load.model.GlideUrl; //導入依賴的package包/類
@Override
public void registerComponents(Context context, Registry registry) {
  registerMockModelLoader(GlideUrl.class, InputStream.class,
      new ByteArrayInputStream(new byte[0]), registry);
  registerMockModelLoader(File.class, InputStream.class,
      new ByteArrayInputStream(new byte[0]), registry);
  registerMockModelLoader(File.class, ParcelFileDescriptor.class,
      mock(ParcelFileDescriptor.class), registry);
  registerMockModelLoader(File.class, ByteBuffer.class,
      ByteBuffer.allocate(10), registry);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:GlideTest.java

示例10: testReturnsUrlFromCacheIfPresent

import com.bumptech.glide.load.model.GlideUrl; //導入依賴的package包/類
@Test
public void testReturnsUrlFromCacheIfPresent() {
  Object model = new Object();
  int width = 100;
  int height = 200;
  GlideUrl expectedUrl = mock(GlideUrl.class);
  when(modelCache.get(eq(model), eq(width), eq(height))).thenReturn(expectedUrl);

  when(wrapped.buildLoadData(eq(expectedUrl), eq(width), eq(height), eq(options)))
      .thenReturn(new ModelLoader.LoadData<>(mock(Key.class), fetcher));

  assertEquals(fetcher, urlLoader.buildLoadData(model, width, height, options).fetcher);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:14,代碼來源:BaseGlideUrlLoaderTest.java

示例11: init

import com.bumptech.glide.load.model.GlideUrl; //導入依賴的package包/類
public static void init(Glide glide, OkHttpClient okHttpClient) {
    OkHttpClient.Builder builder;
    if (okHttpClient != null) {
        builder = okHttpClient.newBuilder();
    } else {
        builder = new OkHttpClient.Builder();
    }
    builder.addNetworkInterceptor(createInterceptor(new DispatchingProgressListener()));
    glide.getRegistry().replace(GlideUrl.class, InputStream.class,
            new OkHttpUrlLoader.Factory(builder.build()));
}
 
開發者ID:alphater,項目名稱:garras,代碼行數:12,代碼來源:GlideProgressSupport.java

示例12: testHandlesHttpUris

import com.bumptech.glide.load.model.GlideUrl; //導入依賴的package包/類
@Test
public void testHandlesHttpUris() throws MalformedURLException {
  Uri httpUri = Uri.parse("http://www.google.com");
  loader.buildLoadData(httpUri, IMAGE_SIDE, IMAGE_SIDE, OPTIONS);

  assertTrue(loader.handles(httpUri));
  verify(urlLoader)
      .buildLoadData(eq(new GlideUrl(httpUri.toString())), eq(IMAGE_SIDE), eq(IMAGE_SIDE),
          eq(OPTIONS));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:11,代碼來源:HttpUriLoaderTest.java

示例13: testHandlesHttpsUris

import com.bumptech.glide.load.model.GlideUrl; //導入依賴的package包/類
@Test
public void testHandlesHttpsUris() throws MalformedURLException {
  Uri httpsUri = Uri.parse("https://www.google.com");
  loader.buildLoadData(httpsUri, IMAGE_SIDE, IMAGE_SIDE, OPTIONS);

  assertTrue(loader.handles(httpsUri));
  verify(urlLoader)
      .buildLoadData(eq(new GlideUrl(httpsUri.toString())), eq(IMAGE_SIDE), eq(IMAGE_SIDE),
          eq(OPTIONS));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:11,代碼來源:HttpUriLoaderTest.java

示例14: testHandlesMostlyInvalidHttpUris

import com.bumptech.glide.load.model.GlideUrl; //導入依賴的package包/類
@Test
public void testHandlesMostlyInvalidHttpUris() {
  Uri mostlyInvalidHttpUri = Uri.parse(
      "http://myserver_url.com:80http://myserver_url.com/webapp/images/no_image.png?size=100");

  assertTrue(loader.handles(mostlyInvalidHttpUri));
  loader.buildLoadData(mostlyInvalidHttpUri, IMAGE_SIDE, IMAGE_SIDE, OPTIONS);
  verify(urlLoader)
      .buildLoadData(eq(new GlideUrl(mostlyInvalidHttpUri.toString())), eq(IMAGE_SIDE),
          eq(IMAGE_SIDE), eq(OPTIONS));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:HttpUriLoaderTest.java

示例15: ArtistImageFetcher

import com.bumptech.glide.load.model.GlideUrl; //導入依賴的package包/類
public ArtistImageFetcher(Context context, LastFMRestClient lastFMRestClient, ArtistImage model, ModelLoader<GlideUrl, InputStream> urlLoader, int width, int height) {
    this.context = context;
    this.lastFMRestClient = lastFMRestClient;
    this.model = model;
    this.urlLoader = urlLoader;
    this.width = width;
    this.height = height;
}
 
開發者ID:h4h13,項目名稱:RetroMusicPlayer,代碼行數:9,代碼來源:ArtistImageFetcher.java


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