Skip to content

Instantly share code, notes, and snippets.

Avatar

Vladimir Baryshnikov vovkab

View GitHub Profile
@vovkab
vovkab / MainThreadWatchDog.java
Created Mar 8, 2018
Monitors main thread for timeouts.
View MainThreadWatchDog.java
package io.wondrous.sns.utils;
import android.os.Handler;
import android.os.Looper;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
public class MainThreadWatchDog {
public static final long MAIN_THREAD_PING_INTERVAL = 200;
@vovkab
vovkab / ExperimentDagger.java
Last active Apr 14, 2019
Example of using Dagger 2 in libraries
View ExperimentDagger.java
package com.example;
import java.lang.annotation.Retention;
import javax.inject.Inject;
import javax.inject.Scope;
import javax.inject.Singleton;
import dagger.Binds;
import dagger.BindsInstance;
@vovkab
vovkab / repo
Created Nov 3, 2017
gerrit repo
View repo
Show traces:
$ repo --trace <command>
Upload for review with topic set to current branch name:
$ repo upload -t
or
review.URL.uploadtopic = true
Issues
View gradle
gradlew :app:dependencyInsight --configuration testCompile --dependency kotlin-reflect
gradlew :tapp:dependencyInsight --configuration appDebugCompileClasspath --dependency okhttp
Resolve all dependencies. Force gradle to precache dependencies for all configurations:
```
allprojects {
task resolveAllDependencies {
doLast {
configurations.all { it.resolve() }
}
@vovkab
vovkab / android-recycler-merge-adapter-tools
Last active Feb 25, 2017
Tools for RecyclerMergeAdapter
View android-recycler-merge-adapter-tools
/**
* Calculates correct item position based on RecyclerAdapter and ViewHolder adapter position.
* Takes in consideration RecyclerMergeAdapter and adjust position accordingly
*
* @param adapter RecyclerAdapter with access to RecyclerView instance
* @param viewHolder ViewHolder that was created by @adapter
* @return adjusted local position for viewHolder
*/
public static int getLocalPosition(RecyclerAdapter adapter, RecyclerView.ViewHolder viewHolder) {
int position = viewHolder.getAdapterPosition();
@vovkab
vovkab / gist:d9f76e3429cdf20a4e0c
Created Jan 13, 2016 — forked from ohmrefresh/gist:55149f68c41a148ae673
How to Server-side verification of Google Play subscriptions
View gist:d9f76e3429cdf20a4e0c
1.create google app (google console)
Example:
Client ID xxx.apps.googleusercontent.com
Email address xxx@developer.gserviceaccount.com
Client secret xxx
Redirect URIs
https://localhost/oauth2callback
Javascript Origins
https://localhost
View genymotion
sudo ln -s /usr/local/bin/VBoxManage /usr/bin/VBoxManage
http://stackoverflow.com/questions/31364475/genymotion-error-unable-to-load-virtualbox-engine-on-yosemite-virtualbox-ins
View okhttp-decode-gzip-response
private String decodeBody(Response response) throws IOException {
final ResponseBody body = response.body();
if (body == null) return null;
if (isZipped(response)) {
return unzip(response.body());
} else {
return body.string();
}
}
@vovkab
vovkab / android-memory-class
Last active Jun 12, 2017
Android device memory class
View android-memory-class
ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
int memoryClass = manager.getMemoryClass();
48 - Samsung Nexus S
64 - Samsung Galaxy Nexus
Samsung S2
Samsung S3
128 - Samsung S4
@vovkab
vovkab / mac-os-haxm.md
Created Oct 21, 2014
Installing HAXM for Mac OS 10.10
View mac-os-haxm.md

Enable unsigned kext to be installed:

$ sudo nvram boot-args="kext-dev-mode=1"
You can’t perform that action at this time.