I'm new to android.
I'm trying to select the file and read it in android java. To choose a file, I'm using https://android-arsenal.com/details/1/6982 file chooser library.
But it's showing that .with(this) is deprecated. What I can replace it with to get rid of the warning?
Screenshot of warning: https://imghostr.com/xapXZzqE
Literally just scroll down that page a bit and take a look at this:
New calling chain
1.1.7+, new constructor ChooserDialog(context) can simplify the chain invoking, such as:
new ChooserDialog(this)
.withFilter(true, false)
.withStartFile(startingDir)
...
Related
I am building a project which downloads several PDF files from different URLs, merges them into a single one and downloads it.
I'm trying to use Vaadin's FileDownloader to achieve this:
final FileDownloader fileDownloader = new FileDownloader(new FileResource(resultResource.getFile()));
fileDownloader.extend(download);
The resultResource is the generated PDF which I want to download.
Now the problem is that it takes a short time to generate the PDF, so that sometimes the download happens before the new file is generated, resulting in it downloading the old file, or an empty one.
So what I've been trying to do is something like this:
download.addClickListener(e -> {
try {
// This creates the new PDF
pdfConverter.manipulatePdf(storeNumber.getValue());
fileDownloader.download();
} catch (...) {
...
}
});
But so far without any success. Is there any way to something like this? To disable the "automatic" download and trigger it manually?
There are two approaches you can try
First approach is to refactor your UI so, that PDF file is started to be generated when you enter the view, and once complete you enable the download button. You can have other indicators like progress bar if that is feasible.
In Vaadin 8.4+ you can also setup FileDownloader by extending EventTrigger (see pull request https://github.com/vaadin/framework/pull/10478 ) and API spec https://vaadin.com/download/release/8.4/8.4.2/docs/api/com/vaadin/server/EventTrigger.html That could be something to be exploited if the first way is not applicable for you.
After adding compile 'org.webrtc:google-webrtc:1.0.+' to my build.gradle file I try to init PeerConnectionFactory, but this class has no any useful methods.
What am I doing wrong?
UPDATE:
enter image description here
The last version org.webrtc:google-webrtc:1.0.21217
You can init by following codes
PeerConnectionFactory.InitializationOptions.Builder optionBuilder =
PeerConnectionFactory.InitializationOptions.builder(/* Put context here */);
optionBuilder.setEnableInternalTracer(true);
optionBuilder.setFieldTrials("WebRTC-FlexFEC-03/Enabled/");
optionBuilder.setEnableVideoHwAcceleration(true);
PeerConnectionFactory.initialize(optionBuilder.createInitializationOptions());
First, try to use an specific version like: compile 'org.webrtc:google-webrtc:1.0.20198'
And then make sure you rebuild your project (not only refresh gradle, since it might not be enough for the autocomplete to work).
In your screenshot, it looks like you are trying to autocomplete outside of any method. Since Android Studio tries to only show you valid stuff, it won't display the other methods unless you write it on a valid context (i.e.: inside of some method's implementation).
In the IntelliJ IDEA I can create automatically a method.
I write the name of the method and if it doesn't exist, the IDE prompts to create it.
I want IDEA to paste the code //TODO: write method ${nameOfMethod} in the body, when it creates a new method automatically. How can I do that?
I found a solution.
The solution:
Open Settings.
Open File and Code Templates.
Open New Method Body.
Paste the code: //TODO: to write the method ${METHOD_NAME}
In Adobe Acrobat there is a possibility to add 'Open a web link action' to acroform. Is it possible to do so with iText usind already existing acroform?
I was unable to find any mention about it at iText docs and therefore tried to create new acrofield programmatically and add this action to it, but without success. Here's my code:
PdfReader pdfReader = new PdfReader(templateStream);
PdfStamper stamper = new PdfStamper(pdfReader, new FileOutputStream("delivery.pdf"));
stamper.setFormFlattening(true);
stamper.getAcroFields().setField("package", packages);
stamper.getAcroFields().setField("purchase_id", purchaseId);
stamper.getAcroFields().setField("activation_code", activationCode);
if (partner != "") {
PdfFormField field = PdfFormField.createTextField(stamper.getWriter(), false,
false, 100);
field.setFieldName("partner");
PdfAction action = new PdfAction(partner);
field.setAction(action);
field.setColor(new BaseColor(0,0,255));
PdfAppearance appearance = stamper.getUnderContent(1).
createAppearance(200, 20);
appearance.setFontAndSize(BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED), 12f);
appearance.setColorFill(BaseColor.BLUE);
field.setAppearance(PdfAnnotation.APPEARANCE_DOWN, appearance);
field.setDefaultAppearanceString(appearance);
stamper.getAcroFields().setField("partner", "Click here to show partner's web site");
}
The resulting PDF document is shown without partner field. Please point me to some docs or to mistake at my code.
You are trying to add interactivity to a form. However, you are also throwing away all interactivity by using this line:
stamper.setFormFlattening(true);
You also claim that you are adding an extra field. As far as I can see, that claim is false. You create a field name field (and you create it the hard way; I would expect you to use the TextField class instead). However, I don't see you adding that field anywhere. I miss the following line:
stamper.addAnnotation(field, 1);
Note that this line doesn't make sense:
stamper.getAcroFields().setField("partner", "Click here to show partner's web site");
Why would you create a field first (and possibly add a caption) and then change it immediately afterwards? Why not create the field correctly from the start?
Finally, it seems that you want to create a button that can be clicked by people. Then why are you creating a text field? Wouldn't it make more sense to create a push button?
This is an example of a question to which a machine would respond: Too many errors... Maybe you should consider reading the documentation before trying to fix your code.
I am trying to unserstand how GWTQuery works, for that I am trying out a simple demo with the slider. As per the documentation at Google (the slider tab is on the bottom left), and using the class AbstractSliderDemo from here, which in turn, is implementing the Demo interface defined here, my onModuleLoad simply contains:
Label e = $("#slider").widget();
Query q = new Query();
q.setupDemoElement(e.getElement());
However on page-load, it is throwing a NullPointer exception. Can anybody guide me how to use it. Probably I am missing something here. (I have added both GWTQuery and GWTQuery-UI jar files to the build path, as well as including <inherits name='gwtquery.plugins.Ui' /> in the XML file).
And here is the directory structure of my project:
GwtQuery-Ui is just a wrapper on jquery-ui. That means that you need to inject the jquery and jquery-ui javascript file. Check the getting started guide og GwtQuery-ui