Skip to content
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
tmp
bin
build
/build
/dist
/libs
*.zip
.apt_generated
Binary file removed dist/com.rkam.swiperefreshlayout-android-0.1.zip
Binary file not shown.
Binary file removed dist/swiperefreshlayout.jar
Binary file not shown.
5 changes: 2 additions & 3 deletions example/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ var listView = Ti.UI.createListView({
});

var swipeRefreshModule = require('com.rkam.swiperefreshlayout');
var swipeRefresh = swipeRefreshModule.createSwipeRefresh({
view: listView
});
var swipeRefresh = swipeRefreshModule.createSwipeRefresh();
swipeRefresh.add(listView)

var fakeData = [
{from: "User 1", message:"Hello there"},
Expand Down
Binary file removed libs/armeabi-v7a/libcom.rkam.swiperefreshlayout.so
Binary file not shown.
Binary file removed libs/x86/libcom.rkam.swiperefreshlayout.so
Binary file not shown.
8 changes: 4 additions & 4 deletions manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 1.0.0
apiversion: 3
version: 3.0.0
apiversion: 4
description: Titanium version of SwipeRefreshLayout
architectures: armeabi-v7a x86
architectures: arm64-v8a armeabi-v7a x86
author: Raymond Kam
license: Specify your license
copyright: Copyright (c) 2016 by Your Company
Expand All @@ -16,4 +16,4 @@ name: swiperefreshlayout
moduleid: com.rkam.swiperefreshlayout
guid: fc0f2168-ac27-4239-bcb0-c51d7683eb05
platform: android
minsdk: 6.0.0
minsdk: 7.0.0
3 changes: 3 additions & 0 deletions src/com/rkam/swiperefreshlayout/MySwipeRefreshLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public boolean canChildScrollUp() {
} else {
nativeChildView = nativeView;
}
if (nativeChildView == null) {
return false;
}
if (android.os.Build.VERSION.SDK_INT < 14) {
if (nativeChildView instanceof AbsListView) {
final AbsListView absListView = (AbsListView) nativeChildView;
Expand Down
49 changes: 30 additions & 19 deletions src/com/rkam/swiperefreshlayout/SwipeRefresh.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.rkam.swiperefreshlayout;

import org.appcelerator.kroll.KrollDict;
import org.appcelerator.titanium.TiApplication;
import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.view.TiUIView;
import org.appcelerator.titanium.util.TiRHelper;
import org.appcelerator.titanium.util.TiRHelper.ResourceNotFoundException;
Expand All @@ -13,9 +11,6 @@

public class SwipeRefresh extends TiUIView {

private MySwipeRefreshLayout layout;
private TiViewProxy view;

public static final String PROPERTY_VIEW = "view";
public static final String PROPERTY_COLOR_SCHEME = "colorScheme";
private static final String TAG = "SwipeRefresh";
Expand All @@ -42,7 +37,8 @@ public SwipeRefresh(final SwipeRefreshProxy proxy) {
}

LayoutInflater inflater = LayoutInflater.from(TiApplication.getInstance());
layout = (MySwipeRefreshLayout) inflater.inflate(layout_swipe_refresh, null, false);
MySwipeRefreshLayout layout =
(MySwipeRefreshLayout) inflater.inflate(layout_swipe_refresh, null, false);

layout.setOnRefreshListener(new OnRefreshListener() {
@Override
Expand All @@ -57,25 +53,40 @@ public void onRefresh() {
}

@Override
public void processProperties(KrollDict d) {
if (d.containsKey(PROPERTY_VIEW)) {
Object view = d.get(PROPERTY_VIEW);
if (view != null && view instanceof TiViewProxy) {
this.view = (TiViewProxy) view;
this.layout.setNativeView(this.view.getOrCreateView().getNativeView());
this.layout.addView(this.view.getOrCreateView().getOuterView());
this.layout.setColorSchemeColors(color1, color2, color3, color4);
}
}
super.processProperties(d);
public void add(TiUIView child)
{
MySwipeRefreshLayout layout = (MySwipeRefreshLayout) getNativeView();
layout.setNativeView(child.getNativeView());
super.add(child);
layout.setColorSchemeColors(color1, color2, color3, color4);
}

public boolean isRefreshing() {
return this.layout.isRefreshing();
MySwipeRefreshLayout layout = (MySwipeRefreshLayout) getNativeView();
if (layout != null) {
return layout.isRefreshing();
}
return false;
}

public void setRefreshing(boolean refreshing) {
this.layout.setRefreshing(refreshing);
MySwipeRefreshLayout layout = (MySwipeRefreshLayout) getNativeView();
if (layout != null) {
layout.setRefreshing(refreshing);
}
}

@Override
public void release() {
Log.d(TAG, "release");
MySwipeRefreshLayout layout = (MySwipeRefreshLayout) getNativeView();
if (layout != null) {
layout.removeAllViews();
layout.setRefreshing(false);
layout.setOnRefreshListener(null);
}
super.release();
proxy = null;
}

}
18 changes: 12 additions & 6 deletions src/com/rkam/swiperefreshlayout/SwipeRefreshProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@
@Kroll.proxy(creatableInModule=SwiperefreshlayoutModule.class)
public class SwipeRefreshProxy extends TiViewProxy implements Handler.Callback {

private SwipeRefresh swipeRefresh;

protected static final int MSG_SET_REFRESHING = KrollProxy.MSG_LAST_ID + 101;

private static final String TAG = "SwipeRefreshProxy";

public SwipeRefreshProxy() {
super();
}

@Override
public TiUIView createView(Activity activity) {
swipeRefresh = new SwipeRefresh(this);
return this.swipeRefresh;
return new SwipeRefresh(this);
}

/* Public API */
Expand All @@ -42,7 +41,11 @@ public void setRefreshing(boolean refreshing) {

@Kroll.method @Kroll.getProperty
public boolean isRefreshing() {
return this.swipeRefresh.isRefreshing();
SwipeRefresh v = (SwipeRefresh) peekView();
if (v != null) {
return v.isRefreshing();
}
return false;
}

/* Utilities */
Expand All @@ -59,6 +62,9 @@ public boolean handleMessage(Message message) {
}

protected void doSetRefreshing(boolean refreshing) {
this.swipeRefresh.setRefreshing(refreshing);
SwipeRefresh v = (SwipeRefresh) peekView();
if (v != null) {
v.setRefreshing(refreshing);
}
}
}