Code Monkey home page Code Monkey logo

Comments (15)

zawadz88 avatar zawadz88 commented on August 17, 2024

Hi, the fragment being recreated is something the ViewPager does so that it doesn't keep too many fragments in memory at once. Please note that going back from the third stp to the first one is not the only scenario in which the first fragment will get recreated. This could also happen if e.g. you rotate the device or your app gets killed by the system and you go back to it.
The recommended approach here would be to save the data in a saved instance state. You could check out the sample app for an example: https://github.com/stepstone-tech/android-material-stepper/blob/master/sample/src/main/java/com/stepstone/stepper/sample/step/StepFragmentSample.java

from android-material-stepper.

EpsilonOrionis avatar EpsilonOrionis commented on August 17, 2024

Ok, but the problem that I'm facing isn't only the lose of values. The main problem is that in the first fragment, I use a library to pick an image and then put it in an ImageView, but when I return back from the third to the first fragment, and I try to pick the image, the app crashes because giving me error in onActivityResult: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { (has extras) }} to activity. The library that I use in the first fragment is the following: https://github.com/jdamcd/android-crop. However I don't think it's a problem related to the library, because I changed it and the same problem occurred again...

from android-material-stepper.

zawadz88 avatar zawadz88 commented on August 17, 2024

Hi, I don't really know this library and without seeing the code there's actually very little I can do. Anyway, I believe the same issue might arise if the fragment was recreated in different scenarios mentioned by me earlier.
Are you sure you're using the library correctly, passing the right values as parameters, etc? Maybe this will help: http://stackoverflow.com/questions/20827237/failure-delivering-result-resultinfowho-null-request-1-result-1-data-intent ?

from android-material-stepper.

EpsilonOrionis avatar EpsilonOrionis commented on August 17, 2024

I think that I'm using it correctly, to start the crop activity. The library has the method startCrop(Context) or something like that, to start cropping the selected Image. But in a fragment this method is .startCrop(getActivity(), StepFragment.this). And it work until the fragment has been destroyed.

from android-material-stepper.

zawadz88 avatar zawadz88 commented on August 17, 2024

It looks lile an issue with the library to be honest or the the setup. The ViewPager in our library doesn't do anything special... Maybe this has something to do with jdamcd/android-crop#240 ? Does the crash occur if you try to start other activities and get the result from them?

from android-material-stepper.

EpsilonOrionis avatar EpsilonOrionis commented on August 17, 2024

No, I get the crash only if I use this library, but the problem occur also with another library. This is why i think it's not a library issue

from android-material-stepper.

EpsilonOrionis avatar EpsilonOrionis commented on August 17, 2024

Could you try it? Maybe I'm doing something wrong...

from android-material-stepper.

zawadz88 avatar zawadz88 commented on August 17, 2024

Hi, I'm currently on my holidays and I only have access to my phone :/ maybe you could fork this library and add the library you're using to the sample app so that I could have the look at the code at least?

from android-material-stepper.

EpsilonOrionis avatar EpsilonOrionis commented on August 17, 2024

Yes, I'll try. Keep in touch

from android-material-stepper.

EpsilonOrionis avatar EpsilonOrionis commented on August 17, 2024

Could you tell me the class where I can find the ViewPager? I mean the class in which you get it with .findViewById

from android-material-stepper.

zawadz88 avatar zawadz88 commented on August 17, 2024

This would be https://github.com/stepstone-tech/android-material-stepper/blob/master/material-stepper/src/main/java/com/stepstone/stepper/StepperLayout.java

from android-material-stepper.

EpsilonOrionis avatar EpsilonOrionis commented on August 17, 2024

Is there a way to access the ViewPager from my activity?

from android-material-stepper.

EpsilonOrionis avatar EpsilonOrionis commented on August 17, 2024

I want to try to use mViewPager.setOffScreenPageLimit(int) without modifying the library

from android-material-stepper.

zawadz88 avatar zawadz88 commented on August 17, 2024

Technically speaking the ViewPager is a view so you can find it and use it in the activity the same way it is found and used in the StepperLayout?

from android-material-stepper.

EpsilonOrionis avatar EpsilonOrionis commented on August 17, 2024

Solved. Using mViewPager.setOffScreenPageLimit(int) solved the problem. As I thought it wasn't a problem related to the library. Thank you for your patience @zawadz88 👍

from android-material-stepper.

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.