Android Open Source - Sunshine Main Activity






From Project

Back to project page Sunshine.

License

The source code is released under:

MIT License

If you think the Android project Sunshine 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 cloudchen.com.sunshine;
//  w  w  w .j  a  v  a2  s.c o m
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;

import cloudchen.com.sunshine.sync.SunshineSyncAdapter;


public class MainActivity extends ActionBarActivity implements ForecastFragment.Callback {

    private static final String TAG = MainActivity.class.getSimpleName();
    private boolean mTwoPane;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        if (findViewById(R.id.weather_detail_container) != null) {
            mTwoPane = true;
            if (savedInstanceState == null) {
                getSupportFragmentManager().beginTransaction()
                        .replace(R.id.weather_detail_container, new DetailFragment())
                        .commit();
            }
        } else {
            mTwoPane = false;
        }

        ForecastFragment forecastFragment =
            ((ForecastFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_forecast));
        forecastFragment.setUseTodayLayout(!mTwoPane);

        SunshineSyncAdapter.initializeSyncAdapter(this);
    }

    @Override
    public void onItemSelected(String date) {
        Log.d(TAG, "Callback onItemSelected triggered.");
        if (mTwoPane) {
            Bundle args = new Bundle();
            args.putString(DetailActivity.DATE_KEY, date);
            DetailFragment detailFragment = new DetailFragment();
            detailFragment.setArguments(args);
            getSupportFragmentManager().beginTransaction()
                    .replace(R.id.weather_detail_container, detailFragment)
                    .commit();
        } else {
            Intent intent = new Intent(this, DetailActivity.class)
                    .putExtra(DetailActivity.DATE_KEY, date);
            startActivity(intent);
        }
    }
}




Java Source Code List

cloudchen.com.sunshine.ApplicationTest.java
cloudchen.com.sunshine.DetailActivity.java
cloudchen.com.sunshine.DetailFragment.java
cloudchen.com.sunshine.ForecastAdapter.java
cloudchen.com.sunshine.ForecastFragment.java
cloudchen.com.sunshine.FullTestSuite.java
cloudchen.com.sunshine.MainActivity.java
cloudchen.com.sunshine.SettingsActivity.java
cloudchen.com.sunshine.TestDb.java
cloudchen.com.sunshine.TestProvider.java
cloudchen.com.sunshine.Utility.java
cloudchen.com.sunshine.data.WeatherContract.java
cloudchen.com.sunshine.data.WeatherDbHelper.java
cloudchen.com.sunshine.data.WeatherProvider.java
cloudchen.com.sunshine.sync.SunshineAuthenticatorService.java
cloudchen.com.sunshine.sync.SunshineAuthenticator.java
cloudchen.com.sunshine.sync.SunshineSyncAdapter.java
cloudchen.com.sunshine.sync.SunshineSyncService.java