forked from raymondkam/Ti.SwipeRefreshLayout
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwipeRefreshProxy.java
More file actions
64 lines (49 loc) · 1.57 KB
/
SwipeRefreshProxy.java
File metadata and controls
64 lines (49 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.rkam.swiperefreshlayout;
import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.kroll.KrollProxy;
import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.view.TiUIView;
import org.appcelerator.titanium.TiApplication;
import android.app.Activity;
import android.os.Handler;
import android.os.Message;
@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;
public SwipeRefreshProxy() {
super();
}
@Override
public TiUIView createView(Activity activity) {
swipeRefresh = new SwipeRefresh(this);
return this.swipeRefresh;
}
/* Public API */
@Kroll.method
public void setRefreshing(boolean refreshing) {
if (TiApplication.isUIThread()) {
doSetRefreshing(refreshing);
} else {
Message message = getMainHandler().obtainMessage(MSG_SET_REFRESHING, refreshing);
message.sendToTarget();
}
}
@Kroll.method @Kroll.getProperty
public boolean isRefreshing() {
return this.swipeRefresh.isRefreshing();
}
/* Utilities */
public boolean handleMessage(Message message) {
switch (message.what) {
case MSG_SET_REFRESHING: {
doSetRefreshing((Boolean) message.obj);
return true;
}
}
return super.handleMessage(message);
}
protected void doSetRefreshing(boolean refreshing) {
this.swipeRefresh.setRefreshing(refreshing);
}
}