Android Open Source - NotATop First Time Surface View






From Project

Back to project page NotATop.

License

The source code is released under:

GNU General Public License

If you think the Android project NotATop 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.gg.view;
/*w w w.ja v a  2s .  com*/
import com.gg.util.Constant;

import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.widget.Toast;

public class FirstTimeSurfaceView extends SurfaceView 
implements SurfaceHolder.Callback  //????????????????
{
  MainActivity mainActivity;
  Paint paint;//????
  Bitmap background;//???logo??????
  
  private Toast helpToast;

  
  public FirstTimeSurfaceView(MainActivity mainActivity) {
    super(mainActivity);
    this.mainActivity = mainActivity;
    this.getHolder().addCallback(this);//???????????????????????
    paint = new Paint();//????????
    paint.setAntiAlias(true);//??????
    
    //??????
    background=BitmapFactory.decodeResource(mainActivity.getResources(), R.drawable.first_time_bg); 
    
    helpToast = Toast.makeText(mainActivity, "???????????", Toast.LENGTH_SHORT);

  }
  public void onDraw(Canvas canvas){  
    
    //???????????????
    paint.setColor(Color.WHITE);//?????????
    paint.setAlpha(255);
    canvas.drawRect(0, 0, Constant.SCREEN_WIDTH, Constant.SCREEN_WIDTH, paint);

    canvas.drawBitmap(background, new Rect(0, 0,
        (int) background.getWidth(), (int) background
            .getHeight()), new Rect(0, 0,
        (int) Constant.SCREEN_WIDTH, (int) Constant.SCREEN_HEIGHT), paint);


  }

  public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
    
  }
  public void surfaceCreated(SurfaceHolder holder) {//???????????    

    SurfaceHolder myholder=FirstTimeSurfaceView.this.getHolder();
    Canvas canvas = myholder.lockCanvas();//???????
    try{
      synchronized(myholder){
        onDraw(canvas);//????
      }
    }
    catch(Exception e){
      e.printStackTrace();
    }
    finally{
      if(canvas != null){
        myholder.unlockCanvasAndPost(canvas);
      }
    }            
        
  }

  public void surfaceDestroyed(SurfaceHolder arg0) {//???????????

  }
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    // TODO Auto-generated method stub
    
    double x = Constant.convertX(event.getX());
    double y = Constant.convertY(event.getY());
    

    SharedPreferences settings = mainActivity.getSettings();
    //voiceControlFlag = settings.getBoolean("voiceControlFlag", true);
      SharedPreferences.Editor editor = settings.edit();
//      editor.putBoolean("voiceControlFlag", false);
//      editor.commit();
    
    if(x>-1 && x<-0.2 && y>-0.8 && y<-0.2){
        editor.putBoolean("voiceControlFlag", true);
        editor.commit();
        mainActivity.getVoiceControl().setFlag(true);

        helpToast.show();
      mainActivity.getHandler().sendEmptyMessage(SurfaceViewFactory.HELP);
    }else if(x>0.2 && x<1 && y>-0.8 && y<-0.2){
        editor.putBoolean("voiceControlFlag", false);
        editor.commit();

        helpToast.show();
      mainActivity.getHandler().sendEmptyMessage(SurfaceViewFactory.HELP);
    }
    
    
    //return super.onTouchEvent(event);
    return false;
  }
  
  
}




Java Source Code List

com.gg.game.ClassicGame.java
com.gg.game.ClassicGame.java
com.gg.game.GameFrame.java
com.gg.game.GameFrame.java
com.gg.game.TimeGame.java
com.gg.game.TimeGame.java
com.gg.module.DrawBackground.java
com.gg.module.DrawBackground.java
com.gg.module.DrawScore.java
com.gg.module.DrawScore.java
com.gg.module.DrawTrack.java
com.gg.module.DrawTrack.java
com.gg.module.SelectControl.java
com.gg.module.SelectControl.java
com.gg.module.SoundControl.java
com.gg.module.SoundControl.java
com.gg.module.VoiceControl.java
com.gg.module.VoiceControl.java
com.gg.top.BasicTop.java
com.gg.top.BasicTop.java
com.gg.top.DrawCircle.java
com.gg.top.DrawCircle.java
com.gg.top.DrawCone.java
com.gg.top.DrawCone.java
com.gg.top.DrawCylinder.java
com.gg.top.DrawCylinder.java
com.gg.top.DrawTop.java
com.gg.top.DrawTop.java
com.gg.util.Circle.java
com.gg.util.Circle.java
com.gg.util.Constant.java
com.gg.util.Constant.java
com.gg.util.DateUtil.java
com.gg.util.DateUtil.java
com.gg.util.Direction.java
com.gg.util.Direction.java
com.gg.util.Line.java
com.gg.util.Line.java
com.gg.util.Point.java
com.gg.util.Point.java
com.gg.util.TextureRect.java
com.gg.util.TextureRect.java
com.gg.util.TrackPoint.java
com.gg.util.TrackPoint.java
com.gg.util.Track.java
com.gg.util.Track.java
com.gg.util.Utils.java
com.gg.util.Utils.java
com.gg.view.ClassicGameSurfaceView.java
com.gg.view.ClassicGameSurfaceView.java
com.gg.view.EndSurfaceView.java
com.gg.view.EndSurfaceView.java
com.gg.view.FirstTimeSurfaceView.java
com.gg.view.FirstTimeSurfaceView.java
com.gg.view.GameModeSurfaceView.java
com.gg.view.GameModeSurfaceView.java
com.gg.view.HelpSurfaceView.java
com.gg.view.HelpSurfaceView.java
com.gg.view.MainActivity.java
com.gg.view.MainActivity.java
com.gg.view.MainMenuSurfaceView.java
com.gg.view.MainMenuSurfaceView.java
com.gg.view.ScoreSurfaceView.java
com.gg.view.ScoreSurfaceView.java
com.gg.view.SelectSurfaceView.java
com.gg.view.SelectSurfaceView.java
com.gg.view.SurfaceViewFactory.java
com.gg.view.SurfaceViewFactory.java
com.gg.view.TimeGameSurfaceView.java
com.gg.view.TimeGameSurfaceView.java
com.gg.view.WelcomeSurfaceView.java
com.gg.view.WelcomeSurfaceView.java