mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2024-11-23 11:31:33 +01:00
Use Java 8 in CuckooChessApp
This commit is contained in:
parent
ec36bfb123
commit
2e1227eed5
|
@ -35,6 +35,10 @@ android {
|
|||
}
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility = '1.8'
|
||||
targetCompatibility = '1.8'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
|
|
@ -88,12 +88,9 @@ public class CuckooChess extends Activity implements GUIInterface {
|
|||
super.onCreate(savedInstanceState);
|
||||
|
||||
settings = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
settings.registerOnSharedPreferenceChangeListener(new OnSharedPreferenceChangeListener() {
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
settings.registerOnSharedPreferenceChangeListener((sharedPreferences, key) -> {
|
||||
readPrefs();
|
||||
ctrl.setHumanWhite(playerWhite);
|
||||
}
|
||||
});
|
||||
|
||||
binding = ((MainBinding) DataBindingUtil.setContentView(this, R.layout.main)).content;
|
||||
|
@ -140,9 +137,7 @@ public class CuckooChess extends Activity implements GUIInterface {
|
|||
}
|
||||
ctrl.startGame();
|
||||
|
||||
binding.chessboard.setOnTouchListener(new OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
binding.chessboard.setOnTouchListener((v, event) -> {
|
||||
if (ctrl.humansTurn() && (event.getAction() == MotionEvent.ACTION_UP)) {
|
||||
int sq = binding.chessboard.eventToSquare(event);
|
||||
Move m = binding.chessboard.mousePressed(sq);
|
||||
|
@ -152,7 +147,6 @@ public class CuckooChess extends Activity implements GUIInterface {
|
|||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
binding.chessboard.setOnTrackballListener(new ChessBoard.OnTrackballListener() {
|
||||
|
@ -165,13 +159,10 @@ public class CuckooChess extends Activity implements GUIInterface {
|
|||
}
|
||||
}
|
||||
});
|
||||
binding.chessboard.setOnLongClickListener(new OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
binding.chessboard.setOnLongClickListener(v -> {
|
||||
if (!ctrl.computerThinking())
|
||||
showDialog(CLIPBOARD_DIALOG);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -289,19 +280,14 @@ public class CuckooChess extends Activity implements GUIInterface {
|
|||
final CharSequence[] items = {"Queen", "Rook", "Bishop", "Knight"};
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("Promote pawn to?");
|
||||
builder.setItems(items, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int item) {
|
||||
ctrl.reportPromotePiece(item);
|
||||
}
|
||||
});
|
||||
builder.setItems(items, (dialog, item) -> ctrl.reportPromotePiece(item));
|
||||
return builder.create();
|
||||
}
|
||||
case CLIPBOARD_DIALOG: {
|
||||
final CharSequence[] items = {"Copy Game", "Copy Position", "Paste"};
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("Clipboard");
|
||||
builder.setItems(items, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int item) {
|
||||
builder.setItems(items, (dialog, item) -> {
|
||||
switch (item) {
|
||||
case 0: {
|
||||
String pgn = ctrl.getPGN();
|
||||
|
@ -328,7 +314,6 @@ public class CuckooChess extends Activity implements GUIInterface {
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
}
|
||||
|
@ -338,11 +323,7 @@ public class CuckooChess extends Activity implements GUIInterface {
|
|||
|
||||
@Override
|
||||
public void requestPromotePiece() {
|
||||
runOnUIThread(new Runnable() {
|
||||
public void run() {
|
||||
showDialog(PROMOTE_DIALOG);
|
||||
}
|
||||
});
|
||||
runOnUIThread(() -> showDialog(PROMOTE_DIALOG));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue
Block a user