- moves tablet-style layouts to layout-large* directories - adds ContentActivity to host the ContentFragment when on phones - adds an OnItemSelectedListener interface to TitlesFragment, which MainActivity implements in order to receive callbacks on click events to the list item and then pass the selected item to the ContentFragment in the manner appropriate for the current configuration... Specifically, when in two-pane mode, it updates the ContentFragment directly, and when in single-pane mode, it starts the ContentActivity with intent data about the selected item, which then updates the ContentFragment - Change CameraSample.java to CameraActivity.java for name conventions - Moves all menu strings into string resources - Fixes camera sample to properly handle front-facing camera on other devices (was broken on nexus s and on g-slate) - Fixes camera sample to handle resume state after the camera has changed (for example, when switched to a different camera, it would crash on resume) - Moves various code around between classes as appropriate for the fragment handling the action. For example, move the ActionBar.TabListener implementation to the TitlesFragment (was originally impemented by the MainActivity) - Adds logic to support devices without camera and properly declare the camera in manifest as such - Maintains the state of hidden titles list across restarts Change-Id: I27a39a68dee37325c0c3607aa0b56ab6c134d026
49 lines
1.6 KiB
Java
49 lines
1.6 KiB
Java
// Copyright 2011 Google Inc. All Rights Reserved.
|
|
|
|
package com.example.android.hcgallery;
|
|
|
|
import android.app.Activity;
|
|
import android.os.Bundle;
|
|
|
|
/** This is a shell activity that hosts ContentFragment when the device screen
|
|
* is smaller than "large".
|
|
*/
|
|
public class ContentActivity extends Activity {
|
|
private int mThemeId = 0;
|
|
|
|
@Override
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
|
|
Bundle extras = getIntent().getExtras();
|
|
if (extras != null) {
|
|
// The activity theme is the only state data that the activity needs
|
|
// to restore. All info about the content displayed is managed by the fragment
|
|
mThemeId = extras.getInt("theme");
|
|
} else if (savedInstanceState != null) {
|
|
// If there's no restore state, get the theme from the intent
|
|
mThemeId = savedInstanceState.getInt("theme");
|
|
}
|
|
|
|
if (mThemeId != 0) {
|
|
setTheme(mThemeId);
|
|
}
|
|
|
|
setContentView(R.layout.content_activity);
|
|
|
|
if (extras != null) {
|
|
// Take the info from the intent and deliver it to the fragment so it can update
|
|
int category = extras.getInt("category");
|
|
int position = extras.getInt("position");
|
|
ContentFragment frag = (ContentFragment) getFragmentManager().findFragmentById(R.id.content_frag);
|
|
frag.updateContentAndRecycleBitmap(category, position);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected void onSaveInstanceState(Bundle outState) {
|
|
super.onSaveInstanceState(outState);
|
|
outState.putInt("theme", mThemeId);
|
|
}
|
|
}
|