Android Open Source - nPuzzle You Win






From Project

Back to project page nPuzzle.

License

The source code is released under:

MIT License

If you think the Android project nPuzzle 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 net.cs76.projects.npuzzle;
/*from  w ww. j  a  v a 2 s  .c  om*/
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * Activity that displays congratulations on winning puzzle.
 * Contains move amount and full image
 * 
 * @author Greg Chapman
 *
 */
public class YouWin extends Activity
{
   private ImageUtility mImageUtility;
   private String mSelectionPath;
   private int mSelection;

   @Override
   protected void onCreate(Bundle aSavedInstanceState)
   {
      super.onCreate(aSavedInstanceState);

      mImageUtility = new ImageUtility(this);
      setContentView(R.layout.activity_youwin);
     
      int lMoves = 0;
      Intent lIntent = getIntent();
      if(lIntent != null)
      {
         lMoves = lIntent.getExtras().getInt("moves");
         mSelectionPath = lIntent.getExtras().getString("selectionPath");
         mSelection = lIntent.getExtras().getInt("selection");
      }
      
      TextView lMovesText = (TextView) findViewById(R.id.moves);
      lMovesText.setText("You made " + lMoves + " moves");
      
      Button lContinue = (Button) findViewById(R.id.continueBtn);
      lContinue.setOnClickListener(new OnClickListener()
      {
         @Override
         public void onClick(View aView)
         {
            finish();
         }
      });
   }
   
   @Override
   public void onWindowFocusChanged(boolean aHasFocus)
   {
      super.onWindowFocusChanged(aHasFocus);
      mImageUtility.onWindowFocusChanged(aHasFocus);
      
      ImageView lPuzzle = (ImageView) findViewById(R.id.puzzleImage);
      if(!mSelectionPath.isEmpty())
      {
         lPuzzle.setImageBitmap(mImageUtility.scaleImage(mSelectionPath, mSelection));
      }
   }
}




Java Source Code List

net.cs76.projects.npuzzle.GamePlay.java
net.cs76.projects.npuzzle.ImageListAdapter.java
net.cs76.projects.npuzzle.ImageSelection.java
net.cs76.projects.npuzzle.ImageUtility.java
net.cs76.projects.npuzzle.PuzzleBoard.java
net.cs76.projects.npuzzle.PuzzleGridAdapter.java
net.cs76.projects.npuzzle.PuzzleSettings.java
net.cs76.projects.npuzzle.YouWin.java