com.google.android.apps.muzei.api
Class RemoteMuzeiArtSource

java.lang.Object
  extended by android.content.Context
      extended by android.content.ContextWrapper
          extended by android.app.Service
              extended by android.app.IntentService
                  extended by com.google.android.apps.muzei.api.MuzeiArtSource
                      extended by com.google.android.apps.muzei.api.RemoteMuzeiArtSource
All Implemented Interfaces:
ComponentCallbacks, ComponentCallbacks2

public abstract class RemoteMuzeiArtSource
extends MuzeiArtSource

A convenience subclass of MuzeiArtSource that's specifically designed for use by art sources that fetch artwork metadata remotely. Sources that publish remote images but who publish Artwork objects based on local data shouldnt need to use this subclass.

The only required method is onTryUpdate(int), which replaces the normal onUpdate(int) callback method.

This class automatically does the following in onUpdate(int):

Applications with sources based on RemoteMuzeiArtSource must add the following permissions:

 <uses-permission android:name="android.permission.INTERNET" />
 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
 <uses-permission android:name="android.permission.WAKE_LOCK" />


Nested Class Summary
static class RemoteMuzeiArtSource.RetryException
          An exception indicating that the RemoteMuzeiArtSource would like to retry a failed update attempt.
 
Field Summary
 
Fields inherited from class com.google.android.apps.muzei.api.MuzeiArtSource
ACTION_MUZEI_ART_SOURCE, BUILTIN_COMMAND_ID_NEXT_ARTWORK, EXTRA_FROM_MUZEI_SETTINGS, MAX_CUSTOM_COMMAND_ID, UPDATE_REASON_INITIAL, UPDATE_REASON_OTHER, UPDATE_REASON_SCHEDULED, UPDATE_REASON_USER_NEXT
 
Fields inherited from class android.app.Service
START_CONTINUATION_MASK, START_FLAG_REDELIVERY, START_FLAG_RETRY, START_NOT_STICKY, START_REDELIVER_INTENT, START_STICKY, START_STICKY_COMPATIBILITY
 
Fields inherited from class android.content.Context
ACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, AUDIO_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_OOM_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_IMPORTANT, BIND_NOT_FOREGROUND, BIND_WAIVE_PRIORITY, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, DEVICE_POLICY_SERVICE, DISPLAY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, KEYGUARD_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MEDIA_ROUTER_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, POWER_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, STORAGE_SERVICE, TELEPHONY_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, UI_MODE_SERVICE, USB_SERVICE, USER_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_P2P_SERVICE, WIFI_SERVICE, WINDOW_SERVICE
 
Fields inherited from interface android.content.ComponentCallbacks2
TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN
 
Constructor Summary
RemoteMuzeiArtSource(String name)
          Remember to call this constructor from an empty constructor!
 
Method Summary
protected  void onDisabled()
          Lifecycle method called when the last subscriber is removed.
protected  void onNetworkAvailable()
          Convenience callback method indicating that a network connection is now available.
protected abstract  void onTryUpdate(int reason)
          Subclasses should implement this method (instead of onUpdate(int)) and attempt an update, throwing a RemoteMuzeiArtSource.RetryException in case of a retryable error such as an HTTP 500-level server error or a read error.
protected  void onUpdate(int reason)
          Subclasses of RemoteMuzeiArtSource should implement onTryUpdate(int) instead of this method.
 
Methods inherited from class com.google.android.apps.muzei.api.MuzeiArtSource
getCurrentArtwork, getSharedPreferences, getSharedPreferences, isEnabled, onAllowSubscription, onBind, onCreate, onCustomCommand, onEnabled, onHandleIntent, onSubscriberAdded, onSubscriberRemoved, publishArtwork, removeAllUserCommands, scheduleUpdate, setDescription, setUserCommands, setUserCommands, setUserCommands, setWantsNetworkAvailable, unscheduleUpdate
 
Methods inherited from class android.app.IntentService
onDestroy, onStart, onStartCommand, setIntentRedelivery
 
Methods inherited from class android.app.Service
dump, getApplication, onConfigurationChanged, onLowMemory, onRebind, onTaskRemoved, onTrimMemory, onUnbind, startForeground, stopForeground, stopSelf, stopSelf, stopSelfResult
 
Methods inherited from class android.content.ContextWrapper
attachBaseContext, bindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkUriPermission, checkUriPermission, clearWallpaper, createConfigurationContext, createDisplayContext, createPackageContext, databaseList, deleteDatabase, deleteFile, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getCacheDir, getClassLoader, getContentResolver, getDatabasePath, getDir, getExternalCacheDir, getExternalFilesDir, getFilesDir, getFileStreamPath, getMainLooper, getObbDir, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getResources, getSharedPreferences, getSystemService, getTheme, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isRestricted, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcastAsUser, sendBroadcastAsUser, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setTheme, setWallpaper, setWallpaper, startActivities, startActivities, startActivity, startActivity, startInstrumentation, startIntentSender, startIntentSender, startService, stopService, unbindService, unregisterReceiver
 
Methods inherited from class android.content.Context
getString, getString, getText, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, registerComponentCallbacks, unregisterComponentCallbacks
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemoteMuzeiArtSource

public RemoteMuzeiArtSource(String name)
Remember to call this constructor from an empty constructor!

Method Detail

onDisabled

protected void onDisabled()
Description copied from class: MuzeiArtSource
Lifecycle method called when the last subscriber is removed. This will be called after MuzeiArtSource.onSubscriberRemoved(ComponentName). Sources generally don't need to override this. For more details on the source lifecycle, see the discussion in the MuzeiArtSource reference.

Overrides:
onDisabled in class MuzeiArtSource

onNetworkAvailable

protected void onNetworkAvailable()
Description copied from class: MuzeiArtSource
Convenience callback method indicating that a network connection is now available. This will only be called if MuzeiArtSource.setWantsNetworkAvailable(boolean) was last called with true.

Overrides:
onNetworkAvailable in class MuzeiArtSource

onTryUpdate

protected abstract void onTryUpdate(int reason)
                             throws RemoteMuzeiArtSource.RetryException
Subclasses should implement this method (instead of onUpdate(int)) and attempt an update, throwing a RemoteMuzeiArtSource.RetryException in case of a retryable error such as an HTTP 500-level server error or a read error.

Throws:
RemoteMuzeiArtSource.RetryException

onUpdate

protected void onUpdate(int reason)
Subclasses of RemoteMuzeiArtSource should implement onTryUpdate(int) instead of this method.

Specified by:
onUpdate in class MuzeiArtSource
Parameters:
reason - The reason for the update. See MuzeiArtSource.UPDATE_REASON_INITIAL and related constants for more details.