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

Commit 17769bc

Browse files
committed
Created the textviews containing best times
1 parent 8bbff44 commit 17769bc

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed

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

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,24 @@
99
import android.view.View;
1010
import android.view.ViewGroup;
1111
import android.view.animation.BounceInterpolator;
12+
import android.widget.TextView;
1213

1314
import com.snatik.matches.R;
1415
import com.snatik.matches.common.Memory;
16+
import com.snatik.matches.common.SQLiteDB;
1517
import com.snatik.matches.common.Shared;
1618
import com.snatik.matches.events.ui.DifficultySelectedEvent;
1719
import com.snatik.matches.themes.Theme;
1820
import com.snatik.matches.ui.DifficultyView;
1921

22+
import java.text.SimpleDateFormat;
23+
import java.util.ArrayList;
24+
import java.util.Date;
25+
import java.util.List;
26+
import java.util.TimeZone;
27+
28+
import static android.R.id.text1;
29+
2030
public class DifficultySelectFragment extends Fragment {
2131

2232
@Override
@@ -50,9 +60,108 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
5060

5161
animate(difficulty1, difficulty2, difficulty3, difficulty4, difficulty5, difficulty6);
5262

63+
TextView text1 = (TextView) view.findViewById(R.id.time_difficulty_1);
64+
TextView text2 = (TextView) view.findViewById(R.id.time_difficulty_2);
65+
TextView text3 = (TextView) view.findViewById(R.id.time_difficulty_3);
66+
TextView text4 = (TextView) view.findViewById(R.id.time_difficulty_4);
67+
TextView text5 = (TextView) view.findViewById(R.id.time_difficulty_5);
68+
TextView text6 = (TextView) view.findViewById(R.id.time_difficulty_6);
69+
70+
SQLiteDB db = new SQLiteDB(Shared.context,null,null,1);
71+
List <Integer> times = new ArrayList<>();
72+
/*for(int i = 1;i<=6;i++) {
73+
74+
int bestTime = db.getBestTimeForStage(theme.id, i);
75+
if (bestTime != 0) {
76+
divsList.add(bestTime / 60);
77+
modList.add(bestTime % 60);
78+
} else {
79+
divsList.add(-1);
80+
modList.add(-1);
81+
}
82+
} */
83+
for(int i = 1; i<=6 ; i++) {
84+
if(db.getBestTimeForStage(theme.id, i)!= 0) {
85+
times.add(db.getBestTimeForStage(theme.id, i));
86+
} else {
87+
times.add(-1);
88+
}
89+
System.out.println(times.get(i-1));
90+
}
91+
92+
if(times.get(0) != -1) {
93+
94+
SimpleDateFormat dateFormat = new SimpleDateFormat("mm:ss");
95+
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
96+
Date date = new Date(times.get(0) * 1000);
97+
text1.setText(" BEST : " + dateFormat.format(date));
98+
99+
} else {
100+
text1.setText("BEST : - ");
101+
}
102+
103+
if(times.get(1) != -1) {
104+
105+
SimpleDateFormat dateFormat = new SimpleDateFormat("mm:ss");
106+
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
107+
Date date = new Date(times.get(1) * 1000);
108+
text2.setText(" BEST : " + dateFormat.format(date));
109+
110+
} else {
111+
text2.setText("BEST : - ");
112+
}
113+
114+
if(times.get(2) != -1) {
115+
116+
SimpleDateFormat dateFormat = new SimpleDateFormat("mm:ss");
117+
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
118+
Date date = new Date(times.get(2) * 1000);
119+
text3.setText(" BEST : " + dateFormat.format(date));
120+
121+
} else {
122+
text3.setText("BEST : - ");
123+
}
124+
125+
if(times.get(3) != -1) {
126+
127+
SimpleDateFormat dateFormat = new SimpleDateFormat("mm:ss");
128+
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
129+
Date date = new Date(times.get(3) * 1000);
130+
text4.setText(" BEST : " + dateFormat.format(date));
131+
132+
} else {
133+
text4.setText("BEST : - ");
134+
}
135+
136+
if(times.get(4) != -1) {
137+
138+
SimpleDateFormat dateFormat = new SimpleDateFormat("mm:ss");
139+
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
140+
Date date = new Date(times.get(4) * 1000);
141+
text5.setText(" BEST : " + dateFormat.format(date));
142+
143+
} else {
144+
text5.setText("BEST : - ");
145+
}
146+
147+
if(times.get(5) != -1) {
148+
149+
SimpleDateFormat dateFormat = new SimpleDateFormat("mm:ss");
150+
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
151+
Date date = new Date(times.get(5) * 1000);
152+
text6.setText(" BEST : " + dateFormat.format(date));
153+
154+
} else {
155+
text6.setText("BEST : - ");
156+
}
157+
158+
53159
return view;
160+
161+
54162
}
55163

164+
56165
private void animate(View... view) {
57166
AnimatorSet animatorSet = new AnimatorSet();
58167
Builder builder = animatorSet.play(new AnimatorSet());

0 commit comments

Comments
 (0)