diff --git a/.idea/caches/gradle_models.ser b/.idea/caches/gradle_models.ser
new file mode 100644
index 0000000..136fbcc
Binary files /dev/null and b/.idea/caches/gradle_models.ser differ
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index 30aa626..554ffcd 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -1,29 +1,161 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmlns:android
+
+ ^$
+
+
+
+
+
+
+
+
+ xmlns:.*
+
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*:id
+
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ .*:name
+
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ name
+
+ ^$
+
+
+
+
+
+
+
+
+ style
+
+ ^$
+
+
+
+
+
+
+
+
+ .*
+
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*
+
+ http://schemas.android.com/apk/res/android
+
+
+ ANDROID_ATTRIBUTE_ORDER
+
+
+
+
+
+
+ .*
+
+ .*
+
+
+ BY_NAME
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/dbnavigator.xml b/.idea/dbnavigator.xml
new file mode 100644
index 0000000..2bcafe4
--- /dev/null
+++ b/.idea/dbnavigator.xml
@@ -0,0 +1,456 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/dictionaries/shrinidhi.xml b/.idea/dictionaries/shrinidhi.xml
new file mode 100644
index 0000000..9773fa2
--- /dev/null
+++ b/.idea/dictionaries/shrinidhi.xml
@@ -0,0 +1,7 @@
+
+
+
+ hacktoberfest
+
+
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 7ac24c7..169fd0d 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -12,6 +12,7 @@
+
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..b28ecda
--- /dev/null
+++ b/README.md
@@ -0,0 +1,9 @@
+# Memory Leaks On Android
+---
+
+This repository has the kotlin code for the forked repository.
+The app is working fine. No issues.
+
+---
+
+Done as a part of hacktoberfest 2019.
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index cff601e..ebdf8a8 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,4 +1,6 @@
apply plugin: 'com.android.application'
+apply plugin: 'kotlin-android-extensions'
+apply plugin: 'kotlin-android'
android {
compileSdkVersion 28
@@ -28,4 +30,8 @@ dependencies {
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.2'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.2'
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
+}
+repositories {
+ mavenCentral()
}
diff --git a/app/src/main/java/com/codingwithmitch/memoryleaks/MainActivity.java b/app/src/main/java/com/codingwithmitch/memoryleaks/MainActivity.java
deleted file mode 100644
index f6403cd..0000000
--- a/app/src/main/java/com/codingwithmitch/memoryleaks/MainActivity.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package com.codingwithmitch.memoryleaks;
-
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.os.AsyncTask;
-import android.support.v7.app.AppCompatActivity;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.TextView;
-
-import java.lang.ref.WeakReference;
-
-public class MainActivity extends AppCompatActivity {
-
- private MyAsyncTask myAsyncTask;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
-
-
- findViewById(R.id.go).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
-
- if(myAsyncTask != null){
- finish();
- }
-
- myAsyncTask = new MyAsyncTask(MainActivity.this);
- myAsyncTask.execute();
-
- }
- });
- }
-
- private class MyAsyncTask extends AsyncTask{
-
-
-// private Context mContext;
- private WeakReference mContextRef;
-
-
-
- public MyAsyncTask(Context context) {
-// this.mContext = context; // METHOD 1: CANCEL ASYNCTASK in onDestroy
- mContextRef = new WeakReference<>(context); // METHOD 2: Use WeakReference
- }
-
- @Override
- protected Void doInBackground(Void... voids) {
-
- Bitmap icon = BitmapFactory.decodeResource(mContextRef.get().getResources(),R.drawable.ic_launcher_background);
-// Bitmap icon = BitmapFactory.decodeResource(mContext.getResources(),R.drawable.ic_launcher_background);
-
- try {
- Thread.sleep(5000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- return null;
- }
- }
-
-
- @Override
- protected void onDestroy() {
-// myAsyncTask.cancel(true);
- super.onDestroy();
- }
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/java/com/codingwithmitch/memoryleaks/MainActivity.kt b/app/src/main/java/com/codingwithmitch/memoryleaks/MainActivity.kt
new file mode 100644
index 0000000..edb5de3
--- /dev/null
+++ b/app/src/main/java/com/codingwithmitch/memoryleaks/MainActivity.kt
@@ -0,0 +1,97 @@
+package com.codingwithmitch.memoryleaks
+
+import android.annotation.SuppressLint
+import android.content.Context
+import android.graphics.Bitmap
+import android.graphics.BitmapFactory
+import android.os.AsyncTask
+import android.support.v7.app.AppCompatActivity
+import android.os.Bundle
+import android.view.View
+import android.widget.TextView
+
+import java.lang.ref.WeakReference
+
+class MainActivity : AppCompatActivity() {
+
+ private var myAsyncTask: MyAsyncTask? = null
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_main)
+
+
+ findViewById(R.id.go).setOnClickListener {
+ if (myAsyncTask != null) {
+ finish()
+ }
+
+ myAsyncTask = MyAsyncTask(this@MainActivity)
+ myAsyncTask!!.execute()
+ }
+ }
+
+ private inner class MyAsyncTask(context: Context) : AsyncTask() {
+
+
+ // private Context mContext;
+ private val mContextRef: WeakReference
+
+
+ init {
+ // this.mContext = context; // METHOD 1: CANCEL ASYNCTASK in onDestroy
+ mContextRef = WeakReference(context) // METHOD 2: Use WeakReference
+ }
+
+ override fun doInBackground(vararg voids: Void): Void? {
+
+ val icon = BitmapFactory.decodeResource(mContextRef.get()?.getResources(), R.drawable.ic_launcher_background)
+ // Bitmap icon = BitmapFactory.decodeResource(mContext.getResources(),R.drawable.ic_launcher_background);
+
+ try {
+ Thread.sleep(5000)
+ } catch (e: InterruptedException) {
+ e.printStackTrace()
+ }
+
+ return null
+ }
+ }
+
+
+ override fun onDestroy() {
+ // myAsyncTask.cancel(true);
+ super.onDestroy()
+ }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/java/com/codingwithmitch/memoryleaks/MyApplication.java b/app/src/main/java/com/codingwithmitch/memoryleaks/MyApplication.java
deleted file mode 100644
index 9cc99f0..0000000
--- a/app/src/main/java/com/codingwithmitch/memoryleaks/MyApplication.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.codingwithmitch.memoryleaks;
-
-import android.app.Application;
-
-import com.squareup.leakcanary.LeakCanary;
-
-public class MyApplication extends Application {
-
- @Override
- public void onCreate() {
- super.onCreate();
- if (LeakCanary.isInAnalyzerProcess(this)) {
- // This process is dedicated to LeakCanary for heap analysis.
- // You should not init your app in this process.
- return;
- }
- LeakCanary.install(this);
- // Normal app init code...
- }
-}
-
diff --git a/app/src/main/java/com/codingwithmitch/memoryleaks/MyApplication.kt b/app/src/main/java/com/codingwithmitch/memoryleaks/MyApplication.kt
new file mode 100644
index 0000000..7749529
--- /dev/null
+++ b/app/src/main/java/com/codingwithmitch/memoryleaks/MyApplication.kt
@@ -0,0 +1,20 @@
+package com.codingwithmitch.memoryleaks
+
+import android.app.Application
+
+import com.squareup.leakcanary.LeakCanary
+
+class MyApplication : Application() {
+
+ override fun onCreate() {
+ super.onCreate()
+ if (LeakCanary.isInAnalyzerProcess(this)) {
+ // This process is dedicated to LeakCanary for heap analysis.
+ // You should not init your app in this process.
+ return
+ }
+ LeakCanary.install(this)
+ // Normal app init code...
+ }
+}
+
diff --git a/build.gradle b/build.gradle
index 8d3ef8e..2fa19f7 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,14 +1,16 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
-
+ ext.kotlin_version = '1.3.50'
+
repositories {
google()
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.2.1'
-
+ classpath 'com.android.tools.build:gradle:3.5.0'
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 9a4163a..c07bc6c 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,6 @@
+#Tue Oct 01 00:27:32 IST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip