onFailure (Call as Amir_CallBack As , Message as String As )
onResponse (Call as Amir_CallBack As , Response as Amir_RetrofitResponse As , Body as Amir_ResponseBody As )
Methods:
isCanceled Asboolean True if was called.
isExecuted Asboolean Returns true if this call has been either Executed or Enqueued.
It is an error to execute or enqueue a call more than once.
Execute Asaghajari.retrofit.Amir_RetrofitResponse Synchronously send the request and return its response.
_________________________________________________________
NetworkOnMainThread exception : You Should Disable Strict Mode!
_________________________________________________________
Example :
DisableStrictMode
Dim Call As Amir_CallBack = _
Retrofit.RequestWithCallback(Null,"Get",Array ("URL",CreateMap()))
Dim Response As Amir_RetrofitResponse = Call.Execute
Log(Response.isSuccessful)
Sub DisableStrictMode
Dim jo As JavaObject
jo.InitializeStatic("android.os.Build.VERSION")
If jo.GetField("SDK_INT") > 9 Then
Dim policy As JavaObject
policy = policy.InitializeNewInstance("android.os.StrictMode.ThreadPolicy.Builder", Null)
policy = policy.RunMethodJO("permitAll", Null).RunMethodJO("build", Null)
Dim sm As JavaObject
sm.InitializeStatic("android.os.StrictMode").RunMethod("setThreadPolicy", Array(policy))
End If
End Sub
Cancel Asvoid Cancel this call. An attempt will be made to cancel in-flight calls, and if the call has not
yet been executed it never will be.
Enqueue (ba Asanywheresoftware.b4a.BA, EventName Asjava.lang.String, Sender Asjava.lang.Object)Asvoid Asynchronously send the request and notify callback of its response or if an error
occurred talking to the server, creating the request, or processing the response.
_____________________________________________________________________________________
Example :
Dim Call As Amir_CallBack = _
Retrofit.RequestWithCallback(Null,"Post",Array ("URL",PARAMS))
Call.Enqueue("Amir",Null)
Sub Amir_onResponse (Call As Amir_CallBack,Response As Amir_RetrofitResponse,Body As Amir_ResponseBody)
If Response.isSuccessful Then
Log(Body.String)
Else
Log(Response.ErrorBody.String)
End If
End Sub
Sub Amir_onFailure (Call As Amir_CallBack,Message As String)
Log(Message)
End Sub
RequestHeaders (name Asjava.lang.String)Asjava.util.List The original HTTP RequestHeaders.
fromJsonTree2 (JsonString Asjava.lang.String, Type Asjava.lang.String)Asjava.lang.Object Get Json Tree Use com.google.gson.JsonParser
Example :
Dim src As String = Json.fromJsonTree("JsonString","String")
isJsonArray (JsonString Asjava.lang.String)Asboolean provides check for verifying if this element is an array or not.
Initialize Asvoid Object Name : GSON (Hide)
fromJsonTree (JsonString Asjava.lang.String, Type Asjava.lang.String)Asjava.lang.Object Get Json Tree
Example :
Dim src As String = Json.fromJsonTree("JsonString","String")
isJSONValid (jsonInString Asjava.lang.String)Asboolean check whether a given string Can Parse in JsonParser or no
Use JsonSyntaxException
Example :
if Json.isJSONValid("JsonString") then
'Now You Can parse this jsonString
End if
isJsonPrimitive (JsonString Asjava.lang.String)Asboolean provides check for verifying if this element is a primitive or not.
getAsList (JsonString Asjava.lang.String)Asjava.util.List Get List Of Objects
Initialize2 (Builder Asaghajari.retrofit.Amir_JsonBuilder)Asvoid Initialize With Custom GsonBuilder
ToJson (src Asjava.lang.Object)Asjava.lang.String
isJsonObject (JsonString Asjava.lang.String)Asboolean provides check for verifying if this element is a Json object or not.
isJSONValidMessage (jsonInString Asjava.lang.String)Asjava.lang.String Return OK Or Error Message
isJSONValid3 (jsonInString Asjava.lang.String)Asboolean check whether a given string is valid json or no | Start With { or [ And
Ends With } or ] | Use JsonSyntaxException.
Example :
if Json.isJSONValid("JsonString") And RB.isJSONValid3("JsonString") then
'Now You Can parse this jsonString
End if
isJSONValid2 (jsonInString Asjava.lang.String)Asboolean check whether a given string Can Parse and use in JsonParser or no
Use JsonSyntaxException
Example :
if Json.isJSONValid2("JsonString") then
'Now You Can parse this jsonString
End if
ToJsonTree2 (src Asjava.lang.Object, Type Asjava.lang.String)Asjava.lang.Object Get Json Tree
Example :
Dim JsonString As String = Json.toJsonTree2("mySrc","String")
Remove2 (key Asjava.lang.Object, value Asjava.lang.Object)Asjava.lang.Object
ContainsValue (value Asjava.lang.Object)Asboolean Returns true if this map maps one or more keys to the specified value.
More formally, returns true if and only if this map contains at least
one mapping to a value v such that (value==null ? v==null : value.equals(v)).
This operation will probably require time linear in the map size for
most implementations.
Parameters:
value whose presence in this map is to be tested
Returns:
true if a mapping to value exists; false otherwise
GetMap Asanywheresoftware.b4a.objects.collections.Map Convert Json TreeMap To B4A Map
Useing entrySet...
Example :
Dim M as Map = JsonMap.GetMap
Log(M.Get("Key"))
Remove (key Asjava.lang.Object)Asjava.lang.Object Removes the mapping for this key from this TreeMap if present.
Parameters:
key for which mapping should be removed
Returns:
the previous value associated with key, or null if there was no
mapping for key. (A null return can also indicate that the map
previously associated null with key.)
Initialize (Linked Asjava.lang.Object)Asvoid Initialize With set Auto Map
Example :
Sub Amir_onNext (ResponseBody as Amir_ResponseBody)
'Get String of Request
Dim Json As Amir_Json
Json.Initialize
Dim Res as String = ResponseBody.String
'example : [{id=0, name=amir},{id=1, name=retrofit}]
Log(Json.fromJson(Res))
'Check Json
if Json.isJsonArray(Res) Then
'Convert To List
Dim List as List = Json.fromJson(Res)
'List Item's To Amir_JsonMap
For i = 0 to List.Size-1
Dim Json as Amir_JsonMap
Json.Initialize(List.Get(i))
Log(Json.Get("name"))
Next
End if
End Sub
Put (key Asjava.lang.Object, value Asjava.lang.Object)Asvoid Associates the specified value with the specified key in this map.
If the map previously contained a mapping for the key, the old value
is replaced.
Parameters:
key with which the specified value is to be associated
value to be associated with the specified key
Returns:
the previous value associated with key, or null if there was no mapping
for key. (A null return can also indicate that the map previously
associated null with key.)
ContainsKey (key Asjava.lang.Object)Asboolean Returns true if this map contains a mapping for the specified key.
Parameters:
key whose presence in this map is to be tested
Returns:
true if this map contains a mapping for the specified key
Clear Asvoid Removes all of the mappings from this map. The map will be
empty after this call returns.
Equals (arg Asjava.lang.Object)Asboolean Compares the specified object with this map for equality.
Returns true if the given object is also a map and the two maps
represent the same mappings. More formally, two maps m1 and m2
represent the same mappings if m1.entrySet().equals(m2.entrySet()).
This ensures that the equals method works properly across different
implementations of the Map interface. This implementation first
checks if the specified object is this map; if so it returns true.
Then, it checks if the specified object is a map whose size is
identical to the size of this map; if not, it returns false. If so,
it iterates over this map's entrySet collection, and checks that the
specified map contains each mapping that this map contains. If the
specified map fails to contain such a mapping, false is returned.
If the iteration completes, true is returned.
Parameters:
object to be compared for equality with this map
Returns:
true if the specified object is equal to this map
Initialize4 (isTreeMap Asboolean)Asvoid Create New LinkedTreeMap Or LinkedHashTreeMap
Get (key Asjava.lang.Object)Asjava.lang.Object Returns the value to which the specified key is mapped, or null if
this map contains no mapping for the key. More formally, if this map
contains a mapping from a key k to a value v such that key compares
equal to k according to the map's ordering, then this method returns v;
otherwise it returns null. (There can be at most one such mapping.)
A return value of null does not necessarily indicate that the map
contains no mapping for the key; it's also possible that the map
explicitly maps the key to null. The containsKey operation may be used
to distinguish these two cases.
PutAll (arg Asjava.util.Map)Asvoid Copies all of the mappings from the specified map to this map. These
mappings replace any mappings that this map had for any of the keys
currently in the specified map.
Parameters:
map mappings to be stored in this map
GetOrDefault (arg0 Asjava.lang.Object, arg1 Asjava.lang.Object)Asjava.lang.Object Try To Get Value From Key (arg0)
if key is null : get a Defualt Value(arg1)
Size Asint[read only] Returns the number of key-value mappings in this map.
Keys Asjava.lang.Object[][read only] Returns a Array of the keys contained in this map
Values Asjava.lang.Object[][read only] Returns a List of the values contained in this map.
isEmpty Asboolean[read only] This implementation returns size() == 0.
Amir_JsonBuilder
Events:
ShouldSkipClass (ClassName AsString))
ShouldSkipField (FieldAttributesName AsString))
TranslateName (FieldName as String) as Strin As )
Fields:
IDENTITY Asjava.lang.String
UPPER_CAMEL_CASE_WITH_SPACES Asjava.lang.String
UPPER_CAMEL_CASE Asjava.lang.String
LOWER_CASE_WITH_UNDERSCORES Asjava.lang.String
STRING Asjava.lang.String
DEFAULT Asjava.lang.String
LOWER_CASE_WITH_DASHES Asjava.lang.String
Methods:
setFieldNamingPolicy (name Asjava.lang.String)Asaghajari.retrofit.Amir_JsonBuilder Configures Gson to apply a specific naming policy to an object's field during serialization
and deserialization.
IDENTITY | LOWER_CASE_WITH_DASHES | LOWER_CASE_WITH_UNDERSCORES
UPPER_CAMEL_CASE | UPPER_CAMEL_CASE_WITH_SPACES
GenerateNonExecutableJson Asaghajari.retrofit.Amir_JsonBuilder Makes the output JSON non-executable in Javascript by prefixing the generated JSON with some
special text. This prevents attacks from third-party sites through script sourcing.
setVersion (ignoreVersionsAfter Asdouble)Asaghajari.retrofit.Amir_JsonBuilder Configures Gson to enable versioning support.
ignoreVersionsAfter : any field or type marked with a version higher than this value
are ignored during serialization or deserialization.
ExcludeFieldsWithModifiers (modifiers Asint[])Asaghajari.retrofit.Amir_JsonBuilder Configures Gson to excludes all class fields that have the specified modifiers. By default,
Gson will exclude all fields marked transient or static. This method will override that
behavior.
SerializeNulls Asaghajari.retrofit.Amir_JsonBuilder Configure Gson to serialize null fields. By default, Gson omits all fields that are null
during serialization.
setFieldNamingStrategy (ba Asanywheresoftware.b4a.BA, EventName Asjava.lang.String)Asaghajari.retrofit.Amir_JsonBuilder Configures Gson to apply a specific naming policy strategy to an object's field during
serialization and deserialization.
Events : EventName_TranslateName (FieldName as String) as String
DisableInnerClassSerialization Asaghajari.retrofit.Amir_JsonBuilder Configures Gson to exclude inner classes during serialization.
Initialize Asaghajari.retrofit.Amir_JsonBuilder
setLenient Asaghajari.retrofit.Amir_JsonBuilder By default, Gson is strict and only accepts JSON as specified by
RFC 4627. This option makes the parser
liberal in what it accepts.
DisableHtmlEscaping Asaghajari.retrofit.Amir_JsonBuilder By default, Gson escapes HTML characters such as < > etc. Use this option to configure
Gson to pass-through HTML characters as is.
addSerializationExclusionStrategy (ba Asanywheresoftware.b4a.BA, EventName Asjava.lang.String)Asaghajari.retrofit.Amir_JsonBuilder Configures Gson to apply the passed in exclusion strategy during serialization.
If this method is invoked numerous times with different exclusion strategy objects
then the exclusion strategies that were added will be applied as a disjunction rule.
This means that if one of the added exclusion strategies suggests that a field (or
class) should be skipped then that field (or object) is skipped during its
serialization.
Events : EventName_ShouldSkipClass (ClassName As String) As Boolean EventName_ShouldSkipField (FieldAttributesName As String) As Boolean
addDeserializationExclusionStrategy (ba Asanywheresoftware.b4a.BA, EventName Asjava.lang.String)Asaghajari.retrofit.Amir_JsonBuilder Configures Gson to apply the passed in exclusion strategy during deserialization.
If this method is invoked numerous times with different exclusion strategy objects
then the exclusion strategies that were added will be applied as a disjunction rule.
This means that if one of the added exclusion strategies suggests that a field (or
class) should be skipped then that field (or object) is skipped during its
deserialization.
Events : EventName_ShouldSkipClass (ClassName As String) As Boolean EventName_ShouldSkipField (FieldAttributesName As String) As Boolean
SerializeSpecialFloatingPointValues Asaghajari.retrofit.Amir_JsonBuilder Section 2.4 of JSON specification disallows
special double values (NaN, Infinity, -Infinity). However,
Javascript specification (see section 4.3.20, 4.3.22, 4.3.23) allows these values as valid
Javascript values. Moreover, most JavaScript engines will accept these special values in JSON
without problem. So, at a practical level, it makes sense to accept these values as valid
JSON even though JSON specification disallows them.
setLongSerializationPolicy (name Asjava.lang.String)Asaghajari.retrofit.Amir_JsonBuilder Configures Gson to apply a specific serialization policy for {@code Long} and {@code long}
objects.
DEFAULT | STRING
setPrettyPrinting Asaghajari.retrofit.Amir_JsonBuilder Configures Gson to output Json that fits in a page for pretty printing. This option only
affects Json serialization.
ExcludeFieldsWithoutExposeAnnotation Asaghajari.retrofit.Amir_JsonBuilder Configures Gson to exclude all fields from consideration for serialization or deserialization
that do not have the com.google.gson.annotations.Expose annotation.
EnableComplexMapKeySerialization Asaghajari.retrofit.Amir_JsonBuilder Enabling this feature will only change the serialized form if the map key is
a complex type (i.e. non-primitive) in its serialized JSON
form. The default implementation of map serialization uses toString()
on the key; however, when this is called then one of the following cases
Release Asvoid Release This Response.
Example :
if RespnseBody.isReleased=False then
RespnseBody.Release
End if
Properties:
Bytes Asbyte[][read only] Returns the response as a byte array.
This method loads entire response body into memory. If the response body is very large this
may trigger an OutOfMemoryError. Prefer to stream the response body if this is a
possibility for your response.
Type Asjava.lang.String[read only] Returns the Content-Type header for this body.
SubType Asjava.lang.String[read only] Returns the Content-SubType header for this body.
byteStream Asjava.io.InputStream[read only]
Length Aslong[read only] Returns the number of bytes in that will returned by bytes, or byteStream, or
-1 if unknown.
Charset Asjava.lang.String[read only]
String Asjava.lang.String[read only] Returns the response as a string decoded with the charset of the Content-Type header. If that
header is either absent or lacks a charset, this will attempt to decode the response body in
accordance to its BOM or UTF-8. Closes ResponseBody automatically.
This method loads entire response body into memory. If the response body is very large this
may trigger an OutOfMemoryError. Prefer to stream the response body if this is a
possibility for your response.
What is BOM? : Byte order mark | More|https://en.wikipedia.org/wiki/Byte_order_mark
sourceStream Asjava.io.InputStream[read only]
Methods:
Byte (content Asbyte[])Asvoid
String (content Asjava.lang.String)Asvoid
Amir_RetrofitManager
Methods:
CancelByUrls (Urls Asjava.lang.String[], ba Asanywheresoftware.b4a.BA)Asvoid Cancel Requests
Event :
RequestEventName_onCancel
CancelByUrl (Url Asjava.lang.String, ba Asanywheresoftware.b4a.BA)Asvoid Cancel Request By Url
Event :
RequestEventName_onCancel
IsUnsubscribed (Url Asjava.lang.String)Asboolean Check the Whether Is Unsubscribed
CancelAll (ba Asanywheresoftware.b4a.BA)Asvoid Cancel All Requests
Event :
RequestEventName_onCancel
ContainsUrl (Url Asjava.lang.String)Asboolean
Properties:
RequestsSize Asint[read only]
RunningUrls Asjava.util.List[read only]
RunningRequestsSize Asint[read only]
Urls Asjava.util.List[read only]
Amir_RetrofitRequest
Methods:
Start2 (Retrofit Asaghajari.retrofit.Retrofit)Asaghajari.retrofit.Amir_RetrofitRequest Start Request With Custom Retrofit
Start Asaghajari.retrofit.Amir_RetrofitRequest Start Request With Last Retrofit
if You have not used Request , set the retrofit
Example :
Request.Retrofit=Retrofit
Retrofit.Sender=Request.Sender
Request=Request.Start
StartHandshake Asvoid Starts a new SSL handshake on this connection.
IsInitialized Asboolean
Properties:
SSLParameters Asjavax.net.ssl.SSLParameters Returns a new SSLParameters based on this SSLSocket's current
cipher suites, protocols, and client authentication settings.
since 1.6
UseClientMode Asboolean Returns true if this connection will act in client mode when handshaking.
SupportedProtocols Asjava.lang.String[][read only] Returns the names of the supported protocols.
NeedClientAuth Asboolean Returns true if the server socket should require client authentication.
This does not apply to sockets in getUseClientMode() client mode.
WantClientAuth Asboolean Returns true if the server should request client authentication. This
does not apply to sockets in getUseClientMode() client mode.
EnabledProtocols Asjava.lang.String[] Returns the names of the enabled protocols.
EnableSessionCreation Asboolean Returns whether new SSL sessions may be created by this socket or if
existing sessions must be reused.
return true if new sessions may be created, otherwise false.
SupportedCipherSuites Asjava.lang.String[][read only] Returns the names of the supported cipher suites.
EnabledCipherSuites Asjava.lang.String[] Returns the names of the enabled cipher suites.
Session Asjavax.net.ssl.SSLSession[read only] Returns the {@code SSLSession} for this connection. If necessary, a
handshake will be initiated, in which case this method will block until the handshake
has been established. If the handshake fails, an invalid session object
will be returned.
URLEscape (arg Asjava.lang.String)Asjava.lang.String Returns the escaped form of a given literal string.
IsLocal (url Asjava.lang.String)Asboolean Whether the URI is a local one.
GetThumbnailFromUri (ba Asanywheresoftware.b4a.BA, uri Asjava.lang.String, Kind Asint)Asandroid.graphics.Bitmap Attempt to retrieve the thumbnail of given Uri from the MediaStore.
This should not be called on the UI thread.
You can only retrieve thumbnails for images and videos. Kind :
Mini Kind = 1 [0x1]
Full Screen Kind = 2 [0x2]
Micro Kind = 3 [0x3]
IsMediaUri (uri Asjava.lang.String)Asboolean Return True if Uri is a MediaStore Uri.
GetThumbnailFromFile (ba Asanywheresoftware.b4a.BA, Dir Asjava.lang.String, FileName Asjava.lang.String, Kind Asint)Asandroid.graphics.Bitmap Attempt to retrieve the thumbnail of given File from the MediaStore.
This should not be called on the UI thread.
Cann't Accept DirAssets !You can only retrieve thumbnails for images and videos. Kind :
Mini Kind = 1 [0x1]
Full Screen Kind = 2 [0x2]
Micro Kind = 3 [0x3]
URLEncoder (string Asjava.lang.String, enc Asjava.lang.String)Asjava.lang.String Translates a string into application/x-www-form-urlencoded format using
a specific encoding scheme. This method uses the supplied encoding scheme
to obtain the bytes for unsafe characters.
Note: The World Wide Web Consortium Recommendation states that UTF-8
should be used. Not doing so may introduce incompatibilites.
___________________________________________________________________________
Parameters:
string : String to be translated.
enc : The name of a supported character encoding.
Returns:
the translated String.
IsDownloadsDocument (uri Asjava.lang.String)Asboolean Whether the Uri authority is DownloadsProvider.
GetMimeTypeFromUri (ba Asanywheresoftware.b4a.BA, uri Asjava.lang.String)Asjava.lang.String return The MIME type for the given Uri.
GetMimeTypeFromFile (Dir Asjava.lang.String, FileName Asjava.lang.String)Asjava.lang.String return The MIME type for the given file.
Cann't Accept DirAssets !
IsRetrofitManagerEnabled (Retrofit Asaghajari.retrofit.Retrofit)Asboolean Example :
Sub GetManager (Retrofit As Amir_Retrofit) As Amir_RetrofitManager
Dim Utils As Amir_RetrofitUtils
If Utils.IsRetrofitManagerEnabled(Retrofit) Then
Return Utils.GetRetrofitManager(Retrofit)
End if
Return Null
End Sub
IsNetworkAvailable (context2 Asanywheresoftware.b4a.BA)Asboolean check NetworkAvailable
Active Network
IsMediaDocument (uri Asjava.lang.String)Asboolean Whether the Uri authority is MediaProvider.
URLDecoder (string Asjava.lang.String, enc Asjava.lang.String)Asjava.lang.String Decodes a application/x-www-form-urlencoded string using a specific
encoding scheme. The supplied encoding is used to determine what
characters are represented by any consecutive sequences of the form "%xy".
Note:The World Wide Web Consortium Recommendation states that UTF-8
should be used. Not doing so may introduce incompatibilites.
___________________________________________________________________________
Parameters:
string : the String to decode
enc : The name of a supported character encoding.
Returns:
the newly decoded String
EnableRetrofitManager (Retrofit Asaghajari.retrofit.Retrofit, Enabled Asboolean)Asvoid Example :
Dim Utils As Amir_RetrofitUtils
If Utils.IsRetrofitManagerEnabled(Retrofit) =False Then
Utils.EnableRetrofitManager(Retrofit,True)
End if
GetRetrofitManager (Retrofit Asaghajari.retrofit.Retrofit)Asaghajari.retrofit.Amir_RetrofitManager Example :
Sub GetManager (Retrofit As Amir_Retrofit) As Amir_RetrofitManager
Dim Utils As Amir_RetrofitUtils
If Utils.IsRetrofitManagerEnabled(Retrofit) Then
Return Utils.GetRetrofitManager(Retrofit)
End if
Return Null
End Sub
_________________________________________________________
Example 2 :
Dim Retrofit As Amir_Retrofit
Dim Manager As Amir_RetrofitManager
Dim Builder As Amir_RetrofitBuilder
'Initialize Retrofit With Manager
Builder.Initialize.baseUrl("BaseUrl").addCache(False).WithManager
Retrofit.Initialize(Builder)
'Get Manager From Retrofit
Manager = Retrofit.Utils.GetRetrofitManager(Retrofit)
GetThumbnailFromUri2 (ba Asanywheresoftware.b4a.BA, uri Asjava.lang.String, MimeType Asjava.lang.String, Kind Asint)Asandroid.graphics.Bitmap Attempt to retrieve the thumbnail of given Uri from the MediaStore.
This should not be called on the UI thread.
You can only retrieve thumbnails for images and videos. Kind :
Mini Kind = 1 [0x1]
Full Screen Kind = 2 [0x2]
Micro Kind = 3 [0x3]
FollowSslRedirects (followProtocolRedirects Asboolean)Asaghajari.retrofit.Builder Configure this client to follow redirects from HTTPS to HTTP and from HTTP to HTTPS.
If unset, protocol redirects will be followed. This is different than the built-in
HttpURLConnection's default.
OkHttpTLSCompat Asaghajari.retrofit.Builder Fix OpenSSL Handshake on PreLollipop OS
Initialize (ba Asanywheresoftware.b4a.BA)Asaghajari.retrofit.Builder Create New Retrofit Builder
Base URL required.Builder.baseUrl("http://lcoders.ir")
addConverterFactory (Factory Asretrofit2.Converter.Factory)Asaghajari.retrofit.Builder Custom
Add converter factory for serialization and deserialization of objects.
You Should Use This Method With inline Java!
______________________________________________________________________
Example : This is a Sample for GsonConverterFactory
Dim J as JavaObject : J.InitializeContext
Builder.addConverterFactory(J.RunMethod("getNewGsonConverterFactory",Null))
#if java
import retrofit2.converter.gson.GsonConverterFactory;
public GsonConverterFactory getNewGsonConverterFactory(){
return GsonConverterFactory.create();
}
#End if
addCookie (isCookie Asboolean)Asaghajari.retrofit.Builder open sync default Cookie
Provides policy and persistence for HTTP cookies.
As policy, implementations of this interface are responsible for selecting which cookies to
accept and which to reject. A reasonable policy is to reject all cookies, though that may
interfere with session-based authentication schemes that require cookies.
DeflateRequest (noHeader Asboolean)Asaghajari.retrofit.Builder.DeflaterBuilder Deflate : Compresses the HTTP request body. Many webservers can't handle this!
noHeader : True indicates that no ZLIB header should be written.
connectTimeout (timeout Asint)Asaghajari.retrofit.Builder Sets the default connect timeout for new connections. A value of 0 means
no timeout, otherwise values must be between 1 and Integer.MAX_VALUE
when converted to milliseconds.
Default : 15
Client (client Asokhttp3.OkHttpClient)Asaghajari.retrofit.Builder The HTTP client used for requests. default OkHttpClient
How To use ? For Example I have a Retrofit And i
Initialize It . My Retrofit Name is R1
Dim Builder2 as Amir_Builder
Builder2.Initialize
Builder2.Client(R1.Client)
Dim R2 As Amir_Retrofit
R2.Initialize(Builder2)
addSSL (hosts Asjava.lang.String[], certificates Asint[])Asaghajari.retrofit.Builder Sets the handler that can accept cookies from incoming HTTP responses
and provides cookies to outgoing HTTP requests.
If unset, no cookies will be accepted nor provided.
addCache (isCache Asboolean)Asaghajari.retrofit.Builder open default Cache
Client2 (client Asanywheresoftware.b4h.okhttp.OkHttpClientWrapper)Asaghajari.retrofit.Builder The HTTP client used for requests. default OkHttpClient
How To use ? For Example I have a OkHttpClientWrapper (OkHttp Library) And i
Initialize It . My OkHttpClientWrapper Name is okHttp
Dim Builder2 as Amir_Builder
Builder2.Initialize
Builder2.Client(okHttp)
Dim R2 As Amir_Retrofit
R2.Initialize(Builder2)
HttpLoggingInterceptor2 (Level Asint, Type Asjava.lang.String, ba Asanywheresoftware.b4a.BA, EventName Asjava.lang.String)Asaghajari.retrofit.Builder Level :
BODY : 1 | BASIC : 2 | HEADERS : 3 | NONE : 4
Type : "NetworkInterceptor""Interceptor"
____________________________________________________________________________
Event :
EventName_onLog (LogMessage As String)
addGsonConverterFactory2 (Amir_Json Asaghajari.retrofit.Amir_Gson)Asaghajari.retrofit.Builder GsonConverterFactory
Add converter factory for serialization and deserialization of objects.
Event_Complete (Enabled Asboolean, EventName Asjava.lang.String)Asaghajari.retrofit.Builder An event when requests are completed
________________________________________
Event :
EventName_Complete (DefaultEventName As String)
HostnameVerifier (ba Asanywheresoftware.b4a.BA, EventName Asjava.lang.String)Asaghajari.retrofit.Builder HostnameVerifier : New HostnameVerifier Events : EventName_verify (hostname as string,session as Object) as boolean
AutoEvict (ba Asanywheresoftware.b4a.BA)Asaghajari.retrofit.Builder AutoEvict :
Delete Cache before start Request
You Should Call This Method Before
AddCache And AddResponseCache !
addInterceptor (Interceptor Asokhttp3.Interceptor)Asaghajari.retrofit.Builder Custom
Returns a modifiable list of interceptors that observe a single network
request and response. These interceptors must call Interceptor.Chain.proceed
exactly once: it is an error for a network interceptor to short-circuit
or repeat a network request.
You Should Use This Method With inline Java!
______________________________________________________________________
Example : This is a Sample for HttpLoggingInterceptor
Dim J as JavaObject : J.InitializeContext
Builder.addInterceptor(J.RunMethod("getNewHttpLoggingInterceptor",Null))
#if java
import okhttp3.logging.HttpLoggingInterceptor;
public HttpLoggingInterceptor getNewHttpLoggingInterceptor(){
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
return interceptor;
}
#End if
WithManager Asaghajari.retrofit.Builder Enable Retrofit Manager
Example :
Dim Retrofit As Amir_Retrofit
Dim Manager As Amir_RetrofitManager
Dim Builder As Amir_RetrofitBuilder
'Initialize Retrofit With Manager
Builder.Initialize.baseUrl("BaseUrl").WithManager
Retrofit.Initialize(Builder)
'Get Manager From Retrofit
Manager = Retrofit.Utils.GetRetrofitManager(Retrofit)
ProxyAuthenticator (username Asjava.lang.String, password Asjava.lang.String)Asaghajari.retrofit.Builder Use Proxy With Password
Example :
Builder.proxy(1,"proxyHost",8080)
Builder.proxyAuthenticator("username","password")
Header (headers Asjava.util.Map, Type Asjava.lang.String)Asaghajari.retrofit.Builder Type : ADD , REMOVE , UPDATE
CookieLanguage (language Asjava.lang.String)Asaghajari.retrofit.Builder set Cookie Intercepter Language
Just Country Code : ch - en ...
Don't Forget To Enable Cookie With
Builder.addCookie(True)
addResponseCache (ba Asanywheresoftware.b4a.BA, MaxAge Asint, MaxStale Asint)Asaghajari.retrofit.Builder MaxAge :
If the same network request is sent within MaxAge, the response is retrieved from cache.
MaxStale :
If the device is offline, stale response is fetched from the cache.
_________________________________
Example :
Dim Builder As Amir_RetrofitBuilder
Builder.Initialize.baseUrl("http://lcoders.ir").KeyCache("Amir_Retrofit_Test").CacheMaxSize( 5 * 1024 * 1024)
Builder.AutoEvict.addCache(False).addResponseCache(1,2419200)
Retrofit.Initialize(Builder)
Retrofit.Get...
addInfoInterceptor (Enabled Asboolean, ba Asanywheresoftware.b4a.BA, EventName Asjava.lang.String, Sender Asjava.lang.Object)Asaghajari.retrofit.Builder Event :
EventName_onInfo(Chain As Object,Request As Object) As Object
Event Return New Response !
Retry (MaxRetryCount Asint, ba Asanywheresoftware.b4a.BA, EventName Asjava.lang.String)Asaghajari.retrofit.Builder.RetryClass Event : EventName_onRetry (TryCount As int,MaxCount As Int,RetryType As String,Request As Object)
___________________________________
Example :
Dim Builder As Amir_RetrofitBuilder
Builder.Initialize.BaseUrl("BaseUrl")
Builder.Retry(5,"Amir").NetworkAvailable
Builder.Retry(5,"Amir").NetworkResponse.IsNotSuccessful
Dim Retrofit As Amir_Retrofit
Retrofit.Initialize(Builder)
Retrofit....
Sub Amir_onRetry (TryCount As Int,MaxCount As Int,RetryType As String,Request As Object)
Log(RetryType&" : Try "&TryCount&"/"&MaxCount)
End Sub
AddSSLSocketFactory (Name Asjava.lang.String)Asaghajari.retrofit.Builder X.509
In cryptography, X.509 is a standard that defines the format of
public key certificates. X.509 certificates are used in many
Internet protocols, including TLS/SSL, which is the basis for
HTTPS, the secure protocol for browsing the web. They're also
used in offline applications, like electronic signatures. An X.509
certificate contains a public key and an identity (a hostname, or
an organization, or an individual), and is either signed by a
certificate authority or self-signed. When a certificate is signed
by a trusted certificate authority, or validated by other means,
someone holding that certificate can rely on the public key it
contains to establish secure communications with another party, or
Besides the format for certificates themselves, X.509 specifies
certificate revocation lists as a means to distribute information
about certificates that are no longer valid, and a certification
path validation algorithm, which allows for certificates to be
signed by intermediate CA certificates, which are in turn signed
by other certificates, eventually reaching a trust anchor.
X.509 is defined by the International Telecommunications Union's
Standardization sector (ITU-T), and is based on ASN.1, another ITU-T
standard....
English|https://en.wikipedia.org/wiki/X.509 | Farsi|https://fa.wikipedia.org/wiki/%D8%A7%D8%B3%D8%AA%D8%A7%D9%86%D8%AF%D8%A7%D8%B1%D8%AF_%D8%A7%DA%A9%D8%B3%DB%B5%DB%B0%DB%B9
name : Assets Certificate file name
GzipRequest Asaghajari.retrofit.Builder Gzip : Compresses the HTTP request body. Many webservers can't handle this!
ConnectionPool (maxldleConnections Asint, keepAliveDuration Aslong)Asaghajari.retrofit.Builder Sets the connection pool used to recycle HTTP and HTTPS connections.
If unset, a new connection pool will be used.
TimeUnit Is SECONDS Example :
Builder.ConnectionPool(5,8)
This is Default Values in Example
FollowRedirects (followRedirects Asboolean)Asaghajari.retrofit.Builder Configure this client to follow redirects. If unset, redirects will be followed.
AutoASCIIEncoder Asaghajari.retrofit.Builder Url representation in ASCII format
writeTimeout (timeout Asint)Asaghajari.retrofit.Builder Sets the default connect timeout for new connections. A value of 0 means
no timeout, otherwise values must be between 1 and Integer.MAX_VALUE when
converted to milliseconds.
addInfoNetworkInterceptor (Enabled Asboolean, ba Asanywheresoftware.b4a.BA, EventName Asjava.lang.String, Sender Asjava.lang.Object)Asaghajari.retrofit.Builder Event :
EventName_onInfo(Chain As Object,Request As Object) As Object
Event Return New Response !
AddSSLSocketFactory2 Asaghajari.retrofit.Builder Set Default SSLSocket
Proxy (Type Asint, ProxyHost Asjava.lang.String, proxyPort Asint)Asaghajari.retrofit.Builder add Proxy With SocketAddress
Type :
HTTP : 1
DIRECT : 2
SOCKS : 3
ProxyHost : "proxy"
Example :Builder.proxy(1,"proxy",8080)
If your Proxy has Password use proxyAuthenticator
HeaderRuntime (Type Asjava.lang.String)Asaghajari.retrofit.Builder Type : ADD , REMOVE , UPDATE
Event_Error (Enabled Asboolean, EventName Asjava.lang.String)Asaghajari.retrofit.Builder An event for all unsuccessful requests
________________________________________
Event :
EventName_Error (DefaultEventName As String,ErrorMessage As String)
addResponseProgress (Enabled Asboolean, ba Asanywheresoftware.b4a.BA, EventName Asjava.lang.String, Sender Asjava.lang.Object)Asaghajari.retrofit.Builder Event :
EventName_onResponseProgress(bytesRead As long,contentLength As long,done As boolean,Chain As Object,Response As Object)
SkipHostnameVerifier Asaghajari.retrofit.Builder HostnameVerifier : creatSkipHostnameVerifier
The HostnameVerifier runs after the TLS handshake,
over a TLS connection that is already valid from
the TLS point of view, so at that point you know
that the certificate is valid, signed by a trusted
issuer, non-expired (?), etc., and all you have
to do is decide (a) whether it's from the
correct server and (b) whether you trust that
server.
SingleEventCallAdapterFactory (Enabled Asboolean)Asaghajari.retrofit.Builder Add RxJava Events To Single Event.
Advanced Download Requests are not included
After Call This Method You Can Use This Events :
EventName_onDone (isSuccess As Boolean,Message As String,Response As Amir_ResponseBody)EventName_onDownloadDone (isSuccess As Boolean,Message As String,Path As String,Name As String)
_______________________________________________________________________________________
Example :
Dim Builder As Amir_RetrofitBuilder
Builder.Initialize.baseUrl("BaseUrl").SingleEventCallAdapterFactory(True)
Dim Retrofit As Amir_Retrofit
Retrofit.Initialize(Builder)
Retrofit.Sender = "Tag"
Retrofit.Get("Amir","Url",CreateMap())
Sub Amir_onDone (isSuccess As Boolean,Message As String,Response As Amir_ResponseBody)
Log(Sender) ' Tag
If isSuccess = True Then
Log(Response.String)
Else
Log(Message)
End If
End Sub
_______________________________________________________________________________________
Download Example :
Dim Builder As Amir_RetrofitBuilder
Builder.Initialize.baseUrl("BaseUrl").SingleEventCallAdapterFactory(True)
Dim Retrofit As Amir_Retrofit
Retrofit.Initialize(Builder)
Retrofit.Sender = "Tag"
Retrofit.Download("Amir","Url")
Sub Amir_onDownloadDone (isSuccess As Boolean,Message As String,Path As String,Name As String)
Log(Sender) 'Tag
If isSuccess = True Then
Log(Path&Name)
Log("Key : "&Message)
Else
Log(Message)
End If
End Sub
UnsafeMode2 Asaghajari.retrofit.Builder Fix OpenSSL Handshake on PreLollipop OS with unsafe mode
RetryOnConnectionFailure (Enabled Asboolean)Asaghajari.retrofit.Builder Configure this client to retry or not when a connectivity problem is encountered. By default,
this client silently recovers from the following problems:
Unreachable IP addresses. If the URL's host has multiple IP addresses,
failure to reach any individual IP address doesn't fail the overall request. This can
increase availability of multi-homed services.
Stale pooled connections. The ConnectionPool reuses sockets
to decrease request latency, but these connections will occasionally time out.
Unreachable proxy servers. A ProxySelector can be used to
attempt multiple proxy servers in sequence, eventually falling back to a direct
connection.
Set this to false to avoid retrying requests when doing so is destructive. In this case the
calling application should do its own recovery of connectivity failures.
addScalarsConverterFactory Asaghajari.retrofit.Builder A converter for strings and both primitives and their boxed types to text/plain bodies.
HttpLoggingInterceptor (Level Asint, Type Asjava.lang.String)Asaghajari.retrofit.Builder Returns a modifiable list of interceptors that observe a single network
request and response. These interceptors must call Interceptor.Chain.proceed
exactly once: it is an error for a network interceptor to short-circuit
or repeat a network request.
____________________________________________________________________________
An OkHttp interceptor which logs request and response information. Can
be applied as an application interceptor or as a network interceptor.
The format of the logs created by this class should not be considered
stable and may change slightly between releases. If you need a stable
logging format, use your own interceptor.
____________________________________________________________________________
Level :
BODY : 1 | BASIC : 2 | HEADERS : 3 | NONE : 4
Type : "NetworkInterceptor""Interceptor"
____________________________________________________________________________
Example :
Dim Builder as Amir_RetrofitBuilder
Builder.Initialize
Builder.HttpLoggingInterceptor(1,"NetworkInterceptor")
Event_DownloadSuccess (Enabled Asboolean, EventName Asjava.lang.String)Asaghajari.retrofit.Builder An event for all successful download requests
________________________________________
Event :
EventName_DownloadSucess (DefaultEventName As String,Key As String,Path As String,Name As String,FileSize As Long)
RunOkHttpBuilderMethod (MethodName Asjava.lang.String, Params Asjava.lang.Object[])Asjava.lang.Object Run OkHttpBuilder Method
Example :
Builder.RunOkHttpBuilderMethod("followRedirects",Array (true))
addHeader (headers Asjava.util.Map)Asaghajari.retrofit.Builder Add Header for serialization and deserialization of objects.
If there are any authenticated query parameters, they can be added in the
form of headers as shown below:
Type Is ADD. You Can Use Header Method For Set Type Example :Builder.addHeader(CreateMap("Authorization":"replace this text with your token"))
The header fields of a single HTTP message. Values are uninterpreted strings; use Request
and Response for interpreted headers. This class maintains the order of the header fields
within the HTTP message.
This class tracks header values line-by-line. A field with multiple comma- separated values on
the same line will be treated as a field with a single value by this class. It is the caller's
responsibility to detect and split on commas if their field permits multiple values. This
simplifies use of single-valued fields whose values routinely contain commas, such as cookies or
dates.
addParameters (parameters Asjava.util.Map, Type Asjava.lang.String, Encoded Asboolean)Asaghajari.retrofit.Builder Add parameters for serialization and deserialization of objects.
Type : ADD , REMOVE , UPDATE
addGsonConverterFactory Asaghajari.retrofit.Amir_Gson GsonConverterFactory
Add converter factory for serialization and deserialization of objects.
Event_Success (Enabled Asboolean, EventName Asjava.lang.String)Asaghajari.retrofit.Builder An event for all successful requests
Download Requests are not included You Should Use Event_DownloadSuccess
________________________________________
Event :
EventName_Sucess (DefaultEventName As String,ResponseBody As Amir_ResponseBody)
HostnameVerifier2 (hostUrls Asjava.lang.String[])Asaghajari.retrofit.Builder HostnameVerifier : New HostnameVerifier With Urls
Just Set hostUrls
addCallAdapterFactory2 (CallAdapterFactory Asjava.lang.Object, Enabled Asboolean)Asaghajari.retrofit.Builder Add Custom Call Adapter Factory With B4A Class
Add This Class Events : getEvents(Name As String) As String() onCompleted(Name As String) As Object() onNext(ResponseBody As Amir_ResponseBody,Name As String) As Object() onError(Error As String,Name As String) As Object()
_____________________________________________________
Example :
1.Crrate a Standard Class (MyCallAdapter)
2.Add This Codes To Class :
private Sub Class_Globals
End Sub
Public Sub Initialize
End Sub
Public Sub getEvents(Name As String) As String()
Return Array As String ("Finish","Sucess","Error")
End Sub
Public Sub onCompleted(Name As String) As Object()
Return Array()
End Sub
Public Sub onNext (ResponseBody As Amir_ResponseBody,Name As String) As Object()
Return Array (ResponseBody.String,ResponseBody)
End Sub
Public Sub onError (Error As String,Name As String) As Object()
Return Array (Error)
End Sub
3.Add Your Class To Retrofit Builder :
Dim Call As MyCallAdapter
Call.Initialize
Dim Builder As Amir_RetrofitBuilder
Builder.Initialize.baseUrl("http://lcoders.ir")
Builder.addCallAdapterFactory2(Call,True)
Retrofit.Initialize(Builder)
4. Now You Can Use Your Events :
EventName_Finish
EventName_Sucess (ResponseString As String,Body As Amir_ResponseBody)
EventName_Error (Error As String)
baseUrl (baseUrl Asjava.lang.String)Asaghajari.retrofit.Builder Set an API base URL which can change over time.
For Example :
Your BaseUrl is : "http://example.com"
In The Requests you can just Set Url Like this :"/arg.php"
Now Requests Address is : "http://example.com/arg.php"
MultipartBody (MultipartBody Asaghajari.retrofit.RequestBodyCreate.MultipartBodyBuilder)Asaghajari.retrofit.Builder Set Default Body
readTimeout (timeout Asint)Asaghajari.retrofit.Builder Sets the handler that can accept cookies from incoming HTTP responses
and provides cookies to outgoing HTTP requests. If unset, no cookies
will be accepted nor provided.
UnsafeMode (Enabled Asboolean)Asaghajari.retrofit.Builder Accept Any SSL Certificate
It basically set OkHttp client with custom SSL verification, which accepts every certificate.
Using this unsafe OkHttp client allows us to connect to the dangerous subdomains of BadSSL.
CacheMaxSize (size Asint)Asaghajari.retrofit.Builder set Cache MaxSize
Parameters:size MaxSize unit kb def 10 * 1024 * 1024
ValidateEagerly (validateEagerly Asboolean)Asaghajari.retrofit.Builder When calling create on the resulting Retrofit instance, eagerly validate
the configuration of all methods in the supplied interface.
DEFAULT_STRATEGY Asvoid The default compression strategy.
DEFAULT_COMPRESSION Asvoid The default compression level.
SYNC_FLUSH Asvoid Flush buffers so recipients can immediately decode the data sent thus
far. This mode may degrade compression.
BEST_COMPRESSION Asvoid Upper bound for the compression level range.
HUFFMAN_ONLY Asvoid A compression strategy.
NO_COMPRESSION Asvoid A compression level.
NO_FLUSH Asvoid Use buffering for best compression.
DEFLATED Asvoid The default compression method.
BEST_SPEED Asvoid Lower bound for compression level range.
FILTERED Asvoid A compression strategy.
FULL_FLUSH Asvoid Flush buffers so recipients can immediately decode the data sent thus
far. The compression state is also reset to permit random access and
recovery for clients who have discarded or damaged their own copy. This
mode may degrade compression.
BigFile (Dir Asjava.lang.String, FileName Asjava.lang.String, ba Asanywheresoftware.b4a.BA, EventName Asjava.lang.String)Asjava.io.File Events :
EventName_onProgress(Progress As Int,Transfered As Long,total As Long)
Streaming (Streaming Asboolean)Asaghajari.retrofit.DownloadOptions Treat the response body on methods returning Response as is, i.e. without converting body() to byte[]
Cut (Dir Asjava.lang.String, Name Asjava.lang.String)Asaghajari.retrofit.DownloadOptions Name : "" = Default File Name
WithName (Name Asjava.lang.String)Asaghajari.retrofit.DownloadOptions Set Download File Name
Copy (Dir Asjava.lang.String, Name Asjava.lang.String)Asaghajari.retrofit.DownloadOptions Copy File After Download
Name : "" = Default File Name
Take (count Asint)Asaghajari.retrofit.myObservable Returns an Observable that emits those items emitted by source
Observable before a specified time runs out.
RunMethod (MethodName Asjava.lang.String, Params Asjava.lang.Object[])Asjava.lang.Object Run Method in Observable
Example :
Dim Rx as Amir_Observable
Dim myObject as Object
myObject=Rx.RunMethod("timeInterval",Null)
if myObject=Null Then
Log("Method Not Found!")
Else
Rx.Observable=myObject
End If
Serialize Asaghajari.retrofit.myObservable Forces an Observable's emissions and notifications to be serialized
and for it to obey the Rx contract in other ways. It is possible for
an Observable to invoke its Subscribers' methods asynchronously,
perhaps from different threads. This could make such an Observable
poorly-behaved, in that it might try to invoke onCompleted or onError
before one of its onNext invocations, or it might call onNext from
two different threads concurrently. You can force such an Observable
to be well-behaved and sequential by applying the serialize method to
it.
Scheduler:
serialize does not operate by default on a particular Scheduler.
TimeOut (t Aslong)Asaghajari.retrofit.myObservable Returns an Observable that mirrors the source Observable but
applies a timeout policy for each emitted item. If the next item
isn't emitted within the specified timeout duration starting from
its predecessor, the resulting Observable terminates and notifies
observers of a TimeoutException.
TimeUnit : SECONDS
Repeat Asaghajari.retrofit.myObservable Returns an Observable that repeats the sequence of items emitted by
the source Observable indefinitely, on a particular Scheduler.
Subscribe (ba Asanywheresoftware.b4a.BA, Sender Asjava.lang.Object, EventName Asjava.lang.String)Asrx.Subscription Events : EventName_onCompletedEventName_onError (Error as String)EventName_onNext (Response as Object)
____________________________________________________________________
Subscribes to an Observable and provides an Observer that implements
functions to handle the items the Observable emits and any error or
completion notification it issues.
asObservable Asaghajari.retrofit.myObservable Disguises a object of an Observable subclass as a simple Observable
object. Useful for instance when you have an implementation of a
subclass of Observable but you want to hide the properties and methods
of this subclass from whomever you are passing the Observable to.
Initialize (Observable Asrx.Observable)Asaghajari.retrofit.myObservable Use NewRequest2 Method . You Don't Need To Initialize After That!
Delay (delay Aslong)Asaghajari.retrofit.myObservable Returns an Observable that emits the items emitted by the source
Observable shifted forward in time by a specified delay. Error
notifications from the source Observable are not delayed.
Scheduler:
you specify which Scheduler this operator will use
TimeUnit : SECONDS
Compose (transformer Asrx.Observable.Transformer)Asaghajari.retrofit.myObservable Transform an Observable by applying a particular Transformer function
to it. This method operates on the Observable itself whereas
lift(rx.Observable.Operator) operates on the Observable's Subscribers
or Observers. If the operator you are creating is designed to act on
the individual items emitted by a source Observable, use
lift(rx.Observable.Operator). If your operator is designed to transform
the source Observable as a whole (for instance, by applying a
particular set of existing RxJava operators to it) use compose.
Scheduler:
compose does not operate by default on a particular Scheduler.
Parameters:
transformer implements the function that transforms the source Observable
Last Asaghajari.retrofit.myObservable Converts a Observable that emits a sequence of objects into one
that only emits the last object in this sequence before completing.
Distinct Asaghajari.retrofit.myObservable Returns an Observable that emits all items emitted by the source
Observable that are distinct.
ignoreElements Asaghajari.retrofit.myObservable Ignores all items emitted by the source Observable and only calls
onCompleted or onError.
Retry2 (Count Aslong)Asaghajari.retrofit.myObservable Returns an Observable that mirrors the source Observable, resubscribing
to it if it calls onError and the predicate returns true for that
specific exception and retry count.
Scheduler:
retry operates by default on the trampoline Scheduler.
Parameters:
predicate the predicate that determines if a resubscription may happen in
case of a specific exception and retry count
Debounce (TimeOut Aslong)Asaghajari.retrofit.myObservable Returns an Observable that mirrors the source Observable, except
that it drops items emitted by the source Observable that are
followed by newer items before a timeout value expires. The timer
resets on each emission.
Note: If items keep being emitted by the source Observable faster than
the timeout then no items will be emitted by the resulting Observable.
Information on debounce vs throttle:
Debounce and Throttle: visual explanation Debouncing: javascript methods Javascript - don't spam your server: debounce and throttle Backpressure Support:
This operator does not support backpressure as it uses time to control
data flow.
Scheduler:
This version of debounce operates by default on the computation Scheduler.
TimeUnit : SECONDS
First Asaghajari.retrofit.myObservable Returns an Observable that emits only the very first item emitted by
the source Observable, or notifies of an NoSuchElementException if
the source Observable is empty.
RetryWithDelays (maxRetries Asint, retryDelayMillis Asint)Asaghajari.retrofit.myObservable Retry
Uses retryWhen in Observable
SkipLast (count Asint)Asaghajari.retrofit.myObservable Returns an Observable that drops items emitted by the source Observable
during a specified time window before the source completes.
Note: this action will cache the latest items arriving in the specified
time window.
Scheduler:
This version of skipLast operates by default on the computation Scheduler.
ObserveOn (scheduler Asrx.Scheduler)Asaghajari.retrofit.myObservable Modifies an Observable to perform its emissions and notifications on a
specified Scheduler, asynchronously with an unbounded buffer.
TakeLast (count Asint)Asaghajari.retrofit.myObservable Returns an Observable that emits at most a specified number of
items from the source Observable that were emitted in a specified
window of time before the Observable completed.
Single Asaghajari.retrofit.myObservable Returns an Observable that emits the single item emitted by the source
Observable that matches a specified predicate, if that Observable
emits one such item. If the source Observable emits more than one such
item or no such items, notify of an IllegalArgumentException or
NoSuchElementException respectively.
Scheduler:
serialize does not operate by default on a particular Scheduler.
Replay Asrx.observables.ConnectableObservable Returns a rx.observables.ConnectableObservable that shares a single
subscription to the underlying Observable that will replay all of
its items and notifications to any future Observer. A Connectable
Observable resembles an ordinary Observable, except that it does not
begin emitting items when it is subscribed to, but only when its
connect method is called.
Skip (count Asint)Asaghajari.retrofit.myObservable Returns an Observable that skips values emitted by the source
Observable before a specified time window elapses.
Scheduler:
This version of skip operates by default on the computation Scheduler.
Retry Asaghajari.retrofit.myObservable Returns an Observable that mirrors the source Observable, resubscribing
to it if it calls onError (infinite retry count). If the source
Observable calls Observer.onError(java.lang.Throwable), this method
will resubscribe to the source Observable rather than propagating the
onError call. Any and all items emitted by the source Observable will
be emitted by the resulting Observable, even those emitted during
failed subscriptions. For example, if an Observable fails at first
but emits [1, 2] then succeeds the second time and emits [1, 2, 3, 4,
5] then the complete sequence of emissions and notifications would be
[1, 2, 1, 2, 3, 4, 5, onCompleted].
Scheduler:
retry operates by default on the trampoline Scheduler.
Limit (Count Asint)Asaghajari.retrofit.myObservable Returns an Observable that emits only the first num items emitted by
the source Observable. Alias of take(int) to match Java 8 Stream API
naming convention. This method returns an Observable that will invoke
a subscribing Observer's onNext function a maximum of num times before
invoking onCompleted.
Share Asaghajari.retrofit.myObservable Returns an Observable that emits the single item emitted by the source
Observable, if that Observable emits only a single item. If the source
Observable emits more than one item or no items, notify of an
IllegalArgumentException or NoSuchElementException respectively.
Scheduler:
serialize does not operate by default on a particular Scheduler.
SubscribeOn (scheduler Asrx.Scheduler)Asaghajari.retrofit.myObservable Asynchronously subscribes Observers to this Observable on the specified Scheduler.
Scheduler:
you specify which Scheduler this operator will use
Cache Asaghajari.retrofit.myObservable Caches the emissions from the source Observable and replays them in order
to any subsequent Subscribers. This method has similar behavior to replay()
except that this auto-subscribes to the source Observable rather than
returning a rx.observables.ConnectableObservable for which you must call
connect to activate the subscription. This is useful when you want an
Observable to cache responses and you can't control the subscribe/unsubscribe
behavior of all the Subscribers. When you call cache, it does not yet
subscribe to the source Observable and so does not yet begin cacheing items.
This only happens when the first Subscriber calls the resulting Observable's
subscribe method. Note: You sacrifice the ability to unsubscribe from the
origin when you use the cache Observer so be careful not to use this Observer
on Observables that emit an infinite or very large number of items that will
use up memory.
Backpressure Support:
This operator does not support upstream backpressure as it is purposefully
requesting and caching everything emitted.
Trampoline Asrx.Scheduler[read only] Creates and returns a rx.Scheduler that queues work on the current thread to be executed after
the current work completes.
Computation Asrx.Scheduler[read only] Creates and returns a rx.Scheduler intended for computational work.
This can be used for event-loops, processing callbacks and other
computational work. Do not perform IO-bound work on this scheduler.
Use io() instead. Unhandled errors will be delivered to the scheduler
Thread's java.lang.Thread.UncaughtExceptionHandler.
Io Asrx.Scheduler[read only] Creates and returns a rx.Scheduler intended for IO-bound work.
The implementation is backed by an java.util.concurrent.Executor thread-pool that will grow as needed.
This can be used for asynchronously performing blocking IO.
Do not perform computational work on this scheduler. Use computation() instead.
Unhandled errors will be delivered to the scheduler Thread's java.lang.Thread.UncaughtExceptionHandler.
NewThread Asrx.Scheduler[read only] Creates and returns a rx.Scheduler that creates a new java.lang.Thread for each unit of work.
Unhandled errors will be delivered to the scheduler Thread's java.lang.Thread.UncaughtExceptionHandler.
WithPartRequestBodyAndHeader (Header Asjava.util.Map, body Asokhttp3.RequestBody)Asokhttp3.MultipartBody.Part
WithProgressRequestBodyObservable (ba Asanywheresoftware.b4a.BA, EventName Asjava.lang.String, MediaType Asjava.lang.String, Dir Asjava.lang.String, FileName Asjava.lang.String, BufferSize Asint)Asaghajari.retrofit.ProgressRequestBodyObservable Events : EventName_onProgressUpdate (Progress as float,uploaded as float,total as float) EventName_WriteTo (BufferedSink as Object,buffer() as byte,Read as int,isFirst as boolean)
_________________________________________________________________
BufferSize : 2048
You Can Use this Request for okhttp3.RequestBody
MultipartBody (boundary Asjava.lang.String)Asaghajari.retrofit.RequestBodyCreate.MultipartBodyBuilder An RFC 2387|http://www.ietf.org/rfc/rfc2387.txt-compliant request body.
Example :
Retrofit.Body("EV","Link", _
Retrofit.RB.MultipartBody("").SetType("Type") _
.AddPart2(Retrofit.RB.WithString("text/*","Hello")) _
.AddPart2(Retrofit.RB.WithString("text/*","Text2")).Build)
AddFormDataPart (Name Asjava.lang.String, Value Asjava.lang.String)Asaghajari.retrofit.RequestBodyCreate.MultipartBodyBuilder Add a form data part to the body.
AddPart (part Asokhttp3.MultipartBody.Part)Asaghajari.retrofit.RequestBodyCreate.MultipartBodyBuilder Add a part to the body.
SetType (MultipartMediaType Asjava.lang.String)Asaghajari.retrofit.RequestBodyCreate.MultipartBodyBuilder Set the MIME type.
Expected values for type are :
1.Mixed : "multipart/mixed"(the default)
2.Alternative : "multipart/alternative"
3.Digest : "multipart/digest"
4.Parallel : "multipart/parallel"
5.Form : "multipart/form-data"
_____________________________________________________________________________________________
MIXED :
The "mixed" subtype of "multipart" is intended for use when the body parts are independent and
need to be bundled in a particular order. Any "multipart" subtypes that an implementation does
not recognize must be treated as being of subtype "mixed".
_____________________________________________________________________________________________
ALTERNATIVE :
The "multipart/alternative" type is syntactically identical to "multipart/mixed", but the
semantics are different. In particular, each of the body parts is an "alternative" version of
the same information.
_____________________________________________________________________________________________
DIGEST :
This type is syntactically identical to "multipart/mixed", but the semantics are different. In
particular, in a digest, the default Content-Type value for a body part is changed from
"text/plain" to "message/rfc822".
_____________________________________________________________________________________________
PARALLEL :
This type is syntactically identical to "multipart/mixed", but the semantics are different. In
particular, in a parallel entity, the order of body parts is not significant.
_____________________________________________________________________________________________
FORM :
The media-type multipart/form-data follows the rules of all multipart MIME data streams as
outlined in RFC 2046. In forms, there are a series of fields to be supplied by the user who
fills out the form. Each field has a name. Within a given form, the names are unique.
AddFormDataPart2 (Name Asjava.lang.String, FileName Asjava.lang.String, Body Asokhttp3.RequestBody)Asaghajari.retrofit.RequestBodyCreate.MultipartBodyBuilder Add a form data part to the body.
Build Asokhttp3.MultipartBody Assemble the specified parts into a request body.
MultipartBody extends RequestBody
AddPart3 (Header Asjava.util.Map, Body Asokhttp3.RequestBody)Asaghajari.retrofit.RequestBodyCreate.MultipartBodyBuilder Add a part to the body.
AddPart2 (Body Asokhttp3.RequestBody)Asaghajari.retrofit.RequestBodyCreate.MultipartBodyBuilder Add a part to the body.
Progress (requestBody Asokhttp3.RequestBody, ba Asanywheresoftware.b4a.BA, EventName Asjava.lang.String, Sender Asjava.lang.Object)Ascom.aghajari.ProgressRequestBody Event : EventName_onRequestProgress(bytesWritten As Long,contentLength As Long,done As Boolean)
________________________________________________
Example :
Retrofit.Body("EV","URL",Retrofit.RB.Create.Progress( _
Retrofit.RB.WithString("text/*","VALUE"),"Amir",null))
Sub Amir_onRequestProgress(bytesWritten As Long,contentLength As Long,done As Boolean)
Log(bytesWritten&"/"&contentLength)
End Sub
Part (partName Asjava.lang.String, Dir Asjava.lang.String, FileName Asjava.lang.String)Asokhttp3.MultipartBody.Part
Pdf (Dir Asjava.lang.String, FileName Asjava.lang.String)Asokhttp3.RequestBody
Xml (XML Asjava.lang.String)Asokhttp3.RequestBody
Video (Dir Asjava.lang.String, FileName Asjava.lang.String)Asokhttp3.RequestBody
Gzip (Dir Asjava.lang.String, FileName Asjava.lang.String)Asokhttp3.RequestBody GZIP File.
You Can Convert RequestBody To Gzip
Request Body With This Code :
RequestBody.Create.Gzip(RequestBody)
onProgress (key as String As , progress as int As , downloadedsize as long As , totalsize as long As )
onSucess (key as String As , path as String As , Name as String As , FileSize as long As )
onProgressUpdate (Progress as float As , uploaded as float As , total as float As )
Fields:
Sender Asjava.lang.Object Use Tag Sender In Events
Default is Null
Example :
Retrofit.Sender="Hello World! Get"
Retrofit.Get("Amir","Link",CreateMap())
Retrofit.Sender="Hello World! Post"
Retrofit.Post("Amir","Link2",CreateMap())
...
Sub Amir_onNext (ResponseBody as Amir_ResponseBody)
Dim Tag as String = Sender
Log(Tag) ' Or Log(Sender)
End Sub
LastRetrofitRequest Asjava.lang.Object Get The Last Retrofit Request
Tag Asjava.lang.Object Use Tag For Amir_Retrofit
Default is (String) "Amir_Retrofit"
Methods:
Delete (EventName Asjava.lang.String, url Asjava.lang.String, Maps Asjava.util.Map)Asaghajari.retrofit.Amir_RetrofitRequest use DELETE when you need to delete a resource
(relative to the URI you've sent) on that system. Events : EventName_onCompletedEventName_onError (Error as String,Code as int)EventName_onNext (ResponseBody as Amir_ResponseBody)
____________________________________________________
Example :
Retrofit.delete("Amir","Address",CreateMap("Key":Value))
Start (Method Asjava.lang.String, EventName Asjava.lang.String, url Asjava.lang.String, body Asjava.lang.Object)Asaghajari.retrofit.Amir_RetrofitRequest Start New Request
Events : EventName_onCompletedEventName_onError (Error as String)EventName_onNext (ResponseBody as Amir_ResponseBody)
____________________________________________________
Example :
Retrofit.Start("PUT","Amir","Address",Body)
____________________________________________________
Methods :
POST - GET - PUT - PATCH - HEAD - DELETE
Initialize (ba Asanywheresoftware.b4a.BA, Builder Asaghajari.retrofit.Builder)Asvoid Create Retrofit With Custom Builder
FakeRequest (EventName Asjava.lang.String, success Asboolean, contentType Asjava.lang.String, content Asjava.lang.String)Asaghajari.retrofit.Amir_RetrofitRequest Start a fake request (Get-Post)
onError : Error=UNKNOW , Code = -1
onNext : ResponseBody= a cusom response with your own content.
Events : EventName_onCompletedEventName_onError (Error as String,Code as int)EventName_onNext (ResponseBody as Amir_ResponseBody)
UploadImage (EventName Asjava.lang.String, url Asjava.lang.String, Dir Asjava.lang.String, Name Asjava.lang.String)Asaghajari.retrofit.Amir_RetrofitRequest Events : EventName_onCompletedEventName_onError (Error as String)EventName_onNext (ResponseBody as Amir_ResponseBody)
_________________________________________________________
Upload Image. Cann't Accept Assets!
RequestWithCallback (CustomClass Asjava.lang.Object, RequestName Asjava.lang.String, Params Asjava.lang.Object[])Asaghajari.retrofit.Amir_CallBack Use Retrofit CallBack Events : Call Enqueue in Amir_CallBack
___________________________________________________
CustomClass :
Api Service. Pass Null For set Defualt Amir_Retrofit Service
if you want to use Custom Class add your Request Methods to your Service with lowercase
___________________________________________________
Requests :
Get : Url As String , maps As Map
Head : Url As String , maps As Map
Options : Url As String , maps As Map
Post : Url As String , maps As Map
PostBody : Url As String , Body As Object
Put : Url As String , maps As Map
PutBody : Url As String , Body As Object
Patch : Url As String , maps As Map
PatchBody : Url As String , Body As Object
Delete : Url As String , maps As Map
DeleteBody : Url As String , Body As Object
Download : FileUrl as String
DownloadMin : FileUrl as String
Upload : Url As String , RequestBody as okhttp3.RequestBody
UploadFiles : Url As String,files as Map
UploadMultipart : Url As String ,partMap as Map,file as MultipartBody.Part
UploadMultipartList : Url As String , List as List
_____________________________________________________________________________________
Example :
Dim Call As Amir_CallBack = _
Retrofit.RequestWithCallback(Null,"Post",Array ("URL",PARAMS))
Call.Enqueue("Amir",Null)
Unsubscribe (Subscription Asjava.lang.Object)Asvoid Unsubscribe Requests
ParametersSubscription : Request Objects
Set Null For Use LastRequest
__________________________________________________
Example :
Dim Subscription as Object
Subscription=Retrofit.Get("Amir","Address",CreateMap()).RequestObject
...
Retrofit.Unsubscribe(Subscription)
__________________________________________________
Example 2 :
Sub Globals
Dim Retrofit As Amir_Retrofit
Dim Subscription As Object = Null
End Sub
Sub Activity_Create(FirstTime As Boolean)
Retrofit.Initialize2("BaseUrl")
End Sub
Sub Download_Click ' Button Click
'Start Downloading
Subscription=Retrofit.download("EventName","Address").RequestObject
Log("Download")
End Sub
Sub Cancel_Click ' Button Click
If Subscription<>Null then
Retrofit.Unsubscribe(Subscription)
Log("Unsubscribe")
Else
Log("Subscription Is NULL !")
End If
End Sub
isUnsubscribed (Subscription Asjava.lang.Object)Asboolean isUnsubscribed Check the Subscribe of the the Requests
ParametersSubscription : Request Objects
Set Null For Use LastRequest
__________________________________________________
Example :
Dim Subscription as Object
Subscription=Retrofit.Get("Amir","Address",CreateMap()).RequestObject
...
Log(Retrofit.isUnsubscribed(Subscription))
Cookie (Cookie Asokhttp3.Cookie)Asaghajari.retrofit.Retrofit.CookieItem get Cookie Information
Example :
Dim L as List=Retrofit.CookieManager.LoadForRequest("Url")
Log(Retrofit.Cookie(L.get(0)).Domain)
Head (EventName Asjava.lang.String, url Asjava.lang.String, maps Asjava.util.Map)Asaghajari.retrofit.Amir_RetrofitRequest The HTTP HEAD method requests the headers that are returned if
the specified resource would be requested with an HTTP GET method.
Such a request can be done before deciding to download a large
resource to save bandwidth, for example. Events : EventName_onCompletedEventName_onError (Error as String,Code as int)EventName_onNext (ResponseBody as Amir_ResponseBody)
__________________________________________________________
Example :
Retrofit.Head("Amir","Address",CreateMap()) Sub Amir_onNext (ResponseBody as Amir_ResponseBody)
Log(ResponseBody.String)
End Sub
GetStreaming (EventName Asjava.lang.String, Url Asjava.lang.String, OutputStream Asjava.io.OutputStream)Asaghajari.retrofit.Amir_RetrofitRequest Events : EventName_onCompletedEventName_onError (Error as String,Code as int)EventName_onNext (ResponseBody as Amir_ResponseBody)
Output Events :
EventName_onSucess(Size As Long,Output As OutputStream) EventName_onProgress(Progress As int,ReadedSize As Long,TotalSize As Long,Read As int,Output As OutputStream)
UploadFiles (EventName Asjava.lang.String, url Asjava.lang.String, files Asjava.util.Map)Asaghajari.retrofit.Amir_RetrofitRequest files : String , RequsetBody
Events : EventName_onCompletedEventName_onError (Error as String)EventName_onNext (ResponseBody as Amir_ResponseBody)
___________________________________________________________
Upload Files
Dim Body as Amir_RequestBody
Dim M as Map : M.Initialize
M.put("Key1":Body.WithFile("image/*",File.DirInternal,"Image1.png"))
M.put("Key2":Body.WithFile("image/*",File.DirInternal,"Image2.png"))
Retrofit.UploadFiles("Amir","Address",M)
PutBody (EventName Asjava.lang.String, url Asjava.lang.String, body Asjava.lang.Object)Asaghajari.retrofit.Amir_RetrofitRequest
Json (EventName Asjava.lang.String, url Asjava.lang.String, jsonStr Asjava.lang.String)Asaghajari.retrofit.Amir_RetrofitRequest http Post by json
Events : EventName_onCompletedEventName_onError (Error as String)EventName_onNext (ResponseBody as Amir_ResponseBody)
__________________________________________________________
Example :
Retrofit.json("Amir","Address",Retrofit.toJson(CreateMap("Key":value)))
json.org|https://www.json.org/
About Asjava.lang.String Amir Hossein Aghajari
Telegram Id : @KingAmir272
Instagram : amirhossein_aghajari_official
toJson (src Asjava.lang.Object)Asjava.lang.String Convert Object To String For Use it In Json Request
UnsubscribeAsync (myAsync Asaghajari.retrofit.Async, UnsubscribeRequest Asboolean, mayInterruptIfRunning Asboolean)Asboolean Attempts to cancel execution of this task.
This attempt will fail if the task has already completed, already been cancelled, or c
ould not be cancelled for some other reason. If successful, and this task has not started
when cancel is called, this task should never run. If the task has already started, then
the mayInterruptIfRunning parameter determines whether the thread executing this task should
be interrupted in an attempt to stop the task.
Parameters:myAsync : Pass Null For Set Last Async.
UnsubscribeRequest : true if you want to Unsubscribe Retrofit Request.
mayInterruptIfRunning : true if the thread executing this task should be interrupted;
otherwise, in-progress tasks are allowed to complete.
Returns:
false if the task could not be cancelled, typically because it has already completed normally;
true otherwise
Get (EventName Asjava.lang.String, url Asjava.lang.String, maps Asjava.util.Map)Asaghajari.retrofit.Amir_RetrofitRequest use GET when you need to access a resource and retrieve data
and you don't have to modify or alter the state of this data. Events : EventName_onCompletedEventName_onError (Error as String,Code as int)EventName_onNext (ResponseBody as Amir_ResponseBody)
__________________________________________________________
Example :
Retrofit.get("Amir","Address",CreateMap()) Sub Amir_onNext (ResponseBody as Amir_ResponseBody)
Log(ResponseBody.String)
End Sub
PatchBody (EventName Asjava.lang.String, url Asjava.lang.String, body Asjava.lang.Object)Asaghajari.retrofit.Amir_RetrofitRequest
Patch (EventName Asjava.lang.String, url Asjava.lang.String, parameters Asjava.util.Map)Asaghajari.retrofit.Amir_RetrofitRequest The HTTP PUT method only allows complete replacement of
a document. Unlike PUT, PATCH is not idempotent, meaning
successive identical patch requests may have different effects.
However, it is possible to issue PATCH requests in such a
way as to be idempotent. Events : EventName_onCompletedEventName_onError (Error as String,Code as int)EventName_onNext (ResponseBody as Amir_ResponseBody)
Cache Asaghajari.retrofit.Retrofit.CacheManager Caches HTTP and HTTPS responses to the filesystem so they may be reused,
saving time and bandwidth.
Return Retrofit CacheManager
Options (EventName Asjava.lang.String, url Asjava.lang.String, maps Asjava.util.Map)Asaghajari.retrofit.Amir_RetrofitRequest The HTTP OPTIONS method is used to describe the communication
options for the target resource. The client can specify a URL
for the OPTIONS method, or an asterisk (*) to refer to the entire
server. Events : EventName_onCompletedEventName_onError (Error as String,Code as int)EventName_onNext (ResponseBody as Amir_ResponseBody)
__________________________________________________________
Example :
Retrofit.Options("Amir","Address",CreateMap()) Sub Amir_onNext (ResponseBody as Amir_ResponseBody)
Log(ResponseBody.String)
End Sub
NewRequest2 (Class Asjava.lang.Object, MethodName Asjava.lang.String, Params Asjava.lang.Object[])Asaghajari.retrofit.myObservable Create New Request With RxJava Events : You Should Use Subscriber in Observable
_____________________________________________
Warnings :
Create interface class
Create Method With Return Type : Observable (T)
____________________________________________
ir.aghajari.retrofit.Retrofit.Amir_GetApiClass public static Object Service(Class Class)public static Object ApiClass()public static Transformer schedulersTransformer()public static Transformer onDdoTransformer()public static Transformer handleErrTransformer()
_____________________________________________
How to Get Class ?
First Import ir.aghajari.retrofit.Retrofit.Amir_GetApiClass
Now Use This Code :
public Object getApiClass(){
return Amir_GetApiClass.Service(MyService.class);
}
_____________________________________________
Example : Edit Java Code !
Dim Rx as Amir_Observable
Dim J As JavaObject : J.InitializeContext
Rx=Retrofit.NewRequest2(J.RunMethod("getApiClass",Null),"ApiGet",Array ("UrlAddress",CreateMap("Key":Value)))
Dim Scheduler As Amir_Scheduler
Rx.Compose(Scheduler.SchedulersTransformer).Compose(Scheduler.HandleErrorTransformer)
Rx.Subscribe(Null,"Amir")
Sub Amir_onNext (Response as Object)
Dim ResponseBody as Amir_ResponseBody
ResponseBody.Import(Response)
Log(ResponseBody.String)
End Sub
#if java
import ir.aghajari.retrofit.Retrofit.Amir_GetApiClass;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.http.*;
import rx.Observable;
import java.util.Map;
public interface MyService {
GET()
Observable ApiGet(
Url String url,
QueryMap Map maps);
}
public Object getApiClass(){
return Amir_GetApiClass.Service(MyService.class);
}
#end if
_____________________________________________
Class: : Your Class .
MethodName: : Your Method Name
Params: : Parameters as Object
Form (EventName Asjava.lang.String, url Asjava.lang.String, fields Asjava.util.Map, Encoded Asboolean)Asaghajari.retrofit.Amir_RetrofitRequest Post With Encoded Enable
Events : EventName_onCompletedEventName_onError (Error as String)EventName_onNext (ResponseBody as Amir_ResponseBody)
__________________________________________________________
* Example :
Retrofit.form("Amir","Address",CreateMap("Key":value),True) Sub Amir_onNext (ResponseBody as Amir_ResponseBody)
Log(ResponseBody.String)
End Sub
PostMultipart (EventName Asjava.lang.String, url Asjava.lang.String, files Asjava.util.List)Asaghajari.retrofit.Amir_RetrofitRequest Events : EventName_onCompletedEventName_onError (Error as String)EventName_onNext (ResponseBody as Amir_ResponseBody)
_______________________________________________________
Post Multipart
Example :
Dim Files As List
Files.Initialize
Files.Add(Retrofit.RB.WithPartFormData2("Name","FileName", _
Retrofit.RB.WithFile("image/*",File.DirRootExternal,"NAME.PNG"))) 'Post File
Files.Add(Retrofit.RB.WithPartFormData("key","hello")) 'Post String
Retrofit.PostMultipart("Amir","Address",Files)
Upload (EventName Asjava.lang.String, url Asjava.lang.String, request Asokhttp3.RequestBody)Asaghajari.retrofit.Amir_RetrofitRequest Events : EventName_onCompletedEventName_onError (Error as String)EventName_onNext (ResponseBody as Amir_ResponseBody)
____________________________________________________________
Upload file.
Example :
Retrofit.upload("Amir","Address",Retrofit.RB.WithFile("image/*",File.DirInternal,"Image.png")
Body (EventName Asjava.lang.String, url Asjava.lang.String, body Asjava.lang.Object)Asaghajari.retrofit.Amir_RetrofitRequest http Post by Body
Events : EventName_onCompletedEventName_onError (Error as String)EventName_onNext (ResponseBody as Amir_ResponseBody)
____________________________________________________
Example :
Retrofit.body("Amir","Address",Body)
Download (EventName Asjava.lang.String, url Asjava.lang.String)Asaghajari.retrofit.Amir_RetrofitRequest Events : EventName_onCompletedEventName_onCancelEventName_onStart (Key as String)EventName_onSucess (key as String,path as String,Name as String,FileSize as long)EventName_onError (Error as String,Code as int)EventName_onProgress (key as String,progress as int,downloadedsize as long,totalsize as long)
_______________________________________________________________
Example :
Retrofit.Download("Amir","Url")
Sub Amir_onSucess (key as String,path as String,Name as String,FileSize as long)
Log(path&"/"&Name)
End Sub
_______________________________________________________________
Example2 :
Retrofit.SetDownloadOptions _
.Streaming(True) _
.Copy(File.DirRootExternal,"") _
.WithName("FileName") _
.WithKey("Key") _
.Build
Retrofit.Download("Amir","Url")
Sub Amir_onSucess (key as String,path as String,Name as String,FileSize as long)
Log(path&"/"&Name)
End Sub
Release (ba Asanywheresoftware.b4a.BA)Asaghajari.retrofit.Retrofit Start New Retrofit With Last Builder!
Retrofit.Release
if you want to start New Retrofit With New Builder
You Can Initialize this Retrofit Again
Retrofit.Initialize2("NewBaseUrl")
Or
Retrofit.Initialize(NewBuilder)
Post (EventName Asjava.lang.String, url Asjava.lang.String, parameters Asjava.util.Map)Asaghajari.retrofit.Amir_RetrofitRequest use POST when you need to send some data to the server.
Ex. from a form to save these data somewhere. Events : EventName_onCompletedEventName_onError (Error as String,Code as int)EventName_onNext (ResponseBody as Amir_ResponseBody)
UploadFileWithPartMap (EventName Asjava.lang.String, url Asjava.lang.String, partMap Asjava.util.Map, body Asokhttp3.MultipartBody.Part)Asaghajari.retrofit.Amir_RetrofitRequest partMap : String , RequestBody
Header : String , String | You Can Set Null
Events : EventName_onCompletedEventName_onError (Error as String)EventName_onNext (ResponseBody as Amir_ResponseBody)
_______________________________________________________
Upload File and Post Params
Example :
Dim Body as Amir_RequestBody
Dim M as Map=CreateMap("Key1":Body.WithString("text/plain","Hello"))
Retrofit.UploadFileWithPartMap("Amir","Address",M,Body.WithPartFormData2("PartName","FileName",Body.WithFile("image/*",File.DirInternal,"Image.png")))
Put (EventName Asjava.lang.String, url Asjava.lang.String, parameters Asjava.util.Map)Asaghajari.retrofit.Amir_RetrofitRequest use PUT when you need to replace the state of
some data already existing on that system. Events : EventName_onCompletedEventName_onError (Error as String,Code as int)EventName_onNext (ResponseBody as Amir_ResponseBody)
DoInBackground (Request Asaghajari.retrofit.Amir_RetrofitRequest)Asaghajari.retrofit.Async Start Request In Background Thread.
Params : Method : Amir_Retrofit Method Name. ToLowerCase EventName : CallBack EventName.
Url : Request URL
params : Amir_Retrofit Method Params With Out EventName And Url.
__________________________________________________________________________
Example :
Default Amir_Retrofit Code :
Retrofit.Post("Amir","UrlAddress",CreateMap("Key":"Value"))
With DoInBackground :
Retrofit.DoInBackground("post","Amir","UrlAddress",Array(CreateMap("Key":"Value")))
PostBody (EventName Asjava.lang.String, url Asjava.lang.String, body Asjava.lang.Object)Asaghajari.retrofit.Amir_RetrofitRequest
Initialize3 (ba Asanywheresoftware.b4a.BA)Asvoid Create Retrofit With Default Builder and without baseUrl
Initialize2 (ba Asanywheresoftware.b4a.BA, BaseUrl Asjava.lang.String)Asvoid Create Retrofit With Default Builder
PostRequestBody (EventName Asjava.lang.String, url Asjava.lang.String, body Asokhttp3.RequestBody)Asaghajari.retrofit.Amir_RetrofitRequest http Post by RequestBody
Events : EventName_onCompletedEventName_onError (Error as String)EventName_onNext (ResponseBody as Amir_ResponseBody)
DeleteBody (EventName Asjava.lang.String, url Asjava.lang.String, body Asjava.lang.Object)Asaghajari.retrofit.Amir_RetrofitRequest
UploadFileWithDescription (EventName Asjava.lang.String, url Asjava.lang.String, description Asokhttp3.RequestBody, part Asokhttp3.MultipartBody.Part)Asaghajari.retrofit.Amir_RetrofitRequest Header : String,String You Can Set Null
Events : EventName_onCompletedEventName_onError (Error as String)EventName_onNext (ResponseBody as Amir_ResponseBody)
_________________________________________________________
Upload File with a description Request
NewRequest (ba Asanywheresoftware.b4a.BA, EventName Asjava.lang.String, Class Asjava.lang.Object, MethodName Asjava.lang.String, Params Asjava.lang.Object[])Asjava.lang.Object Create New Request Events : EventName_onCompletedEventName_onError (Error as String)EventName_onNext (ResponseBody as Amir_ResponseBody)
_____________________________________________
Warnings :
Create interface class
Create Method With Return Type : Observable ResponseBody
____________________________________________
ir.aghajari.retrofit.Retrofit.Amir_GetApiClass public static Object Service(Class Class)public static Object ApiClass()public static Transformer schedulersTransformer()public static Transformer onDdoTransformer()public static Transformer handleErrTransformer()
_____________________________________________
How to Get Class ?
First Import ir.aghajari.retrofit.Retrofit.Amir_GetApiClass
Now Use This Code :
public Object getApiClass(){
return Amir_GetApiClass.Service(MyService.class);
}
_____________________________________________
Example : Edit Java Code !
Dim J As JavaObject : J.InitializeContext
Retrofit.NewRequest("Amir",J.RunMethod("getApiClass",Null),"ApiGet",Array ("UrlAddress",CreateMap("Key":Value)))
#if java
import ir.aghajari.retrofit.Retrofit.Amir_GetApiClass;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.http.*;
import rx.Observable;
import java.util.Map;
public interface MyService {
GET()
Observable ApiGet(
Url String url,
QueryMap Map maps);
}
public Object getApiClass(){
return Amir_GetApiClass.Service(MyService.class);
}
#end if
Sub Amir_onNext (ResponseBody as Amir_ResponseBody)
Log(ResponseBody.String)
End Sub
_____________________________________________
EventName: : Your EventName for Load Events
Class: : Your Class .
MethodName: : Your Method Name
Params: : Parameters as Object
Client Asokhttp3.OkHttpClient[read only] get this retrofit Client for use in new Builder
Methods:
Matches (url Asjava.lang.String)Asboolean Returns true if this cookie should be included on a request to url. In addition to this
check callers should also confirm that this cookie has not expired.
Properties:
Path Asjava.lang.String[read only] Returns this cookie's path. This cookie matches URLs prefixed with path segments that match
this path's segments. For example, if this path is /foo this cookie matches requests to
/foo and /foo/bar, but not / or /football.
Secure Asboolean[read only] Returns true if this cookie should be limited to only HTTPS requests.
Value Asjava.lang.String[read only] Returns a possibly-empty string with this cookie's value.
HostOnly Asboolean[read only] Returns true if this cookie's domain should be interpreted as a single host name, or false if
it should be interpreted as a pattern. This flag will be false if its Set-Cookie header
included a domain attribute.
For example, suppose the cookie's domain is example.com. If this flag is true it
matches only example.com. If this flag is false it matches
example.com and all subdomains including api.example.com, www.example.com, and
beta.api.example.com.
Persistent Asboolean[read only] Returns true if this cookie does not expire at the end of the current session.
Domain Asjava.lang.String[read only] Returns the cookie's domain. If hostOnly returns true this is the only domain that
matches this cookie; otherwise it matches this domain and all subdomains.
ExpiresAt Aslong[read only] Returns the time that this cookie expires, in the same format as
System currentTimeMillis. This is December 31, 9999 if the cookie is
not persistent, in which case it will expire at the end of the current session.
This may return a value less than the current time, in which case the cookie is already
expired. Webservers may return expired cookies as a mechanism to delete previously set cookies
that may or may not themselves be expired.
HttpOnly Asboolean[read only] Returns true if this cookie should be limited to only HTTP APIs. In web browsers this prevents
the cookie from being accessible to scripts.
Name Asjava.lang.String[read only] Returns a non-empty string with this cookie's name.
Methods:
ParseCookie (url Asjava.lang.String, setCookie Asjava.lang.String)Asokhttp3.Cookie Attempt to parse a Set-Cookie HTTP header value setCookie as a cookie. Returns
null if setCookie is not a well-formed cookie.
Return : okhttp3.Cookie
LoadAll Asjava.util.List Return List of Cookies (okhttp3.Cookie)
LoadForRequest (url Asjava.lang.String)Asjava.util.List Get List Of okhttp3.Cookie
ParseAllCookie (url Asjava.lang.String, headers Asjava.util.Map)Asjava.util.List Returns all of the cookies from a set of HTTP response headers.
Return : List of okhttp3.Cookie
ClearSession Asvoid Clear all the session cookies while maintaining the persisted ones.
SaveFromResponse (url Asjava.lang.String, Cookies Asjava.util.List)Asvoid this method uses filterPersistentCookies
Example :
Retrofit.CookieManager.SaveFromResponse("Url",Retrofit.CacheManager.ParseAllCookie("Url",Headers))
Cookies : List of okhttp3.Cookie
Clear Asvoid Clear all the cookies from persistence and from the cache.
Methods:
Delete Asvoid Closes the cache and deletes all of its stored values. This will delete all files in the cache
directory including files that weren't created by the cache.
DirectoryDeleteOnExit Asvoid
maxSize Aslong
Initialize Asvoid Initialize the cache. This will include reading the journal files from the storage and building
up the necessary in-memory cache information.
The initialization time may vary depending on the journal file size and the current actual
cache size. The application needs to be aware of calling this function during the
initialization phase and preferably in a background worker thread.
Note that if the application chooses to not call this method to initialize the cache. By
default, the okhttp will perform lazy initialization upon the first usage of the cache.
writeAbortCount Asint
writeSuccessCount Asint
size Aslong
flush Asvoid
isClosed Asboolean
Close Asvoid
EvictAll Asvoid Deletes all values stored in the cache. In-flight writes to the cache will complete normally,
but the corresponding responses will not be stored.
Properties:
UrlsIterator Asaghajari.retrofit.Retrofit.CacheManager.urls[read only] Returns an iterator over the URLs in this cache. This iterator doesn't throw
ConcurrentModificationException, but if new responses are added while iterating, their URLs
will not be returned. If existing responses are evicted during iteration, they will be absent
(unless they were already returned).
The iterator supports Iterator remove. Removing a URL from the iterator evicts
the corresponding response from the cache. Use this to evict selected responses.
____________________________________________________________________________________________
Example :
Do While Retrofit.Cache.UrlsIterator.hasNext
Log(Retrofit.Cache.UrlsIterator.Next)
Loop
DirectoryPath Asjava.lang.String[read only]
DirectoryFreeSpace Aslong[read only]
DirectoryUsableSpace Aslong[read only]
UrlsList Asjava.util.List[read only] Example :
Dim L as List= Retrofit.Cache.UrlsList
for i = 0 to L.size-1
Log(L.get(i))
Next
DirectoryName Asjava.lang.String[read only]
DirectoryTotalSpace Aslong[read only]
DirectoryDelete Asboolean[read only]
Directory Asjava.io.File[read only]
Methods:
Next Asjava.lang.String Returns the next element in the iteration.
Returns: the next element in the iteration
hasNext Asboolean Returns true if the iteration has more elements. (In other words,
returns true if next() would return an element rather than throwing
an exception.)
Returns: true if the iteration has more elements
remove Asvoid Removes from the underlying collection the last element returned
by this iterator (optional operation). This method can be called
only once per call to next(). The behavior of an iterator is
unspecified if the underlying collection is modified while the
iteration is in progress in any way other than by calling this method.
Methods:
handleErrTransformer Asrx.Observable.Transformer
schedulersTransformer Asrx.Observable.Transformer
Service (Class Asjava.lang.Class)Asjava.lang.Object