This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int find_pid_of(const char *process_name) | |
{ | |
int id; | |
pid_t pid = -1; | |
DIR* dir; | |
FILE *fp; | |
char filename[32]; | |
char cmdline[256]; | |
struct dirent * entry; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void enableStrictMode() { | |
if (PlatformUtils.hasGingerbread()) { | |
StrictMode.ThreadPolicy.Builder threadPolicyBuilder = | |
new StrictMode.ThreadPolicy.Builder() | |
.detectAll() | |
.penaltyLog(); | |
StrictMode.VmPolicy.Builder vmPolicyBuilder = | |
new StrictMode.VmPolicy.Builder() | |
.detectAll() | |
.penaltyLog(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static abstract class Pool<T> { | |
private final Deque<T> pool; | |
Pool(int initialSize) { | |
pool = new ArrayDeque<T>(initialSize); | |
for (int i = 0; i < initialSize; i++) { | |
pool.addLast(newObject()); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void calculateVideoSize() { | |
try { | |
AssetFileDescriptor afd = getAssets().openFd(FILE_NAME); | |
MediaMetadataRetriever metaRetriever = new MediaMetadataRetriever(); | |
metaRetriever.setDataSource( | |
afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength()); | |
String height = metaRetriever | |
.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT); | |
String width = metaRetriever | |
.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DatabaseManager { | |
private AtomicInteger mOpenCounter = new AtomicInteger(); | |
private static DatabaseManager instance; | |
private static SQLiteOpenHelper mDatabaseHelper; | |
private SQLiteDatabase mDatabase; | |
public static synchronized void initializeInstance(SQLiteOpenHelper helper) { | |
if (instance == null) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.graphics.Bitmap; | |
/** | |
* Created by paveld on 3/6/14. | |
*/ | |
public class FastBlur { | |
public static Bitmap doBlur(Bitmap sentBitmap, int radius, boolean canReuseInBitmap) { | |
// Stack Blur v1.0 from |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ScreenUtils { | |
public static float dpToPx(Context context, float dp) { | |
if (context == null) { | |
return -1; | |
} | |
return dp * context.getResources().getDisplayMetrics().density; | |
} | |
public static float pxToDp(Context context, float px) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (C) 2012 The Android Open Source Project | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (C) 2012 The Android Open Source Project | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
NewerOlder