예제 #1
0
  public void loadCache(FilenameFilter aFilenameFilter) {

    File webImageDir = null;
    try {
      webImageDir = getCacheDir();
      List<String> fileList =
          KCUtilFile.getFiles(webImageDir.getAbsolutePath(), true, true, aFilenameFilter);
      for (int i = 0; i < fileList.size(); ++i) {
        mImageFileMap.put(fileList.get(i), DUMMY_STRING);
      }
    } catch (Exception e) {
      KCLog.e(e);
    }

    if (webImageDir != null) {
      try {
        mDirWatcher =
            new KCDirWatcher(
                webImageDir.getAbsolutePath(), FileObserver.DELETE | FileObserver.DELETE_SELF);
        mDirWatcher.startWatching();
      } catch (Exception e) {
        KCLog.e(e);
      }
    }
  }
예제 #2
0
  @SuppressWarnings("rawtypes")
  public KCClassParser(String jsonStr) {
    try {
      JSONObject json = new JSONObject(jsonStr);
      mJSClzName = json.get(CLZ).toString();
      mJSMethodName = json.get(METHOD).toString();
      if (json.has(ARGS)) {
        mArgsJSON = json.getJSONObject(ARGS);
        Iterator it = mArgsJSON.keys();
        while (it.hasNext()) {
          String key = (String) it.next();
          if (key != null) {
            Object value = mArgsJSON.get(key);
            if (KCJSNull.isNull(value)) value = new KCJSNull();
            KCArg arg = null;

            if (key.equals(KCJSDefine.kJS_callbackId)) {
              arg = new KCArg(key, new KCJSCallback(value.toString()), KCJSCallback.class);
            } else {
              arg = new KCArg(key, value);
            }
            mArgList.addArg(arg);
          }
        }
      }
    } catch (JSONException e) {
      KCLog.e(e);
    }
  }
예제 #3
0
 public static File getInternalCacheDirectory(Context context) {
   File internalCacheDirectory = new File(context.getCacheDir(), "temp-images");
   if (!internalCacheDirectory.exists()) {
     if (!internalCacheDirectory.mkdir()) {
       KCLog.i("Failed creating temporary storage directory, this is probably not good");
     }
   }
   return internalCacheDirectory;
 }