Java Code Examples for androidx.constraintlayout.widget.ConstraintLayout#setClickable()

The following examples show how to use androidx.constraintlayout.widget.ConstraintLayout#setClickable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LessonA.java    From SchoolQuest with GNU General Public License v3.0 5 votes vote down vote up
public void endLesson() {
    int score = (int) ( ((float) this.score / (float) (numberOfQuestions * 2)) * 100);
    String text = "> The lesson is over! You scored " + score + "% on the task sheet.";
    displayText(text);

    this.score = score / 20;

    final GameActivity gameActivity = GameActivity.getInstance();
    setUpTextBoxArrowAnimation(
            (ImageView) gameActivity.findViewById(R.id.lesson_a_textbox_box_arrow));

    final ConstraintLayout lessonA = gameActivity.findViewById(R.id.lesson_a);
    final GameView gameView = gameActivity.findViewById(R.id.game_surface);

    lessonA.setAlpha(0.5f);
    gameView.setAlpha(0.5f);

    final ConstraintLayout lessonATextbox = gameActivity.findViewById(R.id.lesson_a_textbox);
    final ImageView lessonATextboxArrow =
            gameActivity.findViewById(R.id.lesson_a_textbox_box_arrow);
    lessonATextboxArrow.setVisibility(View.VISIBLE);

    lessonATextbox.setClickable(true);
    lessonATextbox.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            lessonATextboxArrow.clearAnimation();
            lessonATextboxArrow.setVisibility(View.INVISIBLE);
            lessonA.setAlpha(1f);
            gameView.setAlpha(1f);
            lessonATextbox.setClickable(false);
            lessonA.setVisibility(View.GONE);
            lessonATextbox.setVisibility(View.GONE);
            gameActivity.showButtons();
            resetBars();
            LessonA.super.endLesson();
        }
    });
}
 
Example 2
Source File: LessonC.java    From SchoolQuest with GNU General Public License v3.0 4 votes vote down vote up
public void endLesson() {
    int score = (int) ( ((float) this.score / (float) (numberOfQuestions * 2)) * 100);
    String text = "> The lesson is over! You scored " + score + "% on the course.";
    final ConstraintLayout textBox =
            GameActivity.getInstance().findViewById(R.id.lesson_c_textbox_box);
    textBox.setVisibility(View.VISIBLE);
    displayText(text);

    this.score = score / 20;

    final GameActivity gameActivity = GameActivity.getInstance();
    setUpTextBoxArrowAnimation(
            (ImageView) gameActivity.findViewById(R.id.lesson_c_textbox_box_arrow));

    final ConstraintLayout lessonC = gameActivity.findViewById(R.id.lesson_c);
    final GameView gameView = gameActivity.findViewById(R.id.game_surface);

    lessonC.setAlpha(0.5f);
    gameView.setAlpha(0.5f);

    final ConstraintLayout lessonCTextbox = gameActivity.findViewById(R.id.lesson_c_textbox);
    final ImageView lessonCTextboxArrow =
            gameActivity.findViewById(R.id.lesson_c_textbox_box_arrow);
    lessonC.setVisibility(View.VISIBLE);
    lessonCTextboxArrow.setVisibility(View.VISIBLE);

    lessonCTextbox.setClickable(true);
    lessonCTextbox.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            textBox.setVisibility(View.GONE);
            lessonCTextboxArrow.clearAnimation();
            lessonCTextboxArrow.setVisibility(View.INVISIBLE);
            lessonC.setAlpha(1f);
            gameView.setAlpha(1f);
            lessonCTextbox.setClickable(false);
            lessonC.setVisibility(View.GONE);
            lessonCTextbox.setVisibility(View.GONE);
            gameActivity.showButtons();
            GAME.getPlayer().setPoint(PE_END_X, PE_END_Y);
            GAME.getPlayer().changeTile("default");
            GAME.getPlayer().rotate(OBJECT_DIRECTION_DOWN);
            GAME.loadMap(MAP_SCHOOL_YARD_ID);
            GAME.getPlayer().setSpeed(PLAYER_SPEED);
            resetBars();
            LessonC.super.endLesson();
        }
    });
}
 
