Skip to content

Instantly share code, notes, and snippets.

@cesclong
cesclong / Foreground.java
Created March 19, 2021 02:05
Android Foreground
package com.cn.mi;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import java.util.List;
@cesclong
cesclong / BackView.java
Created March 19, 2021 03:04
滑动返回View
import android.annotation.SuppressLint;
import android.app.Instrumentation;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PointF;
import android.support.v4.graphics.ColorUtils;
import android.util.AttributeSet;
@cesclong
cesclong / dep.gradle
Created March 19, 2021 03:12
support下的Jetpack依赖
// ViewModel and LiveData
implementation "android.arch.lifecycle:extensions:1.1.0"
// alternatively, just ViewModel
implementation "android.arch.lifecycle:viewmodel:1.1.0"
// alternatively, just LiveData
implementation "android.arch.lifecycle:livedata:1.1.0"
@cesclong
cesclong / LoadMoreDecoration.java
Created March 19, 2021 03:14
RecyclerView 加载更多Decoration
/**
* Created by zhoubinjia on 16/6/12.
*/
public class LoadMoreDecoration extends RecyclerView.ItemDecoration {
private static final String TAG = LoadMoreDecoration.class.getSimpleName();
private View mView;
private boolean mViewInited = false;
private Listener mListener;
private boolean mLoadComplete = false;
@cesclong
cesclong / LiveDataBus.java
Created March 19, 2021 03:28
LiveDataBus(包含防止数据倒灌的LiveData)
/**
* LiveData Bus
*
* @author shilong
* @since [历史 创建日期:3/19/21]
*/
public final class LiveDataBus {
private static LiveDataBus liveDataBus;
@cesclong
cesclong / LifecycleFragment.java
Created March 19, 2021 06:51
Support 版本中的具有生命周期的Fragment
public class LifecycleFragment extends Fragment implements LifecycleOwner {
private final LifecycleRegistry registry = new LifecycleRegistry(this);
public LifecycleFragment() {
}
@NonNull
public Lifecycle getLifecycle() {
return this.registry;
}
@cesclong
cesclong / dwn.desktop
Created March 21, 2021 06:38
dwm在/usr/share/xsessions/dwm.desktop
[Desktop Entry]
Name=dwm
Comment=Suckless Window Manager
Exec=/usr/local/bin/dwm
TryExec=/usr/local/bin/dwm
Icon=/home/cesc/dwm/dwm.png
Type=Application
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.longzhu.utils.android;
import android.text.TextUtils;
import android.util.Log;
@cesclong
cesclong / BaseRecyclerView.java
Created March 30, 2021 14:59
响应生命周期Lifecycle的自定义RecyclerView
public class BaseRecyclerView extends RecyclerView implements LifecycleObserver {
public BaseRecyclerView(@NonNull Context context) {
super(context);
init(context);
}
public BaseRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init(context);
}
@cesclong
cesclong / FixCrashWithDialogFragment
Created April 5, 2021 08:01
Fix `DialogFragment` crash questions ... 修复DialogFragment崩溃崩溃的
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Field;
/**
* Fix `DialogFragment` crash questions ... <br /><br />
*