Skip to content

Instantly share code, notes, and snippets.

Working from home

nekocode nekocode

Working from home
Block or report user

Report or block nekocode

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
* Modified from {@link <a href=""/>}
* @author nekocode (
public class DiffUtils {
* 裁剪文本
private static String cutText(float textSize, String title, float maxWidth) {
final TextPaint textPaint = new TextPaint();
if (textPaint.measureText(title) < maxWidth)
return title;
nekocode /
Created Nov 23, 2017
Draw animatable drawable to view.
public class LoadingView extends View {
private CircularProgressDrawable mDrawable;
public LoadingView(Context pContext) {
public LoadingView(Context pContext, AttributeSet pAttributeSet) {
View get_apk_info.gradle
import groovy.json.JsonOutput
android.applicationVariants.all { variant ->
variant.assemble.doLast {
variant.outputs.each { output ->
def apkInfo = [
apk: output.outputFile.absolutePath,
versionCode: variant.versionCode,
versionName: variant.versionName
View conditional_dependence.gradle
project.afterEvaluate {
android.productFlavors.all { flavor ->
dependencies {
if (flavor.applicationIdSuffix) {
it."${}Implementation" "cn.nekocode.lib:keys-alpha:${versions.keys}"
} else {
it."${}Implementation" "cn.nekocode.lib:keys:${versions.keys}"
View androidstudio_trust_
# Referenced from
# Get the certification of the
echo -n | openssl s_client -connect | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/google.cer
# Navigate to the jre security directory insides the Android Studio
cd "/Applications/Android"
# Move the certification to current directory
mv ~/google.cer .
View check_if_task_is_selected.gradle
import org.gradle.util.NameMatcher
def isTaskSelected(String... taskNames) {
def matcher = new NameMatcher()
def nameList = Arrays.asList(taskNames)
def requestedTaskNames = gradle.startParameter.taskNames
for (def requestedTaskName : requestedTaskNames) {
if (matcher.find(requestedTaskName, nameList) != null) {
return true
View always_run_a_transform_task.gradle
project.afterEvaluate {
.outputs.upToDateWhen { false }
View import_external_classes.gradle
def classpathConfig = project.configurations.maybeCreate("gradleClasspath")
project.dependencies {
gradleClasspath "org.xerial:sqlite-jdbc:3.25.2"
def classloader = Thread.currentThread().contextClassLoader as URLClassLoader
classpathConfig.each {
View dependencies2json.gradle
import org.gradle.api.Project
import org.gradle.api.artifacts.component.ComponentIdentifier
import org.gradle.api.artifacts.component.ComponentSelector
import org.gradle.api.artifacts.component.ModuleComponentIdentifier
import org.gradle.api.artifacts.component.ModuleComponentSelector
import org.gradle.api.artifacts.result.DependencyResult
import org.gradle.api.artifacts.result.ResolvedDependencyResult
import org.gradle.api.artifacts.result.UnresolvedDependencyResult
import groovy.json.JsonOutput
You can’t perform that action at this time.