Example 3
Source File: LessonB.java    From SchoolQuest with GNU General Public License v3.0 4 votes vote down vote up
public void endLesson() {
    int score = (int) (((float) this.score / (float) (numberOfQuestions * 2)) * 100);
    String text = "> The lesson is over! You scored " + score + "% on the task sheet.";
    displayText(text);

    this.score = score / 20;

    final GameActivity gameActivity = GameActivity.getInstance();
    setUpTextBoxArrowAnimation(
            (ImageView) gameActivity.findViewById(R.id.lesson_b_textbox_box_arrow));

    final ConstraintLayout lessonB = gameActivity.findViewById(R.id.lesson_b);
    final GameView gameView = gameActivity.findViewById(R.id.game_surface);
    final ImageView lessonBCraftBarSlider =
            gameActivity.findViewById(R.id.lesson_b_craft_bar_slider);

    lessonB.setAlpha(0.5f);
    gameView.setAlpha(0.5f);
    lessonBCraftBarSlider.setVisibility(View.GONE);

    final ConstraintLayout lessonBTextbox = gameActivity.findViewById(R.id.lesson_b_textbox);
    final ImageView lessonBTextboxArrow =
            gameActivity.findViewById(R.id.lesson_b_textbox_box_arrow);
    lessonBTextboxArrow.setVisibility(View.VISIBLE);

    lessonBTextbox.setClickable(true);
    lessonBTextbox.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            lessonBTextboxArrow.clearAnimation();
            lessonBTextboxArrow.setVisibility(View.INVISIBLE);
            lessonB.setAlpha(1f);
            gameView.setAlpha(1f);
            lessonBCraftBarSlider.setVisibility(View.VISIBLE);
            lessonBTextbox.setClickable(false);
            lessonB.setVisibility(View.GONE);
            lessonBTextbox.setVisibility(View.GONE);
            gameActivity.showButtons();
            resetBars();
            LessonB.super.endLesson();
        }
    });
}
 
Example 4
Source File: Exam.java    From SchoolQuest with GNU General Public License v3.0 4 votes vote down vote up
public void endLesson() {
    int score = (int) ( ((float) this.score / (float) (numberOfQuestions * 2)) * 100);
    String feedback;
    if (score >= 90) { feedback = "really well!!"; }
    else if (score >= 70) { feedback = "pretty well!"; }
    else if (score >= 40) { feedback = "ok."; }
    else { feedback = "horribly..."; }
    String text = "The exam is over! You feel it went " + feedback;
    displayText(text);

    this.score = score / 10;

    final int finalScore = this.score;

    final GameActivity gameActivity = GameActivity.getInstance();
    setUpTextBoxArrowAnimation(
            (ImageView) gameActivity.findViewById(R.id.lesson_a_textbox_box_arrow));

    final ConstraintLayout lessonA = gameActivity.findViewById(R.id.lesson_a);
    final GameView gameView = gameActivity.findViewById(R.id.game_surface);

    lessonA.setAlpha(0.5f);
    gameView.setAlpha(0.5f);

    final ConstraintLayout lessonATextbox = gameActivity.findViewById(R.id.lesson_a_textbox);
    final ImageView lessonATextboxArrow =
            gameActivity.findViewById(R.id.lesson_a_textbox_box_arrow);
    lessonATextboxArrow.setVisibility(View.VISIBLE);

    lessonATextbox.setClickable(true);
    lessonATextbox.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            lessonATextboxArrow.clearAnimation();
            lessonATextboxArrow.setVisibility(View.INVISIBLE);
            lessonA.setAlpha(1f);
            gameView.setAlpha(1f);
            lessonATextbox.setClickable(false);
            lessonA.setVisibility(View.GONE);
            lessonATextbox.setVisibility(View.GONE);
            gameActivity.showButtons();
            GAME.setMiniGame(null);
            GAME.increaseExamScore(id, finalScore);
            if (id == ICT_INDEX) {
                GAME.increasePoints(EXAM_INCREASE, id, finalScore);
                GAME.setEventBGM(R.raw._music_results);
                GAME.reloadMap();
                GameActivity.getInstance().runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        GameActivity.getInstance().displayEndScreen();
                    }
                });
            }
            else {
                GAME.addPointChange(EXAM_INCREASE, id, finalScore);
                GAME.goHome();
                GameActivity.getInstance().runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        GameActivity.getInstance().refreshHUD();
                    }
                });
            }
        }
    });
}