mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2024-11-23 11:31:33 +01:00
DroidFish: Small simplification in "edit headers" function.
This commit is contained in:
parent
b39e5c7840
commit
09c270d533
|
@ -1339,10 +1339,9 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||
public void onClick(DialogInterface dialog, int item) {
|
||||
switch (finalActions.get(item)) {
|
||||
case EDIT_HEADERS: {
|
||||
ArrayList<String> tags = new ArrayList<String>();
|
||||
ArrayList<String> tagValues = new ArrayList<String>();
|
||||
ctrl.getHeaders(tags, tagValues);
|
||||
|
||||
final TreeMap<String,String> headers = new TreeMap<String,String>();
|
||||
ctrl.getHeaders(headers);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(DroidFish.this);
|
||||
builder.setTitle(R.string.edit_headers);
|
||||
View content = View.inflate(DroidFish.this, R.layout.edit_headers, null);
|
||||
|
@ -1357,10 +1356,6 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||
white = (TextView)content.findViewById(R.id.ed_header_white);
|
||||
black = (TextView)content.findViewById(R.id.ed_header_black);
|
||||
|
||||
final TreeMap<String,String> headers = new TreeMap<String,String>();
|
||||
for (int i = 0; i < tags.size(); i++)
|
||||
headers.put(tags.get(i), tagValues.get(i));
|
||||
|
||||
event.setText(headers.get("Event"));
|
||||
site .setText(headers.get("Site"));
|
||||
date .setText(headers.get("Date"));
|
||||
|
@ -1377,20 +1372,11 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||
headers.put("Round", round.getText().toString().trim());
|
||||
headers.put("White", white.getText().toString().trim());
|
||||
headers.put("Black", black.getText().toString().trim());
|
||||
|
||||
ArrayList<String> tags = new ArrayList<String>();
|
||||
ArrayList<String> tagValues = new ArrayList<String>();
|
||||
for (String k : headers.keySet()) {
|
||||
tags.add(k);
|
||||
tagValues.add(headers.get(k));
|
||||
}
|
||||
|
||||
ctrl.setHeaders(tags, tagValues);
|
||||
ctrl.setHeaders(headers);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
builder.show();
|
||||
|
||||
break;
|
||||
}
|
||||
case EDIT_COMMENTS: {
|
||||
|
@ -1431,7 +1417,6 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||
});
|
||||
|
||||
builder.show();
|
||||
|
||||
break;
|
||||
}
|
||||
case REMOVE_SUBTREE:
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.petero.droidfish.gamelogic;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.petero.droidfish.BookOptions;
|
||||
import org.petero.droidfish.GUIInterface;
|
||||
|
@ -901,14 +902,14 @@ public class DroidChessController {
|
|||
}
|
||||
}
|
||||
|
||||
public final void setHeaders(ArrayList<String> tags, ArrayList<String> tagValues) {
|
||||
game.tree.setHeaders(tags, tagValues);
|
||||
public final void setHeaders(Map<String,String> headers) {
|
||||
game.tree.setHeaders(headers);
|
||||
gameTextListener.clear();
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
public final void getHeaders(ArrayList<String> tags, ArrayList<String> tagValues) {
|
||||
game.tree.getHeaders(tags, tagValues);
|
||||
public final void getHeaders(Map<String,String> headers) {
|
||||
game.tree.getHeaders(headers);
|
||||
}
|
||||
|
||||
public static final class CommentInfo {
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.util.Calendar;
|
|||
import java.util.Collections;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.petero.droidfish.PGNOptions;
|
||||
import org.petero.droidfish.gamelogic.Game.GameState;
|
||||
|
@ -1362,10 +1363,9 @@ public class GameTree {
|
|||
}
|
||||
}
|
||||
|
||||
void setHeaders(ArrayList<String> tags, ArrayList<String> vals) {
|
||||
for (int i = 0 ; i < tags.size(); i++) {
|
||||
String tag = tags.get(i);
|
||||
String val = vals.get(i);
|
||||
void setHeaders(Map<String,String> headers) {
|
||||
for (String tag : headers.keySet()) {
|
||||
String val = headers.get(tag);
|
||||
if (tag.equals("Event")) event = val;
|
||||
else if (tag.equals("Site")) site = val;
|
||||
else if (tag.equals("Date")) date = val;
|
||||
|
@ -1391,16 +1391,16 @@ public class GameTree {
|
|||
}
|
||||
}
|
||||
|
||||
void getHeaders(ArrayList<String> tags, ArrayList<String> vals) {
|
||||
tags.add("Event"); vals.add(event);
|
||||
tags.add("Site"); vals.add(site);
|
||||
tags.add("Date"); vals.add(date);
|
||||
tags.add("Round"); vals.add(round);
|
||||
tags.add("White"); vals.add(white);
|
||||
tags.add("Black"); vals.add(black);
|
||||
void getHeaders(Map<String,String> headers) {
|
||||
headers.put("Event", event);
|
||||
headers.put("Site", site);
|
||||
headers.put("Date", date);
|
||||
headers.put("Round", round);
|
||||
headers.put("White", white);
|
||||
headers.put("Black", black);
|
||||
for (int i = 0; i < tagPairs.size(); i++) {
|
||||
tags.add(tagPairs.get(i).tagName);
|
||||
vals.add(tagPairs.get(i).tagValue);
|
||||
TagPair tp = tagPairs.get(i);
|
||||
headers.put(tp.tagName, tp.tagValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user