Skip to content

Instantly share code, notes, and snippets.

Avatar

Jitin jitinsharma

View GitHub Profile
View ViewController.swift
import UIKit
import Base
class ViewController: UIViewController {
@IBOutlet weak var sumView: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
let base = BaseHelper()
sumView.text = "Sum: \(base.getSum(first: 2, second: 3))"
View Base.swift
import Foundation
open class KotlinBase : NSObject {
open class func initialize()
}
extension KotlinBase : NSCopying {
}
open class BaseHelper : KotlinBase {
View build.gradle
buildscript {
ext.kotlin_native_version = '0.6'
repositories {
mavenCentral()
maven {
url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies"
}
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$kotlin_native_version"
View MainActivity.kt
package io.github.jitinsharma.androidapp
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import io.github.jitinsharma.API_KEY
import io.github.jitinsharma.Helper
import io.github.jitinsharma.Model
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
View build.gradle
group 'io.github.jitinsharma'
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = '1.2.21'
repositories {
mavenCentral()
}
dependencies {
View Base.kt
package io.github.jitinsharma
const val API_KEY = "abdfkdfgl453"
class Helper {
fun getSum(first: Int, second: Int): Int = first + second
fun sliceFilterAndSort(list: List<String>): List<String> =
list.subList(0, 4).filter { it.length > 3 }.sortedBy { it.length }
companion object {
val helperId: Int = 0
View KotlinSerialization.kt
package io.github.jitinsharma
import kotlinx.serialization.*
import kotlinx.serialization.json.JSON
@Serializable
data class Destination(
var name : String? = "",
var country : String? = "",
var code : Int = 0,
@jitinsharma
jitinsharma / FrameMetrics.java
Created Jun 14, 2016
Getting UI performance data using FrameMetrics - Android N preview
View FrameMetrics.java
final FrameMetrics[] metrics = {null};
Window window = getActivity().getWindow();
Handler mHandler = new Handler();
window.addOnFrameMetricsAvailableListener(new Window.OnFrameMetricsAvailableListener() {
@Override
public void onFrameMetricsAvailable(Window window, FrameMetrics frameMetrics, int i) {
metrics[0] = new FrameMetrics(frameMetrics);
}
},mHandler);