question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What am I doing wrong

See original GitHub issue

I implemented Epoxy according to the wiki. But I was never able to run the app because I’m getting an error :

Caused by: java.lang.IllegalStateException: You cannot call requestModelBuild directly. Call setData instead to trigger a model refresh with new data.

I’ll post the full code for the epoxy implementation.

EpoxyModelClass(layout = R.layout.header_view)
public abstract class HeaderModel extends EpoxyModelWithHolder<HeaderModel.Holder> {
    @EpoxyAttribute String title;

    @Override
    public void bind(Holder holder) {

        holder.tv.setText(title);
    }

    static class Holder extends EpoxyHolder {
        TextView tv;

        @Override
        protected void bindView(@NonNull View itemView) {
            Log.d("DEBAG", "HeaderModel");
            tv = itemView.findViewById(R.id.name_photo);
        }
    }
}

public class PhotoController  extends Typed2EpoxyController<List<SemiAutomaticWeldingData>, Boolean> {
    @AutoModel HeaderModel_ headerModel;

    @Override
    protected void buildModels(List<SemiAutomaticWeldingData> data1, Boolean data2) {
        headerModel
                .title("Hello Lokki")
                .addTo(this);

        for (SemiAutomaticWeldingData photo : data1) {
            new HeaderModel_()
                    .title(photo.getTitle())
                    .addTo(this);
        }
    }
}

public class Activitys extends AppCompatActivity {
    private EpoxyRecyclerView epoxyRecyclerView;
    private PhotoController photoController;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.epoxy_activity);

        epoxyRecyclerView = findViewById(R.id.epoxy_rv);
        photoController = new PhotoController();

        epoxyRecyclerView.setControllerAndBuildModels(photoController);
        epoxyRecyclerView.requestModelBuild();
        
    }
}

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/name_photo"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</LinearLayout>

I use Studio Android 3.2 Canary 8.
My gradle looks like the following.

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "ua.com.dynamicrecyclerview.drawingreadingswelder"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
//    mvvm этап 1

    dataBinding {
        enabled = true
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.0-alpha1'
    implementation 'androidx.recyclerview:recyclerview:1.0.0-alpha1'
    implementation 'androidx.cardview:cardview:1.0.0-alpha1'
    implementation 'com.google.android.material:material:1.0.0-beta01'

    implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0-alpha3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'

    //Glide
    implementation 'com.github.bumptech.glide:glide:4.7.1'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'

    //Retrofit
    implementation "com.squareup.retrofit2:retrofit:${rootProject.ext.retrofit}"
    implementation "com.squareup.retrofit2:adapter-rxjava2:${rootProject.ext.retrofit}"
    implementation "com.squareup.retrofit2:converter-gson:${rootProject.ext.retrofit}"

    //RxJava2
    implementation 'io.reactivex.rxjava2:rxjava:2.1.5'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'

    //epoxy

    implementation 'com.airbnb.android:epoxy:3.0.0-rc1'
    annotationProcessor 'com.airbnb.android:epoxy-processor:3.0.0-rc1'


}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Sergiysscommented, Sep 9, 2018

@elihart Thanks. Indeed, match_parent was my problem.

1reaction
martymillercommented, Jul 12, 2020

I had the same issue. The documentation used a Typed2EpoxyController in their example and then tells you to call setControllerAndBuildModels() which calls requestModelBuild() on the controller which throws the exception. That call supposedly only works for EpoxyController.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Clasio x Rosenfeld - What Am I Doing Wrong? (Official Audio)
Official Audio for Clasio x Rosenfeld - What Am I Doing Wrong ?Stream/Buy : https://rosenfeld.fanlink.to/waidwRosenfeld ...
Read more >
I feel stuck in life, what am I doing wrong? - Quora
Coming to the point, what you are doing wrong can be best judged by you. I feel stuck in life, what am I...
Read more >
Ep #142: Finding the Answer: What Am I Doing Wrong?
I'm sharing how to talk to any shame you're experiencing, and how to define success, failure, and everything in between.
Read more >
What Am I Doing Wrong? - Troubleshoot Your Dating Life for ...
Ever wonder, “What Am I Doing Wrong?” when it comes to dating and love. Find out how you can improve your dating and...
Read more >
What am I doing wrong? : r/socialskills - Reddit
What am I doing wrong ? Hello everybody. First, I just wanted to say 'hi' to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found