package com.toughra.ustadmobile.databinding;
import com.toughra.ustadmobile.R;
import com.toughra.ustadmobile.BR;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.view.View;
@SuppressWarnings("unchecked")
public class ItemSortOptionBindingImpl extends ItemSortOptionBinding implements com.toughra.ustadmobile.generated.callback.OnClickListener.Listener {

    @Nullable
    private static final androidx.databinding.ViewDataBinding.IncludedLayouts sIncludes;
    @Nullable
    private static final android.util.SparseIntArray sViewsWithIds;
    static {
        sIncludes = null;
        sViewsWithIds = null;
    }
    // views
    @NonNull
    private final android.widget.TextView mboundView2;
    // variables
    @Nullable
    private final android.view.View.OnClickListener mCallback157;
    // values
    // listeners
    // Inverse Binding Event Handlers

    public ItemSortOptionBindingImpl(@Nullable androidx.databinding.DataBindingComponent bindingComponent, @NonNull View root) {
        this(bindingComponent, root, mapBindings(bindingComponent, root, 3, sIncludes, sViewsWithIds));
    }
    private ItemSortOptionBindingImpl(androidx.databinding.DataBindingComponent bindingComponent, View root, Object[] bindings) {
        super(bindingComponent, root, 0
            , (androidx.constraintlayout.widget.ConstraintLayout) bindings[0]
            , (android.widget.TextView) bindings[1]
            );
        this.itemSortLayout.setTag(null);
        this.itemSortSelectionText.setTag(null);
        this.mboundView2 = (android.widget.TextView) bindings[2];
        this.mboundView2.setTag(null);
        setRootTag(root);
        // listeners
        mCallback157 = new com.toughra.ustadmobile.generated.callback.OnClickListener(this, 1);
        invalidateAll();
    }

    @Override
    public void invalidateAll() {
        synchronized(this) {
                mDirtyFlags = 0x8L;
        }
        requestRebind();
    }

    @Override
    public boolean hasPendingBindings() {
        synchronized(this) {
            if (mDirtyFlags != 0) {
                return true;
            }
        }
        return false;
    }

    @Override
    public boolean setVariable(int variableId, @Nullable Object variable)  {
        boolean variableSet = true;
        if (BR.alreadySelectedOption == variableId) {
            setAlreadySelectedOption((com.ustadmobile.core.util.SortOrderOption) variable);
        }
        else if (BR.sortOption == variableId) {
            setSortOption((com.ustadmobile.core.util.SortOrderOption) variable);
        }
        else if (BR.sortListener == variableId) {
            setSortListener((com.ustadmobile.core.controller.OnSortOptionSelected) variable);
        }
        else {
            variableSet = false;
        }
            return variableSet;
    }

    public void setAlreadySelectedOption(@Nullable com.ustadmobile.core.util.SortOrderOption AlreadySelectedOption) {
        this.mAlreadySelectedOption = AlreadySelectedOption;
        synchronized(this) {
            mDirtyFlags |= 0x1L;
        }
        notifyPropertyChanged(BR.alreadySelectedOption);
        super.requestRebind();
    }
    public void setSortOption(@Nullable com.ustadmobile.core.util.SortOrderOption SortOption) {
        this.mSortOption = SortOption;
        synchronized(this) {
            mDirtyFlags |= 0x2L;
        }
        notifyPropertyChanged(BR.sortOption);
        super.requestRebind();
    }
    public void setSortListener(@Nullable com.ustadmobile.core.controller.OnSortOptionSelected SortListener) {
        this.mSortListener = SortListener;
        synchronized(this) {
            mDirtyFlags |= 0x4L;
        }
        notifyPropertyChanged(BR.sortListener);
        super.requestRebind();
    }

    @Override
    protected boolean onFieldChange(int localFieldId, Object object, int fieldId) {
        switch (localFieldId) {
        }
        return false;
    }

    @Override
    protected void executeBindings() {
        long dirtyFlags = 0;
        synchronized(this) {
            dirtyFlags = mDirtyFlags;
            mDirtyFlags = 0;
        }
        int sortOptionEqualsAlreadySelectedOptionItemSortSelectionTextAndroidColorOnPrimaryColorItemSortSelectionTextAndroidColorOnSurfaceColor = 0;
        int sortOptionFieldMessageId = 0;
        boolean sortOptionEqualsAlreadySelectedOption = false;
        android.graphics.drawable.Drawable sortOptionEqualsAlreadySelectedOptionItemSortLayoutAndroidDrawableBgSelectedItemItemSortLayoutAndroidDrawableBgListitem = null;
        boolean sortOptionOrder = false;
        com.ustadmobile.core.util.SortOrderOption alreadySelectedOption = mAlreadySelectedOption;
        int sortOptionEqualsAlreadySelectedOptionMboundView2AndroidColorOnPrimaryColorMboundView2AndroidColorOnSurfaceColor = 0;
        java.lang.String stringExtKtInBracketsSortOptionOrderMboundView2AndroidStringAscendingMboundView2AndroidStringDescending = null;
        com.ustadmobile.core.util.SortOrderOption sortOption = mSortOption;
        com.ustadmobile.core.controller.OnSortOptionSelected sortListener = mSortListener;
        java.lang.String sortOptionOrderMboundView2AndroidStringAscendingMboundView2AndroidStringDescending = null;

        if ((dirtyFlags & 0xbL) != 0) {


            if ((dirtyFlags & 0xaL) != 0) {

                    if (sortOption != null) {
                        // read sortOption.fieldMessageId
                        sortOptionFieldMessageId = sortOption.getFieldMessageId();
                        // read sortOption.order
                        sortOptionOrder = sortOption.getOrder();
                    }
                if((dirtyFlags & 0xaL) != 0) {
                    if(sortOptionOrder) {
                            dirtyFlags |= 0x800L;
                    }
                    else {
                            dirtyFlags |= 0x400L;
                    }
                }


                    // read sortOption.order ? @android:string/ascending : @android:string/descending
                    sortOptionOrderMboundView2AndroidStringAscendingMboundView2AndroidStringDescending = ((sortOptionOrder) ? (mboundView2.getResources().getString(R.string.ascending)) : (mboundView2.getResources().getString(R.string.descending)));


                    // read StringExtKt.inBrackets(sortOption.order ? @android:string/ascending : @android:string/descending)
                    stringExtKtInBracketsSortOptionOrderMboundView2AndroidStringAscendingMboundView2AndroidStringDescending = com.ustadmobile.core.util.ext.StringExtKt.inBrackets(sortOptionOrderMboundView2AndroidStringAscendingMboundView2AndroidStringDescending);
            }

                if (sortOption != null) {
                    // read sortOption.equals(alreadySelectedOption)
                    sortOptionEqualsAlreadySelectedOption = sortOption.equals(alreadySelectedOption);
                }
            if((dirtyFlags & 0xbL) != 0) {
                if(sortOptionEqualsAlreadySelectedOption) {
                        dirtyFlags |= 0x20L;
                        dirtyFlags |= 0x80L;
                        dirtyFlags |= 0x200L;
                }
                else {
                        dirtyFlags |= 0x10L;
                        dirtyFlags |= 0x40L;
                        dirtyFlags |= 0x100L;
                }
            }


                // read sortOption.equals(alreadySelectedOption) ? @android:color/onPrimaryColor : @android:color/onSurfaceColor
                sortOptionEqualsAlreadySelectedOptionItemSortSelectionTextAndroidColorOnPrimaryColorItemSortSelectionTextAndroidColorOnSurfaceColor = ((sortOptionEqualsAlreadySelectedOption) ? (getColorFromResource(itemSortSelectionText, R.color.onPrimaryColor)) : (getColorFromResource(itemSortSelectionText, R.color.onSurfaceColor)));
                // read sortOption.equals(alreadySelectedOption) ? @android:drawable/bg_selected_item : @android:drawable/bg_listitem
                sortOptionEqualsAlreadySelectedOptionItemSortLayoutAndroidDrawableBgSelectedItemItemSortLayoutAndroidDrawableBgListitem = ((sortOptionEqualsAlreadySelectedOption) ? (androidx.appcompat.content.res.AppCompatResources.getDrawable(itemSortLayout.getContext(), R.drawable.bg_selected_item)) : (androidx.appcompat.content.res.AppCompatResources.getDrawable(itemSortLayout.getContext(), R.drawable.bg_listitem)));
                // read sortOption.equals(alreadySelectedOption) ? @android:color/onPrimaryColor : @android:color/onSurfaceColor
                sortOptionEqualsAlreadySelectedOptionMboundView2AndroidColorOnPrimaryColorMboundView2AndroidColorOnSurfaceColor = ((sortOptionEqualsAlreadySelectedOption) ? (getColorFromResource(mboundView2, R.color.onPrimaryColor)) : (getColorFromResource(mboundView2, R.color.onSurfaceColor)));
        }
        // batch finished
        if ((dirtyFlags & 0xbL) != 0) {
            // api target 1

            androidx.databinding.adapters.ViewBindingAdapter.setBackground(this.itemSortLayout, sortOptionEqualsAlreadySelectedOptionItemSortLayoutAndroidDrawableBgSelectedItemItemSortLayoutAndroidDrawableBgListitem);
            this.itemSortSelectionText.setTextColor(sortOptionEqualsAlreadySelectedOptionItemSortSelectionTextAndroidColorOnPrimaryColorItemSortSelectionTextAndroidColorOnSurfaceColor);
            this.mboundView2.setTextColor(sortOptionEqualsAlreadySelectedOptionMboundView2AndroidColorOnPrimaryColorMboundView2AndroidColorOnSurfaceColor);
        }
        if ((dirtyFlags & 0x8L) != 0) {
            // api target 1

            this.itemSortLayout.setOnClickListener(mCallback157);
        }
        if ((dirtyFlags & 0xaL) != 0) {
            // api target 1

            com.ustadmobile.port.android.view.binding.TextViewBindingsKt.setTextMessageId(this.itemSortSelectionText, sortOptionFieldMessageId);
            androidx.databinding.adapters.TextViewBindingAdapter.setText(this.mboundView2, stringExtKtInBracketsSortOptionOrderMboundView2AndroidStringAscendingMboundView2AndroidStringDescending);
        }
    }
    // Listener Stub Implementations
    // callback impls
    public final void _internalCallbackOnClick(int sourceId , android.view.View callbackArg_0) {
        // localize variables for thread safety
        // sortListener
        com.ustadmobile.core.controller.OnSortOptionSelected sortListener = mSortListener;
        // sortListener != null
        boolean sortListenerJavaLangObjectNull = false;
        // sortOption
        com.ustadmobile.core.util.SortOrderOption sortOption = mSortOption;



        sortListenerJavaLangObjectNull = (sortListener) != (null);
        if (sortListenerJavaLangObjectNull) {



            sortListener.onClickSort(sortOption);
        }
    }
    // dirty flag
    private  long mDirtyFlags = 0xffffffffffffffffL;
    /* flag mapping
        flag 0 (0x1L): alreadySelectedOption
        flag 1 (0x2L): sortOption
        flag 2 (0x3L): sortListener
        flag 3 (0x4L): null
        flag 4 (0x5L): sortOption.equals(alreadySelectedOption) ? @android:color/onPrimaryColor : @android:color/onSurfaceColor
        flag 5 (0x6L): sortOption.equals(alreadySelectedOption) ? @android:color/onPrimaryColor : @android:color/onSurfaceColor
        flag 6 (0x7L): sortOption.equals(alreadySelectedOption) ? @android:drawable/bg_selected_item : @android:drawable/bg_listitem
        flag 7 (0x8L): sortOption.equals(alreadySelectedOption) ? @android:drawable/bg_selected_item : @android:drawable/bg_listitem
        flag 8 (0x9L): sortOption.equals(alreadySelectedOption) ? @android:color/onPrimaryColor : @android:color/onSurfaceColor
        flag 9 (0xaL): sortOption.equals(alreadySelectedOption) ? @android:color/onPrimaryColor : @android:color/onSurfaceColor
        flag 10 (0xbL): sortOption.order ? @android:string/ascending : @android:string/descending
        flag 11 (0xcL): sortOption.order ? @android:string/ascending : @android:string/descending
    flag mapping end*/
    //end
}