diff --git a/app/src/main/java/com/sunfusheng/StickyHeaderListView/adapter/BaseListAdapter.java b/app/src/main/java/com/sunfusheng/StickyHeaderListView/adapter/BaseListAdapter.java index 12de1f9..ac6c4b8 100644 --- a/app/src/main/java/com/sunfusheng/StickyHeaderListView/adapter/BaseListAdapter.java +++ b/app/src/main/java/com/sunfusheng/StickyHeaderListView/adapter/BaseListAdapter.java @@ -25,8 +25,6 @@ public BaseListAdapter(Context context) { public BaseListAdapter(Context context, List list) { this(context); mList = list; - mInflater = LayoutInflater.from(context); - mImageManager = new ImageManager(context); } @Override @@ -42,11 +40,9 @@ public List getData() { return mList; } - public void addALL(List lists){ - if(lists==null||lists.size()==0){ - return ; - } - mList.addAll(lists); + public void addALL(List list){ + if(list==null||list.size()==0) return; + mList.addAll(list); } public void add(E item){ mList.add(item); diff --git a/app/src/main/java/com/sunfusheng/StickyHeaderListView/adapter/FilterLeftAdapter.java b/app/src/main/java/com/sunfusheng/StickyHeaderListView/adapter/FilterLeftAdapter.java index 79ed43f..c4f5027 100644 --- a/app/src/main/java/com/sunfusheng/StickyHeaderListView/adapter/FilterLeftAdapter.java +++ b/app/src/main/java/com/sunfusheng/StickyHeaderListView/adapter/FilterLeftAdapter.java @@ -1,7 +1,6 @@ package com.sunfusheng.StickyHeaderListView.adapter; import android.content.Context; -import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; @@ -20,8 +19,6 @@ */ public class FilterLeftAdapter extends BaseListAdapter { - private FilterTwoEntity selectedEntity; - public FilterLeftAdapter(Context context) { super(context); } @@ -31,9 +28,8 @@ public FilterLeftAdapter(Context context, List list) { } public void setSelectedEntity(FilterTwoEntity filterEntity) { - this.selectedEntity = filterEntity; for (FilterTwoEntity entity : getData()) { - entity.setSelected(entity.getType().equals(selectedEntity.getType())); + entity.setSelected(filterEntity != null && entity.getType().equals(filterEntity.getType())); } notifyDataSetChanged(); } @@ -42,7 +38,7 @@ public void setSelectedEntity(FilterTwoEntity filterEntity) { public View getView(int position, View convertView, ViewGroup parent) { final ViewHolder holder; if (convertView == null) { - convertView = LayoutInflater.from(mContext).inflate(R.layout.item_filter_left, null); + convertView = mInflater.inflate(R.layout.item_filter_left, null); holder = new ViewHolder(convertView); convertView.setTag(holder); } else { diff --git a/app/src/main/java/com/sunfusheng/StickyHeaderListView/adapter/FilterOneAdapter.java b/app/src/main/java/com/sunfusheng/StickyHeaderListView/adapter/FilterOneAdapter.java index 68473b3..54b631c 100644 --- a/app/src/main/java/com/sunfusheng/StickyHeaderListView/adapter/FilterOneAdapter.java +++ b/app/src/main/java/com/sunfusheng/StickyHeaderListView/adapter/FilterOneAdapter.java @@ -1,7 +1,6 @@ package com.sunfusheng.StickyHeaderListView.adapter; import android.content.Context; -import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; @@ -20,8 +19,6 @@ */ public class FilterOneAdapter extends BaseListAdapter { - private FilterEntity selectedEntity; - public FilterOneAdapter(Context context) { super(context); } @@ -31,9 +28,8 @@ public FilterOneAdapter(Context context, List list) { } public void setSelectedEntity(FilterEntity filterEntity) { - this.selectedEntity = filterEntity; for (FilterEntity entity : getData()) { - entity.setSelected(entity.getKey().equals(selectedEntity.getKey())); + entity.setSelected(filterEntity != null && entity.getKey().equals(filterEntity.getKey())); } notifyDataSetChanged(); } @@ -42,7 +38,7 @@ public void setSelectedEntity(FilterEntity filterEntity) { public View getView(int position, View convertView, ViewGroup parent) { final ViewHolder holder; if (convertView == null) { - convertView = LayoutInflater.from(mContext).inflate(R.layout.item_filter_one, null); + convertView = mInflater.inflate(R.layout.item_filter_one, null); holder = new ViewHolder(convertView); convertView.setTag(holder); } else { diff --git a/app/src/main/java/com/sunfusheng/StickyHeaderListView/adapter/FilterRightAdapter.java b/app/src/main/java/com/sunfusheng/StickyHeaderListView/adapter/FilterRightAdapter.java index 292c636..197fa14 100644 --- a/app/src/main/java/com/sunfusheng/StickyHeaderListView/adapter/FilterRightAdapter.java +++ b/app/src/main/java/com/sunfusheng/StickyHeaderListView/adapter/FilterRightAdapter.java @@ -1,7 +1,6 @@ package com.sunfusheng.StickyHeaderListView.adapter; import android.content.Context; -import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; @@ -35,7 +34,7 @@ public void setSelectedEntity(FilterEntity filterEntity) { public View getView(int position, View convertView, ViewGroup parent) { final ViewHolder holder; if (convertView == null) { - convertView = LayoutInflater.from(mContext).inflate(R.layout.item_filter_one, null); + convertView = mInflater.inflate(R.layout.item_filter_one, null); holder = new ViewHolder(convertView); convertView.setTag(holder); } else { diff --git a/app/src/main/java/com/sunfusheng/StickyHeaderListView/adapter/HeaderChannelAdapter.java b/app/src/main/java/com/sunfusheng/StickyHeaderListView/adapter/HeaderChannelAdapter.java index 399b1a1..15cd560 100644 --- a/app/src/main/java/com/sunfusheng/StickyHeaderListView/adapter/HeaderChannelAdapter.java +++ b/app/src/main/java/com/sunfusheng/StickyHeaderListView/adapter/HeaderChannelAdapter.java @@ -2,7 +2,6 @@ import android.content.Context; import android.text.TextUtils; -import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; @@ -29,7 +28,7 @@ public HeaderChannelAdapter(Context context, List list) { public View getView(int position, View convertView, ViewGroup parent) { final ViewHolder holder; if (convertView == null) { - convertView = LayoutInflater.from(mContext).inflate(R.layout.item_channel, null); + convertView = mInflater.inflate(R.layout.item_channel, null); holder = new ViewHolder(convertView); convertView.setTag(holder); } else { diff --git a/app/src/main/java/com/sunfusheng/StickyHeaderListView/adapter/HeaderOperationAdapter.java b/app/src/main/java/com/sunfusheng/StickyHeaderListView/adapter/HeaderOperationAdapter.java index c9034fe..20f041c 100644 --- a/app/src/main/java/com/sunfusheng/StickyHeaderListView/adapter/HeaderOperationAdapter.java +++ b/app/src/main/java/com/sunfusheng/StickyHeaderListView/adapter/HeaderOperationAdapter.java @@ -2,7 +2,6 @@ import android.content.Context; import android.text.TextUtils; -import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; @@ -33,7 +32,7 @@ public HeaderOperationAdapter(Context context, List list) { public View getView(int position, View convertView, ViewGroup parent) { final ViewHolder holder; if (convertView == null) { - convertView = LayoutInflater.from(mContext).inflate(R.layout.item_operation, null); + convertView = mInflater.inflate(R.layout.item_operation, null); holder = new ViewHolder(convertView); convertView.setTag(holder); } else {