Skip to content

Commit

Permalink
Merge branch 'master' into TIMOB-27237
Browse files Browse the repository at this point in the history
  • Loading branch information
sgtcoolguy committed Sep 9, 2019
2 parents 8e7e851 + 6a2aa4d commit f003d46
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,9 @@ private void finishedReceivingEntityData(long contentLength) throws IOException
if (fileDescriptor != null) {
fileDescriptor.sync();
}
if (responseData != null) {
responseData.loadBitmapInfo();
}
}
responseOut.close();
responseOut = null;
Expand Down Expand Up @@ -621,7 +624,7 @@ public TiBlob getResponseData()
TiBlob blob = this.responseData;
if (blob == null) {
if (this.responseOut instanceof ByteArrayOutputStream) {
blob = TiBlob.blobFromData(((ByteArrayOutputStream) this.responseOut).toByteArray());
blob = TiBlob.blobFromData(((ByteArrayOutputStream) this.responseOut).toByteArray(), this.contentType);
} else if (this.responseText != null) {
blob = TiBlob.blobFromString(this.responseText);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,6 @@
*/
package ti.modules.titanium.ui.widget;

import java.util.HashMap;

import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollProxy;
import org.appcelerator.kroll.common.Log;
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.TiDimension;
import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.util.TiConvert;
import org.appcelerator.titanium.util.TiRHelper;
import org.appcelerator.titanium.TiBaseActivity;
import org.appcelerator.titanium.view.TiCompositeLayout;
import org.appcelerator.titanium.view.TiCompositeLayout.LayoutArrangement;
import org.appcelerator.titanium.view.TiUIView;
import org.xmlpull.v1.XmlPullParser;

import ti.modules.titanium.ui.RefreshControlProxy;

import android.content.Context;
import android.graphics.Canvas;
import android.os.Build;
Expand All @@ -40,6 +22,22 @@
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.HorizontalScrollView;
import java.util.HashMap;
import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollProxy;
import org.appcelerator.kroll.common.Log;
import org.appcelerator.titanium.TiBaseActivity;
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.TiDimension;
import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.util.TiConvert;
import org.appcelerator.titanium.util.TiRHelper;
import org.appcelerator.titanium.view.TiCompositeLayout;
import org.appcelerator.titanium.view.TiCompositeLayout.LayoutArrangement;
import org.appcelerator.titanium.view.TiUIView;
import org.xmlpull.v1.XmlPullParser;
import ti.modules.titanium.ui.RefreshControlProxy;
import ti.modules.titanium.ui.ScrollViewProxy;

public class TiUIScrollView extends TiUIView
{
Expand Down Expand Up @@ -448,9 +446,11 @@ protected void onScrollChanged(int l, int t, int oldl, int oldt)
KrollDict data = new KrollDict();
getProxy().fireEvent(TiC.EVENT_DRAGSTART, data);
}

KrollDict data = new KrollDict();
data.put(TiC.EVENT_PROPERTY_X, l);
data.put(TiC.EVENT_PROPERTY_Y, t);
data.put(TiC.PROPERTY_CONTENT_SIZE, contentSize());
setContentOffset(l, t);
getProxy().fireEvent(TiC.EVENT_SCROLL, data);
}
Expand Down Expand Up @@ -575,13 +575,16 @@ protected void onScrollChanged(int l, int t, int oldl, int oldt)
{
super.onScrollChanged(l, t, oldl, oldt);
KrollDict data = new KrollDict();

if (!isScrolling && isTouching) {
isScrolling = true;
getProxy().fireEvent(TiC.EVENT_DRAGSTART, data);
}

data = new KrollDict();
data.put(TiC.EVENT_PROPERTY_X, l);
data.put(TiC.EVENT_PROPERTY_Y, t);
data.put(TiC.PROPERTY_CONTENT_SIZE, contentSize());
setContentOffset(l, t);
getProxy().fireEvent(TiC.EVENT_SCROLL, data);
}
Expand Down Expand Up @@ -1061,6 +1064,19 @@ public void scrollToTop()
}
}

private KrollDict contentSize()
{
TiDimension dimensionWidth = new TiDimension(getLayout().getMeasuredWidth(), TiDimension.TYPE_WIDTH);
TiDimension dimensionHeight = new TiDimension(getLayout().getMeasuredHeight(), TiDimension.TYPE_HEIGHT);
double contentWidth = dimensionWidth.getAsDefault(getNativeView());
double contentHeight = dimensionHeight.getAsDefault(getNativeView());

KrollDict contentData = new KrollDict();
contentData.put(TiC.PROPERTY_WIDTH, contentWidth);
contentData.put(TiC.PROPERTY_HEIGHT, contentHeight);
return contentData;
}

@Override
public void add(TiUIView child)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public abstract class TiUIAbstractTabGroup extends TiUIView
public abstract String getTabTitle(int index);

// region protected fields
protected static final String TAG = "TiUITabLayoutTabGroup";
protected final static String TAG = "TiUIAbstractTabGroup";
protected static final String WARNING_LAYOUT_MESSAGE =
"Trying to customize an unknown layout, sticking to the default one";

Expand Down Expand Up @@ -237,7 +237,6 @@ public void addTab(TabProxy tabProxy)
tabFragmentIDs.add(fragmentIdGenerator.getAndIncrement());

this.tabGroupPagerAdapter.notifyDataSetChanged();

addTabItemInController(tabProxy);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.ArrayList;

import ti.modules.titanium.ui.TabGroupProxy;
import ti.modules.titanium.ui.TabProxy;

/**
* TabGroup implementation using BottomNavigationView as a controller.
Expand All @@ -48,6 +49,22 @@ public TiUIBottomNavigationTabGroup(TabGroupProxy proxy, TiBaseActivity activity
super(proxy, activity);
}

// Overriding addTab method to provide a proper guard for trying to add more tabs than the limit
// for BottomNavigationView class.
@Override
public void addTab(TabProxy tabProxy)
{
if (this.mBottomNavigationView == null) {
return;
}
final int MAX_TABS = this.mBottomNavigationView.getMaxItemCount();
if (this.tabs.size() < MAX_TABS) {
super.addTab(tabProxy);
} else {
Log.w(TAG, "Bottom style TabGroup cannot have more than " + MAX_TABS + " tabs.");
}
}

@Override
public void addViews(TiBaseActivity activity)
{
Expand Down
5 changes: 5 additions & 0 deletions android/titanium/src/java/org/appcelerator/titanium/TiC.java
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,11 @@ public class TiC
*/
public static final String PROPERTY_CONTENT_HEIGHT = "contentHeight";

/**
* @module.api
*/
public static final String PROPERTY_CONTENT_SIZE = "contentSize";

/**
* @module.api
*/
Expand Down
4 changes: 2 additions & 2 deletions apidoc/Titanium/UI/ScrollView.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ events:
- name: contentSize
summary: |
The current content size of the scroll view defined by its `width` and `height` properties.
Available in Titanium SDK 5.2.0 and later.
type: Dictionary
platforms: [iphone, ipad]
platforms: [android, iphone, ipad]
since: { iphone: "5.2.0", ipad: "5.2.0", android: "8.3.0" }

- name: decelerating
summary: Indicates whether the scroll is decelerating.
Expand Down

0 comments on commit f003d46

Please sign in to comment.