Skip to content

Instantly share code, notes, and snippets.

View ashwin-sp's full-sized avatar
💻
Ready to Restart

Ashwin Suresh Babu ashwin-sp

💻
Ready to Restart
  • New York University
  • Chennai
  • 17:16 (UTC -05:00)
View GitHub Profile
contentList.forEach {
if (it.commentID == -1 && it.feedID == -1) {
val content = it
FeedItemBindingModel_()
.id(it.id)
.content(it)
.listener(View.OnClickListener {
feedID = content.id
recycler_view.requestModelBuild()
showSoftKeyboard(edit_content)
@ashwin-sp
ashwin-sp / view_holder_feed_item.xml
Created January 4, 2019 14:01
A sample data binding layout
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable name="content" type="com.example.epoxydemo.Content" />
<variable
name="listener"
type="android.view.View.OnClickListener"/>
<variable
private var broadcastReceiver: BroadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if(intent.hasExtra(CHECKED))
{
println("broadcast received with intent")
MySliceProvider.state = intent.getBooleanExtra(CHECKED, false)
}
}
}
<provider
android:name=".MySliceProvider"
android:authorities="com.bhaideveloper.slices"
android:exported="true"
android:grantUriPermissions="true">
</provider>
<receiver android:name=".MyReceiver"/>
class MyReceiver : BroadcastReceiver() {
companion object {
var CHECKED = "CHECKED"
}
override fun onReceive(context: Context, intent: Intent) {
if(intent.hasExtra(CHECKED))
{
MySliceProvider.state = intent.getBooleanExtra(CHECKED,state)
companion object {
fun getUri(context: Context, path: String): Uri {
return Uri.Builder()
.scheme(ContentResolver.SCHEME_CONTENT)
.authority(context.packageName)
.appendPath(path)
.build()
}
}
override fun onBindSlice(sliceUri: Uri): Slice? {
return if (sliceUri.path == "/task") {
// Path recognized. Customize the Slice using the androidx.slice.builders API.
// Note: ANR and StrictMode are enforced here so don't do any heavy operations.
// Only bind data that is currently available in memory.
ListBuilder(context, sliceUri, INFINITY)
.addRow {it.setTitle("Task Completed? ")
it.setPrimaryAction(createActivityAction())
it.addEndItem(createToggleAction(!state))
}
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".MainActivity">
<intent-filter>
val args = ListingFragmentArgs.fromBundle(arguments)
println(args.query)