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
nekocode / ResponseWrapper.kt
Created Jun 3, 2019
The json(/gson) deserializer for mix-structure response
View ResponseWrapper.kt
import android.os.Parcelable
import java.lang.reflect.ParameterizedType
import java.lang.reflect.Type
sealed class ResponseWrapper<out T> {
class Anomaly(val value: : ResponseWrapper<Nothing>()
class Single<T : Parcelable>(val value: T) : ResponseWrapper<T>()
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
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 always_run_a_transform_task.gradle
project.afterEvaluate {
.outputs.upToDateWhen { false }
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 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 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 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
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) {
* 裁剪文本
private static String cutText(float textSize, String title, float maxWidth) {
final TextPaint textPaint = new TextPaint();
if (textPaint.measureText(title) < maxWidth)
return title;
You can’t perform that action at this time.