This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implementation 'com.squareup.retrofit2:retrofit:2.6.1' | |
implementation 'com.squareup.retrofit2:converter-gson:2.6.1' | |
implementation 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"user_name": "Alex", | |
"user_email": "alex@gmail.com", | |
"user_age": 32, | |
"user_uid": "164E92FC-D37A-4946-81CB-29DE7EE4B124" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"user_id": 1001, | |
"user_name": "Alex", | |
"user_email": "alex@gmail.com", | |
"user_age": 32, | |
"user_uid": "164E92FC-D37A-4946-81CB-29DE7EE4B124" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class UserInfo ( | |
@SerializedName("user_id") val userId: Int?, | |
@SerializedName("user_name") val userName: String?, | |
@SerializedName("user_email") val userEmail: String?, | |
@SerializedName("user_age") val userAge: String?, | |
@SerializedName("user_uid") val userUid: String? | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import retrofit2.Call | |
import retrofit2.http.Body | |
import retrofit2.http.Headers | |
import retrofit2.http.POST | |
interface RestApi { | |
@Headers("Content-Type: application/json") | |
@POST("users") | |
fun addUser(@Body userData: UserInfo): Call<UserInfo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import okhttp3.OkHttpClient | |
import retrofit2.Retrofit | |
import retrofit2.converter.gson.GsonConverterFactory | |
object ServiceBuilder { | |
private val client = OkHttpClient.Builder().build() | |
private val retrofit = Retrofit.Builder() | |
.baseUrl("http://api.server.com") // change this IP for testing by your actual machine IP | |
.addConverterFactory(GsonConverterFactory.create()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import retrofit2.Call | |
import retrofit2.Callback | |
import retrofit2.Response | |
import retrofit2.Retrofit | |
class RestApiService { | |
fun addUser(userData: UserInfo, onResult: (UserInfo?) -> Unit){ | |
val retrofit = ServiceBuilder.buildService(RestApi::class.java) | |
retrofit.addUser(userData).enqueue( | |
object : Callback<UserInfo> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun addDummyUser() { | |
val apiService = RestApiService() | |
val userInfo = UserInfo( id = null, | |
userName = "Alex", | |
userEmail = "alex@gmail.com", | |
userAge = 32, | |
userUid = "164E92FC-D37A-4946-81CB-29DE7EE4B124" ) | |
apiService.addUser(userInfo) { | |
if (it?.id != null) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "This is simplest bash command" | |
#start of the apple script code | |
osascript <<'END' | |
set theAlertText to "Swiftlint is not installed" | |
set theAlertMessage to "Download from https://github.com/realm/SwiftLint manually. Would you like to open link?" | |
display alert theAlertText message theAlertMessage as critical buttons {"Cancel", "Open link"} default button "Open link" cancel button "Cancel" giving up after 60 | |
set the button_pressed to the button returned of the result | |
if the button_pressed is "Open link" then | |
open location "https://github.com/realm/SwiftLint/blob/master/README.md" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set listWithLinks to {"google.com", "bing.com", "yahoo.com"} | |
set listWithLabels to {"Google", "Bing", "Yahoo"} | |
set dialogTitle to "Select & Go to open link" | |
set buttonOK to "Go" | |
set buttonCancel to "Cancel" | |
set choosedLabels to choose from list (listWithLabels as list) with title dialogTitle OK button name buttonOK cancel button name buttonCancel with multiple selections allowed | |
if false is choosedLabels then return | |
repeat with i from 1 to number of items in choosedLabels | |
set choosedLabel to item i of choosedLabels | |
repeat with i from 1 to number of items in listWithLabels |
OlderNewer