Update data in RecyclerView in Fragment with Data from another FragmentStop EditText from gaining focus at Activity startuponActivityResult is not being called in FragmentfindViewById in FragmentBest practice for instantiating a new Android FragmentDilemma: when to use Fragments vs Activities:How to add dividers and spaces between items in RecyclerView?Why doesn't RecyclerView have onItemClickListener()?How to create RecyclerView with multiple view type?RecyclerView not updating inside ViewPager (Fragment)How to update recyclerview inside a fragment(which is inside a viewpager)

Should I communicate in my applications that I'm unemployed out of choice rather than because nobody will have me?

Is Valonqar prophecy unfulfilled?

Did galley captains put corks in the mouths of slave rowers to keep them quiet?

is it correct to say "When it started to rain, I was in the open air."

Will the volt, ampere, ohm or other electrical units change on May 20th, 2019?

Wireless headphones interfere with Wi-Fi signal on laptop

Is there any good reason to write "it is easy to see"?

Why can't I share a one use code with anyone else?

Is there an academic word that means "to split hairs over"?

Generate ladder of integers using the least number of unique characters (in C++)

What was the ring Varys took off?

Is 12 minutes connection in Bristol Temple Meads long enough?

Filter a data-frame and add a new column according to the given condition

The meaning of the Middle English word “king”

Use of さ as a filler

Find the unknown area, x

What information exactly does an instruction cache store?

Why didn't the Avengers use this object earlier?

How do I adjust encounters to challenge my lycanthrope players without negating their cool new abilities?

Offered a new position but unknown about salary?

How might a landlocked lake become a complete ecosystem?

Unexpected Netflix account registered to my Gmail address - any way it could be a hack attempt?

Can my Serbian girlfriend apply for a UK Standard Visitor visa and stay for the whole 6 months?

Promotion comes with unexpected 24/7/365 on-call



Update data in RecyclerView in Fragment with Data from another Fragment


Stop EditText from gaining focus at Activity startuponActivityResult is not being called in FragmentfindViewById in FragmentBest practice for instantiating a new Android FragmentDilemma: when to use Fragments vs Activities:How to add dividers and spaces between items in RecyclerView?Why doesn't RecyclerView have onItemClickListener()?How to create RecyclerView with multiple view type?RecyclerView not updating inside ViewPager (Fragment)How to update recyclerview inside a fragment(which is inside a viewpager)






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have an AllMoviesActivity and Two Fragments. First One is MovieFragment and another one is UpdateMovieFragment.



I am showing all the movies in a RecyclerView in MovieFragment. The structure of Movie model class is:



class Movie() : Parcelable 
var movieID: String? = ""
var movieName: String? = ""
var movieImage: Uri? = null
...



Whenever I click on the ImageView of the Movie Item in RecyclerView, It goes to UpdateMovieFragment where I select the image for the movie and enter the name of the movie. I am doing the transition from MovieFragment to UpdateMovieFragment from the MovieAdapter class by setting the Movie Item as Fragment's Argument.



val fragment = UpdateMovieFragment()
val bundle = Bundle()
bundle.putParcelable("movie", allMovies[p1])
fragment.arguments = bundle
val transaction = (activity as FragmentActivity).supportFragmentManager.beginTransaction()
transaction.addToBackStack(null)
transaction.replace(R.id.frame_layout, fragment).commit()


Now, I am setting the current time as MovieID to each movie to keep it unique so that I can update that specific Movie Item at RecyclerView Later.



Now, I am using a menu button in the activity for the submit operation of both fragments. Whenever the submit button is clicked, I am checking which fragment is on display. If it is UpdateMovieFragment, then my goal is to return the updated movie to the MovieFragment.



override fun onOptionsItemSelected(item: MenuItem): Boolean 
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
return when (item.itemId)
R.id.action_save ->
val fragment = supportFragmentManager.findFragmentById(R.id.list_fragment_container)
when (fragment)
is UpdateMovieFragment ->
supportFragmentManager.popBackStack()

val fragmentNew = supportFragmentManager.findFragmentByTag("LIST")
if (fragmentNew is MovieFragment)
fragmentNew.refreshMovies(fragment.movie)
else
CommonMethods().showToast(applicationContext, "UpdateMovieFragment")



