text: /*
   * Copyright (c) 2016 United States Government as represented by the Administrator of the
   * National Aeronautics and Space Administration. All Rights Reserved.
   */
  
  package gov.nasa.worldwindx;
  
  import android.content.Intent;
  import android.os.Bundle;
  import android.support.v4.app.Fragment;
  import android.support.v7.app.ActionBar;
  import android.support.v7.app.AppCompatActivity;
  import android.view.MenuItem;
  
  public class CodeActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_code);
  
          // Show the Up button in the action bar.
          ActionBar actionBar = getSupportActionBar();
          if (actionBar != null) {
              actionBar.setDisplayHomeAsUpEnabled(true);
          }
  
          // Create the code viewer fragment
          if (savedInstanceState == null) {
              Bundle bundle = getIntent().getBundleExtra("arguments");
              Fragment fragment = new CodeFragment();
              fragment.setArguments(bundle);
  
              getSupportFragmentManager()
                  .beginTransaction()
                  .replace(R.id.code_container, fragment)
                  .commit();
          }
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          int id = item.getItemId();
          if (id == android.R.id.home) {
              // This ID represents the Home or Up button. In the case of this
              // activity, the Up button is shown. Return to the globe view
              navigateUpTo(new Intent(this, MainActivity.class));
              return true;
          }
          return super.onOptionsItemSelected(item);
      }
  }
  