-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from hqwlkj/develop
fix: add LoadingDialog
- Loading branch information
Showing
21 changed files
with
343 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
android/src/main/java/com/parsec/flutter_chs/loading/Loading.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.parsec.flutter_chs.loading; | ||
|
||
import android.content.Context; | ||
import android.util.AttributeSet; | ||
import android.view.LayoutInflater; | ||
import android.widget.RelativeLayout; | ||
import com.parsec.flutter_chs.R.layout; | ||
|
||
public class Loading extends RelativeLayout { | ||
public Loading(Context context) { | ||
super(context); | ||
} | ||
|
||
public Loading(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
LayoutInflater.from(context).inflate(layout.vs_main_loading, this); | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
android/src/main/java/com/parsec/flutter_chs/loading/LoadingDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package com.parsec.flutter_chs.loading; | ||
|
||
import android.app.Dialog; | ||
import android.content.Context; | ||
import android.os.Handler; | ||
import android.os.Looper; | ||
import android.os.Message; | ||
import android.view.Window; | ||
import android.view.WindowManager; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import com.parsec.flutter_chs.R.id; | ||
import com.parsec.flutter_chs.R.style; | ||
import com.parsec.flutter_chs.R.layout; | ||
|
||
public class LoadingDialog extends Dialog { | ||
private static final int MSG_UPDATE_LOADING_DOT = 1; | ||
private final ImageView mLoadingDot1; | ||
private final ImageView mLoadingDot2; | ||
private final ImageView mLoadingDot3; | ||
private final TextView mLoadingBrand; | ||
private final Handler mHandler; | ||
private int mDotSeq; | ||
|
||
public LoadingDialog(Context context){ | ||
super(context, style.Loading); | ||
this.setContentView(layout.vs_main_loading); | ||
Window window = this.getWindow(); | ||
WindowManager.LayoutParams params = window.getAttributes(); | ||
params.gravity = 17; | ||
window.setAttributes(params); | ||
this.mLoadingDot1 = this.findViewById(id.loading_dot1); | ||
this.mLoadingDot2 = this.findViewById(id.loading_dot2); | ||
this.mLoadingDot3 = this.findViewById(id.loading_dot3); | ||
this.mLoadingBrand = this.findViewById(id.loading_brand); | ||
this.mHandler = new Handler(Looper.myLooper()) { | ||
public void handleMessage(Message msg) { | ||
super.handleMessage(msg); | ||
if (msg.what == 1) { | ||
if (LoadingDialog.this.mDotSeq == 0) { | ||
LoadingDialog.this.mLoadingDot1.setAlpha(0.6F); | ||
LoadingDialog.this.mLoadingDot2.setAlpha(1.0F); | ||
LoadingDialog.this.mLoadingDot3.setAlpha(0.6F); | ||
LoadingDialog.this.mDotSeq++; | ||
} else if (LoadingDialog.this.mDotSeq == 1) { | ||
LoadingDialog.this.mLoadingDot1.setAlpha(0.3F); | ||
LoadingDialog.this.mLoadingDot2.setAlpha(0.6F); | ||
LoadingDialog.this.mLoadingDot3.setAlpha(1.0F); | ||
LoadingDialog.this.mDotSeq++; | ||
} else if (LoadingDialog.this.mDotSeq == 2) { | ||
LoadingDialog.this.mLoadingDot1.setAlpha(1.0F); | ||
LoadingDialog.this.mLoadingDot2.setAlpha(0.6F); | ||
LoadingDialog.this.mLoadingDot3.setAlpha(0.3F); | ||
LoadingDialog.this.mDotSeq = 0; | ||
} | ||
LoadingDialog.this.mHandler.sendEmptyMessageDelayed(1, 800L); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
|
||
public void show(String msg) { | ||
this.mHandler.sendEmptyMessageDelayed(1, 800L); | ||
if(msg == null){ | ||
msg = "中国医疗保障"; | ||
} | ||
mLoadingBrand.setText(msg); | ||
this.mDotSeq = 0; | ||
super.show(); | ||
} | ||
|
||
public void hide() { | ||
this.mHandler.removeMessages(1); | ||
this.mDotSeq = 0; | ||
this.mLoadingDot1.setAlpha(1.0F); | ||
this.mLoadingDot2.setAlpha(0.6F); | ||
this.mLoadingDot3.setAlpha(0.3F); | ||
super.dismiss(); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<!-- 矩形的圆角弧度 --> | ||
<corners android:radius="10dp"/> | ||
<!-- 矩形的填充色 --> | ||
<solid android:color="#b3000000" /> | ||
|
||
|
||
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="oval" | ||
android:useLevel="true"> | ||
|
||
<size | ||
android:width="80dp" | ||
android:height="80dp" /> | ||
|
||
<solid android:color="#ffffff" /> | ||
|
||
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<RelativeLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:id="@+id/loading_wrap" | ||
android:layout_width="150dp" | ||
android:layout_height="150dp" | ||
android:background="@drawable/loading_bg" | ||
> | ||
|
||
<ImageView | ||
android:id="@+id/loading_icon" | ||
android:layout_width="70dp" | ||
android:layout_height="70dp" | ||
android:layout_centerHorizontal="true" | ||
android:layout_marginTop="12dp" | ||
android:background="@drawable/loading_icon" /> | ||
|
||
<TextView | ||
android:id="@+id/loading_brand" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="中国医疗保障" | ||
android:textColor="#ffffff" | ||
android:layout_below="@+id/loading_icon" | ||
android:layout_centerHorizontal="true" | ||
android:layout_marginTop="10dp" | ||
android:textSize="14dp"/> | ||
|
||
<ImageView | ||
android:id="@+id/loading_dot2" | ||
android:layout_width="10dp" | ||
android:layout_height="10dp" | ||
android:background="@drawable/loading_round_dot" | ||
android:layout_centerHorizontal="true" | ||
android:layout_below="@+id/loading_brand" | ||
android:layout_marginTop="8dp" | ||
android:alpha="0.6" | ||
/> | ||
|
||
<ImageView | ||
android:id="@+id/loading_dot1" | ||
android:layout_width="10dp" | ||
android:layout_height="10dp" | ||
android:background="@drawable/loading_round_dot" | ||
android:layout_toLeftOf="@+id/loading_dot2" | ||
android:layout_below="@+id/loading_brand" | ||
android:layout_marginTop="8dp" | ||
android:layout_marginRight="12dp" | ||
/> | ||
|
||
<ImageView | ||
android:id="@+id/loading_dot3" | ||
android:layout_width="10dp" | ||
android:layout_height="10dp" | ||
android:background="@drawable/loading_round_dot" | ||
android:layout_toRightOf="@+id/loading_dot2" | ||
android:layout_below="@+id/loading_brand" | ||
android:layout_marginTop="8dp" | ||
android:layout_marginLeft="12dp" | ||
android:alpha="0.3" | ||
/> | ||
|
||
|
||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="app_name">flutter_chs</string> | ||
<style name="Loading" parent="@android:style/Theme.Dialog"> | ||
<item name="android:windowFrame">@null</item> | ||
<item name="android:windowIsFloating">true</item> | ||
<item name="android:windowIsTranslucent">true</item> | ||
<item name="android:windowNoTitle">true</item> | ||
<!-- 设置背景色 透明--> | ||
<item name="android:background">@android:color/transparent</item> | ||
<item name="android:windowBackground">@android:color/transparent</item> | ||
<!-- 设置是否显示背景 --> | ||
<item name="android:backgroundDimEnabled">true</item> | ||
<!-- 设置背景透明度 --> | ||
<item name="android:backgroundDimAmount">0</item> | ||
<!-- 设置点击空白不消失 --> | ||
<item name="android:windowCloseOnTouchOutside">false</item> | ||
</style> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.