app/src/main/java/com/codepath/apps/restclienttemplate/TimelineActivity.java
// On compose intent finish or details finish (return to timeline)
On compose intent finish or details finish (return to timeline)
On compose intent finish or details finish ( return to timeline )
@Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable @org.jetbrains.annotations.Nullable Intent data) {
        if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) {
            assert data != null;
            Tweet tweet = Parcels.unwrap(data.getParcelableExtra("tweet"));
            tweets.add(0, tweet);
            adapter.notifyDataSetChanged();
            rvTweets.smoothScrollToPosition(0);
        } if (requestCode == DETAILS_REQUEST_CODE && resultCode == RESULT_OK) {
            assert data != null;
            Tweet tweet = Parcels.unwrap(data.getParcelableExtra("tweet"));
            int pos = data.getIntExtra("position", 0);
            tweets.set(pos, tweet);
            adapter.notifyDataSetChanged();
        }
        super.onActivityResult(requestCode, resultCode, data);
    }
@ Override protected void onActivityResult ( int requestCode , int resultCode , @ Nullable @ org . jetbrains . annotations . Nullable Intent data ) { if ( requestCode == REQUEST_CODE && resultCode == RESULT_OK ) { assert data != null ; Tweet tweet = Parcels . unwrap ( data . getParcelableExtra ( "tweet" ) ) ; tweets . add ( 0 , tweet ) ; adapter . notifyDataSetChanged ( ) ; rvTweets . smoothScrollToPosition ( 0 ) ; } if ( requestCode == DETAILS_REQUEST_CODE && resultCode == RESULT_OK ) { assert data != null ; Tweet tweet = Parcels . unwrap ( data . getParcelableExtra ( "tweet" ) ) ; int pos = data . getIntExtra ( "position" , 0 ) ; tweets . set ( pos , tweet ) ; adapter . notifyDataSetChanged ( ) ; } super . onActivityResult ( requestCode , resultCode , data ) ; }
On compose intent finish or details finish (return to timeline)
On compose intent finish or details finish ( return to timeline )
// Get tweet from compose intent, and add to recycler view by adding to dataset and notifying adapter // Scroll to new published tweet // Get the tweet info from the details activity and let the adapter know an update has occurred