Skip to content

Instantly share code, notes, and snippets.

View heruoxin's full-sized avatar
🏠
Working from home

little_cup heruoxin

🏠
Working from home
View GitHub Profile
@heruoxin
heruoxin / AdvancedLinearLayoutManager.java
Last active January 10, 2020 07:50
修复当 RecyclerView 被其他透明或半透明 View 遮挡时,LinearLayoutManager#findFirstVisibleItemPosition 等方法会失效的问题。
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import java.util.HashMap;
import java.util.Map;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
@heruoxin
heruoxin / AdvancedLinearLayoutManager.java
Last active March 29, 2022 14:30
LinearLayoutManager with fixed computeVerticalScrollOffset()
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import java.util.HashMap;
import java.util.Map;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@heruoxin
heruoxin / gist:804b112c28a34f43d7e0c1fbb8414544
Created January 29, 2018 05:05
读取 Device Owner 模式下的 ApplicationInfo
// 读列表
pm.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES)
// 读到之后需要过滤掉双开/访客账户的 app
boolean installed = (applicationInfo.flags | ApplicationInfo.FLAG_INSTALLED == applicationInfo.flags);
@heruoxin
heruoxin / MainActivity.java
Created March 30, 2017 10:16
使用 dataBinding 来优化 fitsSystemWindows 系统边距分发
public class MainActivity extends BaseActivity {
private ActivityMainBinding mBinding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_main);
mBinding.setInsets(new WindowInsetsBindingAdapter.WindowInset());
import android.graphics.Color;
import android.support.annotation.ColorInt;
import android.support.v7.graphics.Palette;
/**
* Created by heruoxin on 16/4/15.
*/
public class ColorUtil {
Intent i = new Intent("com.catchingnow.icebox.FREEZE_APP")
.putExtra("broadcast_action", 0) // 0 冻结,1 解冻,2 解冻并运行
.putExtra("broadcast_package_name_set", {}); // String Array, action 为运行时,size 必须为 1,其余无限制
context.sendBroadcast(i);
@heruoxin
heruoxin / material_design_color.xml
Created November 16, 2015 03:56
Google Material Design Color XML for Android. var: http://www.v2ex.com/t/231395
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="red_500_main">#f44336</color>
<color name="red_50">#ffebee</color>
<color name="red_100">#ffcdd2</color>
<color name="red_200">#ef9a9a</color>
<color name="red_300">#e57373</color>
<color name="red_400">#ef5350</color>
<color name="red_500">#f44336</color>
<color name="red_600">#e53935</color>
@heruoxin
heruoxin / Android Lollipop Widget Tinting Guide
Created November 12, 2015 15:47 — forked from seanKenkeremath/Android Lollipop Widget Tinting Guide
How base colors in Lollipop apply to different UI elements
Unless specified otherwise, all of the below tinting applies to both Lollipop and pre-Lollipop using AppCompat v21. To use the support version of these attributes, remove the android namespace. For instance, "android:colorControlNormal" becomes "colorControlNormal". These attributes will be propagated to their corresponding attributes within the android namespace for devices running Lollipop. Any exceptions to this will be noted by including the "android:" prefix.
All Clickable Views:
-----------
* ripple effect (Lollipop only) -- "colorControlHighlight"
Status Bar:
------------
* background (Lollipop only) - "colorPrimaryDark"
//成都理工课表转换为Google Claendar兼容的csv
//登录后选择「我的课表」并将html文件另存,然后用本脚本转换,即可导入Google Calendar。
//2014秋测试有效。
//依赖包就cheerio一个,用的时候请酌情修改filePath。
//用法: node ./index.js > 课表.csv
var cheerio = require('cheerio');
var fs = require('fs');
var filePath = "./StuProductionSchedule.aspx.html";
@heruoxin
heruoxin / arp_os_x.sh
Created July 2, 2014 15:05
Simple arp hack script on OS X. Install arpspoof and wireshark before using it.
#!/bin/bash
#subset=`ifconfig en0 | grep 'inet ' | cut -d" " -f2 | cut -d"." -f1-3`
#echo "nmap -sP $subset.1/24"
#nmap -sP $subset.1/24
#echo
while true; do
read -p "dst IP: " dstip
if ! [ -z $dstip ]; then