Code Monkey home page Code Monkey logo

Comments (4)

cachapa avatar cachapa commented on July 21, 2024

You need to give a bit more details, otherwise there's little chance to help you.
Can you share some code, and maybe a video of the problem happening?

from expandablelayout.

Tjart avatar Tjart commented on July 21, 2024

Here is my code

`

RecyclerView recyclerView;
private List<NewsListItem> newsListItems;
private Context context;

static ViewHolder selectedHolder = null;

public NewsListAdapter(List<NewsListItem> listItems, Context context) {
    this.newsListItems = listItems;
    this.context = context;
}

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View v = LayoutInflater.from(parent.getContext())
            .inflate(R.layout.news_list_item, parent, false);
    return new ViewHolder(v);
}

@Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
    final NewsListItem newsListItem = newsListItems.get(position);

    holder.textViewHead.setText(newsListItem.getHead());
    Picasso.with(context).load(newsListItem.getImageUrl()).into(holder.imageView);
    holder.textViewText.setText(newsListItem.getText());

    holder.textViewHead.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (selectedHolder == null){
                holder.textViewHead.setSelected(true);
                holder.expandableLayout.expand();
                selectedHolder = holder;
            }
            else if (holder == selectedHolder){
                holder.textViewHead.setSelected(false);
                holder.expandableLayout.collapse();
                selectedHolder = null;
            }
            else{
                selectedHolder.textViewHead.setSelected(false);
                selectedHolder.expandableLayout.collapse();
                holder.textViewHead.setSelected(true);
                holder.expandableLayout.expand();
                selectedHolder = holder;
            }
        }
    });
    holder.expandableLayout.setInterpolator(new OvershootInterpolator());
    holder.expandableLayout.setOnExpansionUpdateListener(new ExpandableLayout.OnExpansionUpdateListener() {
        @Override
        public void onExpansionUpdate(float expansionFraction, int state) {
            Log.d("ExpandableLayout", "State: " + state);
        }
    });
    runEnterAnimation(holder.itemView, position);
}

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

public class ViewHolder extends RecyclerView.ViewHolder{

    public ExpandableLayout expandableLayout;
    public TextView textViewHead;
    public ImageView imageView;
    public TextView textViewText;

    public ViewHolder(View itemView) {
        super(itemView);

        expandableLayout = (ExpandableLayout) itemView.findViewById(R.id.news_list_item_ExpendableLayout);
        textViewHead = (TextView) itemView.findViewById(R.id.news_textView_head);
        imageView = (ImageView) itemView.findViewById(R.id.news_imageView);
        textViewText = (TextView) itemView.findViewById(R.id.news_textView_text);
    }
}
private void runEnterAnimation(View view, int position){
    view.setTranslationX(context.getResources().getDisplayMetrics().widthPixels);
    view.animate().translationX(0).setInterpolator(new DecelerateInterpolator(3.f)).
            setDuration(700).setStartDelay((MainActivity.recyclerAnimDelay)+position*700/5).start();
    if (position == (newsListItems.size()-1)){
        MainActivity.recyclerAnimDelay = 0;
    }
}

`

And this link leads to the video

https://www.dropbox.com/s/bl0ee4s0u1o7jm9/2017_10_13_11_46_13.mp4?dl=0

from expandablelayout.

cachapa avatar cachapa commented on July 21, 2024

The problem seems to be that you're changing the item layout during the expansion animation.
From just a cursory look at your code it seems the problem is with the runEnterAnimation method. Try removing that method and see if it fixes the issue.

In any case this doesn't seem to be an issue with ExpandableLayout so I'm closing this.

from expandablelayout.

the-kool-sk avatar the-kool-sk commented on July 21, 2024

Add little delay it will fix the issue

from expandablelayout.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.