Skip to content

Instantly share code, notes, and snippets.

nosix

Block or report user

Report or block nosix

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nosix
nosix / MainActivity.kt
Created Jul 9, 2016
UpdateReceiver for Android (SDK 22) in Kotlin 1.0.2
View MainActivity.kt
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 Jul 17, 2016
Custom View for Android (SDK 22) in Kotlin 1.0.2
View CircleMeter.kt
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 Jul 17, 2016
RecylerView for Android (SDK 22) in Kotlin 1.0.2
View XXXFragment.kt
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 Jul 17, 2016
dismiss DialogFragment for Android (SDK 22) in Kotlin 1.0.2
View XXXDialogFragment
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 / AndroidManifest.xml
Last active Jul 24, 2016
Dialog Activity for Android (SDK 22) in Kotlin 1.0.2
View AndroidManifest.xml
...
<activity
android:name=".NewItemActivity"
android:label="@string/new_item"
android:theme="@style/DialogTheme" />
...
@nosix
nosix / CustomViewPager.kt
Last active Jul 26, 2016
ViewPager for Android (SDK 22) in Kotlin 1.0.2. It can be scrolled in one direction. (Left only, Right only or Both)
View CustomViewPager.kt
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 Jul 26, 2016
ViewPager for Android (SDK 22) in Kotlin 1.0.2. It can be scrolled in one direction. (Left only, Right only or Both)
View MainActivity.kt
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 Jul 28, 2016
Using the LeakCanary that is a memory leak detection library for Android and Java.
View AndroidManifest.xml
<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 / text-to-speech.html
Created Sep 7, 2016
Text to Speech using Watson
View text-to-speech.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Text to Speech</title>
</head>
<body>
<div id="text-to-speech">
<input type="text" name="speech-text" placeholder="Sentence">
@nosix
nosix / AndroidManifest.xml
Last active Sep 14, 2016
How to use Android Service API
View AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="xxx">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission
android:name="android.permission.PACKAGE_USAGE_STATS"
tools:ignore="ProtectedPermissions" />
You can’t perform that action at this time.