This file contains hidden or 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
package com.example.sagar.physicsanimation | |
import android.support.v7.app.AppCompatActivity | |
import android.os.Bundle | |
import android.support.v7.app.ActionBarDrawerToggle | |
import android.support.v7.widget.Toolbar | |
import androidx.navigation.Navigation | |
import androidx.navigation.ui.NavigationUI | |
import androidx.navigation.ui.setupWithNavController | |
import kotlinx.android.synthetic.main.activity_main.* |
This file contains hidden or 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
package com.example.sagar.physicsanimation | |
import android.support.v7.app.AppCompatActivity | |
import android.os.Bundle | |
import android.os.PersistableBundle | |
import android.support.design.widget.NavigationView | |
import android.support.v4.app.Fragment | |
import android.support.v4.view.GravityCompat | |
import android.support.v7.app.ActionBarDrawerToggle | |
import android.support.v7.widget.Toolbar |
This file contains hidden or 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
/** | |
* Heap sort | |
* | |
* Given an array, sort it in ascending order using heap sort algorithm | |
*/ | |
fun main(args: Array<String>) { | |
val array = intArrayOf(4, 1, 3, 2, 16, 9, 10, 14, 8, 7) |
This file contains hidden or 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
/** | |
* Maximum sub array problem | |
* | |
* Given an array of integers find the sub array whose sum is maximum | |
*/ | |
fun main(args: Array<String>) { | |
val array = intArrayOf(13, -3, -25, 20, -3, -16, -23, 18, 20, -7, 12, -5, -22, 15, -4, 7) | |
print(getMaximumSubArray(array, 0, array.size - 1)) |
This file contains hidden or 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
firstSpringAnimationX.addUpdateListener { _, value, _ -> | |
secondSpringAnimationX.animateToFinalPosition(value) | |
} | |
firstSpringAnimationY.addUpdateListener { _, value, _ -> | |
secondSpringAnimationY.animateToFinalPosition(value) | |
} |
This file contains hidden or 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
private fun setupOnTouchListener() { | |
... | |
android_bot.setOnTouchListener { view, motionEvent -> | |
if(motionEvent.action == MotionEvent.ACTION_MOVE) { | |
val deltaX = motionEvent.rawX - lastX | |
val deltaY = motionEvent.rawY - lastY |