当前位置: 首页>>代码示例>>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;未经允许,请勿转载。