1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-03 09:49:19 +02:00

Fix a bug with Ok button in FileChooser

This commit is contained in:
Dmitri Yuranov 2014-04-25 14:05:41 +02:00
parent 2db6151b21
commit ba3a866690

View file

@ -363,15 +363,14 @@ public class FileChooserActivity extends Activity {
mHistory = savedInstanceState.getParcelable(_History); mHistory = savedInstanceState.getParcelable(_History);
else else
mHistory = new HistoryStore<IFile>(DisplayPrefs._DefHistoryCapacity); mHistory = new HistoryStore<IFile>(DisplayPrefs._DefHistoryCapacity);
mHistory.addListener(new HistoryListener<IFile>() { mHistory.addListener(new HistoryListener<IFile>() {
@Override
@Override public void onChanged(History<IFile> history) {
public void onChanged(History<IFile> history) { int idx = history.indexOf(getLocation());
int idx = history.indexOf(getLocation()); mViewGoBack.setEnabled(idx > 0);
mViewGoBack.setEnabled(idx > 0); mViewGoForward.setEnabled(idx >= 0 && idx < history.size() - 1);
mViewGoForward.setEnabled(idx >= 0 && idx < history.size() - 1); }
} });
});
// full history // full history
if (savedInstanceState != null && savedInstanceState.get(_FullHistory) instanceof HistoryStore<?>) if (savedInstanceState != null && savedInstanceState.get(_FullHistory) instanceof HistoryStore<?>)
@ -1363,6 +1362,11 @@ public class FileChooserActivity extends Activity {
*/ */
createLocationButtons(path); createLocationButtons(path);
/*
* update UI elements
*/
updateUI(path);
if (listener != null) if (listener != null)
listener.onFinish(true, path); listener.onFinish(true, path);
}// onPostExecute() }// onPostExecute()
@ -1391,7 +1395,6 @@ public class FileChooserActivity extends Activity {
mHistory.truncateAfter(mLastPath); mHistory.truncateAfter(mLastPath);
mHistory.push(dir); mHistory.push(dir);
mFullHistory.push(dir); mFullHistory.push(dir);
checkUIForFolderCreation(dir);
} }
} }
}); });
@ -1586,7 +1589,6 @@ public class FileChooserActivity extends Activity {
} }
} }
}); });
checkUIForFolderCreation(preLoc);
} else { } else {
mViewGoBack.setEnabled(false); mViewGoBack.setEnabled(false);
} }
@ -1641,14 +1643,13 @@ public class FileChooserActivity extends Activity {
} }
} }
}); });
checkUIForFolderCreation(nextLoc);
} else { } else {
mViewGoForward.setEnabled(false); mViewGoForward.setEnabled(false);
} }
} }
};// mBtnGoForwardOnClickListener };// mBtnGoForwardOnClickListener
private void checkUIForFolderCreation(IFile dir){ private void updateUI(IFile dir){
final boolean isDirectoryWriteable = ((File)dir).canWrite(); final boolean isDirectoryWriteable = ((File)dir).canWrite();
mViewCreateFolder.setEnabled(isDirectoryWriteable); mViewCreateFolder.setEnabled(isDirectoryWriteable);
mBtnOk.setEnabled( mBtnOk.setEnabled(