Clover Coverage Report - HeartsSkyThread Coverage Report
Coverage timestamp: gio dic 18 2014 15:52:24 EST
../../../../img/srcFileCovDistChart9.png 0% of files have more coverage
83   217   25   5,53
16   161   0,3   15
15     1,67  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  MainActivity       Line # 25 83 25 82,5% 0.8245614
 
No Tests
 
1    package game.shad.tempus.hearts;
2   
3   
4   
5   
6    import game.shad.tempus.hearts.GameThread.State;
7    import android.app.Activity;
8    import android.content.Context;
9    import android.content.Intent;
10    import android.os.AsyncTask;
11    import android.os.Bundle;
12    import android.os.Handler;
13    import android.os.Looper;
14    import android.os.PowerManager.WakeLock;
15    import android.util.Log;
16    import android.view.View;
17    import android.widget.Toast;
18   
19    /**
20    * Starts the craps game,
21    *
22    * @author Shadoath
23    *
24    */
 
25    public class MainActivity extends Activity {
26    /** For use with Android logging functions */
27    public static final String TAG = "Hearts--Main";
28   
29    public Game game;
30    public GameView gameView;
31    public GameThread gt;
32    public GameView view;
33    private Toast myToast;
34   
35    public Handler handler; //Handler to UI thread to post tasks to.
36    private WakeLock mWakeLock;
37    private boolean loaded =false;
38    private Bundle gameBundle;
39    private Context appContext;
40    private MainActivity main;
 
41  8 toggle @Override
42   
43    public void onCreate(Bundle savedInstanceState) {
44  8 super.onCreate(savedInstanceState);
45  8 Intent gameIntent = getIntent();
46  8 gameBundle = gameIntent.getExtras();
47  8 Log.d(TAG, "onCreate");
48  8 setContentView(R.layout.table);
49  8 appContext = getApplicationContext();
50  8 main= this;
51  8 game = new Game(gameBundle, getApplicationContext());
52  8 gameView = new GameView(appContext, main, game, gameBundle.getInt("width"), gameBundle.getInt("height"));
53  8 gt = new GameThread(appContext, main, game, gameView);
54  8 myToast = Toast.makeText(getBaseContext(), "", Toast.LENGTH_SHORT);
55  8 gameView.createViews();
56  8 Log.d(TAG, "created Views");
57  8 gt.firstInit();
58  8 gameView.clubsPlayed.setText("C="+game.clubsPlayedInt);
59  8 gameView.diamondsPlayed.setText("D="+game.diamondsPlayedInt);
60  8 gameView.spadesPlayed.setText("A="+game.spadesPlayedInt);
61  8 gameView.heartsPlayed.setText("H="+game.heartsPlayedInt);
62  8 int total=game.clubsPlayedInt+game.diamondsPlayedInt+game.spadesPlayedInt+game.heartsPlayedInt;
63  8 gameView.totalPlayed.setText("total= "+total);
64   
65    }
66   
 
67  8 toggle @Override
68    protected void onStart(){
69  8 super.onStart();
70  8 Log.d(TAG, "onStart");
71  8 handler= new Handler();
72  8 if(gt==null){
73  0 return;
74    }
75  8 if(gt.state.compareAndSet(State.PAUSED, State.RUNNING)){
76  8 Log.d(TAG, "Restarting game thread in start");
77  8 gt.interrupt();
78    }
79   
80   
81    }
82   
 
83  8 toggle @Override
84    protected void onPause() {
85  8 Log.d(TAG, "onPause");
86   
87  8 super.onPause();
88  8 if(gt.state.compareAndSet(State.RUNNING, State.PAUSED)) {
89  8 gt.interrupt();
90    }
91   
92    }
93   
 
94  8 toggle @Override
95    protected void onResume() {
96  8 Log.d(TAG, "onResume");
97  8 super.onResume();
98   
99  8 if(gt.state.compareAndSet(State.PAUSED, State.RUNNING)) {
100  0 gt.interrupt();
101   
102    }
103    //view.setInitializedTo(true);
104   
105    }
106   
 
107  8 toggle @Override
108    public void onStop() {
109  8 Log.d(TAG, "onStop");
110  8 super.onStop();
111    }
112   
 
113  8 toggle @Override
114    protected void onDestroy() {
115   
116  8 Log.d(TAG, "onDestroy");
117   
118  8 super.onDestroy();
119  8 gt.state.set(State.DEAD);
120  8 gt.interrupt();
121    }
122   
 
123  0 toggle @Override
124    public void onRestart(){
125  0 super.onRestart();
126  0 Log.d(TAG, "onRestart");
127  0 Log.d(TAG, "gt.state="+gt.state);
128    }
129   
 
130  24 toggle public void onDebugButtonPressed(View v){
131  24 gameView.setInitializedTo(true);
132  24 game.showHand(game.p1);
133  24 game.showHand(game.p2);
134  24 game.showHand(game.p3);
135  24 game.showHand(game.p4);
136  24 Toast.makeText(this, "Printed Hands", Toast.LENGTH_SHORT).show();
137  24 game.p1.updateDeck();
138  24 gameView.deckHolder.updateDeck(game.p1.getDeck());
139  24 gameView.deckHolder.initialized=true;
140  24 game.playing=!game.playing;
141   
142   
143    }
 
144  32 toggle public void onNextButtonPressed(View v){
145  32 if(game.playing){
146   
147  1 if(game.playerHelper&&game.playerHelperInt>0){
148  0 game.playerHelperInt=0;
149  0 gt.GO();
150   
151    }
152    else{
153  1 game.playerHelperInt++;
154  1 Toast.makeText(this, "Please play card", Toast.LENGTH_SHORT).show();
155    }
156    }
157    else{
158  31 gt.GO();
159    }
160   
161    }
 
162  0 toggle public void onTablePressed(View v){
163  0 Log.d(TAG, "onClearPressed");
164  0 gameView.updateTH();
165   
166    }
 
167  0 toggle public void onDeckPressed(View v){
168  0 gameView.updateDH();
169   
170    }
 
171  8 toggle public void onExitPressed(View v){
172  8 finish();
173    }
174   
 
175  23 toggle public void onSwipeLeftPressed(View v){
176  23 gameView.deckHolder.swipeLeft();
177  23 Toast.makeText(this, "position is "+gameView.deckHolder.getPosition(), Toast.LENGTH_SHORT).show();
178   
179    }
180   
 
181  32 toggle public void onSwipeRightPressed(View v){
182  32 gameView.deckHolder.swipeRight();
183  32 Toast.makeText(this, "position is "+gameView.deckHolder.getPosition(), Toast.LENGTH_SHORT).show();
184   
185   
186    }
187   
188   
 
189  32 toggle public void onPlayCardPressed(View v){
190  32 if(game.cardToPlay!=null&&game.playing){ //make sure we have a card selected and we have not already played.
191  10 if(game.pile.size()==0){
192  0 gameView.clearTableCards();
193    }
194  10 game.cardToPlay.setTouched(false);
195  10 game.pile.add(game.cardToPlay);
196  10 game.playing=false;
197  10 this.game.p1.deck.removeCard(game.cardToPlay);
198  10 gt.playCard(game.cardToPlay);
199  10 game.cardToPlay=null;
200    }
201    else{
202  22 Toast.makeText(this, "Not your turn", Toast.LENGTH_SHORT).show();
203    }
204  32 game.playing=false;
205  32 game.p1.updateSuits();
206  32 gameView.deckHolder.updateDeck(game.p1.getDeck());
207   
208   
209   
210    }
211    }
212   
213   
214   
215   
216   
217