Search in sources :

Example 6 with GlideUrl

use of com.bumptech.glide.load.model.GlideUrl in project glide by bumptech.

the class BaseGlideUrlLoaderTest method testReturnsUrlFromCacheIfPresent.

@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);
}
Also used : ModelLoader(com.bumptech.glide.load.model.ModelLoader) GlideUrl(com.bumptech.glide.load.model.GlideUrl) Test(org.junit.Test)

Example 7 with GlideUrl

use of com.bumptech.glide.load.model.GlideUrl in project glide by bumptech.

the class HttpUriLoaderTest method testHandlesMostlyInvalidHttpUris.

// Test for https://github.com/bumptech/glide/issues/71.
@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));
}
Also used : GlideUrl(com.bumptech.glide.load.model.GlideUrl) Uri(android.net.Uri) Test(org.junit.Test)

Example 8 with GlideUrl

use of com.bumptech.glide.load.model.GlideUrl in project CircleDemo by Naoki2015.

the class CircleVideoView method init.

private void init() {
    inflate(getContext(), R.layout.layout_video, this);
    videoPlayer = (TextureVideoView) findViewById(R.id.video_player);
    videoFrame = (ImageView) findViewById(R.id.iv_video_frame);
    videoProgress = (CircularProgressBar) findViewById(R.id.video_progress);
    videoButton = (ImageView) findViewById(R.id.iv_video_play);
    videoTarget = new VideoLoadTarget(this);
    progressTarget = new VideoProgressTarget(videoTarget, videoProgress);
    videoPlayer.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (videoPlayer.isPlaying()) {
                videoPlayer.stop();
            }
        }
    });
    videoButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (TextUtils.isEmpty(videoUrl)) {
                Toast.makeText(getContext(), "video url is empty...", Toast.LENGTH_LONG).show();
                return;
            }
            // load video file
            videoState = STATE_ACTIVED;
            progressTarget.start();
            Glide.with(getContext()).using(VideoListGlideModule.getOkHttpUrlLoader(), InputStream.class).load(new GlideUrl(videoUrl)).as(File.class).diskCacheStrategy(DiskCacheStrategy.SOURCE).into(progressTarget);
            videoButton.setVisibility(View.INVISIBLE);
            if (onPlayClickListener != null) {
                onPlayClickListener.onPlayClick(postion);
            }
        }
    });
}
Also used : VideoProgressTarget(com.yiw.circledemo.widgets.videolist.target.VideoProgressTarget) InputStream(java.io.InputStream) VideoLoadTarget(com.yiw.circledemo.widgets.videolist.target.VideoLoadTarget) GlideUrl(com.bumptech.glide.load.model.GlideUrl) ImageView(android.widget.ImageView) VideoLoadMvpView(com.yiw.circledemo.widgets.videolist.model.VideoLoadMvpView) TextureVideoView(com.yiw.circledemo.widgets.videolist.widget.TextureVideoView) View(android.view.View) File(java.io.File)

Aggregations

GlideUrl (com.bumptech.glide.load.model.GlideUrl)8 Test (org.junit.Test)5 Uri (android.net.Uri)3 ModelLoader (com.bumptech.glide.load.model.ModelLoader)2 InputStream (java.io.InputStream)2 Nullable (android.support.annotation.Nullable)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 HttpUrlFetcher (com.bumptech.glide.load.data.HttpUrlFetcher)1 VideoLoadMvpView (com.yiw.circledemo.widgets.videolist.model.VideoLoadMvpView)1 VideoLoadTarget (com.yiw.circledemo.widgets.videolist.target.VideoLoadTarget)1 VideoProgressTarget (com.yiw.circledemo.widgets.videolist.target.VideoProgressTarget)1 TextureVideoView (com.yiw.circledemo.widgets.videolist.widget.TextureVideoView)1 File (java.io.File)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1