Modification of the onCreate() method

1.) Display of the current difficulty of the DailySudokus

Modification of the getView() method
1.) Calculation and display of the Daily Sudoku data
This commit is contained in:
ErikWaegerle 2020-06-01 01:22:15 +02:00
parent 236be00504
commit a8c8280dc4

View file

@ -18,12 +18,15 @@ import android.view.View;
import android.widget.RatingBar; import android.widget.RatingBar;
import android.widget.Toast; import android.widget.Toast;
import org.secuso.privacyfriendlysudoku.controller.GameController; import org.secuso.privacyfriendlysudoku.controller.GameController;
import org.secuso.privacyfriendlysudoku.controller.NewLevelManager;
import org.secuso.privacyfriendlysudoku.controller.database.DatabaseHelper; import org.secuso.privacyfriendlysudoku.controller.database.DatabaseHelper;
import org.secuso.privacyfriendlysudoku.controller.database.model.DailySudoku; import org.secuso.privacyfriendlysudoku.controller.database.model.DailySudoku;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import org.secuso.privacyfriendlysudoku.controller.SaveLoadStatistics; import org.secuso.privacyfriendlysudoku.controller.SaveLoadStatistics;
import org.secuso.privacyfriendlysudoku.controller.qqwing.QQWing;
import org.secuso.privacyfriendlysudoku.game.GameDifficulty; import org.secuso.privacyfriendlysudoku.game.GameDifficulty;
import org.secuso.privacyfriendlysudoku.game.GameType;
import org.secuso.privacyfriendlysudoku.ui.GameActivity; import org.secuso.privacyfriendlysudoku.ui.GameActivity;
import org.secuso.privacyfriendlysudoku.ui.StatsActivity; import org.secuso.privacyfriendlysudoku.ui.StatsActivity;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@ -96,6 +99,23 @@ public class DailySudokuActivity<Database> extends AppCompatActivity {
sudokuListAdapter = new DailySudokuActivity.SudokuListAdapter(this, sudokuList); sudokuListAdapter = new DailySudokuActivity.SudokuListAdapter(this, sudokuList);
listView.setAdapter(sudokuListAdapter); listView.setAdapter(sudokuListAdapter);
NewLevelManager newLevelManager = NewLevelManager.getInstance(getApplicationContext(), settings);
int[] level = newLevelManager.loadDailySudoku();
QQWing difficultyCheck = new QQWing(GameType.Default_9x9, GameDifficulty.Unspecified);
difficultyCheck.setRecordHistory(true);
difficultyCheck.setPuzzle(level);
difficultyCheck.solve();
RatingBar ratingbar = findViewById(R.id.first_diff_bar);
TextView tz = findViewById(R.id.first_diff_text);
tz.setText(difficultyCheck.getDifficulty().getStringResID());
ratingbar.setNumStars(GameDifficulty.getValidDifficultyList().size());
ratingbar.setMax(GameDifficulty.getValidDifficultyList().size());
ratingbar.setRating(GameDifficulty.getValidDifficultyList().indexOf(difficultyCheck.getDifficulty())+1);
} }
public void onClick(View view) { public void onClick(View view) {
@ -206,7 +226,20 @@ public class DailySudokuActivity<Database> extends AppCompatActivity {
difficultyBar.setNumStars(GameDifficulty.getValidDifficultyList().size()); difficultyBar.setNumStars(GameDifficulty.getValidDifficultyList().size());
difficultyBar.setMax(GameDifficulty.getValidDifficultyList().size()); difficultyBar.setMax(GameDifficulty.getValidDifficultyList().size());
difficultyBar.setRating(GameDifficulty.getValidDifficultyList().indexOf(sudoku.getDifficulty())+1); difficultyBar.setRating(GameDifficulty.getValidDifficultyList().indexOf(sudoku.getDifficulty())+1);
//lastTimePlayed.setText(sudoku.getTimeNeeded());
Calendar currentDate = Calendar.getInstance();
//int id = currentDate.get(Calendar.DAY_OF_MONTH) * 1000000
// + (currentDate.get(Calendar.MONTH) + 1) * 10000 + currentDate.get(Calendar.YEAR);
int id = sudoku.getId();
int dayOfMonth = id/1000000;
int month = (id/10000) % 100;
int year = id%10000;
String str = String.format("%02d.%02d.%02d", dayOfMonth, month, year);
lastTimePlayed.setText(str);
playedTime.setText(sudoku.getTimeNeeded()); playedTime.setText(sudoku.getTimeNeeded());
return convertView; return convertView;
} }