Skip to content
This repository was archived by the owner on Aug 4, 2021. It is now read-only.

Commit d7fd361

Browse files
committed
Removed all unused Imports and done some formatting
1 parent 8794068 commit d7fd361

File tree

7 files changed

+40
-48
lines changed

7 files changed

+40
-48
lines changed

app/src/main/java/com/snatik/matches/MainActivity.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.snatik.matches;
22

3-
import android.database.sqlite.SQLiteDatabase;
4-
import android.database.sqlite.SQLiteOpenHelper;
3+
54
import android.graphics.Bitmap;
65
import android.os.Bundle;
76
import android.support.v4.app.FragmentActivity;
Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
package com.snatik.matches.common;
22

3-
import android.content.Context;
4-
import android.content.SharedPreferences;
5-
import android.content.SharedPreferences.Editor;
6-
import android.preference.PreferenceManager;
7-
import android.util.Log;
83

9-
import java.util.Map;
4+
import android.content.SharedPreferences;
105

11-
import static android.R.attr.id;
12-
import static android.R.id.edit;
136
import static android.content.Context.MODE_PRIVATE;
147

158

@@ -20,30 +13,22 @@ public class Memory {
2013
private static String bestTimeKey = "themeTime_%d_difficultyTime_%d";
2114

2215
public static void save(int theme, int difficulty, int stars) {
23-
Log.i("In save()","");
16+
2417
int highStars = getHighStars(theme, difficulty);
2518

2619
if (stars > highStars) {
27-
Log.i("New best stars","");
2820
SharedPreferences sharedPreferences = Shared.context.getSharedPreferences(SHARED_PREFERENCES_NAME, MODE_PRIVATE);
2921
SharedPreferences.Editor edit = sharedPreferences.edit();
3022
String key = String.format(highStartKey, theme, difficulty);
3123
edit.putInt(key, stars).commit();
3224
}
3325
}
3426

35-
public static void saveTime(int theme,int difficulty,int passedSecs) {
27+
public static void saveTime(int theme, int difficulty, int passedSecs) {
3628

3729
int bestTime = getBestTime(theme,difficulty);
3830

39-
if(passedSecs<bestTime && bestTime != -1) {
40-
SharedPreferences sharedPreferences = Shared.context.getSharedPreferences(SHARED_PREFERENCES_NAME,MODE_PRIVATE);
41-
SharedPreferences.Editor editor = sharedPreferences.edit();
42-
String timeKey = String.format(bestTimeKey, theme, difficulty);
43-
editor.putInt(timeKey,passedSecs);
44-
editor.commit();
45-
}
46-
if( bestTime == -1) {
31+
if(passedSecs<bestTime || bestTime == -1) {
4732
SharedPreferences sharedPreferences = Shared.context.getSharedPreferences(SHARED_PREFERENCES_NAME,MODE_PRIVATE);
4833
SharedPreferences.Editor editor = sharedPreferences.edit();
4934
String timeKey = String.format(bestTimeKey, theme, difficulty);
@@ -59,25 +44,11 @@ public static int getHighStars(int theme, int difficulty) {
5944
return sharedPreferences.getInt(key, 0);
6045
}
6146

62-
public static int getBestTime(int theme,int difficulty) {
47+
public static int getBestTime(int theme, int difficulty) {
6348

6449
SharedPreferences sharedPreferences = Shared.context.getSharedPreferences(SHARED_PREFERENCES_NAME, MODE_PRIVATE);
6550
String key = String.format(bestTimeKey, theme, difficulty);
6651
return sharedPreferences.getInt(key, -1);
6752
}
6853

69-
public static String getBestTimeForStage(int theme,int difficulty) {
70-
71-
int bestTime = getBestTime(theme,difficulty);
72-
if(bestTime != -1) {
73-
Log.i("Best time for diff", ""+bestTime);
74-
int minutes = (bestTime % 3600) / 60;
75-
int seconds = (bestTime) % 60;
76-
String result = String.format("BEST : %02d:%02d", minutes, seconds);
77-
return result;
78-
} else {
79-
String result = "BEST : -";
80-
return result;
81-
}
82-
}
8354
}

app/src/main/java/com/snatik/matches/engine/Engine.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import android.graphics.drawable.TransitionDrawable;
77
import android.os.AsyncTask;
88
import android.os.Handler;
9-
import android.util.Log;
109
import android.widget.ImageView;
1110

1211
import com.snatik.matches.R;
@@ -261,7 +260,7 @@ public void run() {
261260

262261
// save to memory
263262
Memory.save(mPlayingGame.theme.id, mPlayingGame.boardConfiguration.difficulty, gameState.achievedStars);
264-
Memory.saveTime(mPlayingGame.theme.id,mPlayingGame.boardConfiguration.difficulty,gameState.passedSeconds);
263+
Memory.saveTime(mPlayingGame.theme.id, mPlayingGame.boardConfiguration.difficulty ,gameState.passedSeconds);
265264

266265

267266

app/src/main/java/com/snatik/matches/events/engine/GameWonEvent.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.snatik.matches.events.engine;
22

3-
import com.snatik.matches.common.Shared;
43
import com.snatik.matches.events.AbstractEvent;
54
import com.snatik.matches.events.EventObserver;
65
import com.snatik.matches.model.GameState;

app/src/main/java/com/snatik/matches/fragments/DifficultySelectFragment.java

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
import android.animation.AnimatorSet;
44
import android.animation.AnimatorSet.Builder;
55
import android.animation.ObjectAnimator;
6-
import android.content.res.AssetManager;
76
import android.graphics.Typeface;
87
import android.os.Bundle;
98
import android.support.v4.app.Fragment;
10-
import android.util.Log;
119
import android.view.Gravity;
1210
import android.view.LayoutInflater;
1311
import android.view.View;
@@ -22,6 +20,8 @@
2220
import com.snatik.matches.themes.Theme;
2321
import com.snatik.matches.ui.DifficultyView;
2422

23+
import static com.snatik.matches.common.Memory.getBestTime;
24+
2525

2626
public class DifficultySelectFragment extends Fragment {
2727

@@ -56,45 +56,59 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
5656

5757
animate(difficulty1, difficulty2, difficulty3, difficulty4, difficulty5, difficulty6);
5858

59-
Typeface type = Typeface.createFromAsset(Shared.context.getAssets(),"fonts/grobold.ttf");
59+
Typeface type = Typeface.createFromAsset(Shared.context.getAssets(), "fonts/grobold.ttf");
6060

6161

6262
TextView text1 = (TextView) view.findViewById(R.id.time_difficulty_1);
6363
text1.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
6464
text1.setTypeface(type);
65-
text1.setText(Memory.getBestTimeForStage(theme.id,1));
65+
text1.setText(getBestTimeForStage(theme.id,1));
6666

6767
TextView text2 = (TextView) view.findViewById(R.id.time_difficulty_2);
6868
text2.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
6969
text2.setTypeface(type);
70-
text2.setText(Memory.getBestTimeForStage(theme.id,2));
70+
text2.setText(getBestTimeForStage(theme.id,2));
7171

7272
TextView text3 = (TextView) view.findViewById(R.id.time_difficulty_3);
7373
text3.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
7474
text3.setTypeface(type);
75-
text3.setText(Memory.getBestTimeForStage(theme.id,3));
75+
text3.setText(getBestTimeForStage(theme.id,3));
7676

7777
TextView text4 = (TextView) view.findViewById(R.id.time_difficulty_4);
7878
text4.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
7979
text4.setTypeface(type);
80-
text4.setText(Memory.getBestTimeForStage(theme.id,4));
80+
text4.setText(getBestTimeForStage(theme.id,4));
8181

8282
TextView text5 = (TextView) view.findViewById(R.id.time_difficulty_5);
8383
text5.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
8484
text5.setTypeface(type);
85-
text5.setText(Memory.getBestTimeForStage(theme.id,5));
85+
text5.setText(getBestTimeForStage(theme.id,5));
8686

8787
TextView text6 = (TextView) view.findViewById(R.id.time_difficulty_6);
8888
text6.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
8989
text6.setTypeface(type);
90-
text6.setText(Memory.getBestTimeForStage(theme.id,6));
90+
text6.setText(getBestTimeForStage(theme.id,6));
9191

9292

9393
return view;
9494

9595

9696
}
9797

98+
public static String getBestTimeForStage(int theme, int difficulty) {
99+
100+
int bestTime = getBestTime(theme,difficulty);
101+
if(bestTime != -1) {
102+
int minutes = (bestTime % 3600) / 60;
103+
int seconds = (bestTime) % 60;
104+
String result = String.format("BEST : %02d:%02d", minutes, seconds);
105+
return result;
106+
} else {
107+
String result = "BEST : -";
108+
return result;
109+
}
110+
}
111+
98112
private void animate(View... view) {
99113
AnimatorSet animatorSet = new AnimatorSet();
100114
Builder builder = animatorSet.play(new AnimatorSet());

app/src/main/res/Temporary.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* Created by Dimitris on 13/9/2017.
3+
*/
4+
5+
public class Temporary {
6+
int minutes = 123 / (60 * 1000);
7+
int seconds = (123 / 1000) % 60;
8+
String str = String.format("%d:%02d", minutes, seconds);
9+
System.out.println(str);
10+
}

git

Whitespace-only changes.

0 commit comments

Comments
 (0)