Android Open Source - MyFlickrSearch Abstract Back Button Activity






From Project

Back to project page MyFlickrSearch.

License

The source code is released under:

MIT License

If you think the Android project MyFlickrSearch 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.devng.flickrsearch;
/*w  w  w. j  av a 2  s. c o  m*/
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
import android.view.MenuItem;

import roboguice.activity.RoboActivity;

/**
 * Activities which extend this class will have a back button on the left side of the menu bar.
 */
public abstract class AbstractBackButtonActivity extends RoboActivity {

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

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      setupActionBar();
    }
  }

  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  private void setupActionBar() {
    getActionBar().setDisplayHomeAsUpEnabled(true);
  }

  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case android.R.id.home:
        this.onBackPressed();
        return true;
    }
    return super.onOptionsItemSelected(item);
  }

}




Java Source Code List

com.devng.flickrsearch.AbstractBackButtonActivity.java
com.devng.flickrsearch.ImageViewerActivity.java
com.devng.flickrsearch.MainActivity.java
com.devng.flickrsearch.MainModule.java
com.devng.flickrsearch.SearchResultsActivity.java
com.devng.flickrsearch.SearchResultsListAdapter.java
com.devng.flickrsearch.common.Config.java
com.devng.flickrsearch.common.Enums.java
com.devng.flickrsearch.common.Helpers.java
com.devng.flickrsearch.model.FlickrImgContainer.java
com.devng.flickrsearch.model.FlickrImgRef.java
com.devng.flickrsearch.model.FlickrImgRoot.java
com.devng.flickrsearch.task.DownloadFlickrImagesHandler.java
com.devng.flickrsearch.task.DownloadFlickrImagesTask.java
com.devng.flickrsearch.task.SearchFlickrResultHadler.java
com.devng.flickrsearch.task.SearchFlickrTask.java