Back to project page HapiPodcastJ.
The source code is released under:
GNU General Public License
If you think the Android project HapiPodcastJ 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 info.xuluan.podcast; //from www . ja v a 2 s . co m import info.xuluan.podcast.actionbar.ActionBarHelper; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; public abstract class HapiActivity extends Activity { final ActionBarHelper mActionBarHelper = ActionBarHelper.createInstance(this); /** * Returns the {@link ActionBarHelper} for this activity. */ protected ActionBarHelper getActionBarHelper() { return mActionBarHelper; } /**{@inheritDoc}*/ @Override public MenuInflater getMenuInflater() { return mActionBarHelper.getMenuInflater(super.getMenuInflater()); } /**{@inheritDoc}*/ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mActionBarHelper.onCreate(savedInstanceState); } /**{@inheritDoc}*/ @Override protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); mActionBarHelper.onPostCreate(savedInstanceState); } /** * Base action bar-aware implementation for * {@link Activity#onCreateOptionsMenu(android.view.Menu)}. * * Note: marking menu items as invisible/visible is not currently supported. */ @Override public boolean onCreateOptionsMenu(Menu menu) { boolean retValue = false; retValue |= mActionBarHelper.onCreateOptionsMenu(menu); retValue |= super.onCreateOptionsMenu(menu); return retValue; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: tapHome(); break; } return super.onOptionsItemSelected(item); } protected void tapHome() { //Toast.makeText(this, "Tapped Home", Toast.LENGTH_SHORT).show(); SharedPreferences prefsPrivate = getSharedPreferences(Pref.HAPI_PREFS_FILE_NAME, Context.MODE_PRIVATE); int homeActivity = prefsPrivate.getInt("homeActivity", 1); if (homeActivity!=0) startActivity(new Intent(this, HomeActivity.class)); else startActivity(new Intent(this, MainActivity.class)); } /**{@inheritDoc}*/ @Override protected void onTitleChanged(CharSequence title, int color) { mActionBarHelper.onTitleChanged(title, color); super.onTitleChanged(title, color); } }