Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
shehuan committed Oct 22, 2018
1 parent c2f1171 commit bf85903
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
7 changes: 3 additions & 4 deletions app/src/main/java/com/othershe/test/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.Gravity;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
Expand Down Expand Up @@ -38,7 +37,7 @@ public void onClick(View v) {
}
})
.setDimAmount(0.3f)
.setPosition(Gravity.RIGHT)
.setShowBottom(true)
.show(getSupportFragmentManager());
}

Expand All @@ -51,7 +50,7 @@ public void convertView(ViewHolder holder, final BaseNiceDialog dialog) {

}
})
.setPosition(Gravity.BOTTOM)
.setShowBottom(true)
.setHeight(310)
.show(getSupportFragmentManager());
}
Expand All @@ -72,7 +71,7 @@ public void run() {
});
}
})
.setPosition(Gravity.BOTTOM)
.setShowBottom(true)
.show(getSupportFragmentManager());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public abstract class BaseNiceDialog extends DialogFragment {
private static final String WIDTH = "width";
private static final String HEIGHT = "height";
private static final String DIM = "dim_amount";
private static final String POSITION = "position";
private static final String BOTTOM = "show_bottom";
private static final String CANCEL = "out_cancel";
private static final String ANIM = "anim_style";
private static final String LAYOUT = "layout_id";
Expand All @@ -28,7 +28,7 @@ public abstract class BaseNiceDialog extends DialogFragment {
private int width;//宽度
private int height;//高度
private float dimAmount = 0.5f;//灰度深浅
private int position;//显示的位置
private boolean showBottom;//是否底部显示
private boolean outCancel = true;//是否点击外部取消
@StyleRes
private int animStyle;
Expand All @@ -51,7 +51,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
width = savedInstanceState.getInt(WIDTH);
height = savedInstanceState.getInt(HEIGHT);
dimAmount = savedInstanceState.getFloat(DIM);
position = savedInstanceState.getInt(POSITION);
showBottom = savedInstanceState.getBoolean(BOTTOM);
outCancel = savedInstanceState.getBoolean(CANCEL);
animStyle = savedInstanceState.getInt(ANIM);
layoutId = savedInstanceState.getInt(LAYOUT);
Expand Down Expand Up @@ -84,7 +84,7 @@ public void onSaveInstanceState(Bundle outState) {
outState.putInt(WIDTH, width);
outState.putInt(HEIGHT, height);
outState.putFloat(DIM, dimAmount);
outState.putInt(POSITION, position);
outState.putBoolean(BOTTOM, showBottom);
outState.putBoolean(CANCEL, outCancel);
outState.putInt(ANIM, animStyle);
outState.putInt(LAYOUT, layoutId);
Expand All @@ -96,8 +96,9 @@ private void initParams() {
WindowManager.LayoutParams lp = window.getAttributes();
//调节灰色背景透明度[0-1],默认0.5f
lp.dimAmount = dimAmount;
lp.gravity = position;
if (position == Gravity.BOTTOM) {
//是否在底部显示
if (showBottom) {
lp.gravity = Gravity.BOTTOM;
if (animStyle == 0) {
animStyle = R.style.DefaultAnimation;
}
Expand Down Expand Up @@ -146,8 +147,8 @@ public BaseNiceDialog setDimAmount(float dimAmount) {
return this;
}

public BaseNiceDialog setPosition(int position) {
this.position = position;
public BaseNiceDialog setShowBottom(boolean showBottom) {
this.showBottom = showBottom;
return this;
}

Expand Down

0 comments on commit bf85903

Please sign in to comment.