Skip to content

Commit f109cd6

Browse files
committed
优化细节
1 parent c051071 commit f109cd6

File tree

16 files changed

+269
-40
lines changed

16 files changed

+269
-40
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ sudo: false
55

66
env:
77
global:
8-
- ANDROID_API_LEVEL=29
9-
- ANDROID_BUILD_TOOLS_VERSION=29.0.3
8+
- ANDROID_API_LEVEL=30
9+
- ANDROID_BUILD_TOOLS_VERSION=30.0.3
1010
- TRAVIS_SECURE_ENV_VARS=true
1111

1212
before_install:

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ allprojects {
4040
#### **v2.x**(使用 **Hilt** 简化 **Dagger2** 依赖注入用法)
4141
```gradle
4242
//AndroidX 版本
43-
implementation 'com.github.jenly1314:mvvmframe:2.1.1'
43+
implementation 'com.github.jenly1314:mvvmframe:2.2.0'
4444
4545
```
4646

@@ -545,11 +545,10 @@ public interface ApplicationComponent {
545545

546546
## 版本记录
547547

548-
#### v2.2.0:2021-11-17
548+
#### v2.2.0:2021-11-18
549549
* minSdk要求从 16+ 改为 21+
550550
* 更新编译SDK至30
551551
* 更新Gradle至v6.7.1
552-
* 更新Appcompat至v1.3.1
553552
* 更新Okhttp至v4.9.2
554553
* 更新Hilt至v2.40.1
555554
* 更新Gson至v2.8.9

app/release/app-release.apk

1.06 MB
Binary file not shown.

app/release/output-metadata.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
"kind": "Directory"
66
},
77
"applicationId": "com.king.mvvmframe",
8-
"variantName": "processReleaseResources",
8+
"variantName": "release",
99
"elements": [
1010
{
1111
"type": "SINGLE",
1212
"filters": [],
13-
"versionCode": 11,
14-
"versionName": "2.1.1",
13+
"versionCode": 12,
14+
"versionName": "2.2.0",
1515
"outputFile": "app-release.apk"
1616
}
1717
]

build.gradle

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,7 @@ buildscript {
1818
// in the individual module build.gradle files
1919
}
2020
}
21-
repositories {
22-
flatDir {
23-
dirs 'libs' //this way we can find the .aar file in libs folder
24-
}
2521

26-
}
2722
allprojects {
2823
addRepos(repositories)
2924
}

gradle.properties

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ org.gradle.jvmargs = -Xmx1536m
1414
android.useAndroidX=true
1515
android.enableJetifier=true
1616

17-
VERSION_NAME=2.1.1
18-
VERSION_CODE=11
17+
VERSION_NAME=2.2.0
18+
VERSION_CODE=12
1919
GROUP=com.github.jenly1314
2020

2121
POM_DESCRIPTION=MVVMFrame for Android
@@ -33,3 +33,4 @@ RELEASE_REPOSITORY_URL=https://s01.oss.sonatype.org/service/local/staging/deploy
3333
SNAPSHOT_REPOSITORY_URL=https://s01.oss.sonatype.org/content/repositories/snapshots/
3434
RELEASE_SIGNING_ENABLED=false
3535

36+

mvvmframe/src/main/java/com/king/frame/mvvmframe/base/BaseActivity.java

Lines changed: 110 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -481,44 +481,135 @@ protected void showProgressDialog(View v,boolean isCancel){
481481
mProgressDialog.show();
482482
}
483483

484+
/**
485+
* 显示对话框
486+
* @param contentView 弹框内容视图
487+
*/
484488
protected void showDialog(View contentView){
485489
showDialog(contentView,DEFAULT_WIDTH_RATIO);
486490
}
487491

492+
/**
493+
* 显示对话框
494+
* @param contentView 弹框内容视图
495+
* @param isCancel 是否可取消(默认为true,false则拦截back键)
496+
*/
488497
protected void showDialog(View contentView,boolean isCancel){
489498
showDialog(getContext(),contentView,R.style.mvvmframe_dialog,DEFAULT_WIDTH_RATIO,isCancel);
490499
}
491500

501+
/**
502+
* 显示对话框
503+
* @param contentView 弹框内容视图
504+
* @param widthRatio 宽度比例,根据屏幕宽度计算得来
505+
*/
492506
protected void showDialog(View contentView,float widthRatio){
493507
showDialog(getContext(),contentView,widthRatio);
494508
}
495509

510+
/**
511+
* 显示对话框
512+
* @param contentView 弹框内容视图
513+
* @param widthRatio 宽度比例,根据屏幕宽度计算得来
514+
*/
496515
protected void showDialog(View contentView,float widthRatio,boolean isCancel){
497516
showDialog(getContext(),contentView,R.style.mvvmframe_dialog,widthRatio,isCancel);
498517
}
499518

