Skip to content

Commit

Permalink
0.0.41.beta5
Browse files Browse the repository at this point in the history
  • Loading branch information
kongzue committed Jul 30, 2021
1 parent d8fcb09 commit 5cda6e5
Show file tree
Hide file tree
Showing 16 changed files with 185 additions and 26 deletions.
10 changes: 5 additions & 5 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions .idea/runConfigurations.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -955,4 +955,9 @@ public void hide() {
getDialogView().setVisibility(View.GONE);
}
}

@Override
protected void shutdown() {
dismiss();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1060,4 +1060,9 @@ public BottomMenu setExitAnimDuration(long exitAnimDuration) {
public SELECT_MODE getSelectMode() {
return selectMode;
}

@Override
protected void shutdown() {
dismiss();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -495,4 +495,9 @@ public void hide() {
getDialogView().setVisibility(View.GONE);
}
}

@Override
protected void shutdown() {
dismiss();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -450,4 +450,9 @@ public void hide() {
getDialogView().setVisibility(View.GONE);
}
}

@Override
protected void shutdown() {
dismiss();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1071,4 +1071,9 @@ public MessageDialog setExitAnimResId(int exitResId) {
customExitAnimResId = exitResId;
return this;
}

@Override
protected void shutdown() {
dismiss();
}
}
5 changes: 5 additions & 0 deletions DialogX/src/main/java/com/kongzue/dialogx/dialogs/PopTip.java
Original file line number Diff line number Diff line change
Expand Up @@ -924,4 +924,9 @@ public PopTip setExitAnimResId(int exitResId) {
this.exitAnimResId = exitResId;
return this;
}

@Override
protected void shutdown() {
dismiss();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -839,4 +839,9 @@ protected static void showWithInstance(boolean noInstance, Activity activity) {
getInstanceNotNull(activity).refreshUI();
}
}

@Override
protected void shutdown() {
dismiss();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,19 @@ public static Context getContext() {
return contextWeakReference.get();
}

/**
* 自动执行,不建议自行调用此方法
*
* @hide
*/
public static void cleanContext() {
contextWeakReference.clear();
if (contextWeakReference != null) contextWeakReference.clear();
contextWeakReference = null;
System.gc();
}

protected abstract void shutdown();

protected boolean cancelable = true;
protected OnBackPressedListener onBackPressedListener;
protected boolean isShow;
Expand Down Expand Up @@ -440,6 +447,18 @@ public Activity getActivity() {

protected void cleanActivityContext() {
if (ownActivity != null) ownActivity.clear();
ownActivity = null;
}

public static void cleanAll(){
if (runningDialogList != null) {
CopyOnWriteArrayList<BaseDialog> copyOnWriteList = new CopyOnWriteArrayList<>(runningDialogList);
for (BaseDialog baseDialog : copyOnWriteList) {
if (baseDialog.isShow())baseDialog.shutdown();
baseDialog.cleanActivityContext();
runningDialogList.remove(baseDialog);
}
}
}

public static void recycleDialog(Activity activity) {
Expand All @@ -464,6 +483,20 @@ public static void recycleDialog(Activity activity) {
}
}
break;
default:
if (runningDialogList != null) {
CopyOnWriteArrayList<BaseDialog> copyOnWriteList = new CopyOnWriteArrayList<>(runningDialogList);
for (BaseDialog baseDialog : copyOnWriteList) {
if (baseDialog.getActivity() == activity) {
baseDialog.cleanActivityContext();
runningDialogList.remove(baseDialog);
}
}
}
break;
}
if (activity == getContext()) {
cleanContext();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected void onDraw(Canvas canvas) {
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);

refreshImage();
if (isAttachedToWindow()) refreshImage();
}

private int screenWidth, screenHeight;
Expand All @@ -104,16 +104,19 @@ private void doScreenshotActivityAndZoom() {
if (BaseDialog.getRootFrameLayout() == null) return;
final View view = BaseDialog.getRootFrameLayout().getChildAt(0);
//先执行一次绘制,防止出现闪屏问题
drawViewImage(view);
if (!inited) drawViewImage(view);
view.post(new Runnable() {
@Override
public void run() {
//当view渲染完成后再次通知刷新一下界面(当旋转屏幕执行时,很可能出现渲染延迟的问题)
drawViewImage(view);
inited = true;
}
});
}

private boolean inited = false;

private void drawViewImage(View view) {
view.destroyDrawingCache();
view.setDrawingCacheEnabled(true);
Expand Down
40 changes: 40 additions & 0 deletions app/src/main/java/com/kongzue/dialogxdemo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public class MainActivity extends BaseActivity {
private ImageView btnShare;
private TextView txtTitle;
private LinearLayout boxBody;
private RadioGroup grpMode;
private RadioButton rdoModeView;
private RadioButton rdoModeWindow;
private RadioButton rdoModeDialogFragment;
private RadioGroup grpStyle;
private RadioButton rdoMaterial;
private RadioButton rdoIos;
Expand Down Expand Up @@ -107,6 +111,10 @@ public void initViews() {
btnShare = findViewById(R.id.btn_share);
txtTitle = findViewById(R.id.txt_title);
boxBody = findViewById(R.id.box_body);
grpMode = findViewById(R.id.grp_mode);
rdoModeView = findViewById(R.id.rdo_mode_view);
rdoModeWindow = findViewById(R.id.rdo_mode_window);
rdoModeDialogFragment = findViewById(R.id.rdo_mode_dialogFragment);
grpStyle = findViewById(R.id.grp_style);
rdoMaterial = findViewById(R.id.rdo_material);
rdoIos = findViewById(R.id.rdo_ios);
Expand Down Expand Up @@ -172,6 +180,20 @@ public boolean onClick(BaseDialog baseDialog, View v) {
})
.setCancelable(false);
}

switch (DialogX.implIMPLMode){
case VIEW:
rdoModeView.setChecked(true);
break;
case WINDOW:
rdoModeWindow.setChecked(true);
break;
case DIALOG_FRAGMENT:
rdoModeDialogFragment.setChecked(true);
break;
}

txtTitle.setText("Kongzue DialogX (" + BuildConfig.VERSION_NAME +")");
}

//用于模拟进度提示
Expand Down Expand Up @@ -201,6 +223,24 @@ public boolean onClick(BaseDialog baseDialog, View v) {

@Override
public void setEvents() {
grpMode.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
BaseDialog.cleanAll();
switch (checkedId){
case R.id.rdo_mode_view:
DialogX.implIMPLMode = DialogX.IMPL_MODE.VIEW;
break;
case R.id.rdo_mode_window:
DialogX.implIMPLMode = DialogX.IMPL_MODE.WINDOW;
break;
case R.id.rdo_mode_dialogFragment:
DialogX.implIMPLMode = DialogX.IMPL_MODE.DIALOG_FRAGMENT;
break;
}
}
});

grpTheme.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
Expand Down
54 changes: 54 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,60 @@
android:paddingLeft="15dp"
android:paddingRight="15dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:text="实现方式"
android:textColor="#dc000000"
android:textSize="14dp"
android:textStyle="bold" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:text="请注意后两者属于测试阶段,且存在已知未解决bug。"
android:textColor="#80000000"
android:textSize="14dp" />

<RadioGroup
android:id="@+id/grp_mode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:orientation="horizontal">

<RadioButton
android:id="@+id/rdo_mode_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:padding="10dp"
android:text="View"
android:textColor="#7b000000"
android:textSize="12dp" />

<RadioButton
android:id="@+id/rdo_mode_window"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Window"
android:textColor="#7b000000"
android:textSize="12dp" />

<RadioButton
android:id="@+id/rdo_mode_dialogFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="DialogFragment"
android:textColor="#7b000000" />

</RadioGroup>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

BUILD_VERSION=0.0.41.beta4
BUILD_VERSION=0.0.41.beta5
BUILD_VERSION_INT=40

0 comments on commit 5cda6e5

Please sign in to comment.