Skip to content

Commit

Permalink
add loading view
Browse files Browse the repository at this point in the history
  • Loading branch information
yangchao29 committed Jul 24, 2019
1 parent 1d81509 commit c5988e3
Show file tree
Hide file tree
Showing 26 changed files with 1,091 additions and 57 deletions.
1 change: 1 addition & 0 deletions resume/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ dependencies {
implementation dep.design
implementation project(path: ':platform')
implementation project(path: ':data')
implementation project(path: ':widget')
}
18 changes: 7 additions & 11 deletions resume/src/main/java/com/oo/resume/activity/MineFragment.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.oo.resume.activity

import android.app.AlertDialog
import android.os.Bundle
import android.view.View
import androidx.lifecycle.Observer
Expand All @@ -9,7 +8,8 @@ import com.oo.platform.viewmodel.ViewModelBinder
import com.oo.resume.R
import com.oo.resume.data.response.AccountDTO
import com.oo.resume.viewmodel.AccountViewModel
import com.oo.resume.widget.ActionSheetDialog
import com.oo.widget.BottomDialog
import com.oo.widget.OoDialog
import kotlinx.android.synthetic.main.fragment_mine.*

/**
Expand All @@ -22,7 +22,7 @@ class MineFragment : BaseFragment() {

private lateinit var viewModel: AccountViewModel

private lateinit var loading: AlertDialog
private lateinit var loading: OoDialog

override fun getContentViewResId(): Int {
return R.layout.fragment_mine
Expand All @@ -43,13 +43,13 @@ class MineFragment : BaseFragment() {
private fun setListener() {
btn_save.setOnClickListener(View.OnClickListener { viewModel.update(getUIAccount()) })
sex.setOnClickListener(View.OnClickListener {
ActionSheetDialog(context)
BottomDialog(context)
.builder()
.setTitle("请选择性别")
.setCancelable(false)
.setCanceledOnTouchOutside(true)
.addSheetItem("", ActionSheetDialog.OnSheetItemClickListener { sex.text = "" })
.addSheetItem("", ActionSheetDialog.OnSheetItemClickListener { sex.text = "" }).show()
.addSheetItem("", BottomDialog.OnSheetItemClickListener { sex.text = "" })
.addSheetItem("", BottomDialog.OnSheetItemClickListener { sex.text = "" }).show()
})
}

Expand All @@ -74,11 +74,7 @@ class MineFragment : BaseFragment() {
}

private fun initLoadingDialog() {
loading = AlertDialog.Builder(context)
.setMessage("Loading")
.setCancelable(false)
.setIcon(R.mipmap.ic_launcher_round)
.create()
loading = OoDialog(context, OoDialog.TYPE_LOADING,"Loading")
}

private fun refreshView(account: AccountDTO?) {
Expand Down
10 changes: 3 additions & 7 deletions resume/src/main/java/com/oo/resume/activity/SignInActivity.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.oo.resume.activity

import android.app.AlertDialog
import android.os.Bundle
import android.view.View
import android.widget.Toast
Expand All @@ -14,13 +13,14 @@ import com.oo.resume.constance.Regex
import com.oo.resume.data.request.LoginRequest
import com.oo.resume.data.request.RegistRequest
import com.oo.resume.viewmodel.SignInViewModel
import com.oo.widget.OoDialog
import kotlinx.android.synthetic.main.activity_sign_in.*
import java.util.regex.Pattern

@Route(RouteUrl.SIGNIN_PAGE)
class SignInActivity : BaseActivity() {

private lateinit var loading: AlertDialog
private lateinit var loading: OoDialog

private lateinit var viewmodel: SignInViewModel

Expand All @@ -37,11 +37,7 @@ class SignInActivity : BaseActivity() {
}

private fun initLoadingDialog() {
loading = AlertDialog.Builder(this)
.setMessage("Loading")
.setCancelable(false)
.setIcon(R.mipmap.ic_launcher_round)
.create()
loading = OoDialog(this, OoDialog.TYPE_LOADING, "Loading")
}

private fun refreshUI(type: SignInViewModel.SignType) {
Expand Down
24 changes: 0 additions & 24 deletions resume/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,4 @@
<item name="android:textSize">16sp</item>
</style>

<style name="ActionSheetDialogStyle" parent="@android:style/Theme.Dialog">

<!-- 背景透明 -->
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<!-- 浮于Activity之上 -->
<item name="android:windowIsFloating">true</item>
<!-- 边框 -->
<item name="android:windowFrame">@null</item>
<!-- Dialog以外的区域模糊效果 -->
<item name="android:backgroundDimEnabled">true</item>
<!-- 无标题 -->
<item name="android:windowNoTitle">true</item>
<!-- 半透明 -->
<item name="android:windowIsTranslucent">true</item>
<!-- Dialog进入及退出动画 -->
<item name="android:windowAnimationStyle">@style/ActionSheetDialogAnimation</item>
</style>

<style name="ActionSheetDialogAnimation" parent="@android:style/Animation.Dialog">
<item name="android:windowEnterAnimation">@anim/actionsheet_dialog_in</item>
<item name="android:windowExitAnimation">@anim/actionsheet_dialog_out</item>
</style>

</resources>
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include ':resume', ':platform', ':data'
include ':resume', ':platform', ':data', ':widget'
1 change: 1 addition & 0 deletions widget/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
30 changes: 30 additions & 0 deletions widget/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 29
buildToolsVersion "29.0.1"


defaultConfig {
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

}

dependencies {
def dep = rootProject.ext.dependencies
implementation dep.constraint_layout
}
21 changes: 21 additions & 0 deletions widget/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
2 changes: 2 additions & 0 deletions widget/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.oo.widget"/>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.oo.resume.widget;
package com.oo.widget;

import android.app.Dialog;
import android.content.Context;
Expand All @@ -11,13 +11,12 @@
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import com.oo.resume.R;

import java.util.ArrayList;
import java.util.List;


public class ActionSheetDialog {
public class BottomDialog {
private Dialog dialog;
private TextView txt_title;
private View txt_title_layout;
Expand All @@ -28,23 +27,23 @@ public class ActionSheetDialog {
private final Context context;
private final DisplayMetrics display;

public ActionSheetDialog(Context context) {
public BottomDialog(Context context) {
this.context = context;
display = context.getResources().getDisplayMetrics();
}

public ActionSheetDialog builder() {
public BottomDialog builder() {
// 获取Dialog布局
View view = LayoutInflater.from(context).inflate(
R.layout.view_actionsheet, null);
R.layout.dialog_bottom, null);

// 设置Dialog最小宽度为屏幕宽度
view.setMinimumWidth(display.widthPixels);

// 获取自定义Dialog布局中的控件
lLayout_content = (LinearLayout) view.findViewById(R.id.lLayout_content);
lLayout_content = view.findViewById(R.id.lLayout_content);
txt_title_layout = view.findViewById(R.id.txt_title_layout);
txt_title = (TextView) view.findViewById(R.id.txt_title);
txt_title = view.findViewById(R.id.txt_title);

// 定义Dialog布局和参数
dialog = new Dialog(context, R.style.ActionSheetDialogStyle);
Expand All @@ -60,18 +59,18 @@ public ActionSheetDialog builder() {
return this;
}

public ActionSheetDialog setTitle(String title) {
public BottomDialog setTitle(String title) {
txt_title_layout.setVisibility(View.VISIBLE);
txt_title.setText(title);
return this;
}

public ActionSheetDialog setCancelable(boolean cancel) {
public BottomDialog setCancelable(boolean cancel) {
dialog.setCancelable(cancel);
return this;
}

public ActionSheetDialog setCanceledOnTouchOutside(boolean cancel) {
public BottomDialog setCanceledOnTouchOutside(boolean cancel) {
dialog.setCanceledOnTouchOutside(cancel);
return this;
}
Expand All @@ -82,8 +81,8 @@ public ActionSheetDialog setCanceledOnTouchOutside(boolean cancel) {
* @param listener listener
* @return ActionSheetDialog
*/
public ActionSheetDialog addSheetItem(String strItem,
OnSheetItemClickListener listener) {
public BottomDialog addSheetItem(String strItem,
OnSheetItemClickListener listener) {
if (sheetItemList == null) {
sheetItemList = new ArrayList<>();
}
Expand Down Expand Up @@ -116,7 +115,7 @@ private void setSheetItems() {
textView.setGravity(Gravity.CENTER);

// 字体颜色
textView.setTextColor(context.getResources().getColor(R.color.text_black));
textView.setTextColor(Color.BLACK);

// 高度
float scale = context.getResources().getDisplayMetrics().density;
Expand Down
Loading

0 comments on commit c5988e3

Please sign in to comment.