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
| 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
| 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
| // 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
| // 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
| // 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
| // 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
| 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
| // set on long click listener | |
| launcherGrid.setOnItemLongClickListener { parent, view, position, id -> | |
| Timber.d("jsp grid item id=$id pos=$position long clicked") | |
| launcherAdapter().startDrag(view, position) | |
| false | |
| } | |
| data class DragData(val view: View, | |
| val position: Int) |
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 initRvActions() { | |
| rvCommands.layoutManager = LinearLayoutManager(this) | |
| rvCommands.adapter = AdapterCommands(model) | |
| rvCommands.addItemDecoration(DividerItemDecoration(this, DividerItemDecoration.VERTICAL)) | |
| val swipeHandler = object : SwipeToDeleteCallback(this) { | |
| override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) { | |
| val adapter = rvCommands.adapter as AdapterCommands | |
| adapter.removeAt(viewHolder.adapterPosition) | |
| } |