Skip to content

Commit

Permalink
Merge pull request #57 from JeasonWong/master
Browse files Browse the repository at this point in the history
fix uet fresco NPE
  • Loading branch information
JeasonWong authored Jun 25, 2019
2 parents 6f00b57 + f1955ce commit 122c035
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 25 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ At present, UETool provides functionality as follows:

```gradle
dependencies {
debugImplementation 'me.ele:uetool:1.1.4'
releaseImplementation 'me.ele:uetool-no-op:1.1.4'
debugImplementation 'me.ele:uetool:1.1.5'
releaseImplementation 'me.ele:uetool-no-op:1.1.5'
// if you want to show more attrs about Fresco's DraweeView
debugImplementation 'me.ele:uetool-fresco:1.1.4'
debugImplementation 'me.ele:uetool-fresco:1.1.5'
}
```

Expand Down
6 changes: 3 additions & 3 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ UETool 是一个各方人员(设计师、程序员、测试)都可以使用

```gradle
dependencies {
debugImplementation 'me.ele:uetool:1.1.4'
releaseImplementation 'me.ele:uetool-no-op:1.1.4'
debugImplementation 'me.ele:uetool:1.1.5'
releaseImplementation 'me.ele:uetool-no-op:1.1.5'
// if you want to show more attrs about Fresco's DraweeView
debugImplementation 'me.ele:uetool-fresco:1.1.4'
debugImplementation 'me.ele:uetool-fresco:1.1.5'
}
```

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/me/ele/uetool/sample/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void onClick(View view) {
private void updateDraweeView() {
SimpleDraweeView draweeView = findViewById(R.id.drawee_view);
DraweeController draweeController = Fresco.newDraweeControllerBuilder()
.setUri("http://p0.ifengimg.com/pmop/2017/0823/3B8D6E5B199841F33C1FFB62D849C1D89F6BAA2B_size79_w240_h240.gif")
.setUri("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1561443230828&di=066c39a584cfe5cdcb244cc3af74afff&imgtype=0&src=http%3A%2F%2Fzkres1.myzaker.com%2F201905%2F5cda353b77ac6420a360a53f_320.jpg")
.setAutoPlayAnimations(true)
.build();
draweeView.setController(draweeController);
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ buildscript {
'buildTool' : '28.0.1',

'supportLibrary': '27.1.1',
'fresco' : '1.4.0',
'fresco' : '1.0.1',

'release' : '1.1.4',]
'release' : '1.1.5',]
repositories {
jcenter()
google()
Expand Down
22 changes: 11 additions & 11 deletions uetool-fresco/src/main/java/me/ele/uetool/fresco/UETFresco.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.view.View;

import com.facebook.common.internal.Supplier;
import com.facebook.drawee.backends.pipeline.PipelineDraweeController;
import com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder;
Expand All @@ -14,18 +13,17 @@
import com.facebook.drawee.generic.RoundingParams;
import com.facebook.drawee.view.DraweeView;
import com.facebook.drawee.view.GenericDraweeView;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

import me.ele.uetool.base.Element;
import me.ele.uetool.base.IAttrs;
import me.ele.uetool.base.item.BitmapItem;
import me.ele.uetool.base.item.Item;
import me.ele.uetool.base.item.TextItem;
import me.ele.uetool.base.item.TitleItem;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

import static me.ele.uetool.base.DimenUtil.px2dip;

public class UETFresco implements IAttrs {
Expand Down Expand Up @@ -54,13 +52,15 @@ private String getCornerRadius(DraweeView draweeView) {
RoundingParams params = hierarchy.getRoundingParams();
if (params != null) {
float[] cornersRadii = params.getCornersRadii();
float firstRadii = cornersRadii[0];
for (int i = 1; i < 8; i++) {
if (firstRadii != cornersRadii[i]) {
return null;
if (cornersRadii != null) {
float firstRadii = cornersRadii[0];
for (int i = 1; i < 8; i++) {
if (firstRadii != cornersRadii[i]) {
return null;
}
}
return px2dip(firstRadii, true);
}
return px2dip(firstRadii, true);
}
}
return null;
Expand Down
2 changes: 1 addition & 1 deletion uetool/src/main/java/me/ele/uetool/UETCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public List<Item> getAttrs(Element element) {

View view = element.getView();

items.add(new TextItem("Fragment", Util.getCurrentFragmentName(element.getView())));
items.add(new SwitchItem("Move", element, SwitchItem.Type.TYPE_MOVE));
items.add(new SwitchItem("ValidViews", element, SwitchItem.Type.TYPE_SHOW_VALID_VIEWS));
items.add(new TextItem("Fragment", Util.getCurrentFragmentName(element.getView())));

IAttrs iAttrs = AttrsManager.createAttrs(view);
if (iAttrs != null) {
Expand Down
10 changes: 6 additions & 4 deletions uetool/src/main/java/me/ele/uetool/UETool.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
import android.os.Build;
import android.provider.Settings;
import android.widget.Toast;
import me.ele.uetool.base.Application;

import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;

import me.ele.uetool.base.Application;

public class UETool {

private static volatile UETool instance;
Expand Down Expand Up @@ -94,8 +93,11 @@ private boolean showMenu(int y) {
if (uetMenu == null) {
uetMenu = new UETMenu(Application.getApplicationContext(), y);
}
uetMenu.show();
return true;
if (!uetMenu.isShown()) {
uetMenu.show();
return true;
}
return false;
}

private int dismissMenu() {
Expand Down

0 comments on commit 122c035

Please sign in to comment.