Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5819731

Browse files
committedApr 9, 2022
change app version
1 parent 9c84856 commit 5819731

File tree

6 files changed

+60
-11
lines changed

6 files changed

+60
-11
lines changed
 

‎build.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ buildscript {
33
repositories {
44
google()
55
mavenCentral()
6+
maven { url 'https://jitpack.io' }
7+
68
}
79
dependencies {
810
classpath "com.android.tools.build:gradle:7.0.3"

‎settings.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ dependencyResolutionManagement {
33
repositories {
44
google()
55
mavenCentral()
6+
67
jcenter() // Warning: this repository is going to shut down soon
78
}
89
}

‎showmoretextview/build.gradle

+24-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
plugins {
22
id 'com.android.library'
33
id 'kotlin-android'
4+
id 'maven-publish' // configure that plugin
5+
46
}
57

8+
def versionMajor = 1
9+
def versionMinor = 0
10+
def versionPatch = 0
11+
def appVersion = "${versionMajor}.${versionMinor}.${versionPatch}"
12+
def appVersionCode = versionMajor * 1000 + versionMinor * 100 + versionPatch
13+
614
android {
715
compileSdk 31
816

917
defaultConfig {
1018
minSdk 22
1119
targetSdk 31
12-
versionCode 1
13-
versionName "1.0"
20+
versionCode appVersionCode
21+
versionName appVersion
1422

1523
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1624
consumerProguardFiles "consumer-rules.pro"
@@ -39,4 +47,18 @@ dependencies {
3947
testImplementation 'junit:junit:4.+'
4048
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
4149
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
50+
}
51+
52+
53+
afterEvaluate {
54+
publishing {
55+
publications {
56+
library(MavenPublication) {
57+
from components.release
58+
groupId = 'com.github.sanjaydraws'
59+
artifactId = 'show-more-textview'
60+
version = appVersion
61+
}
62+
}
63+
}
4264
}

‎showmoretextview/src/main/java/com/sanjayprajapat/showmoretextview/ShowMoreTextView.kt

+17-9
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ import com.sanjayprajapat.showmoretextview.enums.TextState
1515
import com.sanjayprajapat.showmoretextview.listener.StateChangeListener
1616
import com.sanjayprajapat.showmoretextview.utils.safeToInt
1717

18+
/**
19+
* @author : Sanjay Prajapat
20+
* Created On: 09-4-2022
21+
* Github:https://github.com/sanjaydraws
22+
* Blog: https://dev.to/sanjayprajapat
23+
* https://sanjayprajapat.hashnode.dev/
24+
***/
1825

1926
class ShowMoreTextView @JvmOverloads constructor(
2027
context: Context,
@@ -35,6 +42,9 @@ class ShowMoreTextView @JvmOverloads constructor(
3542
* this is Original text
3643
* */
3744
private var expendedText:CharSequence =""
45+
/**
46+
*
47+
* */
3848
private var collapsedText:CharSequence =""
3949

4050

@@ -74,11 +84,11 @@ class ShowMoreTextView @JvmOverloads constructor(
7484
private fun setUpListener(){
7585
super.setOnClickListener{
7686
// Toast.makeText(context,"click",Toast.LENGTH_LONG).show()
77-
switchText()
87+
switchTextState()
7888
}
7989
}
8090

81-
private fun switchText(){
91+
private fun switchTextState(){
8292
when(textState) {
8393
TextState.EXPANDED -> doOnCollapse()
8494
TextState.COLLAPSED -> doOnExpand()
@@ -105,17 +115,17 @@ class ShowMoreTextView @JvmOverloads constructor(
105115
* otherwise the action will be performed after the view is next laid out
106116
* */
107117
doOnLayout {
108-
// post{
118+
post{
109119
setUpShowMoreTextView()
110-
// }
120+
}
111121
}
112122
}
113123
private fun setUpShowMoreTextView(){
114124
if(ifNeedToSkipSetup()){
115125
return
116126
}
117127
expendedText = text
118-
val adjustCutCount = getAdjustCutCount(maxLine = showMoreMaxLine, showMoreText)
128+
val adjustCutCount = getAdjustCutCount(maxLine = showMoreMaxLine, showMoreText) // 6
119129
val maxTextIndex = layout.getLineVisibleEnd(showMoreMaxLine?.minus(1).safeToInt())
120130
val originalSubText = expendedText.substring(0, maxTextIndex - 1 - adjustCutCount)
121131

@@ -133,10 +143,10 @@ class ShowMoreTextView @JvmOverloads constructor(
133143
private fun getAdjustCutCount(maxLine:Int?, readMoreText:String?):Int{
134144
val lastLineStartIndex = layout.getLineVisibleEnd(maxLine?.minus(2)?:0) + 1
135145
val lastLineEndIndex = layout.getLineVisibleEnd(maxLine?.minus(1)?:0)
136-
val lastLineText = text.substring(lastLineStartIndex, lastLineEndIndex)
146+
val lastLineText = text.substring(lastLineStartIndex, lastLineEndIndex)//available, but the majority have suffered alteration in
137147

138148
val bounds = Rect()
139-
paint.getTextBounds(lastLineText, 0 , lastLineText.length, bounds)
149+
paint.getTextBounds(lastLineText, 0 , lastLineText.length, bounds)//Rect(1, -22 - 647, 6)
140150
var adjustCutCount = -1
141151
do {
142152
adjustCutCount++
@@ -146,8 +156,6 @@ class ShowMoreTextView @JvmOverloads constructor(
146156
val replacedTextWidth = bounds.width()
147157
}while (replacedTextWidth>width)
148158
return adjustCutCount
149-
150-
return 0
151159
}
152160

153161
public fun addOnStateChangeListener(stateChangeListener: StateChangeListener) {

‎showmoretextview/src/main/java/com/sanjayprajapat/showmoretextview/enums/TextState.kt

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
package com.sanjayprajapat.showmoretextview.enums
22

33

4+
/**
5+
* @author : Sanjay Prajapat
6+
* Created On: 09-4-2022
7+
* Github:https://github.com/sanjaydraws
8+
* Blog: https://dev.to/sanjayprajapat
9+
* https://sanjayprajapat.hashnode.dev/
10+
***/
411

512
enum class TextState{
613
EXPANDED, COLLAPSED

‎showmoretextview/src/main/java/com/sanjayprajapat/showmoretextview/listener/StateChangeListener.kt

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ package com.sanjayprajapat.showmoretextview.listener
22

33
import com.sanjayprajapat.showmoretextview.enums.TextState
44

5+
/**
6+
* @author : Sanjay Prajapat
7+
* Created On: 09-4-2022
8+
* Github:https://github.com/sanjaydraws
9+
* Blog: https://dev.to/sanjayprajapat
10+
* https://sanjayprajapat.hashnode.dev/
11+
***/
12+
13+
514
interface StateChangeListener {
615
fun onStateChange(textState:TextState)
716
}

0 commit comments

Comments
 (0)
Please sign in to comment.