Skip to content

Instantly share code, notes, and snippets.

View Aspsine's full-sized avatar
🎯
Focusing

Running man! Aspsine

🎯
Focusing
  • Beijing
View GitHub Profile
@loganj
loganj / script.sh
Last active April 3, 2024 03:45 — forked from dlew/script.sh
Simple AndroidX Migration Script
#!/usr/bin/env bash
# Original by Dan Lew
#
# I've found that the "Migrate to AndroidX" converter in Android Studio doesn't work very
# well, so I wrote my own script to do the simple job of converting package names.
#
# You can download a CSV of package names here: https://developer.android.com/topic/libraries/support-library/downloads/androidx-class-mapping.csv
#
# It'll run faster on a clean build because then there are fewer files to scan over.
#
@dlew
dlew / script.sh
Created November 9, 2018 16:36
Simple AndroidX Migration Script
#!/usr/bin/env bash
# I've found that the "Migrate to AndroidX" converter in Android Studio doesn't work very
# well, so I wrote my own script to do the simple job of converting package names.
#
# You can download a CSV of package names here: https://developer.android.com/topic/libraries/support-library/downloads/androidx-class-mapping.csv
#
# It'll run faster on a clean build because then there are fewer files to scan over.
#
# Uses `gsed` because I'm on a Mac. Can easily replace with `sed` if you don't have `gsed`.
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
@nielsutrecht
nielsutrecht / RsaExample.java
Created December 21, 2016 09:55
Example of using RSA in Java to sign/verify and encrypt/decryt
import javax.crypto.Cipher;
import java.nio.charset.StandardCharsets;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.SecureRandom;
import java.security.Signature;
public class RsaExample {
public static void main(String... argv) throws Exception {
//First generate a public/private key pair
@arturokunder
arturokunder / README.md
Created October 6, 2016 18:25
Verify APK signature

Do I have the correct certificate to sign my APK?

Use keytool Keytool is part of Java, so make sure your PATH has Java installation dir in it.

Get APK Certificate Signature

First, unzip the APK and extract the file /META-INF/ANDROID_.RSA (this file may also be CERT.RSA or something.RSA, but there should only be one .RSA file).

Then, run:

@SuhailMehta
SuhailMehta / OrientationListener.java
Last active August 21, 2017 16:50
Detect screen orientation in portrait locked screen for android
public abstract class OrientationListener extends OrientationEventListener {
public static final int CONFIGURATION_ORIENTATION_UNDEFINED = Configuration.ORIENTATION_UNDEFINED;
private volatile int defaultScreenOrientation = CONFIGURATION_ORIENTATION_UNDEFINED;
public int prevOrientation = OrientationEventListener.ORIENTATION_UNKNOWN;
private Context ctx;
private ReentrantLock lock = new ReentrantLock(true);
public OrientationListener(Context context) {
super(context);
@swankjesse
swankjesse / HostSelectionInterceptor.java
Last active July 20, 2023 19:01
This OkHttp application interceptor will replace the destination hostname in the request URL.
import java.io.IOException;
import okhttp3.HttpUrl;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
/** An interceptor that allows runtime changes to the URL hostname. */
public final class HostSelectionInterceptor implements Interceptor {
private volatile String host;
@Leaking
Leaking / dispatchTouchEvent源码解析
Created March 18, 2015 13:21
android事件分发dispatchTouchEvent方法的源码解析
package cc.aa;
import android.os.Environment;
import android.view.MotionEvent;
import android.view.View;
public class UnderstandDispatchTouchEvent {
/**
* dispatchTouchEvent()源码学习及其注释
* 常说事件传递中的流程是:dispatchTouchEvent->onInterceptTouchEvent->onTouchEvent
@georgioupanayiotis
georgioupanayiotis / List running service of Android device
Last active November 7, 2022 03:54
List running service of Android device
List running service of Android device
@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;