Once you have setup the Retrofit environment in your project, you can use the following example that demonstrates how to upload multiple files using Retrofit:
private void mulipleFileUploadFile(Uri[] fileUri) {
OkHttpClient okHttpClient = new OkHttpClient();
OkHttpClient clientWith30sTime...
This is the advanced approach with example
class FundsController < ApplicationController
def index
@funds = Fund.all_funds(current_user)
end
def show
@fund = Fund.find(params[:id])
respond_to do |format|
format.html
format.pdf do
pdf = FundsPdf....
Without a try catch block, undefined functions will throw errors and stop execution:
undefinedFunction("This will not get executed");
console.log("I will never run because of the uncaught error!");
Will throw an error and not run the second line:
// Uncaught ReferenceError:...
gradlew tasks -- show all tasks
Android tasks
-------------
androidDependencies - Displays the Android dependencies of the project.
signingReport - Displays the signing info for each variant.
sourceSets - Prints out all the source sets defined in this project.
Build tasks
-----------...
The advantages of using Session State are
1)Better security
2)Reduced bandwidth
The disadvantages of using Session state are
1)More resource consumption of server.
2)Extra code/care if a Web farm is used(we will discuss this shortly)
**Session State Modes**
...
To make a new directory from a File instance you would need to use one of two methods: mkdirs() or mkdir().
mkdir() - Creates the directory named by this abstract pathname. (source)
mkdirs() - Creates the directory named by this abstract pathname, including any necessary but nonexistent parent d...
For more complex applications, you'll want to build up a ``settings.json` object using multiple environment variables.
if(Meteor.isServer){
Meteor.startup(function()){
// this needs to be run on the server
var environment, settings;
environment = process.env.METEOR_ENV || "...
We can load components in two ways.
By initialize or override $components property in Controller
By using loadComponent() method in initialize() method of Controller.
Way-1
It should be override loading component by AppsController.php
load one or more component
class UsersController extend...
dependencies {
compile 'com.google.code.gson:gson:2.8.1'
}
To use latest version of Gson
The below line will compile latest version of gson library everytime you compile, you do not have to change version.
Pros: You can use latest features, speed and less bugs.
Cons: It might break com...
This will load a JSON file from disk and convert it to the given type.
public static <T> T getFile(String fileName, Class<T> type) throws FileNotFoundException {
Gson gson = new GsonBuilder()
.create();
FileReader json = new FileReader(fileName);
return gson....
Sometimes you need to serialize or deserialize some fields in a desired format, for example your backend may use the format "YYYY-MM-dd HH:mm" for dates and you want your POJOS to use the DateTime class in Joda Time.
In order to automatically convert these strings into DateTimes object, y...
To enable or disable a BroadcastReceiver, we need to get a reference to the PackageManager and we need a ComponentName object containing the class of the receiver we want to enable/disable:
ComponentName componentName = new ComponentName(context, MyBroadcastReceiver.class);
PackageManager packageM...
Add a init.gradle to your user gradle folder. The init.gradle is recognized on every project.
Unix: ~/.gradle/init.gradle
These are also alternative locations where init script can be placed and
loaded automatically:-
Any *.gradle file in USER_HOME/.gradle/init.d
Any *.gradle file in t...
eof returns true only after reading the end of file. It does NOT indicate that the next read will be the end of stream.
while (!f.eof())
{
// Everything is OK
f >> buffer;
// What if *only* now the eof / fail bit is set?
/* Use `buffer` */
}
You could correctly write:
...
When working with large files, you can use the System.IO.File.ReadLines method to read all lines from a file into an IEnumerable<string>. This is similar to System.IO.File.ReadAllLines, except that it doesn't load the whole file into memory at once, making it more efficient when working with l...
Another straightforward way to go is to create a dictionary of functions:
switch = {
1: lambda: 'one',
2: lambda: 'two',
42: lambda: 'the answer of life the universe and everything',
}
then you add a default function:
def default_case():
raise Exception('No case found!')
...
Overloading is the creation of more than one procedure, instance constructor, or property in a class with the same name but different argument types.
Class Person
Overloads Sub Display(ByVal theChar As Char)
' Add code that displays Char data.
End Sub
Overloads Sub Display...