diff --git a/samples/Javascript/CocosPlayer/Classes/Java_org_cocos2dx_cocosplayer_CocosPlayerSocket.cpp b/samples/Javascript/CocosPlayer/Classes/Java_org_cocos2dx_cocosplayer_CocosPlayerSocket.cpp index 41ae2fface..0790f4c197 100644 --- a/samples/Javascript/CocosPlayer/Classes/Java_org_cocos2dx_cocosplayer_CocosPlayerSocket.cpp +++ b/samples/Javascript/CocosPlayer/Classes/Java_org_cocos2dx_cocosplayer_CocosPlayerSocket.cpp @@ -10,7 +10,6 @@ #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) #define SOCKET_CLASS_NAME "org/cocos2dx/cocosplayer/CocosPlayerSocket" -#define HELPER_CLASS_NAME "org/cocos2dx/cocosplayer/CCBFileUtilsHelper" using namespace cocos2d; using namespace std; @@ -26,7 +25,7 @@ extern "C" { void cleanCacheDirJNI() { JniMethodInfo t; - if (JniHelper::getStaticMethodInfo(t, HELPER_CLASS_NAME, "cleanCache", "()V")) { + if (JniHelper::getStaticMethodInfo(t, SOCKET_CLASS_NAME, "cleanCache", "()V")) { t.env->CallStaticVoidMethod(t.classID, t.methodID); t.env->DeleteLocalRef(t.classID); } diff --git a/samples/Javascript/CocosPlayer/proj.android/src/org/cocos2dx/cocosplayer/CCBFileUtilsHelper.java b/samples/Javascript/CocosPlayer/proj.android/src/org/cocos2dx/cocosplayer/CCBFileUtilsHelper.java index a30d55f7b2..6b191f0469 100644 --- a/samples/Javascript/CocosPlayer/proj.android/src/org/cocos2dx/cocosplayer/CCBFileUtilsHelper.java +++ b/samples/Javascript/CocosPlayer/proj.android/src/org/cocos2dx/cocosplayer/CCBFileUtilsHelper.java @@ -151,25 +151,4 @@ public class CCBFileUtilsHelper { return android.os.Environment.getExternalStorageDirectory(); } - private static void cleanDir(File dir) { - - long bytesDeleted = 0; - File[] files = dir.listFiles(); - - for (File file : files) { - if(file.isDirectory()) { - cleanDir(file); - continue; - } - Log.i(TAG, "Deleting file: "+file.getName()); - bytesDeleted += file.length(); - file.delete(); - } - } - - public static void cleanCache(Context cw) { - File path = new File(getBaseDirectory(cw)); - cleanDir(path); - } - } diff --git a/samples/Javascript/CocosPlayer/proj.android/src/org/cocos2dx/cocosplayer/CocosPlayer.java b/samples/Javascript/CocosPlayer/proj.android/src/org/cocos2dx/cocosplayer/CocosPlayer.java index 199017feae..13634825a8 100644 --- a/samples/Javascript/CocosPlayer/proj.android/src/org/cocos2dx/cocosplayer/CocosPlayer.java +++ b/samples/Javascript/CocosPlayer/proj.android/src/org/cocos2dx/cocosplayer/CocosPlayer.java @@ -39,6 +39,6 @@ public class CocosPlayer extends Cocos2dxActivity{ } static { - System.loadLibrary("cocosdragonjs"); + System.loadLibrary("cocosplayer"); } } diff --git a/samples/Javascript/CocosPlayer/proj.android/src/org/cocos2dx/cocosplayer/CocosPlayerSocket.java b/samples/Javascript/CocosPlayer/proj.android/src/org/cocos2dx/cocosplayer/CocosPlayerSocket.java index cc1454a684..1597f42323 100644 --- a/samples/Javascript/CocosPlayer/proj.android/src/org/cocos2dx/cocosplayer/CocosPlayerSocket.java +++ b/samples/Javascript/CocosPlayer/proj.android/src/org/cocos2dx/cocosplayer/CocosPlayerSocket.java @@ -21,6 +21,7 @@ import java.io.OutputStream; import java.io.InputStream; import java.io.ByteArrayOutputStream; +import java.io.File; import com.dd.plist.NSDictionary; import com.dd.plist.NSData; @@ -78,7 +79,7 @@ public class CocosPlayerSocket { for(int i =0 ; i < keys.length; ++i ) { } if(cmd.equalsIgnoreCase("zip")) { - CCBFileUtilsHelper.cleanCache(cw); + cleanCache(); try { Log.i(TAG, "Size of NSDATA payload: "+((NSData)data.objectForKey("data")).bytes().length); CCBFileUtilsHelper.unzipCCB(((NSData)data.objectForKey("data")).bytes(), cw); @@ -99,6 +100,27 @@ public class CocosPlayerSocket { } } + private static void cleanDir(File dir) { + + long bytesDeleted = 0; + File[] files = dir.listFiles(); + + for (File file : files) { + if(file.isDirectory()) { + cleanDir(file); + continue; + } + Log.i(TAG, "Deleting file: "+file.getName()); + bytesDeleted += file.length(); + file.delete(); + } + } + + public static void cleanCache() { + File path = new File(CCBFileUtilsHelper.getBaseDirectory(cw)); + cleanDir(path); + } + private void parsePayload(byte[] b) { try { NSDictionary rootDict = CCBStreamHandler.parseBinaryPLIST(b);