Skip to content

Instantly share code, notes, and snippets.

View oksep's full-sized avatar
🎯
Cogito, ergo sum

Septenary oksep

🎯
Cogito, ergo sum
View GitHub Profile
@oksep
oksep / RoundedCornerLayout.java
Last active February 19, 2016 03:04
RoundedCorner
public class RoundedCornerLayout extends FrameLayout {
private final static float CORNER_RADIUS = 6.0f;
private float cornerRadius;
public RoundedCornerLayout(Context context) {
super(context);
init(context, null, 0);
}
public RoundedCornerLayout(Context context, AttributeSet attrs) {
@oksep
oksep / CustomTheme.md
Created February 24, 2016 02:34
Define your custom widget theme

Define your custom widget theme:

1.Suppose you have a declaration of attributes for your widget (in attrs.xml):

<declare-styleable name="CustomImageButton">
    <attr name="customAttr" format="string"/>
</declare-styleable>
@oksep
oksep / ImageUtil.java
Created April 1, 2016 09:31
ImageUtil
public class ImageUtil {
public static void setColorFilter(ImageView imageView, int color) {
final float r = Color.red(color) / 255f;
final float g = Color.green(color) / 255f;
final float b = Color.blue(color) / 255f;
final float a = Color.alpha(color) / 255f;
setColorFilter(imageView, r, g, b, a);
}
@oksep
oksep / MyLog.java
Last active May 12, 2016 04:11
Custom Log Util
package cn.septenary;
import java.util.Locale;
public class MyLog {
// adb shell setprop log.tag.MyLog VERBOSE
public static String TAG = "MyLog";
@oksep
oksep / GetCpuAbi.java
Created May 13, 2016 07:46
Get Cpu Abi
private static String getCpuAbi() {
ShellUtils.CommandResult result = ShellUtils.execCommand("getprop ro.product.cpu.abi", false);
String cpuAbi;
switch (result.successMsg) {
case "arm64-v8a":
cpuAbi = "arm64-v8a";
break;
case "armeabi":
@oksep
oksep / log.h
Created May 16, 2016 06:52
jni log.h
//
// log.h
#ifndef __CUSTOM__LOG_H
#define __CUSTOM__LOG_H
#include <android/log.h>
#define TAG "jni"
#define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, TAG, __VA_ARGS__)
@oksep
oksep / app build.gradle
Last active May 16, 2016 06:57
AndroidStudio JNI-support
apply plugin: 'com.android.model.application'
apply plugin: 'idea'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.2"
defaultConfig.with {
applicationId = "cn.septenary.keepdebug"
@oksep
oksep / CustomToast
Last active June 15, 2016 11:45
CustomToast.java
import android.content.Context;
import android.graphics.Color;
import android.graphics.PixelFormat;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
@oksep
oksep / mount read-only-filesystem.md
Created May 20, 2016 10:06
read-only-filesystem

Open terminal

adb shell

su

  • Mount system RW: mount -o rw,remount,rw /system
@oksep
oksep / UINavigationBar+.swift
Last active June 15, 2016 11:45
UINavigationBar transparency by ScrollView
/**
* 可渐变的 UINavigationBar
* 从 objective-c 版本 https://github.com/ltebean/LTNavigationBar 翻译而来
*/
extension UINavigationBar {
@nonobjc static var overlay:UIView?
// 设置 overlay 背景色
func lt_setBackgroundColor(backgroundColor: UIColor) {