GithubHelp home page GithubHelp logo

Comments (9)

ParkSangGwon avatar ParkSangGwon commented on September 12, 2024

@blunden
Can you upload your sample project code?
I will test and check error.

from tedbottompicker.

blunden avatar blunden commented on September 12, 2024

I don't have a sample project so I would have to create one. I imagine that this happens in any app using this library though so if you have your own sample app it should be reproducible there too. If not, let me know and I'll have to create one.

You fixed this once before though as described above.

from tedbottompicker.

rdadkins avatar rdadkins commented on September 12, 2024

I faced this issue the other day. I believe it happens when the picker is opened and the underlying Fragment / Activity is destroyed and is trying to recreate the picker.

This may (more than likely) be caused by onSaveInstanceState not saving the TedBottomPicker.Builder and thus the NPE being thrown when trying to access showTitle on builder after recreating the Fragment.

A solution would be to convert the Builder to a Parcelable and save it during onSaveInstanceState and restoring it when needed. The only issue would be that the listeners would not persist - this will require the library to change where listeners do not have to be provided in order to create a picker, instead they can be supplied later on.

A temporary solution is to save an instance of the picker dialog when it is shown and to dismiss() it during onPause().

from tedbottompicker.

iammert avatar iammert commented on September 12, 2024

@rdadkins If you dismiss onPause, camera intent result will not be handled by picker dialog and you won't get any callback.

from tedbottompicker.

rdadkins avatar rdadkins commented on September 12, 2024

@iammert You're right. I did not test this with the camera, only the initial gallery provided. The gallery intent will also not be handled from what I just discovered. I edited my original response.

from tedbottompicker.

rdadkins avatar rdadkins commented on September 12, 2024

Coming back to this issue, I found a pretty simple solution when using fragments (in Kotlin):

fun showTedBottomPicker() {
  val builder = getTedBottomPickerBuilder()
  ...
  val fragment = builder.create()
  fragment.show(fragmentManager, TedBottomPicker.TAG) // or any tag you want
}

fun getTedBottomPickerBuilder() = TedBottomPicker.Builder(context) // configure as needed

fun onCreateView(...) {
  super.onCreateView(...)
  fragmentManager.findFragmentByTag(TedBottomPicker.TAG)?.apply { // match tag above
    if (this is TedBottomPicker) {
      builder = getTedBottomPickerBuilder()
    }
  }
}

This will reassign all attributes including the title and click listeners that you define in getTedBottomPickerBuilder() and should prevent any future NPE's.

There may be better places to utilize findFragmentByTag - I just found that onCreateView seems to work fine for me.

from tedbottompicker.

sooorajjj avatar sooorajjj commented on September 12, 2024

@ParkSangGwon remove this https://github.com/ParkSangGwon/TedBottomPicker/blob/master/app/src/main/AndroidManifest.xml#L12
and this issue is reproduceable everytime you rotate device to landscape .
Dirty fix for me ATM is to set it to Portrait in manifest.

from tedbottompicker.

ParkSangGwon avatar ParkSangGwon commented on September 12, 2024

This issue solved at v1.2.0

from tedbottompicker.

blunden avatar blunden commented on September 12, 2024

Great! I'll give the new version a try.

from tedbottompicker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.