Follow API changes.

Change-Id: Ieb1df7fc0708f22aae3d851f74ade1343eb44e08
This commit is contained in:
Dianne Hackborn
2011-01-17 12:31:08 -08:00
parent d8865cc32c
commit 0d11c9c345
17 changed files with 31 additions and 35 deletions

View File

@@ -41,7 +41,7 @@ public class FragmentContextMenu extends Activity {
// Create the list fragment and add it as our sole content. // Create the list fragment and add it as our sole content.
ContextMenuFragment content = new ContextMenuFragment(); ContextMenuFragment content = new ContextMenuFragment();
getFragmentManager().openTransaction().add(android.R.id.content, content).commit(); getFragmentManager().beginTransaction().add(android.R.id.content, content).commit();
} }
public static class ContextMenuFragment extends Fragment { public static class ContextMenuFragment extends Fragment {

View File

@@ -70,7 +70,7 @@ public class FragmentDialog extends Activity {
// DialogFragment.show() will take care of adding the fragment // DialogFragment.show() will take care of adding the fragment
// in a transaction. We also want to remove any currently showing // in a transaction. We also want to remove any currently showing
// dialog, so make our own transaction and take care of that here. // dialog, so make our own transaction and take care of that here.
FragmentTransaction ft = getFragmentManager().openTransaction(); FragmentTransaction ft = getFragmentManager().beginTransaction();
Fragment prev = getFragmentManager().findFragmentByTag("dialog"); Fragment prev = getFragmentManager().findFragmentByTag("dialog");
if (prev != null) { if (prev != null) {
ft.remove(prev); ft.remove(prev);

View File

@@ -39,7 +39,7 @@ public class FragmentDialogOrActivity extends Activity {
if (savedInstanceState == null) { if (savedInstanceState == null) {
// First-time init; create fragment to embed in activity. // First-time init; create fragment to embed in activity.
//BEGIN_INCLUDE(embed) //BEGIN_INCLUDE(embed)
FragmentTransaction ft = getFragmentManager().openTransaction(); FragmentTransaction ft = getFragmentManager().beginTransaction();
DialogFragment newFragment = MyDialogFragment.newInstance(); DialogFragment newFragment = MyDialogFragment.newInstance();
ft.add(R.id.embedded, newFragment); ft.add(R.id.embedded, newFragment);
ft.commit(); ft.commit();

View File

@@ -51,7 +51,7 @@ public class FragmentHideShow extends Activity {
final Button button = (Button)findViewById(buttonId); final Button button = (Button)findViewById(buttonId);
button.setOnClickListener(new OnClickListener() { button.setOnClickListener(new OnClickListener() {
public void onClick(View v) { public void onClick(View v) {
FragmentTransaction ft = getFragmentManager().openTransaction(); FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.setCustomAnimations(android.R.animator.fade_in, ft.setCustomAnimations(android.R.animator.fade_in,
android.R.animator.fade_out); android.R.animator.fade_out);
if (fragment.isHidden()) { if (fragment.isHidden()) {

View File

@@ -74,7 +74,7 @@ public class FragmentLayout extends Activity {
// During initial setup, plug in the details fragment. // During initial setup, plug in the details fragment.
DetailsFragment details = new DetailsFragment(); DetailsFragment details = new DetailsFragment();
details.setArguments(getIntent().getExtras()); details.setArguments(getIntent().getExtras());
getFragmentManager().openTransaction().add(android.R.id.content, details).commit(); getFragmentManager().beginTransaction().add(android.R.id.content, details).commit();
} }
} }
} }
@@ -150,11 +150,9 @@ public class FragmentLayout extends Activity {
// Execute a transaction, replacing any existing fragment // Execute a transaction, replacing any existing fragment
// with this one inside the frame. // with this one inside the frame.
FragmentTransaction ft = getFragmentManager().openTransaction(); FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.details, df); ft.replace(R.id.details, df);
ft.setTransition(index > mCurCheckPosition ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
? FragmentTransaction.TRANSIT_FRAGMENT_NEXT
: FragmentTransaction.TRANSIT_FRAGMENT_PREV);
ft.commit(); ft.commit();
mShownCheckPosition = index; mShownCheckPosition = index;
} }

View File

@@ -39,7 +39,7 @@ public class FragmentListArray extends Activity {
// Create the list fragment and add it as our sole content. // Create the list fragment and add it as our sole content.
if (getFragmentManager().findFragmentById(android.R.id.content) == null) { if (getFragmentManager().findFragmentById(android.R.id.content) == null) {
ArrayListFragment list = new ArrayListFragment(); ArrayListFragment list = new ArrayListFragment();
getFragmentManager().openTransaction().add(android.R.id.content, list).commit(); getFragmentManager().beginTransaction().add(android.R.id.content, list).commit();
} }
} }

View File

@@ -52,7 +52,7 @@ public class FragmentListCursorLoader extends Activity {
// Create the list fragment and add it as our sole content. // Create the list fragment and add it as our sole content.
if (fm.findFragmentById(android.R.id.content) == null) { if (fm.findFragmentById(android.R.id.content) == null) {
CursorLoaderListFragment list = new CursorLoaderListFragment(); CursorLoaderListFragment list = new CursorLoaderListFragment();
fm.openTransaction().add(android.R.id.content, list).commit(); fm.beginTransaction().add(android.R.id.content, list).commit();
} }
} }

View File

@@ -37,7 +37,7 @@ public class FragmentMenu extends Activity {
// Make sure the two menu fragments are created. // Make sure the two menu fragments are created.
FragmentManager fm = getFragmentManager(); FragmentManager fm = getFragmentManager();
FragmentTransaction ft = fm.openTransaction(); FragmentTransaction ft = fm.beginTransaction();
mFragment1 = fm.findFragmentByTag("f1"); mFragment1 = fm.findFragmentByTag("f1");
if (mFragment1 == null) { if (mFragment1 == null) {
mFragment1 = new MenuFragment(); mFragment1 = new MenuFragment();
@@ -69,7 +69,7 @@ public class FragmentMenu extends Activity {
// Update fragment visibility based on current check box state. // Update fragment visibility based on current check box state.
void updateFragmentVisibility() { void updateFragmentVisibility() {
FragmentTransaction ft = getFragmentManager().openTransaction(); FragmentTransaction ft = getFragmentManager().beginTransaction();
if (mCheckBox1.isChecked()) ft.show(mFragment1); if (mCheckBox1.isChecked()) ft.show(mFragment1);
else ft.hide(mFragment1); else ft.hide(mFragment1);
if (mCheckBox2.isChecked()) ft.show(mFragment2); if (mCheckBox2.isChecked()) ft.show(mFragment2);

View File

@@ -31,7 +31,7 @@ public class FragmentReceiveResult extends Activity {
if (savedInstanceState == null) { if (savedInstanceState == null) {
// Do first time initialization -- add fragment. // Do first time initialization -- add fragment.
Fragment newFragment = new ReceiveResultFragment(); Fragment newFragment = new ReceiveResultFragment();
FragmentTransaction ft = getFragmentManager().openTransaction(); FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.add(R.id.simple_fragment, newFragment).commit(); ft.add(R.id.simple_fragment, newFragment).commit();
} }
} }

View File

@@ -42,7 +42,7 @@ public class FragmentRetainInstance extends Activity {
// First time init, create the UI. // First time init, create the UI.
if (savedInstanceState == null) { if (savedInstanceState == null) {
getFragmentManager().openTransaction().add(android.R.id.content, getFragmentManager().beginTransaction().add(android.R.id.content,
new UiFragment()).commit(); new UiFragment()).commit();
} }
} }
@@ -84,7 +84,7 @@ public class FragmentRetainInstance extends Activity {
mWorkFragment = new RetainedFragment(); mWorkFragment = new RetainedFragment();
// Tell it who it is working with. // Tell it who it is working with.
mWorkFragment.setTargetFragment(this, 0); mWorkFragment.setTargetFragment(this, 0);
fm.openTransaction().add(mWorkFragment, "work").commit(); fm.beginTransaction().add(mWorkFragment, "work").commit();
} }
} }

View File

@@ -48,7 +48,7 @@ public class FragmentStack extends Activity {
if (savedInstanceState == null) { if (savedInstanceState == null) {
// Do first time initialization -- add initial fragment. // Do first time initialization -- add initial fragment.
Fragment newFragment = CountingFragment.newInstance(mStackLevel); Fragment newFragment = CountingFragment.newInstance(mStackLevel);
FragmentTransaction ft = getFragmentManager().openTransaction(); FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.add(R.id.simple_fragment, newFragment).commit(); ft.add(R.id.simple_fragment, newFragment).commit();
} else { } else {
mStackLevel = savedInstanceState.getInt("level"); mStackLevel = savedInstanceState.getInt("level");
@@ -70,7 +70,7 @@ public class FragmentStack extends Activity {
// Add the fragment to the activity, pushing this transaction // Add the fragment to the activity, pushing this transaction
// on to the back stack. // on to the back stack.
FragmentTransaction ft = getFragmentManager().openTransaction(); FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.simple_fragment, newFragment); ft.replace(R.id.simple_fragment, newFragment);
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
ft.addToBackStack(null); ft.addToBackStack(null);

View File

@@ -376,7 +376,7 @@ public class LoaderThrottle extends Activity {
// Create the list fragment and add it as our sole content. // Create the list fragment and add it as our sole content.
if (fm.findFragmentById(android.R.id.content) == null) { if (fm.findFragmentById(android.R.id.content) == null) {
ThrottledLoaderListFragment list = new ThrottledLoaderListFragment(); ThrottledLoaderListFragment list = new ThrottledLoaderListFragment();
fm.openTransaction().add(android.R.id.content, list).commit(); fm.beginTransaction().add(android.R.id.content, list).commit();
} }
} }

View File

@@ -98,21 +98,20 @@ public class ClipboardSample extends Activity {
} }
public void pasteStyledText(View button) { public void pasteStyledText(View button) {
mClipboard.setPrimaryClip(ClipData.newPlainText("Styled Text", null, mStyledText)); mClipboard.setPrimaryClip(ClipData.newPlainText("Styled Text", mStyledText));
} }
public void pastePlainText(View button) { public void pastePlainText(View button) {
mClipboard.setPrimaryClip(ClipData.newPlainText("Styled Text", null, mPlainText)); mClipboard.setPrimaryClip(ClipData.newPlainText("Styled Text", mPlainText));
} }
public void pasteIntent(View button) { public void pasteIntent(View button) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.android.com/")); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.android.com/"));
mClipboard.setPrimaryClip(ClipData.newIntent("VIEW intent", null, intent)); mClipboard.setPrimaryClip(ClipData.newIntent("VIEW intent", intent));
} }
public void pasteUri(View button) { public void pasteUri(View button) {
mClipboard.setPrimaryClip(ClipData.newRawUri("URI", null, mClipboard.setPrimaryClip(ClipData.newRawUri("URI", Uri.parse("http://www.android.com/")));
Uri.parse("http://www.android.com/")));
} }
void updateClipData() { void updateClipData() {
@@ -128,15 +127,15 @@ public class ClipboardSample extends Activity {
if (clip == null) { if (clip == null) {
mSpinner.setSelection(0); mSpinner.setSelection(0);
mEditText.setText(""); mEditText.setText("");
} else if (clip.getItem(0).getText() != null) { } else if (clip.getItemAt(0).getText() != null) {
mSpinner.setSelection(1); mSpinner.setSelection(1);
mEditText.setText(clip.getItem(0).getText()); mEditText.setText(clip.getItemAt(0).getText());
} else if (clip.getItem(0).getIntent() != null) { } else if (clip.getItemAt(0).getIntent() != null) {
mSpinner.setSelection(2); mSpinner.setSelection(2);
mEditText.setText(clip.getItem(0).getIntent().toUri(0)); mEditText.setText(clip.getItemAt(0).getIntent().toUri(0));
} else if (clip.getItem(0).getUri() != null) { } else if (clip.getItemAt(0).getUri() != null) {
mSpinner.setSelection(3); mSpinner.setSelection(3);
mEditText.setText(clip.getItem(0).getUri().toString()); mEditText.setText(clip.getItemAt(0).getUri().toString());
} else { } else {
mSpinner.setSelection(0); mSpinner.setSelection(0);
mEditText.setText("Clip containing no data"); mEditText.setText("Clip containing no data");

View File

@@ -33,7 +33,7 @@ public class FragmentPreferences extends Activity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// Display the fragment as the main content. // Display the fragment as the main content.
getFragmentManager().openTransaction().replace(android.R.id.content, getFragmentManager().beginTransaction().replace(android.R.id.content,
new PrefsFragment()).commit(); new PrefsFragment()).commit();
} }

View File

@@ -130,7 +130,7 @@ public class DraggableDot extends View {
setOnLongClickListener(new View.OnLongClickListener() { setOnLongClickListener(new View.OnLongClickListener() {
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
ClipData data = ClipData.newPlainText("dot", null, "Dot : " + v.toString()); ClipData data = ClipData.newPlainText("dot", "Dot : " + v.toString());
v.startDrag(data, new ANRShadowBuilder(v, mAnrType == ANR_SHADOW), v.startDrag(data, new ANRShadowBuilder(v, mAnrType == ANR_SHADOW),
(Object)v, 0); (Object)v, 0);
return true; return true;
@@ -247,7 +247,7 @@ public class DraggableDot extends View {
final ClipData data = event.getClipData(); final ClipData data = event.getClipData();
final int N = data.getItemCount(); final int N = data.getItemCount();
for (int i = 0; i < N; i++) { for (int i = 0; i < N; i++) {
ClipData.Item item = data.getItem(i); ClipData.Item item = data.getItemAt(i);
Log.i(TAG, "Dropped item " + i + " : " + item); Log.i(TAG, "Dropped item " + i + " : " + item);
if (mReportView != null) { if (mReportView != null) {
String text = item.coerceToText(getContext()).toString(); String text = item.coerceToText(getContext()).toString();

View File

@@ -470,7 +470,7 @@ public class NoteEditor extends Activity {
String title=null; String title=null;
// Gets the first item from the clipboard data // Gets the first item from the clipboard data
ClipData.Item item = clip.getItem(0); ClipData.Item item = clip.getItemAt(0);
// Tries to get the item's contents as a URI pointing to a note // Tries to get the item's contents as a URI pointing to a note
Uri uri = item.getUri(); Uri uri = item.getUri();

View File

@@ -406,7 +406,6 @@ public class NotesList extends ListActivity {
clipboard.setPrimaryClip(ClipData.newUri( // new clipboard item holding a URI clipboard.setPrimaryClip(ClipData.newUri( // new clipboard item holding a URI
getContentResolver(), // resolver to retrieve URI info getContentResolver(), // resolver to retrieve URI info
"Note", // label for the clip "Note", // label for the clip
null, // icon for the clip
noteUri) // the URI noteUri) // the URI
); );