Skip to content

Instantly share code, notes, and snippets.

View legendmohe's full-sized avatar
🎯
Focusing

Xinyu He legendmohe

🎯
Focusing
View GitHub Profile
@legendmohe
legendmohe / LifecycleBinder.java
Created January 21, 2019 03:53
Observable在onDestory时自动解绑
import android.app.Activity;
import android.app.Application;
import android.arch.lifecycle.GenericLifecycleObserver;
import android.arch.lifecycle.Lifecycle;
import android.arch.lifecycle.LifecycleObserver;
import android.arch.lifecycle.LifecycleOwner;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
package com.legendmohe.webviewtest;
import android.support.annotation.NonNull;
import android.util.Log;
import java.util.Arrays;
import java.util.Deque;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
@legendmohe
legendmohe / DataPreloader.java
Created March 29, 2018 10:24
预加载工具类
/**
* 预加载工具类
* <p>
* 适用范围:列表形式的数据进行预加载.
* 注意这里的预加载是指预加载数据项的详细信息(例如预拉取视频列表里面某些视频的播放地址等),不是指预先拉取更多的列表项。
* <p>
* 概念:加载窗口--即需要发起预加载的项目的index区间; 焦点--即当前外围逻辑所关心的中心点的index,决定了区间的中心
* <p>
* 该工具类引入加载窗口的概念(由upperPosition和LowerPosition组成的闭区间),外围调用triggerPreload()传入当前
* 焦点的index,该工具类即回调哪些index离开了加载窗口和哪些index进入了加载窗口(即窗口的变化情况)。
/**
* 用于缓存View使用
*
* @author legendmohe
*/
public final class ViewCache {
private static final String TAG = "ViewCache";
private final ExecutorService service;
@legendmohe
legendmohe / CommentPanelLayout.java
Last active October 21, 2018 15:35
解决因键盘和表情panel显示/隐藏引起的闪动
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.LinearLayout;
/**
""""""""""""""""""""""""""""""
" vundle setting
""""""""""""""""""""""""""""""
filetype off " required!
if has('win32') || has('win64')
set rtp+=$HOME/vimfiles/vundle/
call vundle#rc('$HOME/vimfiles/bundle/')
else
" Usual quickstart instructions
set rtp+=~/.vim/vundle/
@legendmohe
legendmohe / Handler.java
Last active July 12, 2017 05:42
Handler Object for Java Handler
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
@legendmohe
legendmohe / Looper.java
Created July 12, 2017 04:56
Looper Object for Java Handler
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
/**
* Created by legendmohe on 2017/7/7.
*/
public class Looper {
private static class LazyHolder {
@legendmohe
legendmohe / Message.java
Created July 12, 2017 04:55
Message Object for Java Handler
import java.util.concurrent.ScheduledFuture;
/**
* Created by legendmohe on 2017/7/7.
*/
public class Message {
public int what;
public int arg1;
#!/usr/bin/env python
import argparse
import itertools
import os
import re
INDEX_PATTERN = re.compile(r'\s*((\d\.?)+)\s*', re.DOTALL)