This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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 | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
OlderNewer