mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-11 16:45:48 -04:00
Android: Make events queue static so it persists across activity create/destroy, fix not compiling
This commit is contained in:
parent
7bc5decec6
commit
cf788603fc
@ -63,8 +63,9 @@ public class MainActivity extends Activity {
|
|||||||
// Therefore pushing/pulling events must be thread-safe, which is achieved through ConcurrentLinkedQueue
|
// Therefore pushing/pulling events must be thread-safe, which is achieved through ConcurrentLinkedQueue
|
||||||
// Additionally, a cache is used (freeCmds) to avoid constantly allocating NativeCmdArgs instances
|
// Additionally, a cache is used (freeCmds) to avoid constantly allocating NativeCmdArgs instances
|
||||||
class NativeCmdArgs { public int cmd, arg1, arg2, arg3, arg4; public String str; public Surface sur; }
|
class NativeCmdArgs { public int cmd, arg1, arg2, arg3, arg4; public String str; public Surface sur; }
|
||||||
Queue<NativeCmdArgs> pending = new ConcurrentLinkedQueue<NativeCmdArgs>();
|
// static to persist across activity destroy/create
|
||||||
Queue<NativeCmdArgs> freeCmds = new ConcurrentLinkedQueue<NativeCmdArgs>();
|
static Queue<NativeCmdArgs> pending = new ConcurrentLinkedQueue<NativeCmdArgs>();
|
||||||
|
static Queue<NativeCmdArgs> freeCmds = new ConcurrentLinkedQueue<NativeCmdArgs>();
|
||||||
|
|
||||||
NativeCmdArgs getCmdArgs() {
|
NativeCmdArgs getCmdArgs() {
|
||||||
NativeCmdArgs args = freeCmds.poll();
|
NativeCmdArgs args = freeCmds.poll();
|
||||||
@ -136,8 +137,9 @@ public class MainActivity extends Activity {
|
|||||||
// ======================================
|
// ======================================
|
||||||
// --------------- EVENTS ---------------
|
// --------------- EVENTS ---------------
|
||||||
// ======================================
|
// ======================================
|
||||||
static boolean gameRunning;
|
|
||||||
InputMethodManager input;
|
InputMethodManager input;
|
||||||
|
// static to persist across activity destroy/create
|
||||||
|
static boolean gameRunning;
|
||||||
|
|
||||||
void startGameAsync() {
|
void startGameAsync() {
|
||||||
Log.i("CC_WIN", "handing off to native..");
|
Log.i("CC_WIN", "handing off to native..");
|
||||||
|
@ -631,8 +631,8 @@ static cc_result HttpBackend_Do(struct HttpRequest* req, cc_string* url) {
|
|||||||
*-----------------------------------------------------Android backend-----------------------------------------------------*
|
*-----------------------------------------------------Android backend-----------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
struct HttpRequest* java_req;
|
struct HttpRequest* java_req;
|
||||||
static JMethodID JAVA_httpInit, JAVA_httpSetHeader, JAVA_httpPerform, JAVA_httpSetData;
|
static jmethodID JAVA_httpInit, JAVA_httpSetHeader, JAVA_httpPerform, JAVA_httpSetData;
|
||||||
static JMethodID JAVA_httpDescribeError;
|
static jmethodID JAVA_httpDescribeError;
|
||||||
|
|
||||||
cc_bool Http_DescribeError(cc_result res, cc_string* dst) {
|
cc_bool Http_DescribeError(cc_result res, cc_string* dst) {
|
||||||
char buffer[NATIVE_STR_LEN];
|
char buffer[NATIVE_STR_LEN];
|
||||||
@ -741,7 +741,7 @@ static cc_result HttpBackend_Do(struct HttpRequest* req, cc_string* url) {
|
|||||||
|
|
||||||
req->_capacity = 0;
|
req->_capacity = 0;
|
||||||
http_curProgress = HTTP_PROGRESS_FETCHING_DATA;
|
http_curProgress = HTTP_PROGRESS_FETCHING_DATA;
|
||||||
res = JavaInstanceCall_Int(env, JAVA_httpPerform, args);
|
res = JavaInstanceCall_Int(env, JAVA_httpPerform, NULL);
|
||||||
http_curProgress = 100;
|
http_curProgress = 100;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user