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

fix: Display abnormal about SwipeMenuAdapter #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions library/src/com/baoyz/swipemenulistview/SwipeMenuAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.database.DataSetObserver;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListAdapter;
Expand Down Expand Up @@ -45,29 +44,41 @@ public Object getItem(int position) {
public long getItemId(int position) {
return mAdapter.getItemId(position);
}

/**
*
* @author aem3372
* @date 2015-5-14
*
* fix: Display abnormal, When mAdapter return View different from
* convertView and convertView is not null
*/
@Override
public View getView(int position, View convertView, ViewGroup parent) {
SwipeMenuLayout layout = null;
if (convertView == null) {
View contentView = mAdapter.getView(position, convertView, parent);
View view = null;
if (convertView != null) {
layout = (SwipeMenuLayout) convertView;
layout.closeMenu();
layout.setPosition(position);
view = mAdapter.getView(position, layout.getContentView(),
parent);
}

if (convertView == null || view != layout.getContentView()) {
if(view == null) {
view = mAdapter.getView(position, convertView, parent);
}
SwipeMenu menu = new SwipeMenu(mContext);
menu.setViewType(mAdapter.getItemViewType(position));
createMenu(menu);
SwipeMenuView menuView = new SwipeMenuView(menu,
(SwipeMenuListView) parent);
menuView.setOnSwipeItemClickListener(this);
SwipeMenuListView listView = (SwipeMenuListView) parent;
layout = new SwipeMenuLayout(contentView, menuView,
layout = new SwipeMenuLayout(view, menuView,
listView.getCloseInterpolator(),
listView.getOpenInterpolator());
layout.setPosition(position);
} else {
layout = (SwipeMenuLayout) convertView;
layout.closeMenu();
layout.setPosition(position);
View view = mAdapter.getView(position, layout.getContentView(),
parent);
}
return layout;
}
Expand Down