|
9 | 9 | import android.view.View;
|
10 | 10 | import android.view.ViewGroup;
|
11 | 11 | import android.view.animation.BounceInterpolator;
|
| 12 | +import android.widget.TextView; |
12 | 13 |
|
13 | 14 | import com.snatik.matches.R;
|
14 | 15 | import com.snatik.matches.common.Memory;
|
| 16 | +import com.snatik.matches.common.SQLiteDB; |
15 | 17 | import com.snatik.matches.common.Shared;
|
16 | 18 | import com.snatik.matches.events.ui.DifficultySelectedEvent;
|
17 | 19 | import com.snatik.matches.themes.Theme;
|
18 | 20 | import com.snatik.matches.ui.DifficultyView;
|
19 | 21 |
|
| 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 | + |
20 | 30 | public class DifficultySelectFragment extends Fragment {
|
21 | 31 |
|
22 | 32 | @Override
|
@@ -50,9 +60,108 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
|
50 | 60 |
|
51 | 61 | animate(difficulty1, difficulty2, difficulty3, difficulty4, difficulty5, difficulty6);
|
52 | 62 |
|
| 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 | + |
53 | 159 | return view;
|
| 160 | + |
| 161 | + |
54 | 162 | }
|
55 | 163 |
|
| 164 | + |
56 | 165 | private void animate(View... view) {
|
57 | 166 | AnimatorSet animatorSet = new AnimatorSet();
|
58 | 167 | Builder builder = animatorSet.play(new AnimatorSet());
|
|
0 commit comments