com.github.ignition.core.widgets
Class RemoteImageView

java.lang.Object
  extended by android.view.View
      extended by android.view.ViewGroup
          extended by android.widget.FrameLayout
              extended by android.widget.ViewAnimator
                  extended by android.widget.ViewSwitcher
                      extended by com.github.ignition.core.widgets.RemoteImageView
All Implemented Interfaces:
android.graphics.drawable.Drawable.Callback, android.view.accessibility.AccessibilityEventSource, android.view.KeyEvent.Callback, android.view.ViewManager, android.view.ViewParent

public class RemoteImageView
extends android.widget.ViewSwitcher

An image view that fetches its image off the web using the supplied URL. While the image is being downloaded, a progress indicator will be shown. The following attributes are supported:

Author:
Matthias Kaeppler

Nested Class Summary
 
Nested classes/interfaces inherited from class android.widget.ViewSwitcher
android.widget.ViewSwitcher.ViewFactory
 
Nested classes/interfaces inherited from class android.widget.FrameLayout
android.widget.FrameLayout.LayoutParams
 
Nested classes/interfaces inherited from class android.view.ViewGroup
android.view.ViewGroup.MarginLayoutParams, android.view.ViewGroup.OnHierarchyChangeListener
 
Nested classes/interfaces inherited from class android.view.View
android.view.View.BaseSavedState, android.view.View.MeasureSpec, android.view.View.OnClickListener, android.view.View.OnCreateContextMenuListener, android.view.View.OnFocusChangeListener, android.view.View.OnKeyListener, android.view.View.OnLongClickListener, android.view.View.OnTouchListener
 
Field Summary
static int DEFAULT_ERROR_DRAWABLE_RES_ID
           
 
Fields inherited from class android.view.ViewGroup
CLIP_TO_PADDING_MASK, FLAG_USE_CHILD_DRAWING_ORDER, FOCUS_AFTER_DESCENDANTS, FOCUS_BEFORE_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS, PERSISTENT_ALL_CACHES, PERSISTENT_ANIMATION_CACHE, PERSISTENT_NO_CACHE, PERSISTENT_SCROLLING_CACHE
 
Fields inherited from class android.view.View
DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, EMPTY_STATE_SET, ENABLED_FOCUSED_SELECTED_STATE_SET, ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_FOCUSED_STATE_SET, ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, ENABLED_SELECTED_STATE_SET, ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_STATE_SET, ENABLED_WINDOW_FOCUSED_STATE_SET, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSABLES_ALL, FOCUSABLES_TOUCH_MODE, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, HAPTIC_FEEDBACK_ENABLED, INVISIBLE, KEEP_SCREEN_ON, NO_ID, PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET, PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_SELECTED_STATE_SET, PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_STATE_SET, PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SOUND_EFFECTS_ENABLED, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET
 
Constructor Summary
RemoteImageView(android.content.Context context, android.util.AttributeSet attributes)
           
RemoteImageView(android.content.Context context, String imageUrl, boolean autoLoad)
           
RemoteImageView(android.content.Context context, String imageUrl, android.graphics.drawable.Drawable progressDrawable, android.graphics.drawable.Drawable errorDrawable, boolean autoLoad)
           
 
Method Summary
 android.graphics.drawable.Drawable getErrorDrawable()
          The drawable that will be shown when the image download fails.
 String getImageUrl()
          Returns the URL of the image to show.
 android.widget.ImageView getImageView()
          The image view that will render the downloaded image.
 android.widget.ProgressBar getProgressBar()
          The progress bar that is shown while the image is loaded.
 android.graphics.drawable.Drawable getProgressDrawable()
          The drawable that should be used to indicate progress while downloading the image.
 boolean isAutoLoad()
          Whether or not the image should be downloaded immediately after view inflation.
 boolean isLoaded()
           
 void loadImage()
          Use this method to trigger the image download if you had previously set autoLoad to false.
 void reset()
           
 void setImageUrl(String imageUrl)
           
 void setNoImageDrawable(int imageResourceId)
          Often you have resources which usually have an image, but some don't.
static void setSharedImageLoader(RemoteImageLoader imageLoader)
          Use this method to inject an image loader that will be shared across all instances of this class.
 
Methods inherited from class android.widget.ViewSwitcher
addView, getNextView, setFactory
 
Methods inherited from class android.widget.ViewAnimator
getBaseline, getCurrentView, getDisplayedChild, getInAnimation, getOutAnimation, removeAllViews, removeView, removeViewAt, removeViewInLayout, removeViews, removeViewsInLayout, setAnimateFirstView, setDisplayedChild, setInAnimation, setInAnimation, setOutAnimation, setOutAnimation, showNext, showPrevious
 
