package view_inspector.ui.dialog;

import android.app.AlertDialog;
import android.content.Context;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import com.f2prateek.rx.preferences.Preference;
import javax.inject.Inject;
import view_inspector.R;
import view_inspector.ViewInspector;
import view_inspector.dagger.qualifier.BypassInterceptor;
import view_inspector.ui.ViewInspectorToolbar;
import view_inspector.ui.menu.BaseMenu;

public class BaseDialog extends AlertDialog {
  @Inject @BypassInterceptor Preference<Boolean> bypassInterceptor;
  @Inject ViewInspectorToolbar toolbar;
  BaseMenu mMenu;

  public BaseDialog(Context context) {
    super(context);
    ViewInspector.runtimeComponentMap.get(((ContextThemeWrapper) context).getBaseContext())
        .inject(this);
    setCancelable(true);
    setCanceledOnTouchOutside(true);
  }

  @Override protected void onStart() {
    super.onStart();
    bypassInterceptor.set(true);
    mMenu = toolbar.getMenu();
    toolbar.closeToolbar();
  }

  @Override protected void onStop() {
    bypassInterceptor.set(false);
    toolbar.toggleToolbar();
    if (mMenu != null) toolbar.openMenu(mMenu);
    super.onStop();
  }

  @Override public void onAttachedToWindow() {
    super.onAttachedToWindow();
  }

  @Override public void onDetachedFromWindow() {
    super.onDetachedFromWindow();
  }

  public static int getDialogTheme(Context context) {
    TypedValue outValue = new TypedValue();
    context.getTheme().resolveAttribute(R.attr.isLightTheme, outValue, true);
    return outValue.data != 0 ? R.style.DialogThemeLight : R.style.DialogTheme;
  }
}

@@ -880,54 +880,41 @@
 de p
-rotected void onStart() %7B%0A    super.onStart();
+ublic void onAttachedToWindow() %7B
 %0A   
@@ -1008,44 +1008,87 @@
 ;%0A  
-%7D%0A%0A  @Override protected void onStop
+  super.onAttachedToWindow();%0A  %7D%0A%0A  @Override public void onDetachedFromWindow
 () %7B
@@ -1203,166 +1203,8 @@
 u);%0A
-    super.onStop();%0A  %7D%0A%0A  @Override public void onAttachedToWindow() %7B%0A    super.onAttachedToWindow();%0A  %7D%0A%0A  @Override public void onDetachedFromWindow() %7B%0A
     

Fix issue#4