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);
}
});
}
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());
}
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());
}
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());
}
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));
}
Aggregations