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
| import android.content.BroadcastReceiver | |
| import android.content.Context | |
| import android.content.Intent | |
| import timber.log.Timber | |
| class HeadsetPlugReciever : BroadcastReceiver() { | |
| override fun onReceive(context: Context?, | |
| intent: Intent) { | |
| if (intent.action != Intent.ACTION_HEADSET_PLUG) { | |
| Timber.e("jsp HeadsetPlugReciever recieved ${intent.action} event") |
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
| // sensor | |
| private lateinit var mSensorManager: SensorManager | |
| private var mAccel: Float = 0.toFloat() // acceleration apart from gravity | |
| private var mAccelCurrent: Float = 0.toFloat() // current acceleration including gravity | |
| private var mAccelLast: Float = 0.toFloat() // last acceleration including gravity | |
| override onCreate(){ | |
| ... |
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
| // by application package name | |
| val packName = "com.google.chrome" | |
| val intent = packageManager.getLaunchIntentForPackage(packName) | |
| intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT) | |
| intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION) | |
| intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP) | |
| intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) | |
| startActivity(intent) | |
| //launch shortcut (package name+ activity name) |
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
| // interface: need to use constructor | |
| interface Launchable { | |
| fun idString(): String | |
| fun description(): String | |
| fun execute(manager: LaunchManager) | |
| fun getIcon(model: Model, | |
| color: Int): Single<Drawable> | |
| } | |
| class LaunchAppAction(var pac: Pac) : Launchable { |
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
| // take auto generated xml | |
| class XXXActivity : BaseRxActivity() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_upgrade_to_premium) | |
| supportActionBar?.setDisplayHomeAsUpEnabled(true) | |
| } |
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
| class MainActivity : AppCompatActivity() { | |
| val tapTargets: MutableList<TapAct> = mutableListOf() | |
| /** | |
| * @param listener - what will be done onTargetClick | |
| */ | |
| fun getTapTarget(listener: () -> Unit): TapTargetView.Listener { | |
| return object : TapTargetView.Listener() { // The listener can listen for regular clicks, long clicks or cancels | |
| override fun onTargetClick(view: TapTargetView) { |
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
| org.gradle.daemon=true | |
| org.gradle.parallel=true | |
| org.gradle.configureondemand=true | |
| org.gradle.jvmargs=-Xmx3g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 |
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 setLogoInsteadOfText(){ | |
| // setSupportActionBar(toolbar) // use it if not set yet | |
| supportActionBar?.setDisplayShowTitleEnabled(false) | |
| toolbar.setLogo(R.drawable.ic_launcher_foreground) | |
| } |
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
| override fun onCreateOptionsMenu(menu: Menu): Boolean { | |
| // Inflate the menu; this adds items to the action bar if it is present. | |
| menuInflater.inflate(R.menu.home, menu) | |
| return true | |
| } | |
| override fun onOptionsItemSelected(item: MenuItem): Boolean { | |
| // Handle action bar item clicks here. The action bar will | |
| // automatically handle clicks on the Home/Up button, so long | |
| // as you specify a parent activity in AndroidManifest.xml. |
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 var mSectionsPagerAdapter: SectionsPagerAdapter? = null | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| ... | |
| mSectionsPagerAdapter = SectionsPagerAdapter(supportFragmentManager) | |
| container.adapter = mSectionsPagerAdapter | |
| tl_9.setViewPager(container) | |
| nav_view.setNavigationItemSelectedListener(this) |