Skip to content

Commit

Permalink
Fixed set background null object reference issue
Browse files Browse the repository at this point in the history
  • Loading branch information
AliAzaz committed Jan 14, 2020
1 parent 059a5b5 commit 56737fa
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ android {
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0.0"
versionName "1.0.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
Expand All @@ -35,6 +35,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
Expand Down
2 changes: 1 addition & 1 deletion validatorcrawler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0.0"
versionName "1.0.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.validatorcrawler.aliazaz.other
import android.graphics.drawable.Drawable

internal data class ErrorClass(
var activityName: String,
var drawable: Drawable? = null,
var padding: PaddingClass = PaddingClass(),
var prvcolor: Int = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.graphics.Color
import androidx.core.content.ContextCompat
import androidx.core.view.ViewCompat
import android.view.View
import android.widget.CheckBox
import android.widget.EditText
import android.widget.Spinner
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.core.view.ViewCompat
import com.validatorcrawler.aliazaz.R

internal object ValidatorError {
Expand All @@ -24,6 +24,7 @@ internal object ValidatorError {
when (error) {
null -> {
error = ErrorClass(
context::class.java.name,
viewCom.background,
padding = PaddingClass(
viewCom.paddingTop,
Expand All @@ -50,7 +51,7 @@ internal object ValidatorError {
fun clearError(activity: Activity = Activity()) {

when {
error != null -> {
error != null && error!!.activityName == activity::class.java.name -> {
val view = activity.findViewById<View>(error!!.id)
ViewCompat.setBackground(view, error!!.drawable)
view.setPadding(
Expand Down Expand Up @@ -79,6 +80,7 @@ internal object ValidatorError {

error = null
}
error != null && error!!.activityName != activity::class.java.name -> error = null
}

}
Expand Down

0 comments on commit 56737fa

Please sign in to comment.