2 * Copyright (C) 2012 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.gallery3d.filtershow.editors;
19 import android.content.Context;
20 import android.view.LayoutInflater;
21 import android.view.View;
22 import android.view.ViewGroup;
23 import android.widget.FrameLayout;
24 import android.widget.LinearLayout;
26 import com.android.gallery3d.filtershow.PanelController;
27 import com.android.gallery3d.filtershow.cache.ImageLoader;
28 import com.android.gallery3d.filtershow.imageshow.ImageShow;
31 * Base class for Editors Must contain a mImageShow and a top level view
34 protected Context mContext;
36 protected ImageShow mImageShow;
37 protected FrameLayout mFrameLayout;
38 protected PanelController mPanelController;
40 private final String LOGTAG = "Editor";
42 public void setPanelController(PanelController panelController) {
43 this.mPanelController = panelController;
46 protected Editor(int id) {
53 public void createEditor(Context context,FrameLayout frameLayout) {
55 mFrameLayout = frameLayout;
58 protected void unpack(int viewid, int layoutid) {
61 mView = mFrameLayout.findViewById(viewid);
63 LayoutInflater inflater = (LayoutInflater) mContext.getSystemService
64 (Context.LAYOUT_INFLATER_SERVICE);
65 mView = inflater.inflate(layoutid, mFrameLayout, false);
66 mFrameLayout.addView(mView, mView.getLayoutParams());
69 mImageShow = findImageShow(mView);
72 private ImageShow findImageShow(View view) {
73 if (view instanceof ImageShow) {
74 return (ImageShow) view;
76 if (!(view instanceof ViewGroup)) {
79 ViewGroup vg = (ViewGroup) view;
80 int n = vg.getChildCount();
81 for (int i = 0; i < n; i++) {
82 View v = vg.getChildAt(i);
83 if (v instanceof ImageShow) {
85 } else if (v instanceof ViewGroup) {
86 return findImageShow(v);
92 public View getTopLevelView() {
96 public ImageShow getImageShow() {
100 public void setImageLoader(ImageLoader imageLoader) {
101 mImageShow.setImageLoader(imageLoader);
104 public void setVisibility(int visible) {
105 mView.setVisibility(visible);
109 * called after the filter is set and the select is called
111 public void reflectCurrentFilter() {
114 public boolean useUtilityPanel() {
115 if (mImageShow != null) {
116 return mImageShow.useUtilityPanel();
121 public void openUtilityPanel(LinearLayout mAccessoryViewList) {
122 if (mImageShow != null) {
123 mImageShow.openUtilityPanel(mAccessoryViewList);