Adjust ImportBoardDialog: Use String.startsWith instead of String.contains when examining the whether or not the input contains the correct url schemes
This commit is contained in:
parent
c51fbfd579
commit
a3a9ae4d39
2 changed files with 10 additions and 6 deletions
|
@ -215,9 +215,9 @@ public class CreateSudokuActivity extends BaseActivity implements IFinalizeDialo
|
||||||
remove the present prefix, or, if the input contains neither of the prefixes, notify the user
|
remove the present prefix, or, if the input contains neither of the prefixes, notify the user
|
||||||
that their input is not valid
|
that their input is not valid
|
||||||
*/
|
*/
|
||||||
if (input.contains(prefix1)) {
|
if (input.startsWith(prefix1)) {
|
||||||
inputSudoku = input.replace(prefix1, "");
|
inputSudoku = input.replace(prefix1, "");
|
||||||
} else if (input.contains(prefix2)) {
|
} else if (input.startsWith(prefix2)) {
|
||||||
inputSudoku = input.replace(prefix2, "");
|
inputSudoku = input.replace(prefix2, "");
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(CreateSudokuActivity.this,
|
Toast.makeText(CreateSudokuActivity.this,
|
||||||
|
|
|
@ -40,6 +40,8 @@ import androidx.viewpager.widget.ViewPager;
|
||||||
import androidx.drawerlayout.widget.DrawerLayout;
|
import androidx.drawerlayout.widget.DrawerLayout;
|
||||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -442,9 +444,9 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||||
remove the present prefix, or, if the input contains neither of the prefixes, notify the user
|
remove the present prefix, or, if the input contains neither of the prefixes, notify the user
|
||||||
that their input is not valid
|
that their input is not valid
|
||||||
*/
|
*/
|
||||||
if (input.contains(prefix1)) {
|
if (input.startsWith(prefix1)) {
|
||||||
inputSudoku = input.replace(prefix1, "");
|
inputSudoku = input.replace(prefix1, "");
|
||||||
} else if (input.contains(prefix2)) {
|
} else if (input.startsWith(prefix2)) {
|
||||||
inputSudoku = input.replace(prefix2, "");
|
inputSudoku = input.replace(prefix2, "");
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(MainActivity.this,
|
Toast.makeText(MainActivity.this,
|
||||||
|
@ -452,7 +454,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int size = (int)Math.sqrt(inputSudoku.length());
|
double size = Math.sqrt(inputSudoku.length());
|
||||||
boolean validSize = false;
|
boolean validSize = false;
|
||||||
|
|
||||||
// check whether or not the size of the encoded sudoku is valid; if not, notify the user
|
// check whether or not the size of the encoded sudoku is valid; if not, notify the user
|
||||||
|
@ -468,7 +470,9 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameType gameType = Enum.valueOf(GameType.class, "Default_" + size + "x" + size);
|
Log.i("Default_" + size + "x" + size, "SudokuTag");
|
||||||
|
|
||||||
|
GameType gameType = Enum.valueOf(GameType.class, "Default_" + (int)size + "x" + (int)size);
|
||||||
|
|
||||||
//check whether or not the sudoku is valid and has a unique solution
|
//check whether or not the sudoku is valid and has a unique solution
|
||||||
boolean solvable = CreateSudokuActivity.verify(gameType, inputSudoku);
|
boolean solvable = CreateSudokuActivity.verify(gameType, inputSudoku);
|
||||||
|
|
Loading…
Reference in a new issue