| Chunk |
|---|
| Conflicting content |
|---|
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_save:
<<<<<<< HEAD
Toast.makeText(getApplicationContext(), "Implement me!", 3);
=======
saveToSdcard();
return true;
case R.id.menu_load:
loadFromSdcard();
>>>>>>> 7e64efb35e21a9ebd5b561b871f471211f0ee421
return true;
case R.id.menu_stroke_width:
showDialog(STROKE_WIDTH_DIALOG_ID); |
| Solution content |
|---|
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_save:
Toast.makeText(getApplicationContext(), "Implement me!", 3);
saveToSdcard();
return true;
case R.id.menu_load:
loadFromSdcard();
return true;
case R.id.menu_stroke_width:
showDialog(STROKE_WIDTH_DIALOG_ID); |
| File |
|---|
| WhiteBoardActivity.java |
| Developer's decision |
|---|
| Concatenation |
| Kind of conflict |
|---|
| Case statement |
| Method invocation |
| Return statement |
| Chunk |
|---|
| Conflicting content |
|---|
}
};
<<<<<<< HEAD
=======
private boolean saveToSdcard() {
if(!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
System.out.println("External storage not available");
return false;
}
String baseDir = Environment.getExternalStorageDirectory().getAbsolutePath();
File createDirs[] = {
new File(baseDir + "/Android"),
new File(baseDir + "/Android/data"),
new File(baseDir + "/Android/data/" + getClass().getPackage().getName()),
new File(baseDir + "/Android/data/" + getClass().getPackage().getName() + "/files")
};
for (File createDir : createDirs) {
if(!createDir.exists()) {
if(!createDir.mkdir()) {
System.out.println("Couldn't mkdir " + createDir.getAbsolutePath());
return false;
}
}
}
File file = new File(createDirs[createDirs.length - 1], "save.dat");
try {
mDataStore.serializeDataStore(new FileOutputStream(file));
} catch (FileNotFoundException e) {
e.printStackTrace();
return false;
} catch (IOException e) {
e.printStackTrace();
return false;
}
return true;
}
private boolean loadFromSdcard() {
if(!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
System.out.println("External storage not available");
return false;
}
String baseDir = Environment.getExternalStorageDirectory().getAbsolutePath();
File file = new File(baseDir + "/Android/data/" + getClass().getPackage().getName() + "/files", "save.dat");
try {
mDataStore.deserializeDataStore(new FileInputStream(file));
} catch (FileNotFoundException e) {
System.out.println("Could not load save file");
e.printStackTrace();
return false;
} catch (IOException e) {
System.out.println("I/O error loading save file");
e.printStackTrace();
return false;
}
return true;
}
@Override
public void colorChanged(int color) {
mWhiteBoardView.setPrimColor(color);
}
>>>>>>> 7e64efb35e21a9ebd5b561b871f471211f0ee421
} |
| Solution content |
|---|
}
};
private boolean saveToSdcard() {
if(!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
System.out.println("External storage not available");
return false;
}
String baseDir = Environment.getExternalStorageDirectory().getAbsolutePath();
File createDirs[] = {
new File(baseDir + "/Android"),
new File(baseDir + "/Android/data"),
new File(baseDir + "/Android/data/" + getClass().getPackage().getName()),
new File(baseDir + "/Android/data/" + getClass().getPackage().getName() + "/files")
};
for (File createDir : createDirs) {
if(!createDir.exists()) {
if(!createDir.mkdir()) {
System.out.println("Couldn't mkdir " + createDir.getAbsolutePath());
return false;
}
}
}
File file = new File(createDirs[createDirs.length - 1], "save.dat");
try {
mDataStore.serializeDataStore(new FileOutputStream(file));
} catch (FileNotFoundException e) {
e.printStackTrace();
return false;
} catch (IOException e) {
e.printStackTrace();
return false;
}
return true;
}
private boolean loadFromSdcard() {
if(!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
System.out.println("External storage not available");
return false;
}
String baseDir = Environment.getExternalStorageDirectory().getAbsolutePath();
File file = new File(baseDir + "/Android/data/" + getClass().getPackage().getName() + "/files", "save.dat");
try {
mDataStore.deserializeDataStore(new FileInputStream(file));
} catch (FileNotFoundException e) {
System.out.println("Could not load save file");
e.printStackTrace();
return false;
} catch (IOException e) {
System.out.println("I/O error loading save file");
e.printStackTrace();
return false;
}
return true;
}
} |
| File |
|---|
| WhiteBoardActivity.java |
| Developer's decision |
|---|
| Combination |
| Kind of conflict |
|---|
| Annotation |
| Method declaration |