Methods inherited from class android.widget.FrameLayout
checkLayoutParams, draw, drawableStateChanged, gatherTransparentRegion, generateDefaultLayoutParams, generateLayoutParams, generateLayoutParams, getConsiderGoneChildrenWhenMeasuring, getForeground, onLayout, onMeasure, onSizeChanged, setForeground, setForegroundGravity, setMeasureAllChildren, verifyDrawable
 
Methods inherited from class android.view.ViewGroup
addFocusables, addFocusables, addStatesFromChildren, addTouchables, addView, addView, addView, addView, addViewInLayout, addViewInLayout, attachLayoutAnimationParameters, attachViewToParent, bringChildToFront, canAnimate, childDrawableStateChanged, cleanupLayoutState, clearChildFocus, clearDisappearingChildren, clearFocus, debug, detachAllViewsFromParent, detachViewFromParent, detachViewFromParent, detachViewsFromParent, dispatchDraw, dispatchFreezeSelfOnly, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchPopulateAccessibilityEvent, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetPressed, dispatchSetSelected, dispatchThawSelfOnly, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchWindowFocusChanged, dispatchWindowVisibilityChanged, drawChild, findFocus, fitSystemWindows, focusableViewAvailable, focusSearch, getChildAt, getChildCount, getChildDrawingOrder, getChildMeasureSpec, getChildStaticTransformation, getChildVisibleRect, getDescendantFocusability, getFocusedChild, getLayoutAnimation, getLayoutAnimationListener, getPersistentDrawingCache, hasFocus, hasFocusable, indexOfChild, invalidateChild, invalidateChildInParent, isAlwaysDrawnWithCacheEnabled, isAnimationCacheEnabled, isChildrenDrawnWithCacheEnabled, measureChild, measureChildren, measureChildWithMargins, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onAnimationEnd, onAnimationStart, onCreateDrawableState, onInterceptTouchEvent, onRequestFocusInDescendants, recomputeViewAttributes, removeAllViewsInLayout, removeDetachedView, requestChildFocus, requestChildRectangleOnScreen, requestDisallowInterceptTouchEvent, requestFocus, requestTransparentRegion, scheduleLayoutAnimation, setAddStatesFromChildren, setAlwaysDrawnWithCacheEnabled, setAnimationCacheEnabled, setChildrenDrawingCacheEnabled, setChildrenDrawnWithCacheEnabled, setClipChildren, setClipToPadding, setDescendantFocusability, setLayoutAnimation, setLayoutAnimationListener, setOnHierarchyChangeListener, setPadding, setPersistentDrawingCache, setStaticTransformationsEnabled, showContextMenuForChild, startLayoutAnimation, updateViewLayout
 
Methods inherited from class android.view.View
bringToFront, buildDrawingCache, buildDrawingCache, cancelLongPress, checkInputConnectionProxy, clearAnimation, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeScroll, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createContextMenu, destroyDrawingCache, finalize, findViewById, findViewWithTag, focusSearch, forceLayout, getAnimation, getApplicationWindowToken, getBackground, getBottom, getBottomFadingEdgeStrength, getBottomPaddingOffset, getContentDescription, getContext, getContextMenuInfo, getDefaultSize, getDrawableState, getDrawingCache, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getFocusables, getFocusedRect, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getId, getKeepScreenOn, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLeftPaddingOffset, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMeasuredHeight, getMeasuredWidth, getNextFocusDownId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getParent, getResources, getRight, getRightFadingEdgeStrength, getRightPaddingOffset, getRootView, getScrollBarStyle, getScrollX, getScrollY, getSolidColor, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getTag, getTag, getTop, getTopFadingEdgeStrength, getTopPaddingOffset, getTouchables, getTouchDelegate, getVerticalFadingEdgeLength, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, hasWindowFocus, inflate, initializeFadingEdge, initializeScrollbars, invalidate, invalidate, invalidate, invalidateDrawable, isClickable, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isHapticFeedbackEnabled, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isInEditMode, isInTouchMode, isLayoutRequested, isLongClickable, isPaddingOffsetRequired, isPressed, isSaveEnabled, isSelected, isShown, isSoundEffectsEnabled, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, layout, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onAttachedToWindow, onCheckIsTextEditor, onCreateContextMenu, onCreateInputConnection, onDetachedFromWindow, onDraw, onFinishInflate, onFinishTemporaryDetach, onFocusChanged, onKeyDown, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onRestoreInstanceState, onSaveInstanceState, onScrollChanged, onSetAlpha, onStartTemporaryDetach, onTouchEvent, onTrackballEvent, onWindowFocusChanged, onWindowVisibilityChanged, performClick, performHapticFeedback, performHapticFeedback, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, refreshDrawableState, removeCallbacks, requestFocus, requestFocus, requestFocusFromTouch, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, resolveSize, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEvent, sendAccessibilityEventUnchecked, setAnimation, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setClickable, setContentDescription, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setEnabled, setFadingEdgeLength, setFocusable, setFocusableInTouchMode, setHapticFeedbackEnabled, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setId, setKeepScreenOn, setLayoutParams, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNextFocusDownId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnClickListener, setOnCreateContextMenuListener, setOnFocusChangeListener, setOnKeyListener, setOnLongClickListener, setOnTouchListener, setPressed, setSaveEnabled, setScrollBarStyle, setScrollContainer, setSelected, setSoundEffectsEnabled, setTag, setTag, setTouchDelegate, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVisibility, setWillNotCacheDrawing, setWillNotDraw, showContextMenu, startAnimation, unscheduleDrawable, unscheduleDrawable, willNotCacheDrawing, willNotDraw
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface android.view.ViewParent
createContextMenu, getParent, isLayoutRequested, requestLayout
 

Field Detail

DEFAULT_ERROR_DRAWABLE_RES_ID

public static final int DEFAULT_ERROR_DRAWABLE_RES_ID
See Also:
Constant Field Values
Constructor Detail

RemoteImageView

public RemoteImageView(android.content.Context context,
                       String imageUrl,
                       boolean autoLoad)
Parameters:
context - the view's current context
imageUrl - the URL of the image to download and show
autoLoad - Whether the download should start immediately after creating the view. If set to false, use loadImage() to manually trigger the image download.

RemoteImageView

public RemoteImageView(android.content.Context context,
                       String imageUrl,
                       android.graphics.drawable.Drawable progressDrawable,
                       android.graphics.drawable.Drawable errorDrawable,
                       boolean autoLoad)
Parameters:
context - the view's current context
imageUrl - the URL of the image to download and show
progressDrawable - the drawable to be used for the ProgressBar which is displayed while the image is loading
errorDrawable - the drawable to be used if a download error occurs
autoLoad - Whether the download should start immediately after creating the view. If set to false, use loadImage() to manually trigger the image download.

RemoteImageView

public RemoteImageView(android.content.Context context,
                       android.util.AttributeSet attributes)
Method Detail

setSharedImageLoader

public static void setSharedImageLoader(RemoteImageLoader imageLoader)
Use this method to inject an image loader that will be shared across all instances of this class. If the shared reference is null, a new RemoteImageLoader will be instantiated for every instance of this class.

Parameters:
imageLoader - the shared image loader

loadImage

public void loadImage()
Use this method to trigger the image download if you had previously set autoLoad to false.


isLoaded

public boolean isLoaded()

setImageUrl

public void setImageUrl(String imageUrl)

setNoImageDrawable

public void setNoImageDrawable(int imageResourceId)
Often you have resources which usually have an image, but some don't. For these cases, use this method to supply a placeholder drawable which will be loaded instead of a web image.

Parameters:
imageResourceId - the resource of the placeholder image drawable

reset

public void reset()
Overrides:
reset in class android.widget.ViewSwitcher

getImageUrl

public String getImageUrl()
Returns the URL of the image to show. Corresponds to the view attribute ignition:imageUrl.

Returns:
the image URL

isAutoLoad

public boolean isAutoLoad()
Whether or not the image should be downloaded immediately after view inflation. Corresponds to the view attribute ignition:autoLoad (default: true).

Returns:
true if auto downloading of the image is enabled

getProgressDrawable

public android.graphics.drawable.Drawable getProgressDrawable()
The drawable that should be used to indicate progress while downloading the image. Corresponds to the view attribute ignition:progressDrawable. If left blank, the platform's standard indeterminate progress drawable will be used.

Returns:
the progress drawable

getErrorDrawable

public android.graphics.drawable.Drawable getErrorDrawable()
The drawable that will be shown when the image download fails. Corresponds to the view attribute ignition:errorDrawable. If left blank, a stock alert icon from the Android platform will be used.

Returns:
the error drawable

getImageView

public android.widget.ImageView getImageView()
The image view that will render the downloaded image.

Returns:
the ImageView

getProgressBar

public android.widget.ProgressBar getProgressBar()
The progress bar that is shown while the image is loaded.

Returns:
the ProgressBar


Copyright © 2012. All Rights Reserved.