OSDN Git Service

Add version category
[android-x86/packages-apps-Gallery2.git] / src / com / android / gallery3d / filtershow / category / MainPanel.java
index 9a64ffb..47f575d 100644 (file)
@@ -44,8 +44,10 @@ public class MainPanel extends Fragment {
     public static final int BORDERS = 1;
     public static final int GEOMETRY = 2;
     public static final int FILTERS = 3;
+    public static final int VERSIONS = 4;
 
     private int mCurrentSelected = -1;
+    private int mPreviousToggleVersions = -1;
 
     private void selection(int position, boolean value) {
         if (value) {
@@ -146,6 +148,7 @@ public class MainPanel extends Fragment {
 
     public void loadCategoryLookPanel() {
         if (mCurrentSelected == LOOKS) {
+
             return;
         }
         boolean fromRight = isRightAnimation(LOOKS);
@@ -196,6 +199,21 @@ public class MainPanel extends Fragment {
         selection(mCurrentSelected, true);
     }
 
+    public void loadCategoryVersionsPanel() {
+        if (mCurrentSelected == VERSIONS) {
+            return;
+        }
+        FilterShowActivity activity = (FilterShowActivity) getActivity();
+        activity.updateVersions();
+        boolean fromRight = isRightAnimation(VERSIONS);
+        selection(mCurrentSelected, false);
+        CategoryPanel categoryPanel = new CategoryPanel();
+        categoryPanel.setAdapter(VERSIONS);
+        setCategoryFragment(categoryPanel, fromRight);
+        mCurrentSelected = VERSIONS;
+        selection(mCurrentSelected, true);
+    }
+
     public void showPanel(int currentPanel) {
         switch (currentPanel) {
             case LOOKS: {
@@ -214,18 +232,43 @@ public class MainPanel extends Fragment {
                 loadCategoryFiltersPanel();
                 break;
             }
+            case VERSIONS: {
+                loadCategoryVersionsPanel();
+                break;
+            }
         }
     }
 
+    public void setToggleVersionsPanelButton(ImageButton button) {
+        if (button == null) {
+            return;
+        }
+        button.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                if (mCurrentSelected == VERSIONS) {
+                    showPanel(mPreviousToggleVersions);
+                } else {
+                    mPreviousToggleVersions = mCurrentSelected;
+                    showPanel(VERSIONS);
+                }
+            }
+        });
+    }
+
     public void showImageStatePanel(boolean show) {
         if (mMainView.findViewById(R.id.state_panel_container) == null) {
             return;
         }
         FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
         final View container = mMainView.findViewById(R.id.state_panel_container);
+        int currentPanel = mCurrentSelected;
         if (show) {
             container.setVisibility(View.VISIBLE);
             StatePanel statePanel = new StatePanel();
+            statePanel.setMainPanel(this);
+            FilterShowActivity activity = (FilterShowActivity) getActivity();
+            activity.updateVersions();
             transaction.replace(R.id.state_panel_container, statePanel, StatePanel.FRAGMENT_TAG);
         } else {
             container.setVisibility(View.GONE);
@@ -233,7 +276,12 @@ public class MainPanel extends Fragment {
             if (statePanel != null) {
                 transaction.remove(statePanel);
             }
+            if (currentPanel == VERSIONS) {
+                currentPanel = LOOKS;
+            }
         }
+        mCurrentSelected = -1;
+        showPanel(currentPanel);
         transaction.commit();
     }
 }