519+
/**
520+
* 显示对话框
521+
* @param context
522+
* @param contentView 弹框内容视图
523+
* @param widthRatio 宽度比例,根据屏幕宽度计算得来
524+
*/
500525
protected void showDialog(Context context,View contentView,float widthRatio){
501526
showDialog(context,contentView, R.style.mvvmframe_dialog,widthRatio);
502527
}
503528

529+
/**
530+
* 显示对话框
531+
* @param context
532+
* @param contentView 弹框内容视图
533+
* @param styleId Dialog样式
534+
* @param widthRatio 宽度比例,根据屏幕宽度计算得来
535+
*/
504536
protected void showDialog(Context context, View contentView, @StyleRes int styleId, float widthRatio){
505537
showDialog(context,contentView,styleId,widthRatio,true);
506538
}
507539

540+
/**
541+
* 显示对话框
542+
* @param context
543+
* @param contentView 弹框内容视图
544+
* @param styleId Dialog样式
545+
* @param widthRatio 宽度比例,根据屏幕宽度计算得来
546+
* @param isCancel 是否可取消(默认为true,false则拦截back键)
547+
*/
508548
protected void showDialog(Context context, View contentView, @StyleRes int styleId, float widthRatio, final boolean isCancel){
509549
showDialog(context, contentView, styleId, Gravity.NO_GRAVITY, widthRatio, isCancel);
510550

511551
}
512552

553+
/**
554+
* 显示对话框
555+
* @param context
556+
* @param contentView 弹框内容视图
557+
* @param styleId Dialog样式
558+
* @param gravity Dialog的对齐方式
559+
* @param widthRatio 宽度比例,根据屏幕宽度计算得来
560+
* @param isCancel 是否可取消(默认为true,false则拦截back键)
561+
*/
513562
protected void showDialog(Context context, View contentView, @StyleRes int styleId, int gravity, float widthRatio, final boolean isCancel){
514563
showDialog(context, contentView, styleId, gravity, widthRatio, 0, 0, isCancel);
515564
}
565+
/**
566+
* 显示对话框
567+
* @param context
568+
* @param contentView 弹框内容视图
569+
* @param styleId Dialog样式
570+
* @param gravity Dialog的对齐方式
571+
* @param widthRatio 宽度比例,根据屏幕宽度计算得来
572+
* @param x x轴偏移量,需与 gravity 结合使用
573+
* @param y y轴偏移量,需与 gravity 结合使用
574+
* @param isCancel 是否可取消(默认为true,false则拦截back键)
575+
*/
576+
protected void showDialog(Context context, View contentView, @StyleRes int styleId, int gravity, float widthRatio, int x, int y, final boolean isCancel){
577+
showDialog(context, contentView, styleId, gravity, widthRatio, x, y, 0, 0, isCancel);
578+
}
516579

517-
protected void showDialog(Context context, View contentView, @StyleRes int styleId, int gravity, float widthRatio,float horizontalMargin, float verticalMargin, final boolean isCancel){
518-
showDialog(context, contentView, styleId, gravity, widthRatio, horizontalMargin, verticalMargin, 0, 0, isCancel);
580+
/**
581+
* 显示对话框
582+
* @param context
583+
* @param contentView 弹框内容视图
584+
* @param styleId Dialog样式
585+
* @param gravity Dialog的对齐方式
586+
* @param widthRatio 宽度比例,根据屏幕宽度计算得来
587+
* @param x x轴偏移量,需与 gravity 结合使用
588+
* @param y y轴偏移量,需与 gravity 结合使用
589+
* @param horizontalMargin 水平方向边距
590+
* @param verticalMargin 垂直方向边距
591+
* @param isCancel 是否可取消(默认为true,false则拦截back键)
592+
*/
593+
protected void showDialog(Context context, View contentView, @StyleRes int styleId, int gravity, float widthRatio, int x, int y, float horizontalMargin, float verticalMargin, final boolean isCancel){
594+
showDialog(context, contentView, styleId, gravity, widthRatio, x, y, horizontalMargin, verticalMargin, 0, 0, isCancel);
519595
}
520596

521-
protected void showDialog(Context context, View contentView, @StyleRes int styleId, int gravity, float widthRatio,float horizontalMargin, float verticalMargin, float horizontalWeight, float verticalWeight, final boolean isCancel){
597+
/**
598+
* 显示对话框
599+
* @param context
600+
* @param contentView 弹框内容视图
601+
* @param styleId Dialog样式
602+
* @param gravity Dialog的对齐方式
603+
* @param widthRatio 宽度比例,根据屏幕宽度计算得来
604+
* @param x x轴偏移量,需与 gravity 结合使用
605+
* @param y y轴偏移量,需与 gravity 结合使用
606+
* @param horizontalMargin 水平方向边距
607+
* @param verticalMargin 垂直方向边距
608+
* @param horizontalWeight 水平方向权重
609+
* @param verticalWeight 垂直方向权重
610+
* @param isCancel 是否可取消(默认为true,false则拦截back键)
611+
*/
612+
protected void showDialog(Context context, View contentView, @StyleRes int styleId, int gravity, float widthRatio, int x, int y, float horizontalMargin, float verticalMargin, float horizontalWeight, float verticalWeight, final boolean isCancel){
522613
dismissDialog();
523614
mDialog = new Dialog(context, styleId);
524615
mDialog.setContentView(contentView);
@@ -536,16 +627,29 @@ public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
536627

537628
}
538629
});
539-
setWindow(mDialog.getWindow(),gravity, widthRatio,horizontalMargin, verticalMargin, horizontalWeight, verticalWeight);
630+
setWindow(mDialog.getWindow(),gravity, widthRatio, x, y, horizontalMargin, verticalMargin, horizontalWeight, verticalWeight);
540631
mDialog.show();
541632

