Skip to content

Commit b74b808

Browse files
committedAug 18, 2019
Refactoring: reduce warnings in Android Studio
1 parent 6c73e07 commit b74b808

File tree

1 file changed

+19
-24
lines changed

1 file changed

+19
-24
lines changed
 

‎scidOnTheGo/src/main/java/org/scid/android/ScidAndroidActivity.java

+19-24
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,8 @@ private void flipBoardForPlayerNames(String white, String black) {
455455
this.lastWhitePlayerName = white;
456456
this.lastBlackPlayerName = black;
457457
String[] names = myPlayerNames.split("\\n");
458-
for (int i = 0; i < names.length; i++) {
459-
String playerName = names[i].trim();
458+
for (String name : names) {
459+
String playerName = name.trim();
460460
if (playerName.length() > 0) {
461461
if (white.equalsIgnoreCase(playerName)) {
462462
setFlipped(false);
@@ -510,7 +510,7 @@ public void onFlipBoardClick(View view) {
510510
setFlipped(!cb.flipped);
511511
}
512512

513-
private final byte[] strToByteArr(String str) {
513+
private byte[] strToByteArr(String str) {
514514
int nBytes = str.length() / 2;
515515
byte[] ret = new byte[nBytes];
516516
for (int i = 0; i < nBytes; i++) {
@@ -521,11 +521,11 @@ private final byte[] strToByteArr(String str) {
521521
return ret;
522522
}
523523

524-
private final String byteArrToString(byte[] data) {
524+
private String byteArrToString(byte[] data) {
525525
StringBuilder ret = new StringBuilder(32768);
526526
int nBytes = data.length;
527-
for (int i = 0; i < nBytes; i++) {
528-
int b = data[i];
527+
for (int datum : data) {
528+
int b = datum;
529529
if (b < 0) {
530530
b += 256;
531531
}
@@ -560,7 +560,7 @@ public void onConfigurationChanged(Configuration newConfig) {
560560
setFavoriteRating();
561561
}
562562

563-
private final void initUI(boolean initTitle) {
563+
private void initUI(boolean initTitle) {
564564
if (initTitle) {
565565
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
566566
}
@@ -681,7 +681,7 @@ public boolean onDoubleTapEvent(MotionEvent e) {
681681
return true;
682682
}
683683

684-
private final void handleClick(MotionEvent e) {
684+
private void handleClick(MotionEvent e) {
685685
int sq = cb.eventToSquare(e);
686686
Move m = cb.mousePressed(sq);
687687
makeHumanMove(m);
@@ -884,7 +884,7 @@ protected void onDestroy() {
884884
super.onDestroy();
885885
}
886886

887-
private final void readPrefs() {
887+
private void readPrefs() {
888888
this.myPlayerNames = preferences.getString("playerNames", "");
889889
setFlipped(preferences.getBoolean("boardFlipped", false));
890890
studyOrientation = Integer.parseInt(preferences.getString("studyOrientation", "0"));
@@ -939,7 +939,7 @@ private final void readPrefs() {
939939
ctrl.prefsChanged();
940940
}
941941

942-
private final void setFullScreenMode(boolean fullScreenMode) {
942+
private void setFullScreenMode(boolean fullScreenMode) {
943943
WindowManager.LayoutParams attrs = getWindow().getAttributes();
944944
if (fullScreenMode) {
945945
attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
@@ -973,7 +973,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
973973
static private final int RESULT_PGN_FILE_IMPORT = 11;
974974
static private final int RESULT_GET_FEN = 12;
975975
static private final int RESULT_EXPORT_PGN = 13;
976-
976+
static private final int RESULT_PERMISSION_REQUEST = 14;
977977
@Override
978978
public boolean onOptionsItemSelected(MenuItem item) {
979979
switch (item.getItemId()) {
@@ -1217,7 +1217,7 @@ private boolean currentGameIsValid() {
12171217
&& getScidAppContext().getNoGames() > 0;
12181218
}
12191219

1220-
private final void getFen() {
1220+
private void getFen() {
12211221
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
12221222
i.setType("application/x-chess-fen");
12231223
try {
@@ -1586,7 +1586,7 @@ public void engineChanged(EngineChangeEvent event) {
15861586
engineManager.addEngine(engineName, executable, enginePackage, engineVersion);
15871587
}
15881588

1589-
private final void setFlipped(boolean flipped) {
1589+
private void setFlipped(boolean flipped) {
15901590
if(flipped != cb.flipped){
15911591
cb.setFlipped(flipped);
15921592
ImageButton flip_button = (ImageButton)findViewById(R.id.flip_board);
@@ -1680,7 +1680,7 @@ public void setThinkingInfo(String pvStr, String bookInfo,
16801680
updateThinkingInfo();
16811681
}
16821682

1683-
private final void updateThinkingInfo() {
1683+
private void updateThinkingInfo() {
16841684
boolean thinkingEmpty = true;
16851685
{
16861686
String s = "";
@@ -1782,8 +1782,7 @@ public void onClick(DialogInterface dialog, int whichButton) {
17821782
}
17831783
});
17841784
builder.setNegativeButton(android.R.string.cancel, null);
1785-
AlertDialog alert = builder.create();
1786-
return alert;
1785+
return builder.create();
17871786
}
17881787

17891788
private void showAboutDialog() {
@@ -1818,8 +1817,7 @@ public void onClick(DialogInterface dialog, int whichButton) {
18181817
dialog.cancel();
18191818
}
18201819
});
1821-
AlertDialog alert = builder.create();
1822-
return alert;
1820+
return builder.create();
18231821
}
18241822

18251823
private boolean hasNoDataBaseViewOpened() {
@@ -1882,8 +1880,7 @@ public void onClick(DialogInterface dialog, int item) {
18821880
}
18831881
}
18841882
});
1885-
AlertDialog alert = builder.create();
1886-
return alert;
1883+
return builder.create();
18871884
}
18881885

18891886
private AlertDialog createClipboardDialog() {
@@ -1975,8 +1972,7 @@ public void onClick(DialogInterface dialog, int item) {
19751972
}
19761973
}
19771974
});
1978-
AlertDialog alert = builder.create();
1979-
return alert;
1975+
return builder.create();
19801976
}
19811977

19821978
private AlertDialog createImportDialog() {
@@ -2006,8 +2002,7 @@ public void onClick(DialogInterface dialog, int item) {
20062002
}
20072003
}
20082004
});
2009-
AlertDialog alert = builder.create();
2010-
return alert;
2005+
return builder.create();
20112006
}
20122007

20132008
private void editBoard(String fen) {

0 commit comments

Comments
 (0)
Failed to load comments.