Skip to content

Commit

Permalink
post { } to views so that they are always ready
Browse files Browse the repository at this point in the history
  • Loading branch information
asos-tomlonghurst committed Jan 29, 2019
1 parent bed4613 commit e15f6d6
Show file tree
Hide file tree
Showing 13 changed files with 234 additions and 135 deletions.
32 changes: 4 additions & 28 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/build.gradle
Expand Up @@ -8,7 +8,7 @@ apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.tomlonghurst.expandablehinttextexample"
applicationId "com.tomlonghurst.expandablehinttexttest"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tomlonghurst.expandablehinttext">
package="com.tomlonghurst.expandablehinttexttest">

<application
android:allowBackup="true"
Expand All @@ -9,7 +9,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name="com.tomlonghurst.expandablehinttextexample.MainActivity">
<activity android:name="com.tomlonghurst.expandablehinttexttest.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

Expand Down
@@ -1,8 +1,7 @@
package com.tomlonghurst.expandablehinttextexample
package com.tomlonghurst.expandablehinttexttest

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.tomlonghurst.expandablehinttext.R

class MainActivity : AppCompatActivity() {

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Expand Up @@ -5,7 +5,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.tomlonghurst.expandablehinttextexample.MainActivity"
tools:context="com.tomlonghurst.expandablehinttexttest.MainActivity"
android:background="@color/colorPrimary">

<LinearLayout
Expand All @@ -20,6 +20,7 @@
<com.tomlonghurst.expandablehinttext.ExpandableHintText
android:layout_width="300dp"
android:layout_height="wrap_content"
android:id="@+id/text1"
app:imageColor="@color/colorPrimary"
app:image="@drawable/ic_baseline_sentiment_very_satisfied_24px"
android:hint="First Name"
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
@@ -1,13 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.11'
ext.kotlin_version = '1.3.20'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
9 changes: 7 additions & 2 deletions expandablehinttext/build.gradle
Expand Up @@ -13,8 +13,8 @@ android {
defaultConfig {
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
versionCode 2
versionName "1.02"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Expand All @@ -33,6 +33,11 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'androidx.appcompat:appcompat:1.0.2'

implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core', version: '1.1.1'
implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-android', version: '1.1.1'


testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
Expand Down
Expand Up @@ -10,16 +10,16 @@ class ExpandableEditText : EditText {
constructor(context: Context?) : super(context)
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
private var onBackPressed: (() -> Unit)? = null
private var onBackPressed: Runnable? = null

fun setOnBackPressListener(onBackPressed: () -> Unit) {
fun setOnBackPressListener(onBackPressed: Runnable?) {
this.onBackPressed = onBackPressed
}

override fun onKeyPreIme(keyCode: Int, event: KeyEvent?): Boolean {
if (event?.keyCode == KeyEvent.KEYCODE_BACK) {
this.clearFocus()
onBackPressed?.invoke()
onBackPressed?.run()
}
return super.onKeyPreIme(keyCode, event)
}
Expand Down

0 comments on commit e15f6d6

Please sign in to comment.