Skip to content

Instantly share code, notes, and snippets.

View Assassinss's full-sized avatar
🎯
Focusing

ShangjingZhu Assassinss

🎯
Focusing
View GitHub Profile
@jcdom
jcdom / ReboundInterpolator.java
Last active January 10, 2017 05:00
An interpolator where the rate of change starts out quickly, decelerates and then bounces at the end.
import android.content.Context;
import android.util.AttributeSet;
import android.view.animation.Interpolator;
/**
* An interpolator where the rate of change starts out quickly,
* decelerates and then bounces at the end.
*
* Created by jcdom on 02/04/15.
*/
@rswofxd
rswofxd / PySched.py
Created June 23, 2012 10:45
Python:任务调度,定时执行
#coding=utf-8
import time
import sched
import os
import threading
"""
sched模块,准确的说,它是一个调度(延时处理机制),每次想要定时执行某任务都必须写入一个调度。
使用步骤如下:
(1)生成调度器:
s = sched.scheduler(time.time,time.sleep)
@flyingzl
flyingzl / android_naviator_react-native.js
Last active September 26, 2017 06:32
Use Navigator component in react-native
'use strict';
var React = require('react-native');
var {
AppRegistry,
View,
Navigator,
Text,
BackAndroid,
StyleSheet
@sjudd
sjudd / RecyclerToListViewScrollListener
Last active September 21, 2018 18:19
RecyclerView scroll listener to AbsListView scroll listener
public class RecyclerToListViewScrollListener extends RecyclerView.OnScrollListener {
private final AbsListView.OnScrollListener scrollListener;
private int lastFirstVisible = -1;
private int lastVisibleCount = -1;
private int lastItemCount = -1;
public RecyclerToListViewScrollListener(AbsListView.OnScrollListener scrollListener) {
this.scrollListener = scrollListener;
}
@scottdweber
scottdweber / ExpandingCircleAnimationDrawable.java
Created March 22, 2013 02:14
An example showing how to create and use a Drawable that animates.
package com.example.manualanimation;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.view.animation.AnimationUtils;
@uilianries
uilianries / serial_port.c
Created January 22, 2018 00:33
Read Serial port on Windows
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
int main() {
const char reboot = 'R';
const char ack = 6;
HANDLE hSerial = NULL;
DCB dcbSerialParams = {0};
COMMTIMEOUTS timeouts = {0};
@nickbutcher
nickbutcher / MainActivity.java
Last active August 20, 2021 16:15
A quick sample of the new physics-based animation library added in Support Library 25.3.0 docs: https://developer.android.com/reference/android/support/animation/package-summary.html output: https://twitter.com/crafty/status/842055117323026432
/*
* Copyright 2017 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
/*
* Copyright (C) 2018 Square, 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
@ssinss
ssinss / EndlessRecyclerOnScrollListener.java
Last active January 19, 2024 08:52
Endless RecyclerView OnScrollListener
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
int firstVisibleItem, visibleItemCount, totalItemCount;
@TWiStErRob
TWiStErRob / OkHttpProgressGlideModule.java
Last active January 31, 2024 13:37
Full POC for showing progress of loading in Glide v3 via OkHttp v2
// TODO add <meta-data android:value="GlideModule" android:name="....OkHttpProgressGlideModule" />
// TODO add <meta-data android:value="GlideModule" tools:node="remove" android:name="com.bumptech.glide.integration.okhttp.OkHttpGlideModule" />
// or not use 'okhttp@aar' in Gradle depdendencies
public class OkHttpProgressGlideModule implements GlideModule {
@Override public void applyOptions(Context context, GlideBuilder builder) { }
@Override public void registerComponents(Context context, Glide glide) {
OkHttpClient client = new OkHttpClient();
client.networkInterceptors().add(createInterceptor(new DispatchingProgressListener()));
glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(client));
}