Android Open Source - campus Place Details Activity






From Project

Back to project page campus.

License

The source code is released under:

GNU General Public License

If you think the Android project campus 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 lecho.app.campus.activity;
//from   w w w .j a  v a 2 s. c  o m
import lecho.app.campus.R;
import lecho.app.campus.adapter.PlaceDetailsFragmentAdapter;
import lecho.app.campus.utils.Config;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.ViewPager;

import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;

/**
 * It has to be started with intent containing array of longs(identifiers of all visible places) and integer(current
 * place position in search result adapter).
 * 
 * As results activity will set id and position of place currently displayed on details view.
 * 
 * @author Lecho
 * 
 */
public class PlaceDetailsActivity extends SherlockFragmentActivity {

  private ViewPager mViewPager;
  private PlaceDetailsFragmentAdapter mDetailsFragmentAdapter;

  @Override
  protected void onCreate(Bundle saveInstanceState) {
    super.onCreate(saveInstanceState);
    setContentView(R.layout.activity_place_details);
    long[] visiblePlaces = getIntent().getExtras().getLongArray(Config.EXTRA_VISIBLE_PLACES);
    int currentPlacePostion = getIntent().getExtras().getInt(Config.EXTRA_PLACE_POSITION);
    mDetailsFragmentAdapter = new PlaceDetailsFragmentAdapter(getSupportFragmentManager(), visiblePlaces);
    mViewPager = (ViewPager) findViewById(R.id.view_pager);
    mViewPager.setAdapter(mDetailsFragmentAdapter);
    mViewPager.setCurrentItem(currentPlacePostion);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    return super.onCreateOptionsMenu(menu);
  }

  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    int itemId = item.getItemId();
    if (android.R.id.home == itemId) {
      setReturnResult();
      this.finish();
    }
    return super.onOptionsItemSelected(item);
  }

  @Override
  public void onBackPressed() {
    setReturnResult();
    super.onBackPressed();
  }

  private void setReturnResult() {
    Bundle bundle = new Bundle();
    bundle.putInt(Config.EXTRA_PLACE_POSITION, mViewPager.getCurrentItem());
    bundle.putLong(Config.EXTRA_PLACE_ID, mDetailsFragmentAdapter.getItemId(mViewPager.getCurrentItem()));
    Intent data = new Intent();
    data.putExtras(bundle);
    setResult(Activity.RESULT_OK, data);
  }
}




Java Source Code List

lecho.app.campus.activity.AboutAppActivity.java
lecho.app.campus.activity.CampusMapActivity.java
lecho.app.campus.activity.GalleryActivity.java
lecho.app.campus.activity.LegalInfoActivity.java
lecho.app.campus.activity.PlaceDetailsActivity.java
lecho.app.campus.adapter.GalleryPagesFragmentAdapter.java
lecho.app.campus.adapter.MarkerInfoWindowAdapter.java
lecho.app.campus.adapter.NavigationDrawerAdapter.java
lecho.app.campus.adapter.PlaceDetailsFragmentAdapter.java
lecho.app.campus.adapter.SearchResultViewAdapter.java
lecho.app.campus.adapter.SearchSuggestionAdapter.java
lecho.app.campus.dao.CategoryDao.java
lecho.app.campus.dao.CategoryDao.java
lecho.app.campus.dao.Category.java
lecho.app.campus.dao.Category.java
lecho.app.campus.dao.DaoMaster.java
lecho.app.campus.dao.DaoMaster.java
lecho.app.campus.dao.DaoSession.java
lecho.app.campus.dao.DaoSession.java
lecho.app.campus.dao.FacultyDao.java
lecho.app.campus.dao.FacultyDao.java
lecho.app.campus.dao.Faculty.java
lecho.app.campus.dao.Faculty.java
lecho.app.campus.dao.Main.java
lecho.app.campus.dao.PlaceCategoryDao.java
lecho.app.campus.dao.PlaceCategoryDao.java
lecho.app.campus.dao.PlaceCategory.java
lecho.app.campus.dao.PlaceCategory.java
lecho.app.campus.dao.PlaceDao.java
lecho.app.campus.dao.PlaceDao.java
lecho.app.campus.dao.PlaceFacultyDao.java
lecho.app.campus.dao.PlaceFacultyDao.java
lecho.app.campus.dao.PlaceFaculty.java
lecho.app.campus.dao.PlaceFaculty.java
lecho.app.campus.dao.PlaceUnitDao.java
lecho.app.campus.dao.PlaceUnitDao.java
lecho.app.campus.dao.PlaceUnit.java
lecho.app.campus.dao.PlaceUnit.java
lecho.app.campus.dao.Place.java
lecho.app.campus.dao.Place.java
lecho.app.campus.dao.UnitDao.java
lecho.app.campus.dao.UnitDao.java
lecho.app.campus.dao.Unit.java
lecho.app.campus.dao.Unit.java
lecho.app.campus.fragment.GalleryPageFragment.java
lecho.app.campus.fragment.PlaceDetailsFragment.java
lecho.app.campus.fragment.dialog.NoInternetConnectionDialogFragment.java
lecho.app.campus.fragment.dialog.PlayServicesErrorDialogFragment.java
lecho.app.campus.loader.PlaceDetailsLoader.java
lecho.app.campus.loader.PlacesLoader.java
lecho.app.campus.provider.SearchSuggestionProvider.java
lecho.app.campus.service.PopulateDBIntentService.java
lecho.app.campus.utils.ABSMenuItemConverter.java
lecho.app.campus.utils.BitmapAsyncTask.java
lecho.app.campus.utils.Config.java
lecho.app.campus.utils.DataParser.java
lecho.app.campus.utils.DatabaseHelper.java
lecho.app.campus.utils.ImagesDirAsyncTask.java
lecho.app.campus.utils.NavigationDrawerItem.java
lecho.app.campus.utils.PlaceDetails.java
lecho.app.campus.utils.PlacesList.java
lecho.app.campus.utils.UnitsGroup.java
lecho.app.campus.utils.Utils.java
lecho.app.campus.view.CheckableDrawerItem.java
lecho.app.campus.view.UnitsGroupLayout.java
lecho.app.campus.view.ZoomImageView.java
lecho.app.campus.view.ZoomViewPager.java