Skip to content

Instantly share code, notes, and snippets.

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

Axrorxoja

🏠
Working from home
View GitHub Profile
class MainRepoImpl(private val api: ApiService) : IMainRepo {
val TAG: String = javaClass.simpleName
var isFirst = false
var cache = Observable.empty<Message>()
override
fun loadData(): Observable<Message> {
if (!isFirst) {
cache = api.loadIp()
.subscribeOn(Schedulers.io())
@Axrorxoja
Axrorxoja / EchoClient.java
Created February 7, 2018 06:07 — forked from ochinchina/EchoClient.java
Async socket demo in java
package asyncsocket;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousSocketChannel;
import java.nio.channels.CompletionHandler;
import java.util.concurrent.atomic.AtomicInteger;
@Axrorxoja
Axrorxoja / colors.xml
Last active April 2, 2018 07:12
my colors
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="red_50">#FFEBEE</color>
<color name="red_100">#FFCDD2</color>
<color name="red_200">#EF9A9A</color>
<color name="red_300">#E57373</color>
<color name="red_400">#EF5350</color>
<color name="red_500">#F44336</color>
<color name="red_600">#E53935</color>
@Axrorxoja
Axrorxoja / build.gradle
Created February 17, 2019 07:32
G7 un mahsus
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
// implementation 'com.android.support:animated-vector-drawable:28.0.0'
// implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation('com.google.firebase:firebase-auth:16.1.0') {
exclude group: 'com.android.support'
}
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
@Axrorxoja
Axrorxoja / PacificTrackProvider.kt
Created February 20, 2019 05:46
isEmulator():Boolean
private fun isEmulator(): Boolean {
return (Build.FINGERPRINT.startsWith("generic")
|| Build.FINGERPRINT.startsWith("unknown")
|| Build.MODEL.contains("google_sdk")
|| Build.MODEL.contains("Emulator")
|| Build.MODEL.contains("Android SDK built for x86")
|| Build.MANUFACTURER.contains("Genymotion")
|| Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic")
|| "google_sdk" == Build.PRODUCT)
}
@Axrorxoja
Axrorxoja / ItemClickSupport.java
Created May 19, 2019 07:49 — forked from nesquena/ItemClickSupport.java
Click handling for RecyclerView
/*
Source: http://www.littlerobots.nl/blog/Handle-Android-RecyclerView-Clicks/
USAGE:
ItemClickSupport.addTo(mRecyclerView).setOnItemClickListener(new ItemClickSupport.OnItemClickListener() {
@Override
public void onItemClicked(RecyclerView recyclerView, int position, View v) {
// do it
}
});
import android.content.SharedPreferences
import uz.avtobio.app.extension.edit
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty
class BooleanPreference(
private val pref: SharedPreferences,
private val key: String,
private val defValue: Boolean = false
) : ReadWriteProperty<Any, Boolean> {
interface NominationService {
// https://nominatim.openstreetmap.org/reverse.php?format=html&lat=41.318479&lon=69.294924&zoom=18
@GET("reverse.php")
fun loadAddress(
@Query("lat") lat: Double,
@Query("lon") lon: Double,
@Query("format") format: String = "json",
@Query("accept-language") lang: String = "en"
): Call<NominationResponse>
}
name: Release Action
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ master ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
@Axrorxoja
Axrorxoja / gist:f72c7a46e570081f63bd8be912fd9a51
Created December 1, 2020 14:00 — forked from mediavrog/gist:5625602
Filter out Intents you don"t want to show from a IntentChooser dialog. For example your own app, competing apps or just apps you have a share integration by SDK already :) Based on http://stackoverflow.com/questions/5734678/custom-filtering-of-intent-chooser-based-on-installed-android-package-name/8550043#8550043
// Usage:
// blacklist
String[] blacklist = new String[]{"com.any.package", "net.other.package"};
// your share intent
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "some text");
intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "a subject");
// ... anything else you want to add
// invoke custom chooser