Android Programming: The Big Nerd Ranch Guide (2nd Edition) by Bill Phillips & Chris Stewart

Android Programming: The Big Nerd Ranch Guide (2nd Edition) by Bill Phillips & Chris Stewart

Author:Bill Phillips & Chris Stewart [Phillips, Bill]
Language: eng
Format: epub
Tags: COM051460, Big Nerd Ranch Guides, Android Programming
ISBN: 9780134171456
Publisher: Pearson Education
Published: 2015-07-31T21:00:00+00:00


CrimeFragment.Callbacks must be implemented in all activities that host CrimeFragment. So provide an empty implementation in CrimePagerActivity, too.

Listing 17.13 Providing empty callbacks implementation (CrimePagerActivity.java)

public class CrimePagerActivity extends AppCompatActivity implements CrimeFragment.Callbacks { ... @Override public void onCrimeUpdated(Crime crime) { } }

CrimeFragment will be doing a Time Warp two-step a lot internally: Jump to the left, save mCrime to CrimeLab. Step to the right, call mCallbacks.onCrimeUpdated(Crime). Add a method to make it more convenient to do this jig.

Listing 17.14 Adding updateCrime() method (CrimeFragment.java)

... @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { ... } private void updateCrime() { CrimeLab.get(getActivity()).updateCrime(mCrime); mCallbacks.onCrimeUpdated(mCrime); } private void updateDate() { mDateButton.setText(mCrime.getDate().toString()); } ...



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.