Skip to content

Commit

Permalink
1.0.3
Browse files Browse the repository at this point in the history
解决属性冲突,修复dismiss偶尔无效果问题,加入OnDismissListener
  • Loading branch information
saiwu-bigkoo committed Jul 31, 2016
1 parent d64a62e commit 5966651
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 43 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
buildToolsVersion "23.0.3"

defaultConfig {
applicationId "com.bigkoo.svprogresshuddemo"
Expand All @@ -20,7 +20,7 @@ android {
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':svprogresshud')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:appcompat-v7:23.2.0'

}
16 changes: 10 additions & 6 deletions app/src/main/java/com/bigkoo/svprogresshuddemo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Toast;

import com.bigkoo.svprogresshud.SVProgressHUD;
import com.bigkoo.svprogresshud.listener.OnDismissListener;

public class MainActivity extends Activity {
private SVProgressHUD mSVProgressHUD;
Expand All @@ -17,6 +19,14 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mSVProgressHUD = new SVProgressHUD(this);
mSVProgressHUD.setOnDismissListener(new OnDismissListener(){
@Override
public void onDismiss(SVProgressHUD hud) {
// todo something, like: finish current activity
Toast.makeText(getApplicationContext(),"dismiss",Toast.LENGTH_SHORT).show();
}
});

}

