From 6dc20c100224738f187ec38ca6ef75512a67ff84 Mon Sep 17 00:00:00 2001 From: gonojuarez Date: Wed, 22 Feb 2023 14:40:46 -0300 Subject: [PATCH] GlideAttatcher changes --- app/build.gradle | 6 ++-- app/pictogramslibrary/build.gradle | 8 ++--- .../pictogramslibrary/view/PictoView.java | 31 +++++++++++-------- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 5 files changed, 27 insertions(+), 22 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index b7b8431..3fcc513 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -25,12 +25,12 @@ android { dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) - implementation 'androidx.appcompat:appcompat:1.5.1' + implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation project(path: ':app:pictogramslibrary') testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.4' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' } diff --git a/app/pictogramslibrary/build.gradle b/app/pictogramslibrary/build.gradle index 977ecb8..8ec9e6d 100644 --- a/app/pictogramslibrary/build.gradle +++ b/app/pictogramslibrary/build.gradle @@ -28,14 +28,14 @@ android { dependencies { - implementation 'androidx.appcompat:appcompat:1.5.1' + implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation 'com.google.android.material:material:1.7.0' + implementation 'com.google.android.material:material:1.8.0' implementation 'com.github.bumptech.glide:glide:4.14.2' annotationProcessor 'com.github.bumptech.glide:compiler:4.14.2' testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.4' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' implementation platform('com.google.firebase:firebase-bom:30.5.0') // Add the dependency for the Cloud Storage library diff --git a/app/pictogramslibrary/src/main/java/com/stonefacesoft/pictogramslibrary/view/PictoView.java b/app/pictogramslibrary/src/main/java/com/stonefacesoft/pictogramslibrary/view/PictoView.java index a8134f4..7fbcc78 100644 --- a/app/pictogramslibrary/src/main/java/com/stonefacesoft/pictogramslibrary/view/PictoView.java +++ b/app/pictogramslibrary/src/main/java/com/stonefacesoft/pictogramslibrary/view/PictoView.java @@ -12,6 +12,7 @@ import com.stonefacesoft.pictogramslibrary.R; import com.stonefacesoft.pictogramslibrary.utils.GlideAttatcher; import com.stonefacesoft.pictogramslibrary.utils.MemoryUtils; +import com.stonefacesoft.pictogramslibrary.utils.ValidateContext; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -169,15 +170,17 @@ protected void setData(){ this.setCustom_Texto(pictogramsLibraryPictogram.getObjectName()); this.icon.setScaleType(ImageView.ScaleType.FIT_CENTER); cargarColor(pictogramsLibraryPictogram.getType()); - if(pictogramsLibraryPictogram.getEditedPictogram().isEmpty()){ - if(!pictogramsLibraryPictogram.getPictogram().startsWith("https://")){ - Drawable drawable = findResource(pictogramsLibraryPictogram.getPictogram()); - glideAttatcher.setWidth(IconWidth).setHeight(IconHeight).useDiskCacheStrategy().loadDrawable(drawable,this.icon); + if(ValidateContext.isValidContext(mContext)){ + if(pictogramsLibraryPictogram.getEditedPictogram().isEmpty()){ + if(!pictogramsLibraryPictogram.getPictogram().startsWith("https://")){ + Drawable drawable = findResource(pictogramsLibraryPictogram.getPictogram()); + glideAttatcher.setWidth(IconWidth).setHeight(IconHeight).useDiskCacheStrategy().loadDrawable(drawable,this.icon); + }else{ + glideAttatcher.useDiskCacheStrategy().loadDrawable(Uri.parse(pictogramsLibraryPictogram.getPictogram()),this.icon); + } }else{ - glideAttatcher.useDiskCacheStrategy().loadDrawable(Uri.parse(pictogramsLibraryPictogram.getPictogram()),this.icon); + selectIcon(pictogramsLibraryPictogram,this.icon,glideAttatcher); } - }else{ - selectIcon(pictogramsLibraryPictogram,this.icon,glideAttatcher); } } @@ -192,13 +195,15 @@ public void selectIcon(){ try{ String path = pictogramsLibraryPictogram.getEditedPictogram(); File picto=new File(path); - if(picto.exists()) - glideAttatcher.useDiskCacheStrategy().loadDrawable(picto,this.icon); - else - glideAttatcher.useDiskCacheStrategy().loadDrawable(Uri.parse(pictogramsLibraryPictogram.getUrl()),this.icon); + if(ValidateContext.isValidContext(mContext)) { + if (picto.exists()) + glideAttatcher.useDiskCacheStrategy().loadDrawable(picto, this.icon); + else + glideAttatcher.useDiskCacheStrategy().loadDrawable(Uri.parse(pictogramsLibraryPictogram.getUrl()), this.icon); + } }catch (Exception ex){ - - glideAttatcher.useDiskCacheStrategy().loadDrawable(Uri.parse(pictogramsLibraryPictogram.getUrl()),this.icon); + if(ValidateContext.isValidContext(mContext)) + glideAttatcher.useDiskCacheStrategy().loadDrawable(Uri.parse(pictogramsLibraryPictogram.getUrl()),this.icon); } } diff --git a/build.gradle b/build.gradle index db63603..9a73777 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.2.2' + classpath 'com.android.tools.build:gradle:7.4.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 78a4505..ceeccdd 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip