Skip to content

Commit

Permalink
1.0.4
Browse files Browse the repository at this point in the history
context变为弱引用,动画Listener挪出成内部类
  • Loading branch information
saiwu-bigkoo committed Aug 4, 2016
1 parent 11e1453 commit 4d85cb9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SVProgressHUD For Android

demo是用Module方式依赖,你也可以使用gradle 依赖:
```java
compile 'com.bigkoo:svprogresshud:1.0.3'
compile 'com.bigkoo:svprogresshud:1.0.4'
```

### config in java code
Expand All @@ -19,6 +19,9 @@ new SVProgressHUD(context).showInfoWithStatus(context, "这是提示");

>## 更新说明
>v1.0.4
- 小优化 <br />
>v1.0.3
- 修复dismiss偶尔失效问题 <br />
- 解决属性冲突 <br />
Expand Down
2 changes: 1 addition & 1 deletion svprogresshud/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

version = "1.0.3"
version = "1.0.4"

android {
compileSdkVersion 23
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
import com.bigkoo.svprogresshud.view.SVCircleProgressBar;
import com.bigkoo.svprogresshud.view.SVProgressDefaultView;

import java.lang.ref.WeakReference;

/**
* Created by Sai on 15/8/15.
*/
public class SVProgressHUD {
private Context context;
private WeakReference<Context> contextWeak;
private static final long DISMISSDELAYED = 1000;
private SVProgressHUDMaskType mSVProgressHUDMaskType;
private boolean isShowing;
Expand Down Expand Up @@ -51,14 +53,17 @@ public enum SVProgressHUDMaskType {


public SVProgressHUD(Context context){
this.context = context;
this.contextWeak = new WeakReference<>(context);
gravity = Gravity.CENTER;
initViews();
initDefaultView();
initAnimation();
}

protected void initViews() {
Context context = contextWeak.get();
if(context == null) return;

LayoutInflater layoutInflater = LayoutInflater.from(context);
decorView = (ViewGroup) ((Activity) context).getWindow().getDecorView().findViewById(android.R.id.content);
rootView = (ViewGroup) layoutInflater.inflate(R.layout.layout_svprogresshud, null, false);
Expand All @@ -67,6 +72,9 @@ protected void initViews() {
));
}
protected void initDefaultView(){
Context context = contextWeak.get();
if(context == null) return;

mSharedView = new SVProgressDefaultView(context);
params.gravity = gravity;
mSharedView.setLayoutParams(params);
Expand Down Expand Up @@ -104,6 +112,7 @@ private void svShow() {
}

public void show() {

setMaskType(SVProgressHUDMaskType.Black);
mSharedView.show();
svShow();
Expand Down Expand Up @@ -231,26 +240,31 @@ public void dismiss() {
//消失动画
outAnim.setAnimationListener(outAnimListener);
mSharedView.startAnimation(outAnim);
if(onDismissListener != null){
onDismissListener.onDismiss(this);
}

}

public void dismissImmediately() {
mSharedView.dismiss();
rootView.removeView(mSharedView);
decorView.removeView(rootView);
context = null;
isShowing = false;
if(onDismissListener != null){
onDismissListener.onDismiss(this);
}

}

public Animation getInAnimation() {
Context context = contextWeak.get();
if(context == null) return null;

int res = SVProgressHUDAnimateUtil.getAnimationResource(this.gravity, true);
return AnimationUtils.loadAnimation(context, res);
}

public Animation getOutAnimation() {
Context context = contextWeak.get();
if(context == null) return null;

int res = SVProgressHUDAnimateUtil.getAnimationResource(this.gravity, false);
return AnimationUtils.loadAnimation(context, res);
}
Expand Down Expand Up @@ -292,7 +306,7 @@ public boolean onTouch(View v, MotionEvent event) {
}
};

Animation.AnimationListener outAnimListener = new Animation.AnimationListener() {
private Animation.AnimationListener outAnimListener = new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {

Expand Down

0 comments on commit 4d85cb9

Please sign in to comment.