Carpaccio
Carpaccio copied to clipboard
ImageLoad with custom controller
my project is similar to this #6 and the customController i made with this is not working at all , dont know why
open class CustomController {
fun loadUri(view: ImageView, uri: Uri) {
Picasso.with(view.context).load(uri).placeholder(R.drawable.default_image).into(view)
}
}
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.github.florent37.carpaccio.Carpaccio xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/carpaccioLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:register="
com.github.florent37.carpaccio.controllers.RecyclerViewController;
com.github.florent37.carpaccio.controllers.TextViewController;
com.github.florent37.carpaccio.controllers.ImageViewController;
com.merkmod.mosiqi.application.CustomController;">
<android.support.v7.widget.RecyclerView
android:id="@+id/songList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="4dp"
android:tag="adapter(songs, R.layout.song_viewholder)" />
</com.github.florent37.carpaccio.Carpaccio>
</android.support.design.widget.CoordinatorLayout>
<com.github.florent37.carpaccio.Carpaccio xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:register="
com.github.florent37.carpaccio.controllers.CommonViewController;
com.github.florent37.carpaccio.controllers.TextViewController;
com.github.florent37.carpaccio.controllers.ImageViewController;
com.merkmod.mosiqi.application.CustomController;">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="6dp"
android:paddingLeft="8dp"
android:paddingTop="6dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/albumArt"
android:layout_width="55dp"
android:layout_height="55dp"
android:tag="
loadUri($songs.albumArt);
"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:padding="1dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:layout_toEndOf="@+id/albumArt"
android:layout_toRightOf="@+id/albumArt"
android:orientation="vertical"
android:paddingLeft="12dp"
android:paddingStart="12dp"
android:paddingTop="5dp">
<TextView
android:id="@+id/songTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:tag="setText($songs.songName)"
android:textSize="16sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:tag="setText($songs.artistName)"
android:paddingTop="3dp"
android:textSize="13sp" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
class SongFragment: LifecycleFragment() {
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater?.inflate(R.layout.song_screen, container, false)
val model = ViewModelProviders.of(this)[SongViewModel::class.java]
model.getData().observe(this, Observer {
carpaccioLayout.mapList("songs", it?.sortedBy {
it.songName
})
})
return view
}
}
and i have the permissions setup as well
@florent37 i am waiting for your help