com.richtodd.android.quiltdesign.app.BrowserActivity.java Source code

Java tutorial

Introduction

Here is the source code for com.richtodd.android.quiltdesign.app.BrowserActivity.java

Source

/* Copyright (c) 2013 Richard G. Todd.
 * Licensed under the terms of the GNU General Public License (GPL) Version 3.0.
 */

package com.richtodd.android.quiltdesign.app;

import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.view.MenuItem;

public class BrowserActivity extends Activity {

    public static final String ARG_URL = "com.richtodd.android.quiltdesign.app.url";

    private String m_urlArgument;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_browser);
        getActionBar().setDisplayHomeAsUpEnabled(true);

        m_urlArgument = getIntent().getStringExtra(ARG_URL);

        FragmentManager fm = getFragmentManager();

        // Create color settings fragment.
        {
            Fragment f = fm.findFragmentById(R.id.layout_container);
            if (f == null) {
                f = BrowserFragment.create(m_urlArgument);
                fm.beginTransaction().add(R.id.layout_container, f).commit();
            }
        }
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int itemId = item.getItemId();
        switch (itemId) {
        case android.R.id.home: {
            NavUtils.navigateUpFromSameTask(this);
            return true;
        }
        }

        return super.onOptionsItemSelected(item);
    }
}