|
1 | 1 | /**************************************************************************************
|
2 |
| - * Made for the {N} community by Brad Martin @BradWayneMartin |
3 |
| - * Thanks to Lazaro Danillo for his contributions - https://github.com/lazaromenezes |
| 2 | + * Made for the {N} community by Brad Martin @BradWayneMartin |
| 3 | + * Thanks to Lazaro Danillo for his contributions - https://github.com/lazaromenezes |
4 | 4 | * https://twitter.com/BradWayneMartin
|
5 | 5 | * https://github.com/bradmartin
|
6 | 6 | * Pull requests are welcome. Enjoy!
|
7 | 7 | *************************************************************************************/
|
8 | 8 |
|
9 | 9 | var common = require("./fab-common");
|
10 |
| - var utils = require("utils/utils"); |
| 10 | + var ImageSource = require("image-source"); |
11 | 11 |
|
12 | 12 | require("utils/module-merge").merge(common, module.exports);
|
13 | 13 |
|
|
30 | 30 | this._android.setBackgroundTintList(android.content.res.ColorStateList.valueOf(this.backColor.android));
|
31 | 31 |
|
32 | 32 | if(this.icon){
|
33 |
| - var res = utils.ad.getApplicationContext().getResources(); |
34 |
| - if(res){ |
35 |
| - var identifier = res.getIdentifier(this.icon, 'drawable', utils.ad.getApplication().getPackageName()); |
36 |
| - var bitmapDrawable = res.getDrawable(identifier); |
37 |
| - this._android.setImageDrawable(bitmapDrawable); |
| 33 | + iconDrawable = null; |
| 34 | + |
| 35 | + if(ImageSource.isFileOrResourcePath(this.icon)) |
| 36 | + iconDrawable = ImageSource.fromFileOrResource(this.icon); |
| 37 | + else{ |
| 38 | + var drawableId = android.content.res.Resources.getSystem().getIdentifier(this.icon, "drawable", "android"); |
| 39 | + iconDrawable = android.content.res.Resources.getSystem().getDrawable(drawableId); |
38 | 40 | }
|
| 41 | + |
| 42 | + if(iconDrawable != null) |
| 43 | + this._android.setImageDrawable(iconDrawable); |
39 | 44 | }
|
40 | 45 |
|
41 | 46 | var that = new WeakRef(this);
|
|
0 commit comments