What am I doing wrong
See original GitHub issueI 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:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@elihart Thanks. Indeed, match_parent was my problem.
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.