Skip to content

Commit

Permalink
[Update] Code Optimization
Browse files Browse the repository at this point in the history
[Update] Gradle Version
[Update] Target SDK Version
[Update] Code Documentation
[Update] Clean Code
  • Loading branch information
rajatkumarandroid committed Mar 4, 2022
1 parent 8e198f6 commit 97c1fbb
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .idea/gradle.xml

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

2 changes: 1 addition & 1 deletion .idea/misc.xml

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

13 changes: 0 additions & 13 deletions .idea/runConfigurations.xml

This file was deleted.

12 changes: 6 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ plugins {
}

android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
compileSdk 31
buildToolsVersion '31.0.0'

defaultConfig {
applicationId "in.sarangal.spannabletextview"
minSdkVersion 15
targetSdkVersion 30
targetSdk 31
versionCode 1
versionName "1.0"

Expand Down Expand Up @@ -49,12 +49,12 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation "androidx.core:core-ktx:1.5.0"
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation "androidx.core:core-ktx:1.7.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

/** Spantastic Library */
implementation project (":spantastic")
implementation project(":spantastic")
}

repositories {
Expand Down
8 changes: 6 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="AllowBackup">
<activity android:name=".MainActivity">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".KotlinActivity">
<activity
android:name=".KotlinActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class KotlinActivity : AppCompatActivity() {

/* Show Underline and make Text BOLD for Multiple words */
sentence = "Spannable with underline and bold for multiple words."
var strings: ArrayList<String> = ArrayList()
val strings: ArrayList<String> = ArrayList()
strings.add("spannable")
strings.add("underline")
strings.add("bold")
Expand All @@ -43,7 +43,7 @@ class KotlinActivity : AppCompatActivity() {
/* Set Click on Multiple Words with Bold Style */
sentence =
"Spannable with click, color, underline and bold for multiple words."
strings = ArrayList()
strings.clear()
strings.add("click")
strings.add("color")
strings.add("underline")
Expand Down Expand Up @@ -153,7 +153,7 @@ class KotlinActivity : AppCompatActivity() {
/* Developed By Sarangal */
sentence = "Developed with ❤ by Sarangal"
val tvCredit = findViewById<TextView>(R.id.tv_credit)
val creditModelList: MutableList<SpanModel> = ArrayList<SpanModel>()
val creditModelList = ArrayList<SpanModel>()
creditModelList.add(
SpanModel(
"", Color.parseColor("#FFFF2F2F"),
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@
android:layout_alignParentBottom="true"
android:id="@+id/tv_credit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content" />

</RelativeLayout>
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
buildscript {
ext.kotlin_version = '1.5.0'
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
//noinspection DifferentKotlinGradleVersion
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Apr 05 23:44:04 IST 2021
#Fri Mar 04 23:29:58 IST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
8 changes: 3 additions & 5 deletions local.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file should *NOT* be checked into Version Control Systems,
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
sdk.dir=D\:\\AndroidStudio\\AndroidSDK
#Fri Mar 04 23:26:46 IST 2022
sdk.dir=/Users/relinns/Library/Android/sdk
13 changes: 6 additions & 7 deletions spantastic/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ plugins {
}

android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
compileSdk 31
buildToolsVersion '31.0.0'

defaultConfig {
minSdkVersion 15
targetSdkVersion 30
versionCode 10
versionName "2.1.0"
targetSdk 31
versionCode 11
versionName "2.1.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
Expand Down Expand Up @@ -43,8 +43,7 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation "androidx.core:core-ktx:1.5.0"
implementation "androidx.core:core-ktx:1.7.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
repositories {
Expand Down
28 changes: 6 additions & 22 deletions spantastic/src/main/java/in/sarangal/lib/spantastic/Spantastic.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package `in`.sarangal.lib.spantastic

import android.content.Context
import android.graphics.Color
import android.graphics.Typeface
import android.text.SpannableString
Expand Down Expand Up @@ -41,11 +40,11 @@ class Spantastic private constructor(builder: Builder) {
* */
private fun setSpannable() {

if (fullString.trim().isEmpty()) {
if (fullString.isBlank()) {
return
}

if (spanModelList == null || spanModelList.isEmpty()) {
if (spanModelList.isNullOrEmpty()) {
return
}

Expand Down Expand Up @@ -88,7 +87,8 @@ class Spantastic private constructor(builder: Builder) {
try {
textPaint.color = spanModel.colorId ?: colorID
?: textView.currentTextColor
} catch (ignored: Exception) {
} catch (e: Exception) {
e.printStackTrace()
}

/* Set Span Typeface for Styling */
Expand All @@ -107,7 +107,8 @@ class Spantastic private constructor(builder: Builder) {
spannableString.setSpan(clickSpan, start, end, 0)
}

} catch (ignored: Exception) {
} catch (e: Exception) {
e.printStackTrace()
}
}

Expand All @@ -126,23 +127,6 @@ class Spantastic private constructor(builder: Builder) {
fun onSpanClick(spanString: String?, vararg `object`: Any?)
}

/**
* Builder Class for Handling Spannable Operations
*
* Method Params:
*
* @param mContext Instance or Reference
* @param mTextView TextView on which spannable text will be applied
* @param mFullString Complete string value from which span(s) will be found.
*
* Deprecated: Use Builder class
*/
@Deprecated(message = "Please Use 'Builder' class")
internal class SpantasticBuilder(
private val mContext: Context, private val mTextView: TextView,
private val mFullString: String
) : Builder(mTextView, mFullString)

/**
* Builder Class for Handling Spannable Operations
*
Expand Down

0 comments on commit 97c1fbb

Please sign in to comment.