Back to project page SudokuSolver.
The source code is released under:
License JSON Sudoku Solver is covered under the Creative Commons Attribution 3.0 Unported License http://creativecommons.org/licenses/by/3.0/ Credits Sudoku Solver Java implementation: Kevin Coulombe...
If you think the Android project SudokuSolver listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/** * JSON Sudoku solver is covered under the Creative Commons Attribution 3.0 Unported License * http://creativecommons.org/licenses/by/3.0/ * /*from w w w .jav a 2 s . c om*/ * @author: Andrea Bizzotto {@link www.musevisions.com}, {@link www.bizzotto.biz} * @email: bizz84dev@gmail.com */ package com.musevisions.android.SudokuSolver; import com.musevisions.android.SudokuSolver.SudokuCore.SolverListener; import com.musevisions.android.SudokuSolver.SudokuCore.SolverMethod; import android.os.AsyncTask; public class SudokuSolverTask extends AsyncTask<Void, int[], Void> implements SolverListener { private int mPuzzle[]; private int mSolution[]; private SolverListener mListener; private GridView mGridView; private SolverMethod mMethod; private boolean inProgress; public SudokuSolverTask(int puzzle[], SolverListener listener, GridView updateView, SolverMethod method) { mPuzzle = puzzle; mListener = listener; mGridView = updateView; mMethod = method; inProgress = false; } @Override protected Void doInBackground(Void... arg0) { switch(mMethod) { case SOLVER_BRUTE_FORCE: mSolution = SudokuCore.solveMethodBruteForce(mPuzzle, this); break; case SOLVER_OPTIMISED: mSolution = SudokuCore.solveMethodOptimised(mPuzzle); break; } return null; } @Override protected void onPreExecute() { inProgress = true; } protected void onProgressUpdate(int[]... values) { mGridView.setSolution(values[0]); } /** Listener */ @Override protected void onPostExecute(Void result) { inProgress = false; mListener.onSolverEvent(mSolution); } /** Updater */ @Override public boolean onSolverEvent(int[] result) { publishProgress(result); if (isCancelled() || !inProgress) { return false; } return true; } public boolean inProgress() { return inProgress; } }