/** * Set the type of Service to use for the ImageModel implementation. * * @param serviceType Type of Service, i.e., STARTED_SERVICE. */ public void setServiceType(ImageModel.ServiceType serviceType) { // Only set the new ServiceType if it's different than the one // that's already in place. if (mServiceType != serviceType) { mServiceType = serviceType; if (mImageModelImpl != null) // Destroy the existing implementation, if any. mImageModelImpl.onDestroy(false); switch (mServiceType) { case STARTED_SERVICE: // Create an implementation that uses a Started // Service. mImageModelImpl = new ImageModelImplStartedService(); break; } // Initialize the ImageModel implementation. mImageModelImpl.onCreate(mImagePresenter.get()); } }
/** * Start a download. When the download finishes its results are passed up to the Presentation * layer via the onDownloadComplete() method defined in RequiredPresenterOps. * * @param url URL of the image to download. * @param directoryPathname Uri of the directory to store the downloaded image. */ @Override public void startDownload(Uri url, Uri directoryPathname) { mImageModelImpl.startDownload(url, directoryPathname); }
/** Hook method called to shutdown the Presenter layer. */ @Override public void onDestroy(boolean isChangingConfigurations) { // Forward the onDestroy(). mImageModelImpl.onDestroy(isChangingConfigurations); }