public void show(View view){
Expand All @@ -39,12 +49,6 @@ public void showInfoWithStatus(View view){
}
public void showSuccessWithStatus(View view){
mSVProgressHUD.showSuccessWithStatus("恭喜,提交成功!");
mSVProgressHUD.setOnDismissListener(new SVProgressHUD.OnDismissListener(){
@Override
public void onDismiss() {
// todo something, like: finish current activity
}
});
}
public void showErrorWithStatus(View view){
mSVProgressHUD.showErrorWithStatus("不约,叔叔我们不约~", SVProgressHUD.SVProgressHUDMaskType.GradientCancel);
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
#Sun Jul 31 10:01:38 CST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
2 changes: 1 addition & 1 deletion svprogresshud/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version = "1.0.3"

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
buildToolsVersion "23.0.3"

defaultConfig {
minSdkVersion 9
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@
import android.view.animation.AnimationUtils;
import android.widget.FrameLayout;

import com.bigkoo.svprogresshud.listener.OnDismissListener;
import com.bigkoo.svprogresshud.view.SVCircleProgressBar;
import com.bigkoo.svprogresshud.view.SVProgressDefaultView;

/**
* Created by Sai on 15/8/15.
*/
public class SVProgressHUD {
private Context context;
private static final long DISMISSDELAYED = 1000;
private SVProgressHUDMaskType mSVProgressHUDMaskType;
private boolean isShowing;

public enum SVProgressHUDMaskType {
None, // 允许遮罩下面控件点击
Expand Down Expand Up @@ -78,6 +83,7 @@ protected void initAnimation() {
* show的时候调用
*/
private void onAttached() {
isShowing = true;
decorView.addView(rootView);
if(mSharedView.getParent()!=null)((ViewGroup)mSharedView.getParent()).removeView(mSharedView);
rootView.addView(mSharedView);
Expand Down Expand Up @@ -196,11 +202,9 @@ private void setMaskType(SVProgressHUDMaskType maskType) {
configMaskType(R.color.bgColor_overlay, true, true);
break;
case Gradient:
//TODO 设置半透明渐变背景
configMaskType(R.drawable.bg_overlay_gradient, true, false);
break;
case GradientCancel:
//TODO 设置半透明渐变背景
configMaskType(R.drawable.bg_overlay_gradient, true, true);
break;
default:
Expand All @@ -220,15 +224,15 @@ private void configMaskType(int bg, boolean clickable, boolean cancelable) {
* @return 如果视图已经存在该View返回true
*/
public boolean isShowing() {
return rootView.getParent() != null;
return rootView.getParent() != null && isShowing;
}

public void dismiss() {
//消失动画
outAnim.setAnimationListener(outAnimListener);
mSharedView.startAnimation(outAnim);
if(getOnDismissListener() != null){
getOnDismissListener().onDismiss();
if(onDismissListener != null){
onDismissListener.onDismiss(this);
}

}
Expand All @@ -238,6 +242,7 @@ public void dismissImmediately() {
rootView.removeView(mSharedView);
decorView.removeView(rootView);
context = null;
isShowing = false;
}

public Animation getInAnimation() {
Expand Down Expand Up @@ -309,11 +314,7 @@ public void setOnDismissListener(OnDismissListener listener){
}

public OnDismissListener getOnDismissListener(){
return this.onDismissListener;
}

public interface OnDismissListener{
void onDismiss();
return onDismissListener;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.bigkoo.svprogresshud.listener;

import com.bigkoo.svprogresshud.SVProgressHUD;

/**
* Created by Sai on 16/7/31.
*/
public interface OnDismissListener {
void onDismiss(SVProgressHUD hud);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.bigkoo.svprogresshud;
package com.bigkoo.svprogresshud.view;

import android.content.Context;
import android.content.res.TypedArray;
Expand All @@ -9,11 +9,12 @@
import android.util.AttributeSet;
import android.view.View;

import com.bigkoo.svprogresshud.R;

/**
* Created by Sai on 15/9/1.
*/
public class SVCircleProgressBar extends View {
private Context mContext;
/**
* 画笔对象的引用
*/
Expand Down Expand Up @@ -54,31 +55,27 @@ public class SVCircleProgressBar extends View {

public SVCircleProgressBar(Context context) {
this(context, null);
this.mContext = context;

}

public SVCircleProgressBar(Context context, AttributeSet attrs) {
this(context, attrs, 0);
this.mContext = context;
}

public SVCircleProgressBar(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.mContext = context;

paint = new Paint();

TypedArray mTypedArray = context.obtainStyledAttributes(attrs,
R.styleable.SVCircleProgressBar);

// 获取自定义属性和默认值
roundColor = mTypedArray.getColor(R.styleable.SVCircleProgressBar_roundColor, Color.BLUE);
roundProgressColor = mTypedArray.getColor(R.styleable.SVCircleProgressBar_roundProgressColor,
roundColor = mTypedArray.getColor(R.styleable.SVCircleProgressBar_svprogress_roundColor, Color.BLUE);
roundProgressColor = mTypedArray.getColor(R.styleable.SVCircleProgressBar_svprogress_roundProgressColor,
Color.GRAY);
roundWidth = mTypedArray.getDimension(R.styleable.SVCircleProgressBar_roundWidth, 5);
max = mTypedArray.getInteger(R.styleable.SVCircleProgressBar_max, 100);
style = mTypedArray.getInt(R.styleable.SVCircleProgressBar_style, 0);
roundWidth = mTypedArray.getDimension(R.styleable.SVCircleProgressBar_svprogress_roundWidth, 5);
max = mTypedArray.getInteger(R.styleable.SVCircleProgressBar_svprogress_max, 100);
style = mTypedArray.getInt(R.styleable.SVCircleProgressBar_svprogress_style, 0);

mTypedArray.recycle();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.bigkoo.svprogresshud;
package com.bigkoo.svprogresshud.view;

import android.content.Context;
import android.view.LayoutInflater;
Expand All @@ -10,6 +10,8 @@
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bigkoo.svprogresshud.R;

/**
* Created by Sai on 15/8/15.
* 默认的SVProgress效果
Expand Down
8 changes: 4 additions & 4 deletions svprogresshud/src/main/res/layout/view_svprogressdefault.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
android:scaleType="centerInside"
android:visibility="gone" />

<com.bigkoo.svprogresshud.SVCircleProgressBar
<com.bigkoo.svprogresshud.view.SVCircleProgressBar
android:id="@+id/circleProgressBar"
android:layout_width="@dimen/size_image_smallloading"
android:layout_height="@dimen/size_image_smallloading"
app:roundColor="@color/roundColor_svprogresshuddefault"
app:roundProgressColor="@color/roundProgressColor_svprogresshuddefault"
app:roundWidth="2dip"
app:svprogress_roundColor="@color/roundColor_svprogresshuddefault"
app:svprogress_roundProgressColor="@color/roundProgressColor_svprogresshuddefault"
app:svprogress_roundWidth="2dip"
android:visibility="gone" />

<TextView
Expand Down
10 changes: 5 additions & 5 deletions svprogresshud/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<declare-styleable name="SVCircleProgressBar">
<attr name="roundColor" format="color"/>
<attr name="roundProgressColor" format="color"/>
<attr name="roundWidth" format="dimension"></attr>
<attr name="max" format="integer"></attr>
<attr name="style">
<attr name="svprogress_roundColor" format="color"/>
<attr name="svprogress_roundProgressColor" format="color"/>
<attr name="svprogress_roundWidth" format="dimension"></attr>
<attr name="svprogress_max" format="integer"></attr>
<attr name="svprogress_style">
<enum name="STROKE" value="0"></enum>
<enum name="FILL" value="1"></enum>
</attr>
Expand Down

0 comments on commit 5966651

Please sign in to comment.