When Threshold is reached, do .......
ollyc2015 opened this issue · 1 comments
First of all, thanks for creating a great library!
I am making a little application where the user has a question and 4 possible answers. Next to a possible answer, there is a little scratchcard type section, where they can scratch away to either reveal a star or nothing at all. I am trying to figure out the logic in adding a points system, based on the users actions. In the application, there is a Viewpager, so if they haven't found the star, no points should register, even if they choose to move on after scratching 1 possible answer and not finding the star.
The point is, that they have to find the star for each question. Finding the star straight away will equal 4 points, if they don't find the star on the first go, the points go down to 2 points, if they don't get it again, it goes down to 1 point and the final scratch will reveal the star but they get 0 points if its the last scratch to be revealed.
I am therefore trying to detect when a user has scratched an deal accordingly but I am having trouble with this.
I have the following:
ScratchoffController controller1 = new ScratchoffController(getActivity())
.setThresholdPercent(0.40d)
.setTouchRadiusDip(getActivity(), 30)
.setFadeOnClear(true)
.setClearOnThresholdReached(true)
.setCompletionCallback(() -> {
})
.attach(current_layout.findViewById(R.id.scratch_view1), current_layout.findViewById(R.id.scratch_view_behind1));
Then I try to use the following logic
if (array3[answerCount].contains("Correct") && controller1.isThresholdReached()) {
current_layout.findViewById(R.id.star1).setVisibility(View.VISIBLE);
Score.increaseScoreByFour();
((TextView) current_layout.findViewById(R.id.tv_current_score)).setText(""+Score.getScore());
}
However controller.isThresholdReached isn't working to detect when the user has scratched, is there another method in the library that will achieve this?
Just realised I can solve with
ScratchoffController controller1 = new ScratchoffController(getActivity())
.setThresholdPercent(0.40d)
.setTouchRadiusDip(getActivity(), 30)
.setFadeOnClear(true)
.setClearOnThresholdReached(true)
.setCompletionCallback(() -> {
if (array3[answerCount].contains("Correct")) {
current_layout.findViewById(R.id.star1).setVisibility(View.VISIBLE);
Score.increaseScoreByFour();
((TextView) current_layout.findViewById(R.id.tv_current_score)).setText("" + Score.getScore());
}
})
.attach(current_layout.findViewById(R.id.scratch_view1), current_layout.findViewById(R.id.scratch_view_behind1));