Android Open Source - DroidChineseCheckers Checkers Stall Activity






From Project

Back to project page DroidChineseCheckers.

License

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.

Java Source Code

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();
  }

}




Java Source Code List

com.whiterabbit.checkers.Constants.java
com.whiterabbit.checkers.PegDroidApplication.java
com.whiterabbit.checkers.PreferencesStore.java
com.whiterabbit.checkers.board.AndEngineBoard.java
com.whiterabbit.checkers.board.BoardCell.java
com.whiterabbit.checkers.board.FillableBoardCell.java
com.whiterabbit.checkers.board.FilledBoardCell.java
com.whiterabbit.checkers.board.LastMove.java
com.whiterabbit.checkers.boards.Board32Diamond.java
com.whiterabbit.checkers.boards.BoardAsymmetrical.java
com.whiterabbit.checkers.boards.BoardClassicEng.java
com.whiterabbit.checkers.boards.BoardClassicExtended.java
com.whiterabbit.checkers.boards.BoardClassic.java
com.whiterabbit.checkers.boards.BoardKind.java
com.whiterabbit.checkers.boards.BoardS.java
com.whiterabbit.checkers.boards.BoardStar.java
com.whiterabbit.checkers.boards.CheckersDbHelper.java
com.whiterabbit.checkers.boards.CheckersStorage.java
com.whiterabbit.checkers.boards.HoleMushroom.java
com.whiterabbit.checkers.boards.NineByNineBoard.java
com.whiterabbit.checkers.boards.SimpleCross1.java
com.whiterabbit.checkers.boards.SimpleCross2.java
com.whiterabbit.checkers.boards.SimpleCross3.java
com.whiterabbit.checkers.boards.SixBySixBoard.java
com.whiterabbit.checkers.boards.WieglebBoard.java
com.whiterabbit.checkers.exceptions.CantFillException.java
com.whiterabbit.checkers.ui.BackArrowSprite.java
com.whiterabbit.checkers.ui.BallSprite.java
com.whiterabbit.checkers.ui.BoardListElem.java
com.whiterabbit.checkers.ui.BoardSprite.java
com.whiterabbit.checkers.ui.BoardsListActivity.java
com.whiterabbit.checkers.ui.CheckersGameActivity.java
com.whiterabbit.checkers.ui.CheckersMainMenu.java
com.whiterabbit.checkers.ui.CheckersSpriteFactory.java
com.whiterabbit.checkers.ui.CheckersStallActivity.java
com.whiterabbit.checkers.ui.PegDroidPrefs.java
com.whiterabbit.checkers.util.Utils.java