(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
/* | |
* Copyright (C) 2006 The Android Open Source Project | |
* | |
* 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 |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
You can use this class to realize a simple sectioned RecyclerView.Adapter
without changing your code.
The RecyclerView
should use a LinearLayoutManager
.
You can use this code also with the TwoWayView
with the ListLayoutManager
(https://github.com/lucasr/twoway-view)
This is a porting of the class SimpleSectionedListAdapter
provided by Google
Example:
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; |
List running service of Android device |
package cc.aa; | |
import android.os.Environment; | |
import android.view.MotionEvent; | |
import android.view.View; | |
public class UnderstandDispatchTouchEvent { | |
/** | |
* dispatchTouchEvent()源码学习及其注释 | |
* 常说事件传递中的流程是:dispatchTouchEvent->onInterceptTouchEvent->onTouchEvent |
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; |
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); |
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.
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:
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 |