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
17package com.android.gallery3d.filtershow.controller;
18
19import android.util.Log;
20import android.view.View;
21import android.view.View.OnClickListener;
22import android.view.ViewGroup;
23import android.widget.ImageButton;
24
25import com.android.gallery3d.R;
26import com.android.gallery3d.filtershow.editors.Editor;
27
28public 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