Skip to content

Instantly share code, notes, and snippets.

View nosix's full-sized avatar

nosix nosix

View GitHub Profile
@nosix
nosix / MainActivity.kt
Last active May 26, 2018 02:22
DialogFragment for Android (SDK 22) in Kotlin 1.0.2
class MainActivity : AppCompatActivity(), SeekDialogFragment.SeekDialogListener {
companion object {
private val TAG = MainActivity::class.qualifiedName;
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
@nosix
nosix / AndroidManifest.xml
Last active July 24, 2016 09:29
Dialog Activity for Android (SDK 22) in Kotlin 1.0.2
...
<activity
android:name=".NewItemActivity"
android:label="@string/new_item"
android:theme="@style/DialogTheme" />
...
@nosix
nosix / MainActivity.kt
Created July 9, 2016 12:22
UpdateReceiver for Android (SDK 22) in Kotlin 1.0.2
class MainActivity : AppCompatActivity() {
private val updateReceiver = UpdateReceiver(this)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
registerReceiver(updateReceiver, IntentFilter(SampleService.ACTION_SAMPLE))
}
@nosix
nosix / CircleMeter.kt
Created July 17, 2016 05:51
Custom View for Android (SDK 22) in Kotlin 1.0.2
package xxx.view
import android.content.Context
import android.graphics.*
import android.util.AttributeSet
import android.view.View
import xxx.R
class CircleMeter(context: Context, attrs: AttributeSet?, defStyleAttr: Int) :
View(context, attrs, defStyleAttr) {
@nosix
nosix / XXXFragment.kt
Created July 17, 2016 14:44
RecylerView for Android (SDK 22) in Kotlin 1.0.2
package xxx.view
import android.app.Activity
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v7.widget.RecyclerView
import android.support.v7.widget.helper.ItemTouchHelper
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@nosix
nosix / XXXDialogFragment
Created July 17, 2016 15:26
dismiss DialogFragment for Android (SDK 22) in Kotlin 1.0.2
package xxx.view
import android.app.Activity
import android.app.AlertDialog
import android.app.Dialog
import android.app.DialogFragment
import android.os.Bundle
import android.support.v7.widget.RecyclerView
import xxx.R
@nosix
nosix / CustomViewPager.kt
Last active July 26, 2016 14:07
ViewPager for Android (SDK 22) in Kotlin 1.0.2. It can be scrolled in one direction. (Left only, Right only or Both)
package xxx.view
import android.content.Context
import android.support.v4.view.ViewPager
import android.util.AttributeSet
import android.view.MotionEvent
class CustomViewPager(context: Context, attrs: AttributeSet?) : ViewPager(context, attrs) {
constructor(context: Context) : this(context, null)
@nosix
nosix / MainActivity.kt
Created July 26, 2016 14:25
ViewPager for Android (SDK 22) in Kotlin 1.0.2. It can be scrolled in one direction. (Left only, Right only or Both)
class MainActivity : AppCompatActivity() {
private fun updateViewPager() {
findViewById(R.id.main_container).let {
it as ViewPager
(it.adapter as MainPagerAdapter).last = it.currentItem
}
}
}
@nosix
nosix / AndroidManifest.xml
Created July 28, 2016 02:40
Using the LeakCanary that is a memory leak detection library for Android and Java.
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="xxx">
<application
android:name=".MyApplication"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
@nosix
nosix / AndroidManifest.xml
Last active November 13, 2018 18:40
How to resolve the memory leak for Android (SDK 22) in Kotlin 1.0.2. (InputMethodManager refer to RecyclerView)
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="xxx">
<application
android:name=".MyApplication"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name">
...