Back to project page SeeKampf.
The source code is released under:
GNU General Public License
If you think the Android project SeeKampf listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package net.avedo.seekampf.core; /*w ww .ja v a2 s . c o m*/ import net.avedo.seekampf.R; import net.avedo.seekampf.fragments.HomeDetailsFragment; import net.avedo.seekampf.fragments.IslandDetailsFragment; import net.avedo.seekampf.fragments.MessageDetailsFragment; import net.avedo.seekampf.fragments.RestDetailsFragment; import net.avedo.seekampf.utils.Constants; import net.avedo.seekampf.utils.Interfaces; import android.app.Activity; import android.app.Fragment; import android.app.FragmentTransaction; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.NavUtils; import android.view.MenuItem; public class RestDetailsActivity extends Activity implements Interfaces.OnFragmentActionListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_activity); getActionBar().setDisplayHomeAsUpEnabled(true); // Ensure that there are additional information passed along. Intent intent = getIntent(); if (intent == null) { setResult(Constants.ACTIVITY_RESULT_MISSING_ARGUMENT); finish(); } // Ensure that there are additional information passed along. Bundle extras = intent.getExtras(); if (extras == null) { setResult(Constants.ACTIVITY_RESULT_MISSING_ARGUMENT); finish(); } else { // Get the fragment id ... int serviceFragment = extras.getInt(Constants.INTENT_EXTRA_FRAGMENT, Constants.FRAGMENT_MESSAGE_DETAILS); // ... and set it as main view. this.setFragment(serviceFragment, extras); } } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: NavUtils.navigateUpFromSameTask(this); return true; } return super.onOptionsItemSelected(item); } @Override public void onFragmentAction(int action, Bundle extras) { // Nothing to do here! } @Override public void onFragmentRequest(int request, Bundle extras) { // Nothing to do here! } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case Constants.ACTIVITY_REQUEST_EDIT: switch (resultCode) { case Constants.ACTIVITY_RESULT_OK: // onFragmentRequest(Constants.FRAGMENT_REQUEST_DETAILS, // data.getExtras()); break; } break; } } private void setFragment(int fragmentId, Bundle extras) { RestDetailsFragment fragment; switch(fragmentId) { case Constants.FRAGMENT_MESSAGE_DETAILS: fragment = new MessageDetailsFragment(); getActionBar().setTitle(R.string.messages); break; case Constants.FRAGMENT_ISLAND_DETAILS: fragment = new IslandDetailsFragment(); getActionBar().setTitle(R.string.islands); break; case Constants.FRAGMENT_HOME_DETAILS: fragment = new HomeDetailsFragment(); getActionBar().setTitle(R.string.islands); break; default: fragment = new MessageDetailsFragment(); } // Place the content fragment. fragment.setArguments(extras); getFragmentManager().beginTransaction() .replace(R.id.contentFrgmt, fragment).commit(); } }