Skip to content

Commit

Permalink
Remove ResourceHelper.
Browse files Browse the repository at this point in the history
Guard for passing the correct activity during creation.
Guard for null parameter.
Remove redundant variable.
  • Loading branch information
ypbnv committed Jun 29, 2017
1 parent bd93828 commit 9ccebb2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
import org.appcelerator.titanium.view.TiDrawableReference;

import ti.modules.titanium.android.AndroidModule;
import ti.modules.titanium.filesystem.FileProxy;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v4.app.NotificationCompat.BigPictureStyle;
import ti.modules.titanium.filesystem.ResourceHelper;

@Kroll.proxy(creatableInModule = AndroidModule.class, propertyAccessors = {
TiC.PROPERTY_DECODE_RETRIES
Expand Down Expand Up @@ -83,7 +81,7 @@ public void setBigLargeIcon(Object icon)
@Kroll.method @Kroll.setProperty
public void setBigPicture(Object picture)
{
TiDrawableReference source = ResourceHelper.getInstance().makeImageSource(this, picture);
TiDrawableReference source = TiDrawableReference.fromObject(this.getActivity(), picture);

// Check for decodeRetries
if (hasProperty(TiC.PROPERTY_DECODE_RETRIES)) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.appcelerator.titanium.util.TiColorHelper;
import org.appcelerator.titanium.view.TiDrawableReference;
import org.appcelerator.titanium.view.TiUIView;
import ti.modules.titanium.filesystem.ResourceHelper;

public class TiToolbar extends TiUIView implements Handler.Callback{
//region private primitive fields
Expand Down Expand Up @@ -62,7 +61,7 @@ public class TiToolbar extends TiUIView implements Handler.Callback{
*/
public TiToolbar(TiViewProxy proxy) {
super(proxy);
toolbar = new Toolbar(TiApplication.getAppCurrentActivity());
toolbar = new Toolbar(proxy.getActivity());
toolbar.setContentInsetsAbsolute(0,0);
setNativeView(toolbar);
}
Expand All @@ -72,8 +71,10 @@ public TiToolbar(TiViewProxy proxy) {
* @param proxies View proxies to be used
*/
public void setItems(TiViewProxy[] proxies) {
for (int i=0; i < proxies.length; i++) {
toolbar.addView(convertLayoutParamsForView(proxies[i].getOrCreateView()));
if (proxies != null) {
for (int i = 0; i < proxies.length; i++) {
toolbar.addView(convertLayoutParamsForView(proxies[i].getOrCreateView()));
}
}
}

Expand Down Expand Up @@ -234,7 +235,7 @@ public void setLogo(Object object) {
*/
private void handleSetLogo(Object object) {
logo = object;
TiDrawableReference tiDrawableReference = ResourceHelper.getInstance().makeImageSource(proxy,object);
TiDrawableReference tiDrawableReference = TiDrawableReference.fromObject(proxy.getActivity(), object);
((Toolbar) getNativeView()).setLogo(tiDrawableReference.getDrawable());
}

Expand Down Expand Up @@ -264,7 +265,7 @@ public void setNavigationIcon(Object object) {
*/
private void handleSetNavigationIcon(Object object) {
navigationIcon = object;
TiDrawableReference tiDrawableReference = ResourceHelper.getInstance().makeImageSource(proxy,object);
TiDrawableReference tiDrawableReference = TiDrawableReference.fromObject(proxy.getActivity(), object);
((Toolbar) getNativeView()).setNavigationIcon(tiDrawableReference.getDrawable());
}

Expand Down Expand Up @@ -294,7 +295,7 @@ public void setOverflowMenuIcon(Object object) {
*/
private void handleSetOverflowMenuIcon(Object object) {
overflowMenuIcon = object;
TiDrawableReference tiDrawableReference = ResourceHelper.getInstance().makeImageSource(proxy,object);
TiDrawableReference tiDrawableReference = TiDrawableReference.fromObject(proxy.getActivity(), object);
((Toolbar) getNativeView()).setOverflowIcon(tiDrawableReference.getDrawable());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.appcelerator.titanium.view.TiUIView;

import ti.modules.titanium.filesystem.FileProxy;
import ti.modules.titanium.filesystem.ResourceHelper;
import ti.modules.titanium.ui.ImageViewProxy;
import ti.modules.titanium.ui.ScrollViewProxy;
import android.app.Activity;
Expand Down Expand Up @@ -670,10 +669,10 @@ private void setImageSource(Object object)
imageSources = new ArrayList<TiDrawableReference>();
if (object instanceof Object[]) {
for (Object o : (Object[]) object) {
imageSources.add(ResourceHelper.getInstance().makeImageSource(getProxy(), o));
imageSources.add(TiDrawableReference.fromObject(getProxy().getActivity(), o));
}
} else {
imageSources.add(ResourceHelper.getInstance().makeImageSource(getProxy(), object));
imageSources.add(TiDrawableReference.fromObject(getProxy().getActivity(), object));
}
}

Expand Down Expand Up @@ -810,7 +809,7 @@ public void processProperties(KrollDict d)
// processProperties is also called from TableView, we need check if we changed before re-creating the
// bitmap
boolean changeImage = true;
TiDrawableReference source = ResourceHelper.getInstance().makeImageSource(getProxy(), d.get(TiC.PROPERTY_IMAGE));
TiDrawableReference source = TiDrawableReference.fromObject(getProxy().getActivity(), d.get(TiC.PROPERTY_IMAGE));
if (imageSources != null && imageSources.size() == 1) {
if (imageSources.get(0).equals(source)) {
changeImage = false;
Expand Down Expand Up @@ -862,7 +861,7 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP
view.setEnableZoomControls(TiConvert.toBoolean(newValue));
} else if (key.equals(TiC.PROPERTY_IMAGE)) {
if ((oldValue == null && newValue != null) || (oldValue != null && !oldValue.equals(newValue))) {
TiDrawableReference source = ResourceHelper.getInstance().makeImageSource(getProxy(), newValue);
TiDrawableReference source = TiDrawableReference.fromObject(getProxy().getActivity(), newValue);
Object autoRotate = proxy.getProperty(TiC.PROPERTY_AUTOROTATE);
if (autoRotate != null && TiConvert.toBoolean(autoRotate)) {
view.setOrientation(source.getOrientation());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ public class ActivityProxy extends KrollProxy

private KrollFunction resultCallback;

public TiToolbarProxy toolbarProxy;

public ActivityProxy()
{
}
Expand Down

0 comments on commit 9ccebb2

Please sign in to comment.