File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
java/test/ca/weblite/objc Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ import ca .weblite .objc .Client ;
2+ import ca .weblite .objc .Proxy ;
3+
4+ /**
5+ * Created by IntelliJ IDEA.
6+ * User: remicartier (remi.cartier@gmail.com)
7+ * Date: 2014-08-06
8+ * Time: 8:13 PM
9+ */
10+ public class NSProcessInfoUtils {
11+
12+ private final static long NSActivityUserInitiated = (0x00FFFFFFL | (1L << 20 ));
13+
14+ /**
15+ * To ensure Mac OS X doesn't slow down your app because of App Nap, call this method
16+ * @param reason the reason for allowing the app to work at full speed
17+ * @return the activity id as a Proxy object
18+ */
19+ public static Proxy beginActivityWithOptions (String reason ) {
20+
21+ Client c = Client .getInstance ();
22+ Proxy processInfo = c .sendProxy ("NSProcessInfo" , "processInfo" );
23+ return processInfo .sendProxy ("beginActivityWithOptions:reason:" , NSActivityUserInitiated , reason );
24+ }
25+
26+ /**
27+ * When the activity is finished, to re-enable app napping call this method
28+ * @param activity previously returned by beginActivityWithOptions()
29+ */
30+ public static void endActivity (Proxy activity ) {
31+
32+ if (activity != null ) {
33+ Client c = Client .getInstance ();
34+ Proxy processInfo = c .sendProxy ("NSProcessInfo" , "processInfo" );
35+ processInfo .send ("endActivity:" , activity );
36+ }
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments