mCurrentWebView.loadUrl("javascript:"+ ApplicationUtility.getInjectString(this,ApplicationUtility.INJECT_FILE_NIGHT_MODE));
public static String getInjectString(Context context,String file) {
InputStream is;
String injectString = null;
if (injectString == null) {
if(INJECT_FILE_NIGHT_MODE.equals(file)){
is = context.getResources().openRawResource(R.raw.night);
}else{
return null;
}
if (is != null) {
StringBuilder sb = new StringBuilder();
String line;
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
while ((line = reader.readLine()) != null) {
if ((line.length() > 0) &&
(!line.startsWith("//"))) {
sb.append(line).append("\n");
}
}
} catch (IOException e) {
} finally {
try {
is.close();
} catch (IOException e) {
}
}
injectString = sb.toString();
} else {
injectString = "";
}
}
return injectString;
}