igalata / Bubble-Picker

An easy-to-use animation which can be used for content picking for Android
https://medium.com/@igalata13/how-to-create-a-bubble-selection-animation-on-android-627044da4854#.js8nebsx6
1.4k stars 249 forks source link

lateinit property items has not been initialized #29

Open benzscoutout opened 7 years ago

benzscoutout commented 7 years ago

I'm not use kotlin project, I use java

I try to use this library but error when startActivity

"lateinit property items has not been initialized"

igalata commented 7 years ago

Hi @Mercidez Does this exception appears in the sample app? Otherwise could you please share your code?

dbof10 commented 7 years ago
  1. I hit the same issue. Log

    kotlin.UninitializedPropertyAccessException: lateinit property items has not been initialized
                                                                  at com.igalata.bubblepicker.rendering.PickerRenderer.initialize(PickerRenderer.kt:79)
                                                                  at com.igalata.bubblepicker.rendering.PickerRenderer.onSurfaceChanged(PickerRenderer.kt:67)
                                                                  at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1537)
                                                                  at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1253)
  2. BTW, [Feature request] Is there any way to load image from network?

stathiskaps commented 7 years ago

Hello. Have you by any chance figured out the solution? Cause actually i am facing the same problem right now.

stathiskaps commented 7 years ago

To be more precise this is the code (i believe it is the way it should be)

2017-07-04_23-19-19

and this is the error

2017-07-04_23-19-44

CHRISPASP95 commented 7 years ago

I have the exactly the same problem

stathiskaps commented 7 years ago

I got many errors in GLSurfaceView class. Any ideas that could help?

2017-07-05_00-10-44 2017-07-05_00-15-03 2017-07-05_00-15-13 2017-07-05_00-15-54

ArsalRaza commented 7 years ago

I am also getting this issue, any help!!

sujeet-kumar-mehta commented 6 years ago

Please check if your array is non zero so that the bubblepicker can initialize and adapter get set as otherwise, the PickerRenderer.initialize(PickerRenderer) doesn't get initialized and this issue occur

ismailtosun commented 6 years ago

declare array before main instance this solve my problem

rosanlal26 commented 6 years ago

It is very sad that the developer is not addressing the issue many of us are facing :(

rosanlal26 commented 6 years ago

@ismailtosun Could you paste the code as it should be according to you?

rosanlal26 commented 6 years ago

Here is my code: @ismailtosun @igalata Kindly help

 public class BubblePicker extends AppCompatActivity {

com.igalata.bubblepicker.rendering.BubblePicker picker;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_bubble_picker);
    final String[] titles = getResources().getStringArray(R.array.countries);
    final TypedArray colors = getResources().obtainTypedArray(R.array.colors);
    final TypedArray images = getResources().obtainTypedArray(R.array.images);

    picker=new com.igalata.bubblepicker.rendering.BubblePicker(this);

   picker.setAdapter(new BubblePickerAdapter() {
        @Override
        public int getTotalCount() {
            return images.length();
        }

        @NotNull
        @Override
        public PickerItem getItem(int position) {
            PickerItem item = new PickerItem();
            item.setTitle(titles[position]);
            item.setGradient(new BubbleGradient(colors.getColor((position * 1) % 2, 0),
                    colors.getColor((position) % 1 + 1, 0), BubbleGradient.VERTICAL));

          //  item.setTypeface(mediumTypeface);
            item.setTextColor(ContextCompat.getColor(BubblePicker.this, android.R.color.white));
            item.setBackgroundImage(ContextCompat.getDrawable(BubblePicker.this, images.getResourceId(position, 0)));
            return item;
        }
    });

}

@Override
protected void onResume() {
    super.onResume();
    picker.onResume();
}

@Override
protected void onPause() {
    super.onPause();
    picker.onPause();
}

}

Karlheinzniebuhr commented 6 years ago

same issue, any working solutions?

anujkv commented 6 years ago

I am getting error when i write junit testcase:

kotlin.UninitializedPropertyAccessException: lateinit property inventoryService has not been initialized

at com.e8om.books.junit.svc.InventoryServiceTests.stockGroupListTest(InventoryServicesTest.kt:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
maheswarich commented 6 years ago

Hi All, I too got same exception, any working solution found?

MilanVucic commented 6 years ago

I noticed that this happens when your adapter is not set at the time when "onResume" is called. This happens to me too when I try to fetch items from the API and onResume gets called earlier than I get them and thus I got it to not crash by setting an empty list for an adapter, but now when I do get the items, they do not get displayed even though adapter's methods do get called e.g. getItem.

hantrungkien commented 6 years ago

@BenzScoutOut @dbof10 @P130 @CHRISPASP95 @MilanVucic @rosanlal26 please review my lib was developed based on this lib. This is a conflict between java and kotlin library and I fixed this issue https://github.com/hantrungkien/Bubble-Picker

Kavinrajan commented 4 years ago

I am facing this issue, Any solution

kotlin.UninitializedPropertyAccessException: lateinit property viewModelFactory has not been initialized at com.kavin.task.landist.country.ui.CountryFragment.onCreateView(CountryFragment.kt:31) at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2605) etc.