Я получаю ответ с filterMatchIndicator == true или false из ответа.
Если это правда, мне нужно отобразить все виды. Если это неверно, мне нужно скрыть вид.
Но проблема в том, что вид показывает пространство. При выключении скрываю вид в адаптере. [Но космос приближается]. При включении я отображаю все.
public class RetailerListLastAdapter extends RecyclerView.Adapter<RetailerListLastAdapter.FilterViewHolder> {
public Context context;
private List<Retailer> data;
private static final String TAG = RetailerListLastAdapter.class.getSimpleName();
private boolean isChecked;
private SharedPreferences mSharedPreferences;
public RetailerListLastAdapter(List<Retailer> data, Context context) {
this.data = data;
this.context = context;
}
public RetailerListLastAdapter(List<Retailer> data, Context context,boolean isChecked) {
this.data = data;
this.context = context;
this.isChecked= isChecked;
}
@Override
public RetailerListLastAdapter.FilterViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View rootView = LayoutInflater.from(parent.getContext()).inflate(R.layout.route_plan_se_list_row, parent, false);
return new RetailerListLastAdapter.FilterViewHolder(rootView);
}
@Override
public void onBindViewHolder(RetailerListLastAdapter.FilterViewHolder holder, int position) {
Retailer retailerList = data.get(position);
Boolean filterMatchIndicator = retailerList.getFilterMatchIndicator();
mSharedPreferences = context.getSharedPreferences(AppConstants.MyPREFERENCES, MODE_PRIVATE);
// Boolean userFilterPassIndicator = retailerList.getUserFilterPassInd();
// Log.e("userFilterPassIndicator","userFilterPassIndicator"+userFilterPassIndicator);
if(AppUtils.getToggle(mSharedPreferences).equalsIgnoreCase("1") || filterMatchIndicator==true){
Log.e("going here one","going here one");
Log.e("one togglebutton","togglebutton"+AppUtils.getToggle(mSharedPreferences));
holder.mark.setVisibility(View.VISIBLE);
holder.layout_holders.setVisibility(View.VISIBLE);
}
else if(AppUtils.getToggle(mSharedPreferences).equalsIgnoreCase("0") || filterMatchIndicator==false)
{
Log.e("going here zero","going here zero");
Log.e("zero togglebutton","togglebutton"+AppUtils.getToggle(mSharedPreferences));
holder.mark.setVisibility(View.INVISIBLE);
holder.layout_holders.setVisibility(View.GONE);
}
/*if (!filterMatchIndicator) {
holder.mark.setVisibility(View.INVISIBLE);
}
else{
holder.mark.setVisibility(View.VISIBLE);
}*/
}
@Override
public int getItemCount() {
return data.size();
}
public class FilterViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public TextView name, number;
public CircleImageView avatar;
public ImageView sellIn, sellOut, growth,mark;
public LinearLayout lyout_color_mark;
public LinearLayout layout_holders; //entire layout holder
public FilterViewHolder(View v) {
super(v);
avatar = v.findViewById(R.id.recycle_profile);
name = v.findViewById(R.id.recycle_txt_acc_name);
number = v.findViewById(R.id.recycle_txt_acc_num);
sellIn = v.findViewById(R.id.recycle_sellIn);
sellOut = v.findViewById(R.id.recycle_sellout);
growth = v.findViewById(R.id.recyle_growth);
mark = v.findViewById(R.id.recycle_color_mark);
lyout_color_mark = v.findViewById(R.id.lyout_color_mark);
layout_holders = v.findViewById(R.id.layout_holders);
avatar.setOnClickListener(this);
name.setOnClickListener(this);
number.setOnClickListener(this);
sellIn.setOnClickListener(this);
sellOut.setOnClickListener(this);
growth.setOnClickListener(this);
mark.setOnClickListener(this);
lyout_color_mark.setOnClickListener(this);
}
В основном фрагменте:
private void BindDataToView(List<Retailer> list,String filteredRetailersCount) {
if (list.size() == 0) {
Toast.makeText(mContext, R.string.no_retailer_found, Toast.LENGTH_SHORT).show();
view.findViewById(R.id.no_retailer_found).setVisibility(View.VISIBLE);
view.findViewById(R.id.reatiler_found).setVisibility(View.GONE);
} else {
view.findViewById(R.id.no_retailer_found).setVisibility(View.GONE);
view.findViewById(R.id.reatiler_found).setVisibility(View.VISIBLE);
TextView count = view.findViewById(R.id.dafatar_filter_txtvw);
count.setText(String.valueOf(list.size()));
}
mListData.clear();
mListData.addAll(list);
mMenuRetailerFilterAdapter.notifyDataSetChanged();
}
toggleButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
isChecked = ((ToggleButton) view).isChecked();
if (isChecked) {
AppUtils.saveToggle(mSharedPreferences,"1");
APIInitialize();
} else {
APIInitialize();
AppUtils.saveToggle(mSharedPreferences,"0");
// Disable vibrate
}
}
});