1/* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.android.gallery3d.ui; 18 19import android.os.Bundle; 20import android.widget.Toast; 21 22import com.android.gallery3d.R; 23import com.android.gallery3d.app.AbstractGalleryActivity; 24import com.android.gallery3d.app.AlbumPage; 25import com.android.gallery3d.util.MediaSetUtils; 26 27public class ImportCompleteListener extends WakeLockHoldingProgressListener { 28 private static final String WAKE_LOCK_LABEL = "Gallery Album Import"; 29 30 public ImportCompleteListener(AbstractGalleryActivity galleryActivity) { 31 super(galleryActivity, WAKE_LOCK_LABEL); 32 } 33 34 @Override 35 public void onProgressComplete(int result) { 36 super.onProgressComplete(result); 37 int message; 38 if (result == MenuExecutor.EXECUTION_RESULT_SUCCESS) { 39 message = R.string.import_complete; 40 goToImportedAlbum(); 41 } else { 42 message = R.string.import_fail; 43 } 44 Toast.makeText(getActivity().getAndroidContext(), message, Toast.LENGTH_LONG).show(); 45 } 46 47 private void goToImportedAlbum() { 48 String pathOfImportedAlbum = "/local/all/" + MediaSetUtils.IMPORTED_BUCKET_ID; 49 Bundle data = new Bundle(); 50 data.putString(AlbumPage.KEY_MEDIA_PATH, pathOfImportedAlbum); 51 getActivity().getStateManager().startState(AlbumPage.class, data); 52 } 53} 54