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
inner class DropTargetListener : View.OnDragListener { | |
override fun onDrag(view: View, event: DragEvent): Boolean { | |
return when(event.action) { | |
ACTION_DRAG_STARTED -> { | |
true | |
} | |
ACTION_DRAG_ENTERED -> { | |
true | |
} | |
ACTION_DRAG_LOCATION -> { |
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 onKeyUp(code: Int, ev: KeyEvent?): Boolean { | |
return when (code) { | |
KeyEvent.KEYCODE_J -> { | |
// Do something here | |
true | |
} | |
else -> super.onKeyUp(code, ev) // Important | |
} | |
} |
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
int cleanUpTokens() { | |
int numTokensDisabled = 0; | |
for (subscription in entitlementDb) { | |
if (subscription.linkedPurchaseToken) { | |
if (invalidateToken(subscription.linkedPurchaseToken)) | |
numTokensDisabled++; | |
} | |
} | |
return numTokensDisabled; | |
} |
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
boolean onNewPurchaseToken(SubscriptionPurchaseResource newSub) { | |
if (newSub.linkedPurchaseToken) { | |
disableSubscription(newSub.linkedPurchaseToken); | |
} | |
addAndEnableSubscription(newSub.purchaseToken); | |
} |
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
myView.setBackgroundResource(R.drawable.box_border); |
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
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | |
<item android:state_focused="true"> | |
<shape android:padding="2dp"> | |
<solid android:color="#FFFFFF" /> | |
<stroke android:width="1dp" android:color="@color/colorAccent" /> | |
<padding android:left="2dp" android:top="2dp" android:right="2dp" | |
android:bottom="2dp" /> | |
</shape> | |
</item> | |
</selector> |
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
binding.textDragItem.setOnLongClickListener { | |
val textView = it as TextView | |
val dragContent = "Dragged Text: ${textView.text}" | |
//Set the drag content and type | |
val item = ClipData.Item(dragContent) | |
val dragData = ClipData(dragContent, arrayOf(MIMETYPE_TEXT_PLAIN), item) | |
//Set the visual look of the dragged object | |
//Can be extended and customized. We use the default here. |
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
binding.textDropTarget.setOnDragListener(DropTargetListener()) |
NewerOlder