Back to project page DroidChineseCheckers.
The source code is released under:
Apache License
If you think the Android project DroidChineseCheckers listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.whiterabbit.checkers.ui; /*from w ww .j a v a 2 s .c o m*/ import android.app.Activity; import android.app.AlertDialog; import android.content.ActivityNotFoundException; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; import com.bugsense.trace.BugSenseHandler; import com.google.analytics.tracking.android.EasyTracker; import com.immersion.uhl.Launcher; import com.whiterabbit.checkers.PreferencesStore; import com.whiterabbit.checkers.R; import com.whiterabbit.checkers.util.Utils; public class CheckersStallActivity extends Activity{ // =========================================================== // Constants // =========================================================== String mTitle; String mMessage; String mBoardName; int mMode; private Button mTellAFriendButton; private Button mBackButton; private Button mPlayAgainButton; private Launcher mHapticsLauncher; private Long mRemaining; private Long mSeconds; private String mAchievement = ""; private final int POST_SCORE = 0; @Override protected void onCreate(Bundle pSavedInstanceState) { Bundle extras = getIntent().getExtras(); if(extras != null){ mTitle = extras.getString(CheckersGameActivity.TITLE); mMessage= extras.getString(CheckersGameActivity.MESSAGE); mMode = extras.getInt(CheckersGameActivity.MODE); mBoardName = extras.getString(CheckersGameActivity.BOARD); mRemaining = extras.getLong(CheckersGameActivity.REMAINING_BALLS, 0); mSeconds = extras.getLong(CheckersGameActivity.SECONDS, 0); mAchievement = extras.getString(CheckersGameActivity.ACHIEVEMENT); } setContentView(R.layout.result_layout); mHapticsLauncher = new Launcher(this); setupButtons(); showVoteMeDialog(); setupMessage(mTitle, mMessage); BugSenseHandler.initAndStartSession(this, getString(R.string.bugsensekey)); super.onCreate(pSavedInstanceState); } private void setupMessage(String title, String message){ TextView titleView = (TextView) findViewById(R.id.result_title); titleView.setText(title); TextView messageView = (TextView) findViewById(R.id.result_message); messageView.setText(message); } @Override protected void onStart() { super.onStart(); // Autogenerated EasyTracker.getInstance().activityStart(this); } @Override protected void onStop() { super.onStop(); // Autogenerated EasyTracker.getInstance().activityStop(this); // Add this method. } private void setupButtons(){ mTellAFriendButton = (Button) findViewById(R.id.result_btn_share_with_a_friend); mTellAFriendButton.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { Utils.playButtonPressed(mHapticsLauncher, CheckersStallActivity.this); Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getString(R.string.check_game)); shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, getString(R.string.try_pegdroid)); startActivity(Intent.createChooser(shareIntent, "Share pegdroid")); } }); /* mShareResultOnSocialButton = (Button) findViewById(R.id.result_btn_share_social); mShareResultOnSocialButton.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { Utils.playButtonPressed(mHapticsLauncher, CheckersStallActivity.this); startActivityForResult(new Intent(CheckersStallActivity.this, PostScoreOverlayActivity.class), POST_SCORE); } }); mShareResultOnSocialButton.setVisibility(View.INVISIBLE);*/ mBackButton = (Button) findViewById(R.id.result_btn_return_to_list); mBackButton.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { Utils.playButtonPressed(mHapticsLauncher, CheckersStallActivity.this); finish(); } }); mPlayAgainButton = (Button) findViewById(R.id.result_btn_playagain); if(mPlayAgainButton != null){ // because in small layouts I removed this button mPlayAgainButton.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { Utils.playButtonPressed(mHapticsLauncher, CheckersStallActivity.this); CheckersGameActivity.launch(CheckersStallActivity.this, mBoardName); finish(); } }); } } private void showVoteMeDialog(){ Long c = PreferencesStore.getCount(this); PreferencesStore.setCount(c + 1, this); if(c == 30 || c == 70 || c == 110){ buildOkCancelDialog(getString(R.string.please_vote), getString(R.string.if_you_enjoyed), new DialogInterface.OnClickListener(){ @Override public void onClick(DialogInterface dialog, int which) { try{ Intent goToMarket = new Intent(Intent.ACTION_VIEW,Uri.parse("market://details?id=com.whiterabbit.checkers")); startActivity(goToMarket); }catch(ActivityNotFoundException e){ return; } } }, this); } } void buildOkCancelDialog(String title, String message, DialogInterface.OnClickListener okListener, Context context){ AlertDialog.Builder ad = new AlertDialog.Builder(context); ad.setTitle(title); ad.setMessage(message); ad.setPositiveButton(R.string.yes_please, okListener); ad.setNegativeButton(R.string.no_thanks, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) {}}); ad.show(); } }