本文整理汇总了Java中com.jecelyin.common.utils.L类的典型用法代码示例。如果您正苦于以下问题:Java L类的具体用法?Java L怎么用?Java L使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
L类属于com.jecelyin.common.utils包,在下文中一共展示了L类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: delete
import com.jecelyin.common.utils.L; //导入依赖的package包/类
@Override
public void delete(final BoolResultListener listener) {
RootUtils.RootCommand command = new RootUtils.RootCommand("rm -rf \"%s\"", getAbsolutePath())
{
@Override
public void onFinish(boolean success, String output) {
listener.onResult(success && output.trim().isEmpty());
}
};
try {
RootTools.getShell(true).add(command);
}catch (Exception e) {
L.e(e);
listener.onResult(false);
}
}
示例2: setOAuth2Token
import com.jecelyin.common.utils.L; //导入依赖的package包/类
public GitHubClient setOAuth2Token(Context context) {
byte[] signature = SysUtils.getSignature(context);
if (signature == null)
return this;
int len = Math.min(32, signature.length);
byte[] bytes = new byte[len];
System.arraycopy(signature, 0, bytes, 0, len);
try {
// String u = EncryptionUtils.decryptText(bytes, Base64.decode(BuildConfig.GITHUB_USER, Base64.DEFAULT));
// String p = EncryptionUtils.decryptText(bytes, Base64.decode(BuildConfig.GITHUB_PWD, Base64.DEFAULT));
// setCredentials(u, p);
} catch (Exception e) {
L.e(e);
}
return this;
}
示例3: onCreate
import com.jecelyin.common.utils.L; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
context = getApplicationContext();
if (startupTimestamp == 0)
startupTimestamp = System.currentTimeMillis();
if (SysUtils.isDebug(this))
{
L.debug = true;
//内存泄漏监控
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
builder.detectAll();
builder.penaltyLog();
StrictMode.setVmPolicy(builder.build());
}
installMonitor();
}
示例4: getStackTraces
import com.jecelyin.common.utils.L; //导入依赖的package包/类
public static String getStackTraces(Context context) {
CrashConstants.loadFromContext(context);
File[] list = searchForStackTraces();
StringBuilder sb = new StringBuilder();
if ((list != null) && (list.length > 0)) {
L.d("Found " + list.length + " stacktrace(s).");
for (File file : list) {
try {
// Read contents of stack trace
String stacktrace = contentsOfFile(file);
sb.append("\n\n");
sb.append(stacktrace);
} catch (Exception e) {
e.printStackTrace();
} finally {
file.delete();
}
}
}
return sb.toString();
}
示例5: loadFilesPath
import com.jecelyin.common.utils.L; //导入依赖的package包/类
/**
* Helper method to set the files path. If an exception occurs, the files
* path will be null!
*
* @param context The context to use. Usually your Activity object.
*/
private static void loadFilesPath(Context context) {
if (context != null) {
try {
File file = context.getFilesDir();
// The file shouldn't be null, but apparently it still can happen, see
// http://code.google.com/p/android/issues/detail?id=8886
if (file != null) {
CrashConstants.FILES_PATH = file.getAbsolutePath();
}
} catch (Exception e) {
L.e("Exception thrown when accessing the files dir:");
e.printStackTrace();
}
}
}
示例6: loadPackageData
import com.jecelyin.common.utils.L; //导入依赖的package包/类
/**
* Helper method to set the package name and version code. If an exception
* occurs, these values will be null!
*
* @param context The context to use. Usually your Activity object.
*/
private static void loadPackageData(Context context) {
if (context != null) {
try {
PackageManager packageManager = context.getPackageManager();
PackageInfo packageInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
CrashConstants.APP_PACKAGE = packageInfo.packageName;
CrashConstants.APP_VERSION = "" + packageInfo.versionCode;
CrashConstants.APP_VERSION_NAME = packageInfo.versionName;
int buildNumber = loadBuildNumber(context, packageManager);
if ((buildNumber != 0) && (buildNumber > packageInfo.versionCode)) {
CrashConstants.APP_VERSION = "" + buildNumber;
}
} catch (PackageManager.NameNotFoundException e) {
L.e("Exception thrown when accessing the package info:");
e.printStackTrace();
}
}
}
示例7: loadCrashIdentifier
import com.jecelyin.common.utils.L; //导入依赖的package包/类
/**
* Helper method to load the crash identifier.
*
* @param context the context to use. Usually your Activity object.
*/
private static void loadCrashIdentifier(Context context) {
String deviceIdentifier = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
if (!TextUtils.isEmpty(CrashConstants.APP_PACKAGE) && !TextUtils.isEmpty(deviceIdentifier)) {
String combined = CrashConstants.APP_PACKAGE + ":" + deviceIdentifier + ":" + createSalt(context);
try {
MessageDigest digest = MessageDigest.getInstance("SHA-1");
byte[] bytes = combined.getBytes("UTF-8");
digest.update(bytes, 0, bytes.length);
bytes = digest.digest();
CrashConstants.CRASH_IDENTIFIER = bytesToHex(bytes);
} catch (Throwable e) {
L.e("Couldn't create CrashIdentifier with Exception:" + e.toString());
//TODO handle the exeption
}
}
}
示例8: show
import com.jecelyin.common.utils.L; //导入依赖的package包/类
@Override
public void show() {
UIUtils.showInputDialog(context, R.string.goto_line, 0, null, EditorInfo.TYPE_CLASS_NUMBER, new UIUtils.OnShowInputCallback() {
@Override
public void onConfirm(CharSequence input) {
try {
int line = StringUtils.toInt(input.toString());
Command command = new Command(Command.CommandEnum.GOTO_LINE);
command.args.putInt("line", line);
getMainActivity().doCommand(command);
} catch (Exception e) {
L.e(e);
}
}
});
}
示例9: find
import com.jecelyin.common.utils.L; //导入依赖的package包/类
private void find() {
editorDelegate.mEditText.setSearchResult(editorDelegate.getContext().getString(R.string.searching), grep.getPattern(), null);
grep.execute(new TaskListener<List<ExtGrep.Result>>() {
@Override
public void onCompleted() {
}
@Override
public void onSuccess(List<ExtGrep.Result> result) {
buildResults(result);
}
@Override
public void onError(Exception e) {
L.e(e);
}
});
}
示例10: read
import com.jecelyin.common.utils.L; //导入依赖的package包/类
private StringBuilder read() throws Exception, OutOfMemoryError {
File f = rootFile != null && rootFile.isFile() ? rootFile : file;
if(TextUtils.isEmpty(encoding))
encoding = FileEncodingDetector.detectEncoding(f);
L.d(file.getPath()+" encoding is "+encoding);
LineNumberReader reader = new LineNumberReader(new InputStreamReader(new FileInputStream(f), encoding));
char[] buf = new char[BUFFER_SIZE];
int len;
ssb = new StringBuilder(BUFFER_SIZE * 4);
while ((len = reader.read(buf, 0, BUFFER_SIZE)) != -1) {
ssb.append(buf, 0, len);
}
lineNumber = reader.getLineNumber() + 1;
reader.close();
return ssb;
}
示例11: detectEncoding
import com.jecelyin.common.utils.L; //导入依赖的package包/类
public static String detectEncoding(File file) {
// CharsetDetector detector = new CharsetDetector();
// try {
// detector.setText(new BufferedInputStream(new FileInputStream(file)));
// } catch (IOException e) {
// e.printStackTrace();
// }
// CharsetMatch detect = detector.detect();
// if(detect == null)
// return DEFAULT_ENCODING;
// String encoding = detect.getName();
String encoding = null;
try {
BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file));
encoding = CharsetDetector.detect(bufferedInputStream);
bufferedInputStream.close();
} catch (Exception e) {
L.e(e);
}
if(TextUtils.isEmpty(encoding)) {
encoding = DEFAULT_ENCODING;
}
return encoding;
}
示例12: setOAuth2Token
import com.jecelyin.common.utils.L; //导入依赖的package包/类
public GitHubClient setOAuth2Token(Context context) {
byte[] signature = SysUtils.getSignature(context);
if (signature == null)
return this;
int len = Math.min(32, signature.length);
byte[] bytes = new byte[len];
System.arraycopy(signature, 0, bytes, 0, len);
try {
String u = EncryptionUtils.decryptText(bytes, Base64.decode(BuildConfig.GITHUB_USER, Base64.DEFAULT));
String p = EncryptionUtils.decryptText(bytes, Base64.decode(BuildConfig.GITHUB_PWD, Base64.DEFAULT));
setCredentials(u, p);
} catch (Exception e) {
L.e(e);
}
return this;
}
示例13: prepare
import com.jecelyin.common.utils.L; //导入依赖的package包/类
private void prepare() throws Exception {
if (process != null) {
return;
}
L.d("CMD", "prepare start");
try {
process = Runtime.getRuntime().exec("su");
} catch (Exception e) {
//没有Root的设备无法执行su,但是要访问 / 根目录(用File.listFiles会返回null)
process = Runtime.getRuntime().exec("/system/bin/sh");
}
inputStream = new BufferedReader(new InputStreamReader(process.getInputStream(), "UTF-8"));
errorStream = new BufferedReader(new InputStreamReader(process.getErrorStream(), "UTF-8"));
outputStream = new OutputStreamWriter(process.getOutputStream(), "UTF-8");
inputReadTask = new ReadTask(inputStream, "CMD-INPUT");
errorReadTask = new ReadTask(errorStream, "CMD-OUTPUT");
inputReadTask.start();
errorReadTask.start();
start();
L.d("CMD", "prepare end");
}
示例14: onCreate
import com.jecelyin.common.utils.L; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
context = getApplicationContext();
if (startupTimestamp == 0)
startupTimestamp = System.currentTimeMillis();
if (SysUtils.isDebug(this))
{
L.debug = true;
//内存泄漏监控
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
builder.detectAll();
builder.penaltyLog();
StrictMode.setVmPolicy(builder.build());
}
// 捕捉未知异常
Thread.setDefaultUncaughtExceptionHandler(this);
// 安装内存泄漏监控或UI卡顿监控
if (!SysUtils.isMonkeyRunner(this))
installMonitor();
}
示例15: updateValue
import com.jecelyin.common.utils.L; //导入依赖的package包/类
private void updateValue(String key, Map<String, ?> values) {
Object value = map.get(key);
// 跳过一些不能通过本方法取值的东东
if (value == null)
return;
Class cls = value.getClass();
try {
if (cls == int.class || cls == Integer.class) {
// value = StringUtils.toInt(pm.getString(key, String.valueOf(value)));
Object in = values.get(key);
if (in != null)
value = in instanceof Integer ? (int) in : StringUtils.toInt(String.valueOf(in));
} else if (cls == boolean.class || cls == Boolean.class) {
// value = pm.getBoolean(key, (boolean)value);
Boolean b = (Boolean) values.get(key);
value = b == null ? (boolean) value : b;
} else {
// value = pm.getString(key, (String)value);
String str = (String) values.get(key);
value = str == null ? (String) value : str;
}
} catch (Exception e) {
L.e("key = " + key, e);
return;
}
map.put(key, value);
}