Search in sources :

Example 1 with StraightenPanel

use of com.android.gallery3d.filtershow.category.StraightenPanel in project android_packages_apps_Gallery2 by LineageOS.

the class FilterShowActivity method loadEditorPanel.

public void loadEditorPanel(final FilterRepresentation representation) {
    final int currentId = representation.getEditorId();
    // show representation
    if (mCurrentEditor != null) {
        mCurrentEditor.detach();
    }
    mCurrentEditor = mEditorPlaceHolder.showEditor(currentId);
    if (mCurrentEditor.showsActionBar()) {
        setActionBar();
        showActionBar(true);
    } else {
    // showActionBar(false);
    }
    if (representation.getFilterType() == FilterRepresentation.TYPE_WATERMARK_CATEGORY) {
        loadWaterMarkPanel((FilterWatermarkRepresentation) representation);
        return;
    }
    if (currentId == ImageOnlyEditor.ID) {
        mCurrentEditor.reflectCurrentFilter();
        return;
    }
    if (currentId == EditorTruePortraitImageOnly.ID) {
        mCurrentEditor.reflectCurrentFilter();
        setActionBarForEffects(mCurrentEditor);
        return;
    }
    if (currentId == EditorCrop.ID) {
        loadEditorCropPanel();
        return;
    }
    if (useStraightenPanel(currentId)) {
        new Runnable() {

            @Override
            public void run() {
                StraightenPanel panel = new StraightenPanel();
                Bundle bundle = new Bundle();
                bundle.putInt(StraightenPanel.EDITOR_ID, currentId);
                bundle.putString(StraightenPanel.EDITOR_NAME, representation.getName());
                panel.setArguments(bundle);
                FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
                transaction.remove(getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG));
                transaction.replace(R.id.main_panel_container, panel, MainPanel.FRAGMENT_TAG);
                transaction.commit();
            }
        }.run();
        return;
    }
    if (currentId == TrueScannerEditor.ID) {
        new Runnable() {

            @Override
            public void run() {
                TrueScannerPanel panel = new TrueScannerPanel();
                FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
                transaction.remove(getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG));
                transaction.replace(R.id.main_panel_container, panel, MainPanel.FRAGMENT_TAG);
                transaction.commit();
            }
        }.run();
        return;
    }
    if (currentId == EditorTruePortraitMask.ID) {
        new Runnable() {

            @Override
            public void run() {
                setActionBarForEffects(mCurrentEditor);
                TruePortraitMaskEditorPanel panel = new TruePortraitMaskEditorPanel();
                FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
                transaction.remove(getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG));
                transaction.replace(R.id.main_panel_container, panel, MainPanel.FRAGMENT_TAG);
                transaction.commit();
            }
        }.run();
        return;
    }
    Runnable showEditor = new Runnable() {

        @Override
        public void run() {
            EditorPanel panel = new EditorPanel();
            panel.setEditor(currentId);
            setActionBarForEffects(mCurrentEditor);
            Fragment main = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG);
            if (main instanceof MainPanel) {
                ((MainPanel) main).setEditorPanelFragment(panel);
            }
        }
    };
    Fragment main = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG);
    boolean doAnimation = false;
    if (mShowingImageStatePanel && getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        doAnimation = true;
    }
    if (doAnimation && main != null && main instanceof MainPanel) {
        MainPanel mainPanel = (MainPanel) main;
        View container = mainPanel.getView().findViewById(R.id.category_panel_container);
        View bottom = mainPanel.getView().findViewById(R.id.bottom_panel);
        int panelHeight = container.getHeight() + bottom.getHeight();
        ViewPropertyAnimator anim = mainPanel.getView().animate();
        anim.translationY(panelHeight).start();
        final Handler handler = new Handler();
        handler.postDelayed(showEditor, anim.getDuration());
    } else {
        showEditor.run();
    }
}
Also used : Bundle(android.os.Bundle) TruePortraitMaskEditorPanel(com.android.gallery3d.filtershow.category.TruePortraitMaskEditorPanel) EditorPanel(com.android.gallery3d.filtershow.editors.EditorPanel) Handler(android.os.Handler) TruePortraitMaskEditorPanel(com.android.gallery3d.filtershow.category.TruePortraitMaskEditorPanel) Fragment(android.support.v4.app.Fragment) MediaPickerFragment(com.android.gallery3d.filtershow.mediapicker.MediaPickerFragment) DialogFragment(android.support.v4.app.DialogFragment) CategoryView(com.android.gallery3d.filtershow.category.CategoryView) SwipableView(com.android.gallery3d.filtershow.category.SwipableView) WaterMarkView(com.android.gallery3d.filtershow.category.WaterMarkView) View(android.view.View) AdapterView(android.widget.AdapterView) Point(android.graphics.Point) TrueScannerPanel(com.android.gallery3d.filtershow.category.TrueScannerPanel) ViewPropertyAnimator(android.view.ViewPropertyAnimator) FragmentTransaction(android.support.v4.app.FragmentTransaction) MainPanel(com.android.gallery3d.filtershow.category.MainPanel) StraightenPanel(com.android.gallery3d.filtershow.category.StraightenPanel)

Aggregations

Point (android.graphics.Point)1 Bundle (android.os.Bundle)1 Handler (android.os.Handler)1 DialogFragment (android.support.v4.app.DialogFragment)1 Fragment (android.support.v4.app.Fragment)1 FragmentTransaction (android.support.v4.app.FragmentTransaction)1 View (android.view.View)1 ViewPropertyAnimator (android.view.ViewPropertyAnimator)1 AdapterView (android.widget.AdapterView)1 CategoryView (com.android.gallery3d.filtershow.category.CategoryView)1 MainPanel (com.android.gallery3d.filtershow.category.MainPanel)1 StraightenPanel (com.android.gallery3d.filtershow.category.StraightenPanel)1 SwipableView (com.android.gallery3d.filtershow.category.SwipableView)1 TruePortraitMaskEditorPanel (com.android.gallery3d.filtershow.category.TruePortraitMaskEditorPanel)1 TrueScannerPanel (com.android.gallery3d.filtershow.category.TrueScannerPanel)1 WaterMarkView (com.android.gallery3d.filtershow.category.WaterMarkView)1 EditorPanel (com.android.gallery3d.filtershow.editors.EditorPanel)1 MediaPickerFragment (com.android.gallery3d.filtershow.mediapicker.MediaPickerFragment)1