Skip to content

Instantly share code, notes, and snippets.

View thenixan's full-sized avatar
🐢
On vacation

Ilya Nixan thenixan

🐢
On vacation
View GitHub Profile
buildscript {
ext.kotlin_version = '1.2.10'
ext.rxjava2_version = '2.1.9'
ext.retrofit_version = '2.3.0'
...
}
...
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
class ShareActivity : SplashedActivity() {
private val helloText by lazy { findViewById<TextView>(R.id.helloText) }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
getUser()?.let {
helloText.text = "${it.login}\n${intent.getStringExtra(Intent.EXTRA_TEXT)}"
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.nixan.splashscreenexample">
...
<activity android:name=".ShareActivity">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
class AuthActivity : AppCompatActivity() {
private val authCardView by lazy { findViewById<CardView>(R.id.authCardView) }
private val okButton by lazy { findViewById<Button>(R.id.okButton) }
private val cancelButton by lazy { findViewById<Button>(R.id.cancelButton) }
private val loginEditText by lazy { findViewById<EditText>(R.id.loginEditText) }
private val passwordEditText by lazy { findViewById<EditText>(R.id.passwordEditText) }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
private const val ACTIVITY_AUTH = 1000
abstract class SplashedActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
if (!isAuthenticated()) {
startActivityForResult(Intent(this, AuthActivity::class.java), ACTIVITY_AUTH)
}
setTheme(R.style.AppTheme_Base)
super.onCreate(savedInstanceState)
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.SplashScreen" parent="AppTheme">
<item name="android:windowBackground">@drawable/splash</item>
(0..10)
.asSequence()
.map {
println(it)
it
}
.filter { it % 2 == 0 }
.map { it + 10 }
.forEach { println(it) }
...
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
...
...
dependencies {
compile 'com.github.thenixan:android-regexp-formatter:v0.0.+'
}
...
package org.nixan.sandboxapp
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.widget.Button
import android.widget.EditText
import android.widget.Toast
import ru.nixan.regexpformatter.RegExpFormatter
class MainActivity : AppCompatActivity() {