1 /* 2 * Copyright (C) 2013 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.filtershow.controller; 18 19 import android.util.Log; 20 import android.view.View; 21 import android.view.View.OnClickListener; 22 import android.view.ViewGroup; 23 import android.widget.ImageButton; 24 25 import com.android.gallery3d.R; 26 import com.android.gallery3d.filtershow.editors.Editor; 27 28 public class ActionSlider extends TitledSlider { 29 private static final String LOGTAG = "ActionSlider"; 30 ImageButton mLeftButton; 31 ImageButton mRightButton; 32 public ActionSlider() { 33 mLayoutID = R.layout.filtershow_control_action_slider; 34 } 35 36 @Override 37 public void setUp(ViewGroup container, Parameter parameter, Editor editor) { 38 super.setUp(container, parameter, editor); 39 mLeftButton = (ImageButton) mTopView.findViewById(R.id.leftActionButton); 40 mLeftButton.setOnClickListener(new OnClickListener() { 41 42 @Override 43 public void onClick(View v) { 44 ((ParameterActionAndInt) mParameter).fireLeftAction(); 45 } 46 }); 47 48 mRightButton = (ImageButton) mTopView.findViewById(R.id.rightActionButton); 49 mRightButton.setOnClickListener(new OnClickListener() { 50 51 @Override 52 public void onClick(View v) { 53 ((ParameterActionAndInt) mParameter).fireRightAction(); 54 } 55 }); 56 updateUI(); 57 } 58 59 @Override 60 public void updateUI() { 61 super.updateUI(); 62 if (mLeftButton != null) { 63 int iconId = ((ParameterActionAndInt) mParameter).getLeftIcon(); 64 mLeftButton.setImageResource(iconId); 65 } 66 if (mRightButton != null) { 67 int iconId = ((ParameterActionAndInt) mParameter).getRightIcon(); 68 mRightButton.setImageResource(iconId); 69 } 70 } 71 } 72