Back to project page RedditReader_Android_app.
The source code is released under:
MIT License
If you think the Android project RedditReader_Android_app 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 com.example.dawoon.redditreader; /* w ww . ja v a2s.co m*/ import android.content.Intent; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.view.Menu; import android.view.MenuItem; import com.example.dawoon.redditreader.sync.RedditSyncAdapter; /** * MainActivity of the app. */ public class MainActivity extends ActionBarActivity implements RedditFragment.Callback { public boolean mTwoPane; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (findViewById(R.id.detail_container) != null) { // The detail container view will be present only in the large-screen layouts // (res/layout-sw600dp). If this view is present, then the activity should be // in two-pane mode. mTwoPane = true; // In two-pane mode, show the detail view in this activity by // adding or replacing the detail fragment using a // fragment transaction. if (savedInstanceState == null) { getSupportFragmentManager().beginTransaction() .replace(R.id.detail_container, new DetailFragment()) .commit(); } } else { mTwoPane = false; } RedditSyncAdapter.initializeSyncAdapter(this); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.action_settings) { Intent settingsIntent = new Intent(this, SettingsActivity.class); startActivity(settingsIntent); return true; } return super.onOptionsItemSelected(item); } @Override public void onItemSelected(String permalink) { if (mTwoPane) { // In two-pane mode, show the detail view in this activity by // adding or replacing the detail fragment using a // fragment transaction. Bundle args = new Bundle(); args.putString(DetailActivity.LINK_KEY, permalink); DetailFragment fragment = new DetailFragment(); fragment.setArguments(args); getSupportFragmentManager().beginTransaction() .replace(R.id.detail_container, fragment) .commit(); } else { Intent intent = new Intent(this, DetailActivity.class) .putExtra(DetailActivity.LINK_KEY, permalink); startActivity(intent); } } }