/** * 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()); } }
/** Hook method called to shutdown the Presenter layer. */ @Override public void onDestroy(boolean isChangingConfigurations) { // Forward the onDestroy(). mImageModelImpl.onDestroy(isChangingConfigurations); }