florent37/Carpaccio

url problem

Closed this issue · 7 comments

I have created a blank project to test recyclerview with images, but i have problem with url function. I have even tested with my own controller and Picasso/Glide, but nothing happens.

Tha log, scrolling, write: GC_FOR_ALLOC freed 431K, 12% free 3687K/4172K, paused 21ms, total 21ms

I have written a sample using code similar to yours.

MainActivity:
@OverRide
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

    Carpaccio carpaccio = (Carpaccio)findViewById(R.id.carpaccio);

    List<Object> users = new ArrayList<>();
    for (int i = 0; i < 20; ++i) {
        users.add(new User("Username n°" + i, "http://lorempixel.com/" + generateRandom() + "/" + generateRandom() + "/"));
    }


    carpaccio.mapList("user", users);
}

main activity layout:

<com.github.florent37.carpaccio.Carpaccio
    android:id="@+id/carpaccio"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:register="
        com.github.florent37.carpaccio.controllers.CommonViewController;
        com.github.florent37.carpaccio.controllers.ImageViewController;
        com.github.florent37.carpaccio.controllers.TextViewController;
        com.example.pgulinelli.glidetest.Contr;
    ">

    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="match_parent"

        android:tag="
                    adapter(user,R.layout.item)
                "
        />

</com.github.florent37.carpaccio.Carpaccio>

single row:

<LinearLayout 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="100dp"
    android:gravity="center_vertical"
    android:orientation="horizontal">

    <ImageView
        android:id="@+id/image_episode"
        android:layout_width="100dp"
        android:layout_height="match_parent"
        android:src="@drawable/ic_launcher"
        android:layout_marginRight="20dp"
        android:tag="
        url(http://lorempixel.com/400/400/);
        " />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:tag="
        setText($user.name);" />

</LinearLayout>

hi, can you send me your full project please, so I'll build an try on my
device,

thanks :)

2015-08-05 10:44 GMT+02:00 FunnyDevs notifications@github.com:

I have created a blank project to test recyclerview with images, but i
have problem with url function. I have even tested with my own controller
and Picasso/Glide, but nothing happens.

Tha log, scrolling, write: GC_FOR_ALLOC freed 431K, 12% free 3687K/4172K,
paused 21ms, total 21ms

I have written a sample using code similar to yours.

MainActivity:
@OverRide https://github.com/Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Carpaccio carpaccio = (Carpaccio)findViewById(R.id.carpaccio);

List<Object> users = new ArrayList<>();
for (int i = 0; i < 20; ++i) {
    users.add(new User("Username n°" + i, "http://lorempixel.com/" + generateRandom() + "/" + generateRandom() + "/"));
}


carpaccio.mapList("user", users);

}

main activity layout:
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity">

<com.github.florent37.carpaccio.Carpaccio
android:id="@+id/carpaccio"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:register="
com.github.florent37.carpaccio.controllers.CommonViewController;
com.github.florent37.carpaccio.controllers.ImageViewController;
com.github.florent37.carpaccio.controllers.TextViewController;
com.example.pgulinelli.glidetest.Contr;
">

<android.support.v7.widget.RecyclerView
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    android:tag="
                adapter(user,R.layout.item)
            "
    />

</com.github.florent37.carpaccio.Carpaccio>

single row:

<ImageView
    android:id="@+id/image_episode"
    android:layout_width="100dp"
    android:layout_height="match_parent"
    android:src="@drawable/ic_launcher"
    android:layout_marginRight="20dp"
    android:tag="
    url(http://lorempixel.com/400/400/);
    " />

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:tag="
    setText($user.name);" />


Reply to this email directly or view it on GitHub
#6.

can you display your com.example.pgulinelli.glidetest.Contr please ?

public class Contr {

public void purl(ImageView view, String value) {
    Picasso.with(view.getContext()).load(value).into(view);
}

}

please send me your project to champigny.florent@gmail.com

Just have to add in your AndroidManifest.xml ;)

   <uses-permission android:name="android.permission.INTERNET"/>
   <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

thanks! I 've been a bit ' inattentive!

my project is similar to this 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