is MovieFragment ->
CommonMethods().showToast(applicationContext, "Do nothing for now")


true

else -> super.onOptionsItemSelected(item)




Here, I am not receiving the updated movie in MovieFragment. For the refreshMovies method, I am doing this:



fun refreshMovies(movie: Movie) 
for (i in 0 until movieItems.size)
val secondItem = movieItems[i]

if (movie.movieID == secondItem.movieID)
rankItems[i] = rankItem
break



itemAdapter.notifyDataSetChanged()



What is the best way to solve this?










share|improve this question






























    0















    I have an AllMoviesActivity and Two Fragments. First One is MovieFragment and another one is UpdateMovieFragment.



    I am showing all the movies in a RecyclerView in MovieFragment. The structure of Movie model class is:



    class Movie() : Parcelable 
    var movieID: String? = ""
    var movieName: String? = ""
    var movieImage: Uri? = null
    ...



    Whenever I click on the ImageView of the Movie Item in RecyclerView, It goes to UpdateMovieFragment where I select the image for the movie and enter the name of the movie. I am doing the transition from MovieFragment to UpdateMovieFragment from the MovieAdapter class by setting the Movie Item as Fragment's Argument.



    val fragment = UpdateMovieFragment()
    val bundle = Bundle()
    bundle.putParcelable("movie", allMovies[p1])
    fragment.arguments = bundle
    val transaction = (activity as FragmentActivity).supportFragmentManager.beginTransaction()
    transaction.addToBackStack(null)
    transaction.replace(R.id.frame_layout, fragment).commit()


    Now, I am setting the current time as MovieID to each movie to keep it unique so that I can update that specific Movie Item at RecyclerView Later.



    Now, I am using a menu button in the activity for the submit operation of both fragments. Whenever the submit button is clicked, I am checking which fragment is on display. If it is UpdateMovieFragment, then my goal is to return the updated movie to the MovieFragment.



    override fun onOptionsItemSelected(item: MenuItem): Boolean 
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    return when (item.itemId)
    R.id.action_save ->
    val fragment = supportFragmentManager.findFragmentById(R.id.list_fragment_container)
    when (fragment)
    is UpdateMovieFragment ->
    supportFragmentManager.popBackStack()

    val fragmentNew = supportFragmentManager.findFragmentByTag("LIST")
    if (fragmentNew is MovieFragment)
    fragmentNew.refreshMovies(fragment.movie)
    else
    CommonMethods().showToast(applicationContext, "UpdateMovieFragment")



    is MovieFragment ->
    CommonMethods().showToast(applicationContext, "Do nothing for now")


    true

    else -> super.onOptionsItemSelected(item)




    Here, I am not receiving the updated movie in MovieFragment. For the refreshMovies method, I am doing this:



    fun refreshMovies(movie: Movie) 
    for (i in 0 until movieItems.size)
    val secondItem = movieItems[i]

    if (movie.movieID == secondItem.movieID)
    rankItems[i] = rankItem
    break



    itemAdapter.notifyDataSetChanged()



    What is the best way to solve this?










    share|improve this question


























      0












      0








      0








      I have an AllMoviesActivity and Two Fragments. First One is MovieFragment and another one is UpdateMovieFragment.



      I am showing all the movies in a RecyclerView in MovieFragment. The structure of Movie model class is:



      class Movie() : Parcelable 
      var movieID: String? = ""
      var movieName: String? = ""
      var movieImage: Uri? = null
      ...



      Whenever I click on the ImageView of the Movie Item in RecyclerView, It goes to UpdateMovieFragment where I select the image for the movie and enter the name of the movie. I am doing the transition from MovieFragment to UpdateMovieFragment from the MovieAdapter class by setting the Movie Item as Fragment's Argument.



      val fragment = UpdateMovieFragment()
      val bundle = Bundle()
      bundle.putParcelable("movie", allMovies[p1])
      fragment.arguments = bundle
      val transaction = (activity as FragmentActivity).supportFragmentManager.beginTransaction()
      transaction.addToBackStack(null)
      transaction.replace(R.id.frame_layout, fragment).commit()


      Now, I am setting the current time as MovieID to each movie to keep it unique so that I can update that specific Movie Item at RecyclerView Later.



      Now, I am using a menu button in the activity for the submit operation of both fragments. Whenever the submit button is clicked, I am checking which fragment is on display. If it is UpdateMovieFragment, then my goal is to return the updated movie to the MovieFragment.



      override fun onOptionsItemSelected(item: MenuItem): Boolean 
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      return when (item.itemId)
      R.id.action_save ->
      val fragment = supportFragmentManager.findFragmentById(R.id.list_fragment_container)
      when (fragment)
      is UpdateMovieFragment ->
      supportFragmentManager.popBackStack()

      val fragmentNew = supportFragmentManager.findFragmentByTag("LIST")
      if (fragmentNew is MovieFragment)
      fragmentNew.refreshMovies(fragment.movie)
      else
      CommonMethods().showToast(applicationContext, "UpdateMovieFragment")



      is MovieFragment ->
      CommonMethods().showToast(applicationContext, "Do nothing for now")


      true

      else -> super.onOptionsItemSelected(item)




      Here, I am not receiving the updated movie in MovieFragment. For the refreshMovies method, I am doing this:



      fun refreshMovies(movie: Movie) 
      for (i in 0 until movieItems.size)
      val secondItem = movieItems[i]

      if (movie.movieID == secondItem.movieID)
      rankItems[i] = rankItem
      break



      itemAdapter.notifyDataSetChanged()



      What is the best way to solve this?










      share|improve this question
















      I have an AllMoviesActivity and Two Fragments. First One is MovieFragment and another one is UpdateMovieFragment.



      I am showing all the movies in a RecyclerView in MovieFragment. The structure of Movie model class is:



      class Movie() : Parcelable 
      var movieID: String? = ""
      var movieName: String? = ""
      var movieImage: Uri? = null
      ...



      Whenever I click on the ImageView of the Movie Item in RecyclerView, It goes to UpdateMovieFragment where I select the image for the movie and enter the name of the movie. I am doing the transition from MovieFragment to UpdateMovieFragment from the MovieAdapter class by setting the Movie Item as Fragment's Argument.



      val fragment = UpdateMovieFragment()
      val bundle = Bundle()
      bundle.putParcelable("movie", allMovies[p1])
      fragment.arguments = bundle
      val transaction = (activity as FragmentActivity).supportFragmentManager.beginTransaction()
      transaction.addToBackStack(null)
      transaction.replace(R.id.frame_layout, fragment).commit()


      Now, I am setting the current time as MovieID to each movie to keep it unique so that I can update that specific Movie Item at RecyclerView Later.



      Now, I am using a menu button in the activity for the submit operation of both fragments. Whenever the submit button is clicked, I am checking which fragment is on display. If it is UpdateMovieFragment, then my goal is to return the updated movie to the MovieFragment.



      override fun onOptionsItemSelected(item: MenuItem): Boolean 
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      return when (item.itemId)
      R.id.action_save ->
      val fragment = supportFragmentManager.findFragmentById(R.id.list_fragment_container)
      when (fragment)
      is UpdateMovieFragment ->
      supportFragmentManager.popBackStack()

      val fragmentNew = supportFragmentManager.findFragmentByTag("LIST")
      if (fragmentNew is MovieFragment)
      fragmentNew.refreshMovies(fragment.movie)
      else
      CommonMethods().showToast(applicationContext, "UpdateMovieFragment")



      is MovieFragment ->
      CommonMethods().showToast(applicationContext, "Do nothing for now")


      true

      else -> super.onOptionsItemSelected(item)




      Here, I am not receiving the updated movie in MovieFragment. For the refreshMovies method, I am doing this:



      fun refreshMovies(movie: Movie) 
      for (i in 0 until movieItems.size)
      val secondItem = movieItems[i]

      if (movie.movieID == secondItem.movieID)
      rankItems[i] = rankItem
      break



      itemAdapter.notifyDataSetChanged()



      What is the best way to solve this?







      android android-fragments kotlin android-recyclerview interface






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 23 at 14:57







      Angela Hache

















      asked Mar 23 at 14:42









      Angela HacheAngela Hache

      667




      667






















          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55314877%2fupdate-data-in-recyclerview-in-fragment-with-data-from-another-fragment%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55314877%2fupdate-data-in-recyclerview-in-fragment-with-data-from-another-fragment%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현