Android Open Source - sunshineApp Detail Activity






From Project

Back to project page sunshineApp.

License

The source code is released under:

Apache License

If you think the Android project sunshineApp listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.iyedb.sunshine;
//from   w  w  w.  ja v a2  s  .c  om
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.NavUtils;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.support.v4.app.TaskStackBuilder;


public class DetailActivity extends ActionBarActivity {

    public static final String DATE_KEY = "forecast_date";
    private final String TAG = DetailActivity.class.getSimpleName();


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_detail);
        if (savedInstanceState == null) {
            DetailFragment fragment = new DetailFragment();
            fragment.setArguments(getIntent().getExtras());
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.weather_detail_container, fragment)
                    .commit();
        }
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.detail, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        Log.d(TAG, Integer.toString(item.getItemId()));
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            Intent intent = new Intent(this, SettingsActivity.class);
            startActivity(intent);
            return true;
        }
        if (id == android.R.id.home) {
            Intent upIntent = NavUtils.getParentActivityIntent(this);
            if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
                // This activity is NOT part of this app's task, so create a new task
                // when navigating up, with a synthesized back stack.
                TaskStackBuilder.create(this)
                        // Add all of this activity's parents to the back stack
                        .addNextIntentWithParentStack(upIntent)
                                // Navigate up to the closest parent
                        .startActivities();
            } else {
                // This activity is part of this app's task, so simply
                // navigate up to the logical parent activity.
                NavUtils.navigateUpTo(this, upIntent);
            }
            overridePendingTransition(R.anim.slide_in_to_right, R.anim.slide_out_to_right);
            return true;
        }
        return super.onOptionsItemSelected(item);
    }



    /**
     * A placeholder fragment containing a simple view.
     */
    public static class PlaceholderFragment extends Fragment {

        public PlaceholderFragment() {
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                 Bundle savedInstanceState) {
            View rootView = inflater.inflate(R.layout.fragment_detail, container, false);

            return rootView;
        }
    }



}




Java Source Code List

com.iyedb.sunshine.DetailActivity.java
com.iyedb.sunshine.DetailFragment.java
com.iyedb.sunshine.FetchWeatherTask.java
com.iyedb.sunshine.ForecastAdapter.java
com.iyedb.sunshine.ForecastFragment.java
com.iyedb.sunshine.MainActivity.java
com.iyedb.sunshine.SettingsActivity.java
com.iyedb.sunshine.Utility.java
com.iyedb.sunshine.data.WeatherContract.java
com.iyedb.sunshine.data.WeatherDbHelper.java
com.iyedb.sunshine.data.WeatherProvider.java
com.iyedb.sunshine.service.SunshineService.java
com.iyedb.sunshine.sync.SunshineAuthenticatorService.java
com.iyedb.sunshine.sync.SunshineAuthenticator.java
com.iyedb.sunshine.sync.SunshineSyncAdapter.java
com.iyedb.sunshine.sync.SunshineSyncService.java