Skip to content

Commit 4dd9105

Browse files
committed
* Add TextViewListener
* Create methods to implement TextViewListener in TextView * Implement new additions in demo app * Add new logo by @mansya to demo app
1 parent 10e39bc commit 4dd9105

File tree

22 files changed

+115
-219
lines changed

22 files changed

+115
-219
lines changed

.idea/caches/build_file_checksums.ser

595 Bytes
Binary file not shown.

.idea/codeStyles/Project.xml

+29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/believe/cht/fadeintextviewdemo/MainActivity.java

+23-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import android.view.View;
66
import android.widget.Button;
77
import android.widget.EditText;
8+
import android.widget.Toast;
9+
10+
import believe.cht.fadeintextview.TextViewListener;
811

912
public class MainActivity extends AppCompatActivity {
1013

@@ -17,10 +20,26 @@ protected void onCreate(Bundle savedInstanceState) {
1720
super.onCreate(savedInstanceState);
1821
setContentView(R.layout.activity_main);
1922

20-
textView = (believe.cht.fadeintextview.TextView) findViewById(R.id.textView);
21-
editText = (EditText) findViewById(R.id.editText);
22-
button = (Button) findViewById(R.id.button);
23-
23+
textView = findViewById(R.id.textView);
24+
editText = findViewById(R.id.editText);
25+
button = findViewById(R.id.button);
26+
27+
textView = findViewById(R.id.textView);
28+
textView.setListener(new TextViewListener() {
29+
@Override
30+
public void onTextStart() {
31+
Toast.makeText(getBaseContext(), "onTextStart() fired!", Toast.LENGTH_SHORT).show();
32+
}
33+
34+
@Override
35+
public void onTextFinish() {
36+
Toast.makeText(getBaseContext(), "onTextFinish() fired!", Toast.LENGTH_SHORT).show();
37+
}
38+
});
39+
40+
editText = findViewById(R.id.editText);
41+
button = findViewById(R.id.button);
42+
2443
editText.setText(getResources().getString(R.string.welcome_message));
2544

2645
button.setOnClickListener(new View.OnClickListener() {

app/src/main/res/drawable-v24/ic_launcher_foreground.xml

-34
This file was deleted.

app/src/main/res/drawable/ic_launcher_background.xml

-170
This file was deleted.

app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml

-5
This file was deleted.

app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml

-5
This file was deleted.
13.5 KB
Loading
Loading
14.5 KB
Loading
Loading
12 KB
Loading
Loading
10.2 KB
Loading
Loading
7.48 KB
Loading
Loading

build.gradle

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ buildscript {
88
}
99
dependencies {
1010
classpath 'com.android.tools.build:gradle:3.0.1'
11-
11+
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
12+
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
1213

1314
// NOTE: Do not place your application dependencies here; they belong
1415
// in the individual module build.gradle files
@@ -19,6 +20,7 @@ allprojects {
1920
repositories {
2021
google()
2122
jcenter()
23+
maven { url 'https://jitpack.io' }
2224
}
2325
}
2426

fade-intextview/build.gradle

+27
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
apply plugin: 'com.android.library'
22

3+
ext {
4+
bintrayRepo = 'FadeInTextView-Android'
5+
bintrayName = 'FadeInTextView-Android'
6+
7+
publishedGroupId = 'believe.cht'
8+
libraryName = 'FadeInTextView'
9+
artifact = 'FadeInTextView'
10+
11+
libraryDescription = 'A custom TextView library to set text with a fade-in typewriter animation'
12+
13+
siteUrl = 'https://github.com/ChahatGupta/FadeInTextView-Android'
14+
gitUrl = 'https://github.com/ChahatGupta/FadeInTextView-Android.git'
15+
16+
libraryVersion = '1.0.0'
17+
18+
developerId = 'ChahatGupta'
19+
developerName = 'Chahat Gupta'
20+
developerEmail = '[email protected]'
21+
22+
licenseName = 'The Apache Software License, Version 2.0'
23+
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
24+
allLicenses = ["Apache-2.0"]
25+
}
26+
327
android {
428
compileSdkVersion 26
529

@@ -32,3 +56,6 @@ dependencies {
3256
androidTestImplementation 'com.android.support.test:runner:1.0.2'
3357
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
3458
}
59+
60+
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
61+
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'

fade-intextview/src/main/java/believe/cht/fadeintextview/TextView.java

+14
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class TextView extends AppCompatTextView {
2424
private Interpolator mInterpolator;
2525
private CharSequence charSequence;
2626
private SpannableString spannableString;
27+
TextViewListener textViewListener;
2728

2829
public TextView(Context context) {
2930
super(context);
@@ -75,6 +76,11 @@ public void setText(CharSequence text, BufferType type) {
7576
}
7677

7778
final int length = spannableString.length();
79+
80+
if (textViewListener != null) {
81+
textViewListener.onTextStart(); // firing onTextStart()
82+
}
83+
7884
for (int i = 0; i < length; i++) {
7985
spannableString.setSpan(new Letter(), i, i + 1, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
8086
}
@@ -112,6 +118,9 @@ protected void onDraw(Canvas canvas) {
112118
ViewCompat.postInvalidateOnAnimation(this);
113119
} else {
114120
isAnimating = false;
121+
if (textViewListener != null) {
122+
textViewListener.onTextFinish(); // firing onTextFinish()
123+
}
115124
}
116125

117126
}
@@ -122,4 +131,9 @@ public boolean isAnimating() {
122131
return isAnimating;
123132
}
124133

134+
// to set listener
135+
public void setListener(TextViewListener textViewListener) {
136+
this.textViewListener = textViewListener;
137+
}
138+
125139
}

0 commit comments

Comments
 (0)