Resize view to fit aspect ratio of video in Android ExoPlayer

Been playing with ExoPlayer in Android and trying to resize a view to fit the aspect ratio of the video being played, i.e. fill the view with the video. References: Change resize mode for ExoPlayer Change aspect ratio of SurfaceView for ExoPlayer video 5-part series on building video player using ExoPlayer import android.view.ViewGroup.LayoutParams; import com.google.android.exoplayer2.Player.EventListener; …

Print properties of object in Swift

Reference: StackOverflow – Print Struct name in swift Here’s the code for printing the properties of an object func printProperties(_ object: Any) { var properties = [String: Any]() Mirror(reflecting: object).children.forEach { (child) in if let property = child.label { properties[property] = child.value } } print(object) print(type(of: object)) print(properties) } How the output would look like …

Swift func to show alert dialog in AppDelegate or ViewController

Was trying to show an alert dialog in a project’s AppDelegate.swift and ViewController.swift and decided to move it to a function in a separate utility class. Main issue was how to make it work as the class was a plain Swift class – self.present() could be used inside ViewController, self.window?.rootViewController?.present() could be used inside AppDelegate, …