Skip to content

Instantly share code, notes, and snippets.

View ruijun's full-sized avatar

Jimson Liang ruijun

View GitHub Profile
@PierceZ
PierceZ / EventLiveData.java
Created September 20, 2017 13:00
Another approach where EventLiveData contains a reference to its lifecycle.
public class EventLiveData extends LiveData<Object> {
private final int mSubject;
private final LifecycleRegistryOwner mLifecycle;
public EventLiveData(@LiveDataBus.Subject int subject, @NonNull LifecycleRegistryOwner lifecycle) {
mSubject = subject;
mLifecycle = lifecycle;
}
@wyon
wyon / BlockDetect.java
Last active February 25, 2021 05:56
检测应用在UI线程的卡顿,打印出卡顿时调用堆栈。
public class BlockDetect {
// BlockDetectByPrinter
public static void start() {
Looper.getMainLooper().setMessageLogging(new Printer() {
private static final String START = ">>>>> Dispatching";
private static final String END = "<<<<< Finished";
@Override
@IlyaEremin
IlyaEremin / build.gradle
Created February 18, 2017 20:34
Example of managing dependencies in separate file
apply from: 'deps.gradle'
// ...
dependencies {
compile supportLibs
compile rxJavaLibs
compile retrofitLibs
compile okHttpLibs
获取问题跟文章
http://v3.wufazhuce.com:8000/api/reading/index/
然后根据essay跟question id进去到不同的详细
http://v3.wufazhuce.com:8000/api/question/1282
http://v3.wufazhuce.com:8000/api/essay/1339
获取首页
http://v3.wufazhuce.com:8000/api/hp/idlist/0
然后通过http://v3.wufazhuce.com:8000/api/hp/detail/1275 进入
@qrtt1
qrtt1 / aar-deps.gradle
Last active May 19, 2020 16:09
gradle: package *.jar into aar
project.afterEvaluate {
def isAndroidLibraryProject = project.plugins.hasPlugin('com.android.library')
if(isAndroidLibraryProject) {
task copyDeps(type:Copy) {
from configurations.compile {
include '**/*.jar'
}
into "./build/intermediates/bundles/release/libs/"
}
bundleRelease.dependsOn copyDeps
@ruijun
ruijun / copy-mapping
Created January 12, 2016 05:29
copy proguard mapping.txt to save it
android {
applicationVariants.all { variant ->
variant.outputs.each { output ->
if (variant.getBuildType().isMinifyEnabled()) {
variant.assemble.doLast{
copy {
from variant.mappingFile
into "${projectDir}/mappings"
rename { String fileName ->
"mapping-${variant.name}.txt"
@gabrielemariotti
gabrielemariotti / README.md
Last active February 24, 2021 10:52
How to manage the support libraries in a multi-module projects. Thanks to Fernando Cejas (http://fernandocejas.com/)

Centralize the support libraries dependencies in gradle

Working with multi-modules project, it is very useful to centralize the dependencies, especially the support libraries.

A very good way is to separate gradle build files, defining something like:

root
  --gradleScript
 ----dependencies.gradle
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN" "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<!-- Generated by RHY @will_awoke -->
<module name="Checker">
<property name="charset" value="UTF-8"/>
<property name="severity" value="warning"/>
@lapastillaroja
lapastillaroja / DividerItemDecoration.java
Last active November 17, 2023 23:06 — forked from akmalxxx/DividerItemDecoration.java
DividerItemDecoration. RecyclerView.ItemDecoration simple implementation
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
@rocboronat
rocboronat / BaseActivity.java
Last active April 13, 2016 08:16
Calling setTaskDescription() in a reflected way
private void setTaskDescription(){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
String title = getString(R.string.app_name);
Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
int color = getResources().getColor(R.color.task_background);
// The legacy method call
// setTaskDescription(new ActivityManager.TaskDescription(title, icon, color));
// The reflected method call