AlbumPicker.java revision f9a0a4306d589b4a4e20554fed512a603426bfa1
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.app; 18 19import com.android.gallery3d.R; 20import com.android.gallery3d.data.DataManager; 21import com.android.gallery3d.ui.GLRoot; 22import com.android.gallery3d.ui.GLRootView; 23 24import android.content.Intent; 25import android.os.Bundle; 26import android.view.View; 27import android.view.View.OnClickListener; 28 29public class AlbumPicker extends AbstractGalleryActivity 30 implements OnClickListener { 31 32 public static final String KEY_ALBUM_PATH = "album-path"; 33 34 @Override 35 public void onCreate(Bundle savedInstanceState) { 36 super.onCreate(savedInstanceState); 37 38 setContentView(R.layout.dialog_picker); 39 ((GLRootView) findViewById(R.id.gl_root_view)).setZOrderOnTop(true); 40 findViewById(R.id.cancel).setOnClickListener(this); 41 setTitle(R.string.select_album); 42 Intent intent = getIntent(); 43 Bundle extras = intent.getExtras(); 44 Bundle data = extras == null ? new Bundle() : new Bundle(extras); 45 46 data.putBoolean(Gallery.KEY_GET_ALBUM, true); 47 data.putString(AlbumSetPage.KEY_MEDIA_PATH, 48 getDataManager().getTopSetPath(DataManager.INCLUDE_IMAGE)); 49 getStateManager().startState(AlbumSetPage.class, data); 50 } 51 52 @Override 53 public void onBackPressed() { 54 // send the back event to the top sub-state 55 GLRoot root = getGLRoot(); 56 root.lockRenderThread(); 57 try { 58 getStateManager().getTopState().onBackPressed(); 59 } finally { 60 root.unlockRenderThread(); 61 } 62 } 63 64 @Override 65 public void onClick(View v) { 66 if (v.getId() == R.id.cancel) finish(); 67 } 68} 69