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.videoeditor; 18 19 import android.app.ListActivity; 20 import android.content.Intent; 21 import android.os.Bundle; 22 import android.view.View; 23 import android.widget.ListView; 24 25 import com.android.videoeditor.service.MovieOverlay; 26 27 28 public class OverlayTitleTemplatePicker extends ListActivity { 29 // Incoming parameter keys. 30 public static final String PARAM_MEDIA_ITEM_ID = "media_item_id"; 31 public static final String PARAM_OVERLAY_ATTRIBUTES = "attributes"; 32 public static final String PARAM_OVERLAY_ID = "overlay_id"; 33 34 private OverlaysAdapter mAdapter; 35 36 @Override 37 public void onCreate(Bundle savedInstanceState) { 38 super.onCreate(savedInstanceState); 39 setContentView(R.layout.list_view); 40 setFinishOnTouchOutside(true); 41 42 // Create the list adapter 43 mAdapter = new OverlaysAdapter(this, getListView()); 44 setListAdapter(mAdapter); 45 } 46 47 @Override 48 public void onPause() { 49 super.onPause(); 50 51 if (mAdapter != null) { 52 mAdapter.onPause(); 53 } 54 } 55 56 @Override 57 public void onDestroy() { 58 super.onDestroy(); 59 60 if (mAdapter != null) { 61 mAdapter.onDestroy(); 62 } 63 } 64 65 @Override 66 public void onListItemClick(ListView l, View v, int position, long id) { 67 // Put selected overlay type into extras and finish. 68 final Intent extras = new Intent(); 69 final int overlayType = ((OverlayType) mAdapter.getItem(position)).getType(); 70 final Bundle bundle = MovieOverlay.buildUserAttributes(overlayType, "", ""); 71 extras.putExtra(PARAM_OVERLAY_ATTRIBUTES, bundle); 72 setResult(RESULT_OK, extras); 73 finish(); 74 } 75 76 @Override 77 public boolean onSearchRequested() { 78 return false; 79 } 80 } 81