
it.tidalwave.bluebill.mobile.android.taxonomy.factsheet.stillimage.AndroidTaxonStillImageFactSheetViewController Maven / Gradle / Ivy
The newest version!
/***********************************************************************************************************************
*
* 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://java.net/hg/bluebill-mobile~android-src
*
**********************************************************************************************************************/
package it.tidalwave.bluebill.mobile.android.taxonomy.factsheet.stillimage;
import javax.annotation.Nonnull;
import it.tidalwave.util.AsException;
import it.tidalwave.util.NotFoundException;
import it.tidalwave.role.ui.PresentationModel;
import it.tidalwave.bluebill.mobile.taxonomy.factsheet.ui.stillimage.DefaultTaxonStillImageFactSheetViewController;
import it.tidalwave.bluebill.mobile.taxonomy.factsheet.ui.stillimage.TaxonStillImageFactSheetView;
import it.tidalwave.bluebill.mobile.role.util.RoleRegister.Predicate;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import it.tidalwave.ui.android.widget.StillImageViewer;
import it.tidalwave.role.ui.android.ViewFactory;
import it.tidalwave.role.ui.android.ViewSwitcherViewFactoryAdapter;
import it.tidalwave.role.ui.android.spi.InflatingViewFactory;
import it.tidalwave.bluebill.mobile.android.R;
import static it.tidalwave.semantic.vocabulary.DublinCoreVocabulary.*;
import static it.tidalwave.mobile.media.Media.*;
/***********************************************************************************************************************
*
* @stereotype Controller
*
* @author Fabrizio Giudici
* @version $Id$
*
**********************************************************************************************************************/
public class AndroidTaxonStillImageFactSheetViewController extends DefaultTaxonStillImageFactSheetViewController
{
/*******************************************************************************************************************
*
* A predicate which returns true for objects that are a {@link PresentationModel} for a still image.
*
******************************************************************************************************************/
private final static Predicate ARE_PRESENTATION_MODELS_FOR_STILL_IMAGE = new Predicate()
{
public boolean apply (final @Nonnull Object object)
{
if (!(object instanceof PresentationModel))
{
return false;
}
final PresentationModel presentationModel = (PresentationModel)object;
try
{
return TYPE_STILL_IMAGE.stringValue().equals(presentationModel.as(Media).get(TYPE));
}
catch (NotFoundException e)
{
return false;
}
catch (AsException e)
{
return false;
}
}
};
/*******************************************************************************************************************
*
* A {@link ViewFactory} for rendering the thumbnail of a still image.
*
******************************************************************************************************************/
private final ViewFactory thumbnailViewFactory = new ViewFactory()
{
@Nonnull
public View createView (final @Nonnull Context context, final @Nonnull ViewGroup viewGroup)
{
final StillImageViewer stillImageViewer = new StillImageViewer(context);
final InflatingViewFactory vf = new InflatingViewFactory(R.layout.component_thumbnail_view);
stillImageViewer.setFactory(new ViewSwitcherViewFactoryAdapter(vf, context, null));
return stillImageViewer;
}
};
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
public AndroidTaxonStillImageFactSheetViewController (final @Nonnull TaxonStillImageFactSheetView view)
{
super(view);
roleRegister.registerRole(thumbnailViewFactory).forObjectsThat(ARE_PRESENTATION_MODELS_FOR_STILL_IMAGE);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy