Home | History | Annotate | Download | only in ui
      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 
     17 package com.android.gallery3d.ui;
     18 
     19 import android.os.Bundle;
     20 import android.widget.Toast;
     21 
     22 import com.android.gallery3d.R;
     23 import com.android.gallery3d.app.AlbumPage;
     24 import com.android.gallery3d.app.GalleryActivity;
     25 import com.android.gallery3d.util.MediaSetUtils;
     26 
     27 public class ImportCompleteListener implements MenuExecutor.ProgressListener {
     28     private GalleryActivity mActivity;
     29 
     30     public ImportCompleteListener(GalleryActivity galleryActivity) {
     31         mActivity = galleryActivity;
     32     }
     33 
     34     @Override
     35     public void onProgressComplete(int result) {
     36         int message;
     37         if (result == MenuExecutor.EXECUTION_RESULT_SUCCESS) {
     38             message = R.string.import_complete;
     39             goToImportedAlbum();
     40         } else {
     41             message = R.string.import_fail;
     42         }
     43         Toast.makeText(mActivity.getAndroidContext(), message, Toast.LENGTH_LONG).show();
     44     }
     45 
     46     @Override
     47     public void onProgressUpdate(int index) {
     48     }
     49 
     50     private void goToImportedAlbum() {
     51         String pathOfImportedAlbum = "/local/all/" + MediaSetUtils.IMPORTED_BUCKET_ID;
     52         Bundle data = new Bundle();
     53         data.putString(AlbumPage.KEY_MEDIA_PATH, pathOfImportedAlbum);
     54         mActivity.getStateManager().startState(AlbumPage.class, data);
     55     }
     56 
     57     @Override
     58     public void onConfirmDialogDismissed(boolean confirmed) {
     59     }
     60 
     61     @Override
     62     public void onConfirmDialogShown() {
     63     }
     64 }
     65