Skip to content

Instantly share code, notes, and snippets.

@410063005
410063005 / Api.java
Created May 26, 2016 07:59
RxJava模型和API及示例
public interface Api {
///// 传统阻塞式API
List<Cat> queryCats(String query);
String store(Cat cat);
//// 非阻塞式API
void queryCats(String query, CatsQueryCallback callback);
void store(Cat cat, CatsStoreCallback callback);
@410063005
410063005 / BorderItemDecoration.java
Created March 6, 2017 07:36
给RecyclerView的item添加边框
public class BorderItemDecoration extends RecyclerView.ItemDecoration {
public static final int HORIZONTAL = LinearLayout.HORIZONTAL;
public static final int VERTICAL = LinearLayout.VERTICAL;
private static final int[] ATTRS = new int[]{ android.R.attr.listDivider };
private Drawable mDivider;
private final Rect mBounds = new Rect();
@410063005
410063005 / SoftKeyboardMonitor.java
Created August 18, 2017 03:33
Android监听软键盘
// https://stackoverflow.com/questions/25216749/softkeyboard-open-and-close-listener-in-an-activity-in-android
public class SoftKeyboardMonitor {
private final BaseActivity mActivity;
private KeyboardListener mKeyboardListener;
private View rootLayout;
private boolean isOpened;
public SoftKeyboardMonitor(BaseActivity activity) {
@410063005
410063005 / StatusBarCompat.java
Created September 18, 2017 02:54
修改状态栏颜色
/**
* Created by zhy on 15/9/21.
* http://blog.csdn.net/lmj623565791/article/details/48649563
*/
public class StatusBarCompat
{
private static final int INVALID_VAL = -1;
private static final int COLOR_DEFAULT = Color.parseColor("#20000000");
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@410063005
410063005 / CosClient.java
Last active February 2, 2018 07:18
CosClient 上传腾讯云对象存储服务
/**
* 上传腾讯云cos.
* <p>
* Created by 410063005 on 2018/1/31.
*/
// Config: https://cloud.tencent.com/document/product/436/12159
// Usage:
// File file = new File(Environment.getExternalStorageDirectory(), "hello.png");
// CosClient.create(IndexActivity.this, getAssets().open("heap.json")).upload(file);
public class CosClient {
@410063005
410063005 / png_finder.py
Last active June 4, 2018 06:31
一个可寻找目录中重复图片文件的脚本,用于找到android项目中重复的图片资源
import os
import os.path
import hashlib
import sys
hash_array = {}
def file_md5(file_path):
md5 = hashlib.md5()
with file(file_path, "rb") as f:
/*
* Copyright (C) 2016 Google Inc.
*
* 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
@410063005
410063005 / Helper.java
Created July 26, 2018 08:43
用于打印当前MessageQueue中的所有Message
// usage: Choreographer.getInstance().postFrameCallback(new Helper());
public class Helper implements Choreographer.FrameCallback {
private static final String TAG = "IndexHelper";
private Field messagesField;
private Field nextField;
public Helper() {
try {
@410063005
410063005 / AndroidManifest.xml
Created December 7, 2018 10:02
用于测试华为nova手机内存泄漏的demo
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.demo_glide">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:name=".MyApp"
android:allowBackup="true"
@410063005
410063005 / main.c
Created June 4, 2019 03:45
dlsym 示例。so 编译命令 gcc -fPIC -shared op.c -o libop.so
#include "op.h"
#include <dlfcn.h>
#include <stdio.h>
typedef int (*CACULATE_FUNC)(int, int);
int main(int argc, char* argv[])
{
dlerror();