Android Open Source - RoboBinding-gallery Adapter View Presentation Model






From Project

Back to project page RoboBinding-gallery.

License

The source code is released under:

Apache License

If you think the Android project RoboBinding-gallery 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 org.robobinding.gallery.presentationmodel;
/*from   w  w w.  j a  v  a 2 s .  co m*/
import java.util.List;

import org.robobinding.annotation.DependsOnStateOf;
import org.robobinding.annotation.ItemPresentationModel;
import org.robobinding.annotation.PresentationModel;
import org.robobinding.gallery.invocationlog.PublicMethodInvocationLog;
import org.robobinding.gallery.model.adapterview.SampleStringType;
import org.robobinding.gallery.model.adapterview.SampleStrings;
import org.robobinding.gallery.model.adapterview.StringItemLayout;

/**
 * @author Cheng Wei
 * @version $Revision: 1.0 $
 * @since 1.0
 */
@PresentationModel
public class AdapterViewPresentationModel implements PublicMethodInvocationLog {
    private static final String SELECTED_SOURCE_INDEX = "selectedSourceIndex";

    private static final String SELECTED_ITEM_LAYOUT_INDEX = "selectedItemLayoutIndex";

    private int selectedSourceIndex;

    private int selectedItemLayoutIndex;

    public AdapterViewPresentationModel() {
        selectedSourceIndex = 0;

        selectedItemLayoutIndex = 0;
    }

    @ItemPresentationModel(value = StringItemPresentationModel.class)
    @DependsOnStateOf(SELECTED_SOURCE_INDEX)
    public List<String> getDynamicStrings() {
        return getSelectedSource().getSample();
    }

    @ItemPresentationModel(value = ToStringItemPresentationModel.class)
    public List<SampleStringType> getSources() {
        return SampleStringType.types();
    }

    public int getSelectedSourceIndex() {
        return selectedSourceIndex;
    }

    public void setSelectedSourceIndex(int selectedSourceIndex) {
        this.selectedSourceIndex = selectedSourceIndex;
    }

    private SampleStringType getSelectedSource() {
        return SampleStringType.valueOf(selectedSourceIndex);
    }

    @DependsOnStateOf(SELECTED_ITEM_LAYOUT_INDEX)
    public int getDynamicItemLayout() {
        return getSelectedItemLayout().getLayoutResourceId();
    }

    @ItemPresentationModel(value = StringItemPresentationModel.class)
    public List<String> getStaticStrings() {
        return SampleStrings.getSample();
    }

    @ItemPresentationModel(value = ToStringItemPresentationModel.class)
    public List<StringItemLayout> getItemLayouts() {
        return StringItemLayout.itemLayouts();
    }

    public int getSelectedItemLayoutIndex() {
        return selectedItemLayoutIndex;
    }

    public void setSelectedItemLayoutIndex(int selectedItemLayoutIndex) {
        this.selectedItemLayoutIndex = selectedItemLayoutIndex;
    }

    private StringItemLayout getSelectedItemLayout() {
        return StringItemLayout.valueOf(selectedItemLayoutIndex);
    }
}




Java Source Code List

org.robobinding.gallery.activity.AbstractActivity.java
org.robobinding.gallery.activity.AbstractFragmentActivity.java
org.robobinding.gallery.activity.AbstractFragment.java
org.robobinding.gallery.activity.AdapterViewActivity.java
org.robobinding.gallery.activity.ContextMenuDemoActivity.java
org.robobinding.gallery.activity.ContextualActionModeActivity.java
org.robobinding.gallery.activity.CustomComponentActivity.java
org.robobinding.gallery.activity.DynamicBindingActivity.java
org.robobinding.gallery.activity.EditTextActivity.java
org.robobinding.gallery.activity.FragmentDemo.java
org.robobinding.gallery.activity.GalleryActivity.java
org.robobinding.gallery.activity.GalleryApp.java
org.robobinding.gallery.activity.ListFragmentDemoActivity.java
org.robobinding.gallery.activity.ListFragmentDemo.java
org.robobinding.gallery.activity.ListViewActivity.java
org.robobinding.gallery.activity.OptionMenuFragment.java
org.robobinding.gallery.activity.OptionsMenuActivity.java
org.robobinding.gallery.activity.TypedCursorActivity.java
org.robobinding.gallery.activity.ViewActivity.java
org.robobinding.gallery.activity.ViewPagerActivity.java
org.robobinding.gallery.invocationlog.PublicMethodInvocationLog.java
org.robobinding.gallery.model.MemoryProductStore.java
org.robobinding.gallery.model.Product.java
org.robobinding.gallery.model.Strings.java
org.robobinding.gallery.model.TestData.java
org.robobinding.gallery.model.adapterview.SampleStringType.java
org.robobinding.gallery.model.adapterview.SampleStrings.java
org.robobinding.gallery.model.adapterview.StringItemLayout.java
org.robobinding.gallery.model.customcomponent.DescriptionAttribute.java
org.robobinding.gallery.model.customcomponent.TitleAttribute.java
org.robobinding.gallery.model.customcomponent.TitleDescriptionBarBinding.java
org.robobinding.gallery.model.customcomponent.TitleDescriptionBar.java
org.robobinding.gallery.model.dynamicbinding.CustomOrThirdPartyComponent.java
org.robobinding.gallery.model.listview.SampleStringsFooter.java
org.robobinding.gallery.model.typedcursor.DatabaseHelper.java
org.robobinding.gallery.model.typedcursor.GetAllQuery.java
org.robobinding.gallery.model.typedcursor.ProductItemPresentationModel.java
org.robobinding.gallery.model.typedcursor.ProductRowMapper.java
org.robobinding.gallery.model.typedcursor.ProductTable.java
org.robobinding.gallery.model.view.BooleanVisibility.java
org.robobinding.gallery.model.view.IntegerVisibility.java
org.robobinding.gallery.presentationmodel.AdapterViewPresentationModel.java
org.robobinding.gallery.presentationmodel.ContextMenuDemoPresentationModel.java
org.robobinding.gallery.presentationmodel.ContextMenuPresentationModel.java
org.robobinding.gallery.presentationmodel.ContextualActionModePresentationModel.java
org.robobinding.gallery.presentationmodel.CustomComponentPresentationModel.java
org.robobinding.gallery.presentationmodel.DynamicBindingPresentationModel.java
org.robobinding.gallery.presentationmodel.EditTextPresentationModel.java
org.robobinding.gallery.presentationmodel.FragmentDemoPresentationModel.java
org.robobinding.gallery.presentationmodel.GalleryPresentationModel.java
org.robobinding.gallery.presentationmodel.ListFragmentDemoPresentationModel.java
org.robobinding.gallery.presentationmodel.ListViewPresentationModel.java
org.robobinding.gallery.presentationmodel.MenuPresentationModel.java
org.robobinding.gallery.presentationmodel.StringItemPresentationModel.java
org.robobinding.gallery.presentationmodel.ToStringItemPresentationModel.java
org.robobinding.gallery.presentationmodel.TypedCursorPresentationModel.java
org.robobinding.gallery.presentationmodel.ViewPresentationModel.java
org.robobinding.gallery.util.CircularIntegers.java
org.robobinding.gallerytest.DemoTraveller.java