Skip to content

Commit

Permalink
add callback demo
Browse files Browse the repository at this point in the history
  • Loading branch information
zijing07 committed Apr 19, 2018
1 parent ad05c75 commit 42eb464
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 5 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
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.

1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ android {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
Expand Down
20 changes: 20 additions & 0 deletions app/src/main/java/lib/mozidev/me/extextview/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.graphics.Color;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.view.Gravity;
import android.view.View;
Expand Down Expand Up @@ -120,6 +121,25 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
}
});

findViewById(R.id.button5).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
strikeThroughPainting
.cutTextEdge(cutEdge)
.color(strokeColor)
.strokeWidth(strokeWidth)
.mode(StrikeThroughPainting.MODE_DEFAULT)
.callback(new StrikeThroughPainting.StrikeThroughPaintingCallback() {
@Override
public void onStrikeThroughEnd() {
Snackbar.make(findViewById(R.id.container),
"Callback after animation", Snackbar.LENGTH_LONG).show();
}
})
.strikeThrough();
}
});

findViewById(R.id.button4).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down
15 changes: 13 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/container"
tools:context=".MainActivity">

<lib.mozidev.me.extendedtextview.ExtendedTextView
Expand Down Expand Up @@ -108,15 +109,14 @@
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:text="clear effect"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/switch4"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="@id/button5"
app:layout_constraintTop_toBottomOf="@id/button3" />

<Switch
Expand All @@ -131,4 +131,15 @@
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/button4" />

<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:text="Animation Callback"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="@id/button4"
app:layout_constraintTop_toBottomOf="@+id/button4" />

</android.support.constraint.ConstraintLayout>
Binary file modified demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,11 @@ public StrikeThroughPainting totalTime(long totalTime) {
/**
* Set callback called when the strike through drawing animation ends
* @param callback StrikeThroughPaintingCallback
* @return this
*/
public void callback(@NonNull StrikeThroughPaintingCallback callback) {
strikeThroughPaintingCallback = callback;
public StrikeThroughPainting callback(@NonNull StrikeThroughPaintingCallback callback) {
this.strikeThroughPaintingCallback = callback;
return this;
}

/**
Expand Down

0 comments on commit 42eb464

Please sign in to comment.