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 UIKit | |
class TabBarController: UITabBarController { | |
var indicatorImage: UIImageView? | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
let numberOfItems = CGFloat(tabBar.items!.count) |
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 AnimatorSet.onFinished(execute: Runnable, delay: Long) { | |
var animationDelay : Long = this.childAnimations.last().duration + this.childAnimations.last().startDelay | |
Handler().postDelayed({ | |
execute.run() | |
},animationDelay + delay) | |
} |
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
Picasso.with(context).load(url).resize(width, height).centerCrop().into(ImageView) |
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
class ImageRequest() : AsyncTask<String,Void,Bitmap>() { | |
override fun doInBackground(vararg params: String?): Bitmap { | |
val stream = URL(params[0]).openConnection().getInputStream() | |
val bmp = BitmapFactory.decodeStream(stream) | |
return bmp | |
} | |
override fun onPostExecute(result: Bitmap?) { | |
super.onPostExecute(result) | |
} |
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
class HttpGetRequest : AsyncTask<String, Void, String>() { | |
val REQUEST_METHOD = "GET" | |
val READ_TIMEOUT = 15000 | |
val CONNECTION_TIMEOUT = 15000 | |
override fun doInBackground(vararg params: String?): String { | |
val stringUrl : String = params[0] as String | |
var result : String? = null | |
var inputLine : String? = 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
URLSession.shared.dataTask(with:url!, completionHandler: {(data, response, error) in | |
guard let data = data, error == nil else { return } | |
do { | |
let json = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as! [String:Any] | |
} | |
}) |
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
public class HttpGetRequest : AsyncTask<String, Void, String>() { | |
val REQUEST_METHOD = "GET" | |
val READ_TIMEOUT = 15000 | |
val CONNECTION_TIMEOUT = 15000 | |
override fun doInBackground(vararg params: String?): String { | |
val stringUrl : String = params[0] as String | |
var result : String? = null | |
var inputLine : String? = 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
class ImageRequest(val url: String): AsyncTask<Void,Void,Bitmap>() { | |
override protected fun doInBackground(vararg params: Void?): Bitmap { | |
val bmp = BitmapFactory.decodeStream(URL(url).openConnection().getInputStream()) | |
return bmp | |
} | |
override protected fun onPostExecute(result: Bitmap?) { | |
super.onPostExecute(result) | |
} |
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
DispatchQueue.global().async { | |
//do asynchronous stuff | |
} |
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
struct Person : Codable { | |
var name: String | |
var address: String | |
var avatarUrl: String | |
} | |
let person = try! JSONDecoder().decode(Person.self, from: onePersonJsonString!) | |
let people = try! JSONDecoder().decode([Person].self, from: multiplePeopleJsonString!) |
NewerOlder