package net.miz_hi.smileessence.command;

import net.miz_hi.smileessence.Client;
import net.miz_hi.smileessence.dialog.ConfirmDialog;
import net.miz_hi.smileessence.dialog.MenuDialog;
import net.miz_hi.smileessence.preference.EnumPreferenceKey;
import net.miz_hi.smileessence.util.UiHandler;
import net.miz_hi.smileessence.view.activity.MainActivity;

public abstract class MenuCommand implements ICommand
{

    @Override
    public boolean getDefaultVisibility()
    {
        return true;
    }

    @Override
    public final void run()
    {
        new UiHandler()
        {

            @Override
            public void run()
            {
                if (MenuCommand.this instanceof IConfirmable && Client.<Boolean>getPreferenceValue(EnumPreferenceKey.CONFIRM_DIALOG))
                {
                    ConfirmDialog.show(MainActivity.getInstance(), "実行しますか？", new Runnable()
                    {
                        @Override
                        public void run()
                        {
                            workOnUiThread();
                            MenuDialog.dispose();
                        }
                    });
                }
                else
                {
                    workOnUiThread();
                    MenuDialog.dispose();
                }
            }
        }.post();
    }

    public abstract void workOnUiThread();

}

@@ -1034,38 +1034,42 @@
             
-workOnUiThread
+MenuDialog.dispose
 ();%0A        
@@ -1088,34 +1088,30 @@
         
-MenuDialog.dispose
+workOnUiThread
 ();%0A    
@@ -1229,38 +1229,42 @@
             
-workOnUiThread
+MenuDialog.dispose
 ();%0A        
@@ -1275,34 +1275,30 @@
         
-MenuDialog.dispose
+workOnUiThread
 ();%0A    

Fix bug