Skip to content

Instantly share code, notes, and snippets.

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

yava yava555

🏠
Working from home
View GitHub Profile
@yava555
yava555 / APIException.java
Last active June 14, 2022 06:48
BackGroundTask 后台任务
public class APIException extends RuntimeException {
private int code;
private String msg;
public APIException(int code, String msg) {
this.code = code;
this.msg = msg;
}
@yava555
yava555 / adbproxy.sh
Last active June 8, 2023 07:49
one click setup android http proxy 一键设置 Android Http 代理
// 关闭代理:adb shell settings put global http_proxy :0
// 开启代理:adb shell settings put global http_proxy 192.168.1.50:8080
// 封装函数,自动获取电脑ip,一键设置代理。adbproxy 8080/off
adbproxy(){
if [[ -z $1 ]];
then adb shell settings put global http_proxy "$(ifconfig | grep 192 | awk '{ print $2 ;}'):8080"
return
fi
@yava555
yava555 / OneClickListener.java
Last active May 29, 2021 00:42
Prevent double click
import android.view.View;
public abstract class OneClickListener implements View.OnClickListener {
private long lastClickTime = 0;
private static long DIFF = 1000;
@Override
public void onClick(View v) {
if (!isFastDoubleClick()) {
@yava555
yava555 / TimeUtils.java
Created March 15, 2016 03:09
times ago
private static final long SECOND_MILLIS = 1000;
private static final long MINUTE_MILLIS = 60 * SECOND_MILLIS;
private static final long HOUR_MILLIS = 60 * MINUTE_MILLIS;
private static final long DAY_MILLIS = 24 * HOUR_MILLIS;
private static final long MONTH_MILLIS = 30 * DAY_MILLIS;
private static final long YEAR_MILLIS = 12 * MONTH_MILLIS;
public static String getTimeAgo(long time) {
if (time < 1000000000000L) {
@yava555
yava555 / 0_reuse_code.js
Created March 15, 2016 03:05
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@yava555
yava555 / fullscreen.java
Last active December 22, 2015 06:45
Activity Fullscreen
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
if (Build.VERSION.SDK_INT < 16) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else {
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
@yava555
yava555 / DropboxImage.py
Created March 11, 2014 08:57
Dropbox Camera Uploads rename
__author__ = 'yava'
from PIL import Image
from PIL import ExifTags
import os
import datetime
def getImageTime(path):
try:
@yava555
yava555 / ProgressWebView.java
Created July 31, 2013 09:16
ProgressWebView WebView
package com.cleanmaster.photosync.widget;
import android.content.Context;
import android.util.AttributeSet;
import android.webkit.WebView;
import android.widget.ProgressBar;
public class ProgressWebView extends WebView {
private ProgressBar mProgressbar;
@yava555
yava555 / ByteStreams.java
Created July 19, 2013 04:28
ByteStreams copy stream
/*
* Copyright (c) 2013 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 distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
@yava555
yava555 / BucketHelper.java
Last active December 16, 2021 20:17
BucketHelp extract from Gallery3D App
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import android.content.ContentResolver;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;