Android Open Source - iSlide High Score






From Project

Back to project page iSlide.

License

The source code is released under:

MIT License

If you think the Android project iSlide 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 edu.csun.group2.islide;
// w ww.java  2  s .co  m
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;

import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;

public class HighScore extends Activity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scores_menu);
    File sdCard = Environment.getExternalStorageDirectory();
    File directory = new File (sdCard.getAbsolutePath() + "/iSlide");
    File file = new File(directory, "h_scores.txt"); //or any other format supported
    FileInputStream fs;
    try {
      fs = new FileInputStream(file);
      BufferedReader br = new BufferedReader(new FileReader(file));
      char[] buf = new char[1024];
      int i = br.read(buf);
       String scores = "";
       for(int j = 0 ; j < i ; j++)
       {
         scores += buf[j];
       }
      TextView t = (TextView) findViewById(R.id.textViewScores);
      t.setText(scores);
      
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu)
  {
    menu.add(1, menu.FIRST, menu.FIRST, "Clear High Scores");
    return super.onCreateOptionsMenu(menu);
  }
   @Override
      public boolean onOptionsItemSelected(MenuItem item) {

      switch (item.getItemId()) {
      case 1:
      File sdCard = Environment.getExternalStorageDirectory();
      File directory = new File (sdCard.getAbsolutePath() + "/iSlide");
      File file = new File(directory, "h_scores.txt"); //or any other format supported
      file.delete();
      TextView t = (TextView) findViewById(R.id.textViewScores);
      t.setText("");
  default:
      break;

         }
      return super.onOptionsItemSelected(item);
  }
}




Java Source Code List

edu.csun.group2.islide.CameraPreview.java
edu.csun.group2.islide.HighScore.java
edu.csun.group2.islide.MainActivity.java
edu.csun.group2.islide.MainMenuActivity.java
edu.csun.group2.islide.PhotoHandler.java
edu.csun.group2.islide.PlayMenu.java
edu.csun.group2.islide.SelectImageActivity.java
edu.csun.group2.islide.SettingsMenu.java
edu.csun.group2.islide.TakePictureActivity.java
edu.csun.group2.islide.UtilityInfo.java
edu.csun.group2.islide.Utility.java
edu.csun.group2.islide.engine.BoardTest.java
edu.csun.group2.islide.engine.Board.java
edu.csun.group2.islide.engine.GameBoardTest.java
edu.csun.group2.islide.engine.GameBoard.java
edu.csun.group2.islide.engine.GameManager.java
edu.csun.group2.islide.engine.InputHandler.java
edu.csun.group2.islide.engine.MoveComparator.java
edu.csun.group2.islide.engine.MoveTest.java
edu.csun.group2.islide.engine.Move.java
edu.csun.group2.islide.engine.Pair.java
edu.csun.group2.islide.engine.entity.SlideTile.java
edu.csun.group2.islide.engine.entity.TileManager.java
edu.csun.group2.islide.global.GameInfo.java
edu.csun.group2.islide.interfaces.IRenderable.java
edu.csun.group2.islide.iSlide.java