Example usage for android.app Dialog getClass

List of usage examples for android.app Dialog getClass

Introduction

In this page you can find the example usage for android.app Dialog getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.ezeeideas.wordjam.BaseGameActivity.java

/**
 * One of the options in the GameDialog instance was selected
 *//*from ww w . ja  va 2 s  . c o  m*/
public void onDialogOptionSelected(Dialog dialog, int option) {
    if (dialog.getClass() == GamePauseDialog.class) {
        if (option == GameDialog.GAME_DIALOG_ACTION_POSITIVE_1) {
            //Resume the game
            onResumeGameSelected();
        }
    } else if (dialog.getClass() == LevelPointSummaryDialog.class) {
        if (option == GameDialog.GAME_DIALOG_ACTION_POSITIVE_1) {
            setResult(Constants.ACTION_GO_TO_LEVEL_HOME);
            this.finish();
        }
    } else if (dialog.getClass() == PracticePointSummaryDialog.class) {
        if (option == GameDialog.GAME_DIALOG_ACTION_POSITIVE_1) {
            Analytics.trackEvent(this, Analytics.getAnalyticsCategoryFromGame(mGameType),
                    Analytics.ANALYTICS_ACTION_BUTTON_PRESS,
                    Analytics.ANALYTICS_LABEL_GAME_SUMMARY_SHARE_BUTTON, null);

            String storyTitle = String.format(
                    getResources().getString(R.string.practice_point_summary_share_story_title), mGameNumber,
                    GameUtils.getGameNameFromGameType(mGameType, this));
            String storyCaption = getResources().getString(R.string.practice_point_summary_share_story_caption);
            String storyDescription = String.format(
                    getResources().getString(R.string.practice_point_summary_share_story_description),
                    GameUtils.getGameNameFromGameType(mGameType, this), mGameNumber, mPracticePointsEarned,
                    mPracticeTimeSpent / 1000, mPracticeHintsUsed);

        } else {
            this.finish();
        }
        /*
         * Dont' show ads for now
         */
        /*
           if (canShowInterstitialAd())
           {
              showInterstitialAd(AD_DISMISS_ACTION_DISMISS_ACTIVITY);
           }
           else
           {
              this.finish();
           }
         */
        //this.finish();
    } else if (dialog.getClass() == GameShareDialog.class) {
        if (option == GameDialog.GAME_DIALOG_ACTION_POSITIVE_1) //Share Game
        {
            Analytics.trackEvent(this, Analytics.getAnalyticsCategoryFromGame(mGameType),
                    Analytics.ANALYTICS_ACTION_BUTTON_PRESS, Analytics.ANALYTICS_LABEL_SHARE_GAME_BUTTON, null);
        } else if (option == GameDialog.GAME_DIALOG_ACTION_POSITIVE_2) //Invite Friends
        {
            Analytics.trackEvent(this, Analytics.getAnalyticsCategoryFromGame(mGameType),
                    Analytics.ANALYTICS_ACTION_BUTTON_PRESS, Analytics.ANALYTICS_LABEL_INVITE_FRIENDS_BUTTON,
                    null);

            String storyTitle = getResources().getString(R.string.facebook_share_story_title);
            String storyCaption = getResources().getString(R.string.facebook_share_story_caption);
            String storyDescription = getResources().getString(R.string.facebook_share_story_description);
        }
    } else if (dialog.getClass() == GameGiveUpDialog.class) {
        if (option == GameDialog.GAME_DIALOG_ACTION_POSITIVE_1) {
            Analytics.trackEvent(this, Analytics.getAnalyticsCategoryFromGame(mGameType),
                    Analytics.ANALYTICS_ACTION_BUTTON_PRESS, Analytics.ANALYTICS_LABEL_REVEAL_GAME_BUTTON,
                    null);

            stopTimer();

            doHandleGivenUp();

            mGamePoints += GameUtils.getPointChart(mPlayType, mIsPlay, mLevel,
                    mPracticeType)[GameUtils.GAME_POINTS_ON_GIVING_UP][mGameType];
            mLevelPoints += GameUtils.getPointChart(mPlayType, mIsPlay, mLevel,
                    mPracticeType)[GameUtils.GAME_POINTS_ON_GIVING_UP][mGameType];
            mPracticePointsEarned += GameUtils.getPointChart(mPlayType, mIsPlay, mLevel,
                    mPracticeType)[GameUtils.GAME_POINTS_ON_GIVING_UP][mGameType];

            mGameState = Constants.GAME_STATE_GIVEN_UP;

            refreshViews();
        } else if (option == GameDialog.GAME_DIALOG_ACTION_NEGATIVE_1) {
            //cancel giving up.  Do nothing
            Analytics.trackEvent(this, Analytics.getAnalyticsCategoryFromGame(mGameType),
                    Analytics.ANALYTICS_ACTION_BUTTON_PRESS, Analytics.ANALYTICS_LABEL_REVEAL_CANCELLED, null);
        } else if (option == GameDialog.GAME_DIALOG_ACTION_POSITIVE_2) {
            Analytics.trackEvent(this, Analytics.getAnalyticsCategoryFromGame(mGameType),
                    Analytics.ANALYTICS_ACTION_BUTTON_PRESS, Analytics.ANALYTICS_LABEL_REVEAL_SHARE_BUTTON,
                    null);
        }
    } else if (dialog.getClass() == GameCompletedDialog.class) {
        if (option == GameDialog.GAME_DIALOG_ACTION_POSITIVE_1) {

        } else {
            handleGameCompleted();
        }
    } else if (dialog.getClass() == GameFailedDialog.class) {
        if (option == GameDialog.GAME_DIALOG_ACTION_POSITIVE_1) {
            doHandleGivenUp();

            //Update values
            mGamePoints += GameUtils.getPointChart(mPlayType, mIsPlay, mLevel,
                    mPracticeType)[GameUtils.GAME_POINTS_ON_LOSING_GAME][mGameType];
            mLevelPoints += GameUtils.getPointChart(mPlayType, mIsPlay, mLevel,
                    mPracticeType)[GameUtils.GAME_POINTS_ON_LOSING_GAME][mGameType];
            mPracticePointsEarned += GameUtils.getPointChart(mPlayType, mIsPlay, mLevel,
                    mPracticeType)[GameUtils.GAME_POINTS_ON_LOSING_GAME][mGameType];

            refreshViews();
        }
    } else if (dialog.getClass() == GameHintsExhaustedDialog.class) {
        if (option == GameDialog.GAME_DIALOG_ACTION_POSITIVE_1) {
            Analytics.trackEvent(this, Analytics.getAnalyticsCategoryFromGame(mGameType),
                    Analytics.ANALYTICS_ACTION_BUTTON_PRESS, Analytics.ANALYTICS_LABEL_HINT_SHARE_BUTTON, null);

        }
    } else if (dialog.getClass() == GameHintConfirmationDialog.class) {
        if (option == GameDialog.GAME_DIALOG_ACTION_POSITIVE_1) {
            consumeHint();

            refreshViews();
        } else if (option == GameDialog.GAME_DIALOG_ACTION_NEGATIVE_1) {
            //status quo (don't use hint)
        }
    }

}