Search in sources :

Example 1 with RemoteImageView

use of com.github.ignition.core.widgets.RemoteImageView in project ignition by mttkay.

the class RemoteImageGalleryActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.remote_image_gallery_sample);
    RemoteImageView.setSharedImageLoader(new RemoteImageLoader(this));
    Gallery gallery = (Gallery) findViewById(R.id.gallery);
    gallery.setAdapter(new RemoteImageGalleryAdapter(this, Arrays.asList(imageUrls)) {

        @Override
        protected void onGetView(int position, RemoteImageView remoteImageView, ViewGroup remoteImageViewContainer, ViewGroup parent) {
            // just to illustrate how you can adjust aspects of the rendered images here
            remoteImageView.setScaleType(ScaleType.CENTER_CROP);
            remoteImageViewContainer.setBackgroundResource(android.R.drawable.gallery_thumb);
            int padding = IgnitedScreens.dipToPx(parent.getContext(), 15);
            remoteImageViewContainer.setPadding(padding, padding, padding, padding);
        }
    });
}
Also used : RemoteImageGalleryAdapter(com.github.ignition.core.adapters.RemoteImageGalleryAdapter) RemoteImageView(com.github.ignition.core.widgets.RemoteImageView) ViewGroup(android.view.ViewGroup) Gallery(android.widget.Gallery) RemoteImageLoader(com.github.ignition.support.images.remote.RemoteImageLoader)

Example 2 with RemoteImageView

use of com.github.ignition.core.widgets.RemoteImageView in project ignition by mttkay.

the class RemoteImageViewTest method testCorrectAttributeInflationAndDefaulting.

@Test
public void testCorrectAttributeInflationAndDefaulting() {
    RemoteImageView imageView = (RemoteImageView) activity.findViewById(R.id.image1);
    // default values for unsupplied attributes
    assertTrue(imageView.isAutoLoad());
    Drawable expectedErrorDrawable = Robolectric.application.getResources().getDrawable(RemoteImageView.DEFAULT_ERROR_DRAWABLE_RES_ID);
    assertEquals(expectedErrorDrawable, imageView.getErrorDrawable());
    Drawable expectedProgressDrawable = new TestShadowProgressBar().getIndeterminateDrawable();
    assertEquals(expectedProgressDrawable, imageView.getProgressDrawable());
    assertEquals("http://developer.android.com/images/home/android-design.png", imageView.getImageUrl());
}
Also used : RemoteImageView(com.github.ignition.core.widgets.RemoteImageView) Drawable(android.graphics.drawable.Drawable) TestShadowProgressBar(com.github.ignition.core.test.shadows.TestShadowProgressBar) Test(org.junit.Test)

Example 3 with RemoteImageView

use of com.github.ignition.core.widgets.RemoteImageView in project ignition by mttkay.

the class RemoteImageViewActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.remote_image_view_sample);
    // normal find by ID (see JavaDoc of RemoteImageView why this may be problematic)
    imageView = (RemoteImageView) findViewById(R.id.image5);
    // fail-safe find by ID (this is guaranteed to work)
    RemoteImageView riv = (RemoteImageView) findViewById(R.id.image1);
    Log.i(getClass().getSimpleName(), "custom findViewById: " + riv.getClass().getCanonicalName());
}
Also used : RemoteImageView(com.github.ignition.core.widgets.RemoteImageView)

Example 4 with RemoteImageView

use of com.github.ignition.core.widgets.RemoteImageView in project ignition by mttkay.

the class RemoteImageViewTest method canCustomizeTheErrorDrawable.

@Test
public void canCustomizeTheErrorDrawable() {
    RemoteImageView imageView = (RemoteImageView) activity.findViewById(R.id.image4);
    Drawable expectedErrorDrawable = Robolectric.application.getResources().getDrawable(android.R.drawable.stat_notify_error);
    assertEquals(expectedErrorDrawable, imageView.getErrorDrawable());
}
Also used : RemoteImageView(com.github.ignition.core.widgets.RemoteImageView) Drawable(android.graphics.drawable.Drawable) Test(org.junit.Test)

Example 5 with RemoteImageView

use of com.github.ignition.core.widgets.RemoteImageView in project ignition by mttkay.

the class RemoteImageViewTest method testAutoLoadingOfImages.

// TODO: doesn't work because Robolectric doesn't implement obtainStyledAttributes...
// @Test
// public void canCustomizeTheProgressDrawable() {
// RemoteImageView imageView = (RemoteImageView) activity.findViewById(R.id.image2);
//
// imageView.setupViewSwitcher();
//
// Drawable expectedProgressDrawable = Robolectric.application.getResources().getDrawable(
// android.R.drawable.progress_indeterminate_horizontal);
// assertEquals(expectedProgressDrawable, imageView.getProgressDrawable());
// }
@Test
public void testAutoLoadingOfImages() {
    RemoteImageView view1 = (RemoteImageView) activity.findViewById(R.id.image1);
    RemoteImageView view2 = (RemoteImageView) activity.findViewById(R.id.image2);
    RemoteImageView view3 = (RemoteImageView) activity.findViewById(R.id.image3);
    RemoteImageView view4 = (RemoteImageView) activity.findViewById(R.id.image4);
    RemoteImageView view5 = (RemoteImageView) activity.findViewById(R.id.image5);
    assertTrue(view1.isAutoLoad());
    assertTrue(imageLoader.isLoadImageCalled(view1));
    assertTrue(view2.isAutoLoad());
    assertTrue(imageLoader.isLoadImageCalled(view2));
    assertTrue(view3.isAutoLoad());
    assertTrue(imageLoader.isLoadImageCalled(view3));
    assertTrue(view4.isAutoLoad());
    assertTrue(imageLoader.isLoadImageCalled(view4));
    assertFalse(view5.isAutoLoad());
    assertFalse(imageLoader.isLoadImageCalled(view5));
    Robolectric.clickOn(activity.findViewById(R.id.load_image_button));
    assertTrue(imageLoader.isLoadImageCalled(view5));
}
Also used : RemoteImageView(com.github.ignition.core.widgets.RemoteImageView) Test(org.junit.Test)

Aggregations

RemoteImageView (com.github.ignition.core.widgets.RemoteImageView)6 Test (org.junit.Test)3 Drawable (android.graphics.drawable.Drawable)2 Gallery (android.widget.Gallery)2 ViewGroup (android.view.ViewGroup)1 FrameLayout (android.widget.FrameLayout)1 LayoutParams (android.widget.Gallery.LayoutParams)1 RemoteImageGalleryAdapter (com.github.ignition.core.adapters.RemoteImageGalleryAdapter)1 TestShadowProgressBar (com.github.ignition.core.test.shadows.TestShadowProgressBar)1 RemoteImageLoader (com.github.ignition.support.images.remote.RemoteImageLoader)1