
it.tidalwave.bluebill.mobile.android.taxonomy.factsheet.TaxonFactSheetContainerActivity Maven / Gradle / Ivy
/***********************************************************************************************************************
*
* blueBill Mobile - Android - open source birding
* Copyright (C) 2009-2011 by Tidalwave s.a.s. (http://www.tidalwave.it)
*
***********************************************************************************************************************
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
***********************************************************************************************************************
*
* WWW: http://bluebill.tidalwave.it/mobile
* SCM: https://kenai.com/hg/bluebill~android-src
*
**********************************************************************************************************************/
package it.tidalwave.bluebill.mobile.android.taxonomy.factsheet;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.inject.Provider;
import it.tidalwave.util.NotFoundException;
import it.tidalwave.netbeans.util.Locator;
import it.tidalwave.bluebill.taxonomy.mobile.Taxon;
import it.tidalwave.observation.bluebill.ObservationClipboard;
import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TabHost;
import android.widget.TextView;
import it.tidalwave.bluebill.mobile.android.R;
import it.tidalwave.bluebill.mobile.android.util.CommonOptionsMenuController;
import it.tidalwave.bluebill.mobile.android.taxonomy.TaxonIntentHelper;
import it.tidalwave.bluebill.mobile.android.taxonomy.factsheet.main.TaxonMainFactSheetActivity;
import it.tidalwave.bluebill.mobile.android.taxonomy.factsheet.stillimage.TaxonStillImageFactSheetActivity;
import it.tidalwave.bluebill.mobile.android.taxonomy.factsheet.sound.TaxonSoundFactSheetActivity;
import it.tidalwave.bluebill.mobile.android.taxonomy.factsheet.movingimage.TaxonMovingImageFactSheetActivity;
import it.tidalwave.bluebill.mobile.android.taxonomy.factsheet.commonnames.TaxonCommonNamesFactSheetActivity;
import it.tidalwave.bluebill.mobile.taxonomy.TaxonHistory;
import static org.openide.util.NbBundle.*;
/***********************************************************************************************************************
*
* @stereotype View
* @stereotype Activity
*
* @author Fabrizio Giudici
* @version $Id$
*
**********************************************************************************************************************/
public class TaxonFactSheetContainerActivity extends TabActivity
{
public static final Class TaxonFactSheetContainerActivity = TaxonFactSheetContainerActivity.class;
private static final Class _ = TaxonFactSheetContainerActivity.class;
@CheckForNull
private Taxon taxon;
@Nonnull
private final Provider taxonHistory = Locator.createProviderFor(TaxonHistory.class);
private final CommonOptionsMenuController commonOptionsMenuController = new CommonOptionsMenuController(this);
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
@Override
public void onCreate (final @Nonnull Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_taxon_fact_sheet_container);
final TextView textView = (TextView)findViewById(R.id.tvTaxon);
try
{
taxon = TaxonIntentHelper.getTaxon(getIntent());
taxonHistory.get().addToTaxonHistory(taxon);
createTab(TaxonMainFactSheetActivity.class, "facts", R.drawable.ic_tab_fact_sheet_main);
createTab(TaxonStillImageFactSheetActivity.class, "photo", R.drawable.ic_tab_fact_sheet_photo);
createTab(TaxonMovingImageFactSheetActivity.class, "video", R.drawable.ic_tab_fact_sheet_video);
createTab(TaxonSoundFactSheetActivity.class, "sound", R.drawable.ic_tab_fact_sheet_sound);
createTab(TaxonCommonNamesFactSheetActivity.class, "name", R.drawable.ic_tab_fact_sheet_name);
getTabHost().setCurrentTab(0);
}
catch (NotFoundException e)
{
textView.setText(e.getMessage());
}
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
@Override
public boolean onCreateOptionsMenu (final @Nonnull Menu menu)
{
getMenuInflater().inflate(R.menu.common_options_menu, menu);
return true;
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
@Override
public boolean onOptionsItemSelected (final @Nonnull MenuItem item)
{
return commonOptionsMenuController.onOptionsItemSelected(item);
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
private void createTab (final @Nonnull Class extends Activity> activityClass,
final @Nonnull String id,
final int iconResourceId)
throws NotFoundException
{
final TabHost tabHost = getTabHost();
final Intent intent = TaxonIntentHelper.intentFor(taxon, activityClass);
final Resources resources = getResources();
final String indicator = getMessage(_, "tab_" + id);
tabHost.addTab(tabHost.newTabSpec(id)
.setIndicator(indicator, resources.getDrawable(iconResourceId))
.setContent(intent));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy