package com.android.gallery3d.filtershow.category;
import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentTransaction;
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.FilterShowActivity;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
import com.android.gallery3d.filtershow.state.StatePanel;
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) {
transaction.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left);
}
transaction.replace(R.id.category_panel_container, category, CategoryPanel.FRAGMENT_TAG);
- transaction.commit();
+ transaction.commitAllowingStateLoss();
}
- public void loadCategoryLookPanel() {
- if (mCurrentSelected == LOOKS) {
+ public void loadCategoryLookPanel(boolean force) {
+ if (!force && mCurrentSelected == LOOKS) {
return;
}
boolean fromRight = isRightAnimation(LOOKS);
if (mCurrentSelected == GEOMETRY) {
return;
}
+ if (MasterImage.getImage().hasTinyPlanet()) {
+ return;
+ }
boolean fromRight = isRightAnimation(GEOMETRY);
selection(mCurrentSelected, false);
CategoryPanel categoryPanel = new CategoryPanel();
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: {
- loadCategoryLookPanel();
+ loadCategoryLookPanel(false);
break;
}
case BORDERS: {
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) {
+ View container = mMainView.findViewById(R.id.state_panel_container);
+ FragmentTransaction transaction = null;
+ if (container == null) {
+ FilterShowActivity activity = (FilterShowActivity) getActivity();
+ container = activity.getMainStatePanelContainer(R.id.state_panel_container);
+ } else {
+ transaction = getChildFragmentManager().beginTransaction();
+ }
+ if (container == null) {
return;
+ } else {
+ transaction = getFragmentManager().beginTransaction();
}
- 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);
if (statePanel != null) {
transaction.remove(statePanel);
}
+ if (currentPanel == VERSIONS) {
+ currentPanel = LOOKS;
+ }
}
+ mCurrentSelected = -1;
+ showPanel(currentPanel);
transaction.commit();
}
}