Back to project page Sunshine.
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.
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); } } }