@@ -66,8 +66,7 @@ public BaseCircleDialog() {
66
66
}
67
67
68
68
@ Override
69
- public View onCreateView (LayoutInflater inflater , ViewGroup container , Bundle
70
- savedInstanceState ) {
69
+ public View onCreateView (LayoutInflater inflater , ViewGroup container , Bundle savedInstanceState ) {
71
70
View view = createView (getContext (), inflater , container );
72
71
if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .JELLY_BEAN ) {
73
72
view .setBackground (new CircleDrawable (mBackgroundColor , mRadius ));
@@ -78,20 +77,22 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle
78
77
return view ;
79
78
}
80
79
80
+ public abstract View createView (Context context , LayoutInflater inflater , ViewGroup container );
81
+
81
82
@ Override
82
83
public void onViewCreated (final View view , @ Nullable Bundle savedInstanceState ) {
83
84
super .onViewCreated (view , savedInstanceState );
84
85
if (mMaxHeight > 0 ) {
85
86
mOnLayoutChangeListener = new View .OnLayoutChangeListener () {
86
87
@ Override
87
- public void onLayoutChange (View v , int left , int top , int right , int bottom , int oldLeft , int oldTop , int oldRight , int oldBottom ) {
88
+ public void onLayoutChange (View v , int left , int top , int right , int bottom
89
+ , int oldLeft , int oldTop , int oldRight , int oldBottom ) {
88
90
int height = v .getHeight ();
89
91
DisplayMetrics dm = getDisplayMetrics ();
90
92
int maxHeight = (int ) (dm .heightPixels * mMaxHeight );
91
93
if (height > maxHeight ) {
92
94
view .setLayoutParams (new FrameLayout .LayoutParams (
93
- FrameLayout .LayoutParams .MATCH_PARENT
94
- , maxHeight ));
95
+ FrameLayout .LayoutParams .MATCH_PARENT , maxHeight ));
95
96
}
96
97
}
97
98
};
@@ -107,8 +108,6 @@ private DisplayMetrics getDisplayMetrics() {
107
108
return dm ;
108
109
}
109
110
110
- public abstract View createView (Context context , LayoutInflater inflater , ViewGroup container );
111
-
112
111
@ Override
113
112
public void show (FragmentManager manager , String tag ) {
114
113
FragmentTransaction transaction = manager .beginTransaction ();
@@ -152,6 +151,14 @@ public void onDismiss(DialogInterface dialog) {
152
151
remove ();
153
152
}
154
153
154
+ public void remove () {
155
+ FragmentManager fragmentManager = getFragmentManager ();
156
+ if (fragmentManager == null ) return ;
157
+ FragmentTransaction ft = fragmentManager .beginTransaction ();
158
+ ft .remove (this );
159
+ ft .addToBackStack (null );
160
+ }
161
+
155
162
@ Override
156
163
public void onStart () {
157
164
Dialog dialog = getDialog ();
@@ -163,24 +170,6 @@ public void onStart() {
163
170
super .onStart ();
164
171
}
165
172
166
- @ Override
167
- public void onSaveInstanceState (Bundle outState ) {
168
- super .onSaveInstanceState (outState );
169
- outState .putInt (SAVED_GRAVITY , mGravity );
170
- outState .putBoolean (SAVED_TOUCH_OUT , mCanceledOnTouchOutside );
171
- outState .putBoolean (SAVED_CANCELED_BACK , mCanceledBack );
172
- outState .putFloat (SAVED_WIDTH , mWidth );
173
- outState .putFloat (SAVED_HEIGHT_MAX , mMaxHeight );
174
- if (mPadding != null ) outState .putIntArray (SAVED_PADDING , mPadding );
175
- outState .putInt (SAVED_ANIM_STYLE , mAnimStyle );
176
- outState .putBoolean (SAVED_DIM_ENABLED , isDimEnabled );
177
- outState .putInt (SAVED_BACKGROUND_COLOR , mBackgroundColor );
178
- outState .putInt (SAVED_RADIUS , mRadius );
179
- outState .putFloat (SAVED_ALPHA , mAlpha );
180
- outState .putInt (SAVED_X , mX );
181
- outState .putInt (SAVED_Y , mY );
182
- }
183
-
184
173
/**
185
174
* 对话框配置
186
175
*
@@ -211,12 +200,22 @@ private void setDialogGravity(Dialog dialog) {
211
200
window .setAttributes (wlp );
212
201
}
213
202
214
- public void remove () {
215
- FragmentManager fragmentManager = getFragmentManager ();
216
- if (fragmentManager == null ) return ;
217
- FragmentTransaction ft = fragmentManager .beginTransaction ();
218
- ft .remove (this );
219
- ft .addToBackStack (null );
203
+ @ Override
204
+ public void onSaveInstanceState (Bundle outState ) {
205
+ super .onSaveInstanceState (outState );
206
+ outState .putInt (SAVED_GRAVITY , mGravity );
207
+ outState .putBoolean (SAVED_TOUCH_OUT , mCanceledOnTouchOutside );
208
+ outState .putBoolean (SAVED_CANCELED_BACK , mCanceledBack );
209
+ outState .putFloat (SAVED_WIDTH , mWidth );
210
+ outState .putFloat (SAVED_HEIGHT_MAX , mMaxHeight );
211
+ if (mPadding != null ) outState .putIntArray (SAVED_PADDING , mPadding );
212
+ outState .putInt (SAVED_ANIM_STYLE , mAnimStyle );
213
+ outState .putBoolean (SAVED_DIM_ENABLED , isDimEnabled );
214
+ outState .putInt (SAVED_BACKGROUND_COLOR , mBackgroundColor );
215
+ outState .putInt (SAVED_RADIUS , mRadius );
216
+ outState .putFloat (SAVED_ALPHA , mAlpha );
217
+ outState .putInt (SAVED_X , mX );
218
+ outState .putInt (SAVED_Y , mY );
220
219
}
221
220
222
221
/**
0 commit comments