542633
}
543634

544-
545-
protected void setWindow(Window window,int gravity,float widthRatio, float horizontalMargin, float verticalMargin, float horizontalWeight, float verticalWeight){
635+
/**
636+
* 设置 Window 布局相关参数
637+
* @param window {@link Window}
638+
* @param gravity Dialog的对齐方式
639+
* @param widthRatio 宽度比例,根据屏幕宽度计算得来
640+
* @param x x轴偏移量,需与 gravity 结合使用
641+
* @param y y轴偏移量,需与 gravity 结合使用
642+
* @param horizontalMargin 水平方向边距
643+
* @param verticalMargin 垂直方向边距
644+
* @param horizontalWeight 水平方向权重
645+
* @param verticalWeight 垂直方向权重
646+
*/
647+
protected void setWindow(Window window,int gravity,float widthRatio, int x, int y, float horizontalMargin, float verticalMargin, float horizontalWeight, float verticalWeight){
546648
WindowManager.LayoutParams lp = window.getAttributes();
547649
lp.width = (int)(getWidthPixels() * widthRatio);
548650
lp.gravity = gravity;
651+
lp.x = x;
652+
lp.y = y;
549653
lp.horizontalMargin = horizontalMargin;
550654
lp.verticalMargin = verticalMargin;
551655
lp.horizontalWeight = horizontalWeight;

mvvmframe/src/main/java/com/king/frame/mvvmframe/base/BaseDialogFragment.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ protected void initWindow(Window window){
117117
if(window != null){
118118
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
119119
window.getAttributes().windowAnimations = R.style.mvvmframe_dialog_animation;
120-
setWindow(window, Gravity.NO_GRAVITY, DEFAULT_WIDTH_RATIO, 0, 0, 0, 0);
120+
setWindow(window, Gravity.NO_GRAVITY, DEFAULT_WIDTH_RATIO,0, 0, 0, 0, 0, 0);
121121
}
122122
}
123123

@@ -507,10 +507,24 @@ protected void showProgressDialog(View v,boolean isCancel){
507507
mProgressDialog.show();
508508
}
509509

510-
protected void setWindow(Window window,int gravity,float widthRatio, float horizontalMargin, float verticalMargin, float horizontalWeight, float verticalWeight){
510+
/**
511+
* 设置 Window 布局相关参数
512+
* @param window {@link Window}
513+
* @param gravity Dialog的对齐方式
514+
* @param widthRatio 宽度比例,根据屏幕宽度计算得来
515+
* @param x x轴偏移量,需与 gravity 结合使用
516+
* @param y y轴偏移量,需与 gravity 结合使用
517+
* @param horizontalMargin 水平方向边距
518+
* @param verticalMargin 垂直方向边距
519+
* @param horizontalWeight 水平方向权重
520+
* @param verticalWeight 垂直方向权重
521+
*/
522+
protected void setWindow(Window window,int gravity,float widthRatio,int x, int y, float horizontalMargin, float verticalMargin, float horizontalWeight, float verticalWeight){
511523
WindowManager.LayoutParams lp = window.getAttributes();
512524
lp.width = (int)(getWidthPixels() * widthRatio);
513525
lp.gravity = gravity;
526+
lp.x = x;
527+
lp.y = y;
514528
lp.horizontalMargin = horizontalMargin;
515529
lp.verticalMargin = verticalMargin;
516530
lp.horizontalWeight = horizontalWeight;

0 commit comments

Comments
 (0)