Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android: Ti SDK 9 #98

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

dependencies {
// Add the module's library dependencies here.
// See: https://developer.android.com/studio/build/dependencies
}
Binary file removed android/dist/androidcollectionview.jar
Binary file not shown.
23 changes: 0 additions & 23 deletions android/java-sources.txt

This file was deleted.

6 changes: 3 additions & 3 deletions android/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 3.0.0
version: 4.0.0
apiversion: 4
architectures: arm64-v8a armeabi-v7a x86
architectures: arm64-v8a armeabi-v7a x86 x86_64
description: androidcollectionview
author: Marcel Pociot
license: MIT
Expand All @@ -15,4 +15,4 @@ name: androidcollectionview
moduleid: ti.collectionview
guid: 304bc7f8-ad6c-4348-9d32-658adf6f61f4
platform: android
minsdk: 7.0.0
minsdk: 9.0.0
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package de.marcelpociot.collectionview;

import android.content.Context;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.view.View;
import android.widget.AbsListView;
import android.widget.FrameLayout;
import android.widget.ScrollView;

import androidx.core.view.ViewCompat;

/**
* MySwipeRefreshLayout is a modified SwipeRefreshLayout so that Titanium views
* are supported. It overrides the canChildScrollUp method used by Android to
Expand Down
78 changes: 39 additions & 39 deletions android/src/de/marcelpociot/collectionview/CollectionViewProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
public class CollectionViewProxy extends TiViewProxy {

private static final String TAG = "CollectionViewProxy";

private static final int MSG_FIRST_ID = TiViewProxy.MSG_LAST_ID + 1;

private static final int MSG_SECTION_COUNT = MSG_FIRST_ID + 399;
Expand All @@ -49,11 +49,11 @@ public class CollectionViewProxy extends TiViewProxy {



//indicate if user attempts to add/modify/delete sections before TiListView is created
//indicate if user attempts to add/modify/delete sections before TiListView is created
private boolean preload = false;
private ArrayList<CollectionSectionProxy> preloadSections;
private HashMap<String, Integer> preloadMarker;

public CollectionViewProxy() {
super();
defaultValues.put("columnWidth", 0);
Expand All @@ -64,13 +64,13 @@ public CollectionViewProxy() {
public TiUIView createView(Activity activity) {
return new CollectionView(this, activity);
}

public void handleCreationArgs(KrollModule createdInModule, Object[] args) {
preloadSections = new ArrayList<CollectionSectionProxy>();
defaultValues.put(TiC.PROPERTY_DEFAULT_ITEM_TEMPLATE, "listDefaultTemplate");
defaultValues.put(TiC.PROPERTY_CASE_INSENSITIVE_SEARCH, true);
super.handleCreationArgs(createdInModule, args);

}
public void handleCreationDict(KrollDict options) {
super.handleCreationDict(options);
Expand All @@ -83,26 +83,26 @@ public void handleCreationDict(KrollDict options) {
}
}
}

public void clearPreloadSections() {
if (preloadSections != null) {
preloadSections.clear();
}
}

public ArrayList<CollectionSectionProxy> getPreloadSections() {
return preloadSections;
}

public boolean getPreload() {
return preload;
}

public void setPreload(boolean pload)
{
preload = pload;
}

public HashMap<String, Integer> getPreloadMarker()
{
return preloadMarker;
Expand All @@ -119,7 +119,7 @@ private void addPreloadSections(Object secs, int index, boolean arrayOnly) {
addPreloadSection(secs, -1);
}
}

private void addPreloadSection(Object section, int index) {
if (section instanceof CollectionSectionProxy) {
if (index == -1) {
Expand All @@ -129,7 +129,7 @@ private void addPreloadSection(Object section, int index) {
}
}
}

@Kroll.method @Kroll.getProperty
public int getSectionCount() {
if (TiApplication.isUIThread()) {
Expand All @@ -138,7 +138,7 @@ public int getSectionCount() {
return (Integer) TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_SECTION_COUNT));
}
}

public int handleSectionCount () {
TiUIView listView = peekView();
if (listView != null) {
Expand All @@ -156,7 +156,7 @@ public void scrollToItem(int sectionIndex, int itemIndex, @SuppressWarnings("raw
if (animationargs.containsKeyAndNotNull(TiC.PROPERTY_ANIMATED)) {
animated = TiConvert.toBoolean(animationargs.get(TiC.PROPERTY_ANIMATED), true);
}
}
}
if (TiApplication.isUIThread()) {
handleScrollToItem(sectionIndex, itemIndex, animated);
} else {
Expand All @@ -167,7 +167,7 @@ public void scrollToItem(int sectionIndex, int itemIndex, @SuppressWarnings("raw
TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_SCROLL_TO_ITEM), d);
}
}

@Kroll.method
public void setMarker(Object marker) {
if (marker instanceof HashMap) {
Expand All @@ -180,7 +180,7 @@ public void setMarker(Object marker) {
}
}
}


@Override
public boolean handleMessage(final Message msg) {
Expand Down Expand Up @@ -233,13 +233,13 @@ public boolean handleMessage(final Message msg) {
result.setResult(null);
return true;
}

case MSG_GET_SECTIONS: {
AsyncResult result = (AsyncResult)msg.obj;
result.setResult(handleSections());
return true;
}

case MSG_SET_SECTIONS: {
AsyncResult result = (AsyncResult)msg.obj;
TiUIView listView = peekView();
Expand All @@ -251,7 +251,7 @@ public boolean handleMessage(final Message msg) {
result.setResult(null);
return true;
}

default:
return super.handleMessage(msg);
}
Expand All @@ -262,7 +262,7 @@ private void handleScrollToItem(int sectionIndex, int itemIndex, boolean animate
((CollectionView) listView).scrollToItem(sectionIndex, itemIndex, animated);
}
}

@Kroll.method
public void appendSection(Object section) {
if (TiApplication.isUIThread()) {
Expand All @@ -281,7 +281,7 @@ private void handleAppendSection(Object section) {
addPreloadSections(section, -1, false);
}
}

@Kroll.method
public void deleteSectionAt(int index) {
if (TiApplication.isUIThread()) {
Expand All @@ -290,7 +290,7 @@ public void deleteSectionAt(int index) {
TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_DELETE_SECTION_AT), index);
}
}

private void handleDeleteSectionAt(int index) {
TiUIView listView = peekView();
if (listView != null) {
Expand All @@ -304,7 +304,7 @@ private void handleDeleteSectionAt(int index) {
preloadSections.remove(index);
}
}

@Kroll.method
public void insertSectionAt(int index, Object section) {
if (TiApplication.isUIThread()) {
Expand All @@ -313,14 +313,14 @@ public void insertSectionAt(int index, Object section) {
sendInsertSectionMessage(index, section);
}
}

private void sendInsertSectionMessage(int index, Object section) {
KrollDict data = new KrollDict();
data.put("index", index);
data.put("section", section);
TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_INSERT_SECTION_AT), data);
}

private void handleInsertSectionAt(int index, Object section) {
TiUIView listView = peekView();
if (listView != null) {
Expand All @@ -334,7 +334,7 @@ private void handleInsertSectionAt(int index, Object section) {
addPreloadSections(section, index, false);
}
}

@Kroll.method
public void replaceSectionAt(int index, Object section) {
if (TiApplication.isUIThread()) {
Expand All @@ -343,7 +343,7 @@ public void replaceSectionAt(int index, Object section) {
sendReplaceSectionMessage(index, section);
}
}

private void sendReplaceSectionMessage(int index, Object section) {
KrollDict data = new KrollDict();
data.put("index", index);
Expand All @@ -358,10 +358,10 @@ private void handleReplaceSectionAt(int index, Object section) {
} else {
handleDeleteSectionAt(index);
handleInsertSectionAt(index, section);

}
}

@Kroll.method @Kroll.getProperty
public CollectionSectionProxy[] getSections()
{
Expand All @@ -371,7 +371,7 @@ public CollectionSectionProxy[] getSections()
return (CollectionSectionProxy[]) TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_GET_SECTIONS));
}
}

@Kroll.setProperty @Kroll.method
public void setSections(Object sections)
{
Expand All @@ -395,10 +395,10 @@ public void setSections(Object sections)
} else {
TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_SET_SECTIONS), sectionsArray);
}

}
}

private CollectionSectionProxy[] handleSections()
{
TiUIView listView = peekView();
Expand All @@ -410,27 +410,27 @@ private CollectionSectionProxy[] handleSections()
return preloadedSections.toArray(new CollectionSectionProxy[preloadedSections.size()]);
}

@Kroll.method
@Kroll.method @Kroll.setProperty
public void setRefreshing(boolean refreshing) {
TiUIView listView = peekView();

if (listView != null) {
((CollectionView) listView).setRefreshing(refreshing);
}
}
}

@Kroll.method @Kroll.getProperty
public boolean isRefreshing() {
TiUIView listView = peekView();

if (listView != null) {
return ((CollectionView) listView).isRefreshing();
}

return false;
}


@Override
public String getApiName()
{
Expand Down
Loading