mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-03 09:49:19 +02:00
fixed possible NPE + formatting
This commit is contained in:
parent
68eada9752
commit
95743e388b
1 changed files with 28 additions and 27 deletions
|
@ -309,7 +309,7 @@ public class FileChooserActivity extends Activity {
|
||||||
* THEME
|
* THEME
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (getIntent().hasExtra(_Theme)) {
|
if (getIntent().hasExtra(_Theme)) {
|
||||||
int theme;
|
int theme;
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
|
||||||
|
@ -320,7 +320,7 @@ public class FileChooserActivity extends Activity {
|
||||||
theme = getIntent().getIntExtra(_Theme, android.R.style.Theme);
|
theme = getIntent().getIntExtra(_Theme, android.R.style.Theme);
|
||||||
setTheme(theme);
|
setTheme(theme);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.afc_file_chooser);
|
setContentView(R.layout.afc_file_chooser);
|
||||||
|
@ -351,10 +351,10 @@ public class FileChooserActivity extends Activity {
|
||||||
mViewSort = (ImageView) findViewById(R.id.afc_filechooser_activity_button_sort);
|
mViewSort = (ImageView) findViewById(R.id.afc_filechooser_activity_button_sort);
|
||||||
mViewFoldersView = (ImageView) findViewById(R.id.afc_filechooser_activity_button_folders_view);
|
mViewFoldersView = (ImageView) findViewById(R.id.afc_filechooser_activity_button_folders_view);
|
||||||
mViewCreateFolder = (ImageView) findViewById(R.id.afc_filechooser_activity_button_create_folder);
|
mViewCreateFolder = (ImageView) findViewById(R.id.afc_filechooser_activity_button_create_folder);
|
||||||
if (!getIntent().getBooleanExtra(_ShowNewFolderButton, true)) {
|
if (!getIntent().getBooleanExtra(_ShowNewFolderButton, true)) {
|
||||||
mViewCreateFolder.setVisibility(View.GONE);
|
mViewCreateFolder.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
mFilenameRegexp = getIntent().getStringExtra(_FilenameRegExp);
|
mFilenameRegexp = getIntent().getStringExtra(_FilenameRegExp);
|
||||||
mViewGoBack = (ImageView) findViewById(R.id.afc_filechooser_activity_button_go_back);
|
mViewGoBack = (ImageView) findViewById(R.id.afc_filechooser_activity_button_go_back);
|
||||||
mViewGoForward = (ImageView) findViewById(R.id.afc_filechooser_activity_button_go_forward);
|
mViewGoForward = (ImageView) findViewById(R.id.afc_filechooser_activity_button_go_forward);
|
||||||
mViewLocations = (ViewGroup) findViewById(R.id.afc_filechooser_activity_view_locations);
|
mViewLocations = (ViewGroup) findViewById(R.id.afc_filechooser_activity_view_locations);
|
||||||
|
@ -458,10 +458,10 @@ public class FileChooserActivity extends Activity {
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
IFile currentLoc = getLocation();
|
IFile currentLoc = getLocation();
|
||||||
if (currentLoc == null || mHistory == null) {
|
if (currentLoc == null || mHistory == null) {
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IFile preLoc = null;
|
IFile preLoc = null;
|
||||||
while (currentLoc.equalsToPath(preLoc = mHistory.prevOf(currentLoc)))
|
while (currentLoc.equalsToPath(preLoc = mHistory.prevOf(currentLoc)))
|
||||||
|
@ -1048,13 +1048,14 @@ public class FileChooserActivity extends Activity {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final IFileProvider fileProvider = mFileProvider;
|
final IFileProvider fileProvider = mFileProvider;
|
||||||
if (fileProvider == null) {
|
final IFile location = getLocation();
|
||||||
return;
|
if (fileProvider == null || location == null) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
IFile dir = fileProvider.fromPath(String
|
IFile dir = fileProvider.fromPath(String
|
||||||
.format("%s/%s", getLocation().getAbsolutePath(), name));
|
.format("%s/%s", location.getAbsolutePath(), name));
|
||||||
if (dir.mkdir()) {
|
if (dir.mkdir()) {
|
||||||
Dlg.toast(FileChooserActivity.this, getString(R.string.afc_msg_done), Dlg._LengthShort);
|
Dlg.toast(FileChooserActivity.this, getString(R.string.afc_msg_done), Dlg._LengthShort);
|
||||||
setLocation(getLocation(), null);
|
setLocation(getLocation(), null);
|
||||||
|
@ -1509,13 +1510,13 @@ public class FileChooserActivity extends Activity {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DirectoriesOnly:
|
case DirectoriesOnly:
|
||||||
{
|
{
|
||||||
final File file = (File)getLocation();
|
final File file = (File)getLocation();
|
||||||
if (file != null && file.canWrite()) {
|
if (file != null && file.canWrite()) {
|
||||||
returnPath = getLocation().getAbsolutePath();
|
returnPath = getLocation().getAbsolutePath();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FilesAndDirectories:
|
case FilesAndDirectories:
|
||||||
if(files == null || files.isEmpty()){
|
if(files == null || files.isEmpty()){
|
||||||
returnPath = getLocation().getAbsolutePath();
|
returnPath = getLocation().getAbsolutePath();
|
||||||
|
@ -1676,9 +1677,9 @@ public class FileChooserActivity extends Activity {
|
||||||
final boolean isDirectoryWriteable = ((File)dir).canWrite();
|
final boolean isDirectoryWriteable = ((File)dir).canWrite();
|
||||||
mViewCreateFolder.setEnabled(isDirectoryWriteable);
|
mViewCreateFolder.setEnabled(isDirectoryWriteable);
|
||||||
mBtnOk.setEnabled(
|
mBtnOk.setEnabled(
|
||||||
isDirectoryWriteable ||
|
isDirectoryWriteable ||
|
||||||
mFileProvider.getFilterMode() == IFileProvider.FilterMode.AnyDirectories
|
mFileProvider.getFilterMode() == IFileProvider.FilterMode.AnyDirectories
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final View.OnLongClickListener mBtnGoBackForwardOnLongClickListener = new View.OnLongClickListener() {
|
private final View.OnLongClickListener mBtnGoBackForwardOnLongClickListener = new View.OnLongClickListener() {
|
||||||
|
@ -1909,16 +1910,16 @@ public class FileChooserActivity extends Activity {
|
||||||
else {
|
else {
|
||||||
if (mIsMultiSelection) {
|
if (mIsMultiSelection) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mIsSaveDialog) {
|
if (mIsSaveDialog) {
|
||||||
doCheckSaveasFilenameAndFinish(data.getFile().getName());
|
doCheckSaveasFilenameAndFinish(data.getFile().getName());
|
||||||
} else {
|
} else {
|
||||||
final IFileAdapter.Bag bag = (IFileAdapter.Bag)view.getTag();
|
final IFileAdapter.Bag bag = (IFileAdapter.Bag)view.getTag();
|
||||||
if (bag != null && bag.mIsAccessible) {
|
if (bag != null && bag.mIsAccessible) {
|
||||||
doFinish(data.getFile());
|
doFinish(data.getFile());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}// single tap to choose files
|
}// single tap to choose files
|
||||||
}// onItemClick()
|
}// onItemClick()
|
||||||
};// mViewFilesOnItemClickListener
|
};// mViewFilesOnItemClickListener
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue