Skip to content

Commit 07c1da5

Browse files
Reveal on 50%
1 parent 53570ac commit 07c1da5

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

app/src/main/java/com/anupkumarpanwar/scratchview/MainActivity.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
import android.support.annotation.RequiresApi;
55
import android.support.v7.app.AppCompatActivity;
66
import android.os.Bundle;
7+
import android.util.Log;
78
import android.widget.Toast;
89

910
public class MainActivity extends AppCompatActivity {
1011

1112
ScratchView scratchView;
12-
boolean revealed = false;
1313

1414
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
1515
@Override
@@ -21,14 +21,13 @@ protected void onCreate(Bundle savedInstanceState) {
2121
scratchView.setRevealListener(new ScratchView.IRevealListener() {
2222
@Override
2323
public void onRevealed(ScratchView scratchView) {
24-
Toast.makeText(getApplicationContext(), "Image reveled", Toast.LENGTH_LONG).show();;
24+
Toast.makeText(getApplicationContext(), "Reveled", Toast.LENGTH_LONG).show();;
2525
}
2626

2727
@Override
2828
public void onRevealPercentChangedListener(ScratchView scratchView, float percent) {
29-
if (percent>=0.5 && ! revealed) {
30-
Toast.makeText(getApplicationContext(), "Revealed", Toast.LENGTH_LONG).show();;
31-
revealed = true;
29+
if (percent>=0.5) {
30+
Log.d("Reveal Percentage", "onRevealPercentChangedListener: " + String.valueOf(percent));
3231
}
3332
}
3433
});

scratchview/src/main/java/com/anupkumarpanwar/scratchview/ScratchView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ public void setRevealListener(IRevealListener listener) {
343343
}
344344

345345
public boolean isRevealed() {
346-
return mRevealPercent == 1;
346+
return mRevealPercent >= 0.50;
347347
}
348348

349349
private void checkRevealed() {

0 commit comments

Comments
 (0)