Comments (6)
I've created a gist for that one: https://gist.github.com/SeppPenner/c72e3e3cd90702c42355a12b7bcad2c9
The main changes would be to add two methods:
public void setNegativeButton(@StringRes int textId, final DialogInterface.OnClickListener listener){
builder.setNegativeButton(textId, listener);
}
public void setOnCancelListener(DialogInterface.OnCancelListener listener){
builder.setOnCancelListener(listener);
}
put the builder variable globally:
//...
private @DrawableRes
int _iconRes = -1;
private @LayoutRes
int _layoutRes = -1;
private String _dateFormat;
private AlertDialog.Builder builder;
, update the build() method (removed the whole stuff with setting negative button here)
and adjust the check on top of the build() method like following:
public ChooserDialog build() {
if (_titleRes == 0 || _okRes == 0) {
throw new RuntimeException("withResources() should be called at first.");
}
//...
}
However, I do not know if this can be done in another way as it destroys the method chaining style the library is written in, but my suggestion would need to remove the with(Context) method and add this directly to the constructor:
public ChooserDialog(Context context) {
this._context = context;
builder = new AlertDialog.Builder(_context);
}
An empty constructor would then not exist any longer...
That's also why I didn't create a pull request for this topic.
from android-file-chooser.
yes, here is it
from android-file-chooser.
Thx for your suggestion.
I have another consideration is whether there is a way to make the new improvements and the old style method calling coexist.
Would you mind to separate your thoughts into 2 parts? The first one is some new functions if your think itβs useful or more convenient for every user. So I can simply merge it into new version. The other one I think thereβs some changes have to make to maintain the backwards compatibility.
from android-file-chooser.
Hi @hedzr, I will try to provide 1 (or more) pull requests in the future when I have time. I will check to provide backwards compatibility, too. (I know, my update was just a quick and dirty fix)
from android-file-chooser.
π, i'd maken a new release, because my hands are out of control. Hope it's useful.
from android-file-chooser.
Hi @hedzr. Did you already add my suggestions to your code? It seems so if I look to the ChooserDialog.java class:
public ChooserDialog withNegativeButton(@StringRes int cancelTitle,
final DialogInterface.OnClickListener listener) {
this._negativeRes = cancelTitle;
this._negativeListener = listener;
return this;
}
public ChooserDialog withNegativeButtonListener(final DialogInterface.OnClickListener listener) {
this._negativeListener = listener;
return this;
}
/**
* it's NOT recommended to use the `withOnCancelListener`, replace with `withNegativeButtonListener` pls.
*/
public ChooserDialog withOnCancelListener(final DialogInterface.OnCancelListener listener) {
this._cancelListener2 = listener;
return this;
}
In my opinion, this is already the solution I wanted to have :D
from android-file-chooser.
Related Issues (20)
- Button Background HOT 3
- FileFilter HOT 1
- User decides on choosing File or Folder HOT 3
- Folder added as an item while selecting multiple files HOT 3
- Can't Create Folders in External MicroSD card HOT 1
- Can't list SD card content at all HOT 3
- select multiple HOT 1
- DarkMode support HOT 1
- Quick change color method HOT 1
- error Theme.AppCompat theme HOT 3
- Its not displaying the files/folders for Android 10 HOT 4
- java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/appcompat/view/ContextThemeWrapper;
- when i run it only shows "...SDCardStorage" and nothing else HOT 1
- requestLegacyExternalStorage is ignored on api 30. HOT 1
- Unsolved reference: title_choose_file
- 1.2.0, AndroidX, missing styles like Theme.Appcompat.*?
- CancelListener is not working
- Unresolved reference: ChooserDialog
- Go
- Not working in android 11 and above HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-file-chooser.