reformat the rename conditions a bit
This commit is contained in:
parent
5c144a607b
commit
1da4050d4a
3 changed files with 26 additions and 22 deletions
|
@ -242,7 +242,11 @@ public class MainActivity extends AppCompatActivity
|
|||
public void onClick(View v) {
|
||||
final String newDirName = dirNameET.getText().toString().trim();
|
||||
|
||||
if (!newDirName.isEmpty()) {
|
||||
if (newDirName.isEmpty()) {
|
||||
Utils.showToast(getApplicationContext(), R.string.rename_folder_empty);
|
||||
return;
|
||||
}
|
||||
|
||||
final File newDir = new File(dir.getParent(), newDirName);
|
||||
|
||||
if (dir.renameTo(newDir)) {
|
||||
|
@ -254,9 +258,6 @@ public class MainActivity extends AppCompatActivity
|
|||
} else {
|
||||
Utils.showToast(getApplicationContext(), R.string.rename_folder_error);
|
||||
}
|
||||
} else {
|
||||
Utils.showToast(getApplicationContext(), R.string.rename_folder_error);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -195,7 +195,11 @@ public class ViewPagerActivity extends AppCompatActivity
|
|||
final String fileName = fileNameET.getText().toString().trim();
|
||||
final String extension = extensionET.getText().toString().trim();
|
||||
|
||||
if (!fileName.isEmpty() && !extension.isEmpty()) {
|
||||
if (fileName.isEmpty() || extension.isEmpty()) {
|
||||
Utils.showToast(getApplicationContext(), R.string.rename_file_empty);
|
||||
return;
|
||||
}
|
||||
|
||||
final File newFile = new File(file.getParent(), fileName + "." + extension);
|
||||
|
||||
if (file.renameTo(newFile)) {
|
||||
|
@ -208,9 +212,6 @@ public class ViewPagerActivity extends AppCompatActivity
|
|||
} else {
|
||||
Utils.showToast(getApplicationContext(), R.string.rename_file_error);
|
||||
}
|
||||
} else {
|
||||
Utils.showToast(getApplicationContext(), R.string.rename_file_error);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
<string name="rename_file">Rename file</string>
|
||||
<string name="rename_folder">Rename folder</string>
|
||||
<string name="rename_file_error">Could not rename the file</string>
|
||||
<string name="rename_file_empty">File name must not be empty</string>
|
||||
<string name="rename_folder_error">Could not rename the folder</string>
|
||||
<string name="rename_folder_empty">Folder name must not be empty</string>
|
||||
<string name="rename_folder_ok">Folder renamed successfully</string>
|
||||
<string name="file_name">File name</string>
|
||||
<string name="folder_name">Folder name</string>
|
||||
|
|
Loading…
Reference in a new issue