Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fancy:fb_focusColor dont work on Adapter #87

Closed
pishguy opened this issue Jun 7, 2017 · 5 comments
Closed

fancy:fb_focusColor dont work on Adapter #87

pishguy opened this issue Jun 7, 2017 · 5 comments

Comments

@pishguy
Copy link
Collaborator

pishguy commented Jun 7, 2017

when i use this widget on android recyclerview adapter and setting setOnClickListener for that i dont see color on fancy:fb_focusColor, clicking on that dont work

@medyo
Copy link
Owner

medyo commented Jun 7, 2017

Hi @MahdiPishguy,

Could you share a sample of your code?

@pishguy
Copy link
Collaborator Author

pishguy commented Jun 8, 2017

@medyo yes, please let me to send that for you

@medyo
Copy link
Owner

medyo commented Jun 9, 2017

you can paste it here (not the whole code), just Fancybuttons implementation

@pishguy
Copy link
Collaborator Author

pishguy commented Jun 9, 2017

@medyo ok no problem

My Adapter:

public class MoviesAdapter extends RecyclerView.Adapter<MoviesAdapter.MyViewHolder> {
    private List<Movie> moviesList;
    private Activity    activity;
    private Context     context;
    private Map<String, Boolean> checkBoxStates = new HashMap<>();
    private boolean checkedState;

    public MoviesAdapter(Activity mActivity, List<Movie> moviesList, Context mContext) {
        this.moviesList = moviesList;
        activity = mActivity;
        context = mContext;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.cafe_web_items, parent, false);

        return new MyViewHolder(itemView);
    }

    @Override
    public void onBindViewHolder(final MyViewHolder holder, final int position) {
        holder.postMoreOptions.setOnClickListener(null);

        checkedState = checkBoxStates.containsKey(position + "") ? checkBoxStates.get(position + "") : false;

        if (checkedState) {
            holder.sliderTestPages.openLayer(false);
        } else {
            holder.sliderTestPages.closeLayer(false);
        }

        holder.postMoreOptions.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                changeCheckedContacts(holder, position);
            }
        });

        holder.postVisitCount.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                changeCheckedContacts(holder, position);
            }
        });
    }

    private void changeCheckedContacts(MyViewHolder holder, int position) {
        checkedState = checkBoxStates.containsKey(position + "") ? checkBoxStates.get(position + "") : false;
        checkedState = !checkedState;
        checkBoxStates.put(position + "", checkedState);

        if (checkedState) {
            holder.sliderTestPages.openLayer(true);
        } else {
            holder.sliderTestPages.closeLayer(true);
        }

        notifyDataSetChanged();
    }

    @Override
    public int getItemCount() {
        return moviesList.size();
    }

    public class MyViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.postVoteUp)
        FancyButton postVoteUp;

        @BindView(R.id.postVoteCount)
        TextView postVoteCount;

        @BindView(R.id.postVoteDown)
        FancyButton postVoteDown;

        @BindView(R.id.postVisitCount)
        FancyButton postVisitCount;

        @BindView(R.id.postMoreOptions)
        FancyButton postMoreOptions;

        @BindView(R.id.sliderTestPages)
        SlidingLayer sliderTestPages;

        public MyViewHolder(View view) {
            super(view);

            ButterKnife.bind(this, view);

            postVoteUp.setFontIconSize((int) AndroidUtilities.getAdjustTextSize(activity, context) + 19);
            postVoteCount.setTextSize(AndroidUtilities.getAdjustTextSize(activity, context) * 1.4f);
            postVoteDown.setFontIconSize((int) AndroidUtilities.getAdjustTextSize(activity, context) + 19);

            postMoreOptions.setFontIconSize((int) AndroidUtilities.getAdjustTextSize(activity, context) + 3);

            postVisitCount.setFontIconSize((int) AndroidUtilities.getAdjustTextSize(activity, context) + 3);

        }
    }

}

adapter xml layout:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    xmlns:fancy="http://schemas.android.com/apk/res-auto"
    xmlns:slidingLayer="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="300dp"
    android:layout_marginBottom="10dp"
    android:layout_marginLeft="20dp"
    android:layout_marginRight="20dp"
    card_view:cardBackgroundColor="@color/white"
    card_view:cardCornerRadius="2dp"
    card_view:cardElevation="1dp">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/white">

        <FrameLayout
            android:id="@+id/container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:elevation="2dp">

            <ir.pishguy.cafealachiqpro.Libraries.SlidingLayer.SlidingLayer
                android:id="@+id/sliderTestPages"
                android:layout_width="match_parent"
                android:layout_height="120dp"
                android:layout_below="@+id/contentToolbar"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:layout_marginTop="45dp"
                android:elevation="1dp"
                app:stickTo="top"
                slidingLayer:changeStateOnTap="false">

                <ir.pishguy.cafealachiqpro.Libraries.RoundView.RoundLinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center"
                    android:orientation="vertical"
                    android:paddingLeft="10dp"
                    android:paddingRight="10dp"
                    android:textColor="#ffffff"
                    app:rv_backgroundColor="@color/colorPrimary"
                    app:rv_cornerRadius_BL="5dp"
                    app:rv_cornerRadius_BR="5dp"
                    app:rv_cornerRadius_TL="0dp"
                    app:rv_cornerRadius_TR="0dp">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:orientation="vertical">

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:orientation="horizontal">

                            <LinearLayout
                                android:layout_width="0dp"
                                android:layout_height="match_parent"
                                android:layout_marginRight="10dp"
                                android:layout_weight="1"
                                android:orientation="vertical">

                                <TextView
                                    android:id="@+id/textChannelName"
                                    android:layout_width="match_parent"
                                    android:layout_height="0dp"
                                    android:layout_weight="1"
                                    android:gravity="right|center"
                                    android:text="SALAM"
                                    android:textColor="@color/white"/>

                                <TextView
                                    android:id="@+id/textView9"
                                    android:layout_width="match_parent"
                                    android:layout_height="1dp"
                                    android:background="@color/colorPrimaryDark"/>

                                <TextView
                                    android:id="@+id/textChannelDescription"
                                    android:layout_width="match_parent"
                                    android:layout_height="0dp"
                                    android:layout_weight="1"
                                    android:gravity="right|center"
                                    android:text="SALAM"
                                    android:textColor="@color/white"/>
                            </LinearLayout>

                            <TextView
                                android:layout_width="1dp"
                                android:layout_height="match_parent"
                                android:layout_marginBottom="10dp"
                                android:layout_marginRight="10dp"
                                android:layout_marginTop="10dp"
                                android:background="@color/colorPrimaryDark"/>

                            <RelativeLayout
                                xmlns:android="http://schemas.android.com/apk/res/android"
                                xmlns:fancy="http://schemas.android.com/apk/res-auto"
                                android:layout_width="50dp"
                                android:layout_height="match_parent"
                                android:padding="2dp"
                                android:gravity="center">

                                <mehdi.sakout.fancybuttons.FancyButton
                                    android:id="@+id/postVoteUp"
                                    android:layout_width="40dp"
                                    android:layout_height="40dp"
                                    android:gravity="center"
                                    android:textColor="@color/white"
                                    fancy:fb_defaultColor="@android:color/transparent"
                                    fancy:fb_focusColor="@color/colorPrimary"
                                    fancy:fb_fontIconResource="@string/icon_voteUp"
                                    fancy:fb_radius="30dp"
                                    fancy:fb_text=""
                                    fancy:fb_textColor="@color/white"/>

                                <TextView
                                    android:id="@+id/postVoteCount"
                                    android:layout_width="40dp"
                                    android:layout_height="wrap_content"
                                    android:layout_below="@+id/postVoteUp"
                                    android:gravity="center"
                                    android:text="5"
                                    android:textColor="@color/white"/>

                                <mehdi.sakout.fancybuttons.FancyButton
                                    android:id="@+id/postVoteDown"
                                    android:layout_width="40dp"
                                    android:layout_height="40dp"
                                    android:layout_below="@+id/postVoteCount"
                                    android:gravity="center"
                                    android:textColor="@color/white"
                                    fancy:fb_defaultColor="@android:color/transparent"
                                    fancy:fb_focusColor="@color/colorPrimary"
                                    fancy:fb_fontIconResource="@string/icon_voteDown"
                                    fancy:fb_radius="30dp"
                                    fancy:fb_text=""
                                    fancy:fb_textColor="@color/white"/>
                            </RelativeLayout>

                        </LinearLayout>

                    </LinearLayout>
                </ir.pishguy.cafealachiqpro.Libraries.RoundView.RoundLinearLayout>
            </ir.pishguy.cafealachiqpro.Libraries.SlidingLayer.SlidingLayer>

            <android.support.v7.widget.Toolbar
                android:id="@+id/contentToolbar"
                android:layout_width="match_parent"
                android:layout_height="45dp"
                android:background="@color/white"
                android:elevation="2dp"
                android:gravity="center_vertical">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center_vertical"
                    android:orientation="horizontal">

                    <mehdi.sakout.fancybuttons.FancyButton
                        android:id="@+id/postVisitCount"
                        android:layout_width="50dp"
                        android:layout_height="50dp"
                        fancy:fb_defaultColor="@android:color/transparent"
                        fancy:fb_focusColor="@color/colorPrimary"
                        fancy:fb_fontIconResource="@string/icon_visit_post"
                        fancy:fb_radius="30dp"
                        fancy:fb_text=""
                        fancy:fb_textColor="@color/gray"/>

                    <android.support.v4.widget.Space
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"/>

                    <mehdi.sakout.fancybuttons.FancyButton
                        android:id="@+id/postMoreOptions"
                        android:layout_width="50dp"
                        android:layout_height="50dp"
                        fancy:fb_defaultColor="@android:color/transparent"
                        fancy:fb_focusColor="@color/colorPrimary"
                        fancy:fb_fontIconResource="@string/icon_horizontal_menu"
                        fancy:fb_radius="30dp"
                        fancy:fb_text=""
                        fancy:fb_textColor="@color/gray"/>
                </LinearLayout>
            </android.support.v7.widget.Toolbar>

        </FrameLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:layout_alignParentBottom="true"
            android:layout_marginBottom="-5dp"
            android:layout_marginLeft="50dp"
            android:layout_marginRight="50dp"
            android:background="@drawable/sheet_shadow"
            android:elevation="2dp"
            android:orientation="vertical"
            android:visibility="gone">

        </LinearLayout>

    </RelativeLayout>


    <TextView
        android:id="@+id/title"
        android:layout_width="match_parent"
        android:layout_height="@dimen/default_textview_height"
        android:visibility="gone"/>
</android.support.v7.widget.CardView>

@pishguy
Copy link
Collaborator Author

pishguy commented Jun 9, 2017

@medyo this code resolve my problem

   new Handler().postDelayed(new Runnable() {
       @Override
       public void run() {
           //
       }
   }, 300);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants