<commit_before>package com.dev.bins.shop.fragment.Cart;


import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.helper.ItemTouchHelper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;

import com.dev.bins.shop.R;
import com.dev.bins.shop.bean.Cart;
import com.dev.bins.shop.bean.GoodsItem;
import com.dev.bins.shop.fragment.BaseFragment;
import com.dev.bins.shop.widget.MyToolbar;

import org.litepal.crud.DataSupport;

import java.util.ArrayList;
import java.util.List;


import butterknife.BindView;
import rx.Observable;

import static android.R.attr.data;

/**
 * A simple {@link Fragment} subclass.
 */
public class CartFragment extends BaseFragment {
    @BindView(R.id.cart_toolbar)
    MyToolbar toolbar;

    @BindView(R.id.cart_recycler)
    RecyclerView mCartRecyclerView;

    @BindView(R.id.btn_calc)
    Button btnCalc;
    @BindView(R.id.tv_total_price)
    TextView mTvTotalPrice;
    @BindView(R.id.cb)
    CheckBox mCb;
    double mTotalPrice = 0;
    CartAdapter mCartAdapter;
    private List<GoodsItem> mCards = new ArrayList<>();
    private ItemTouchHelper mHelper;

    public CartFragment() {
        // Required empty public constructor
    }

    public static CartFragment newInstance() {

        Bundle args = new Bundle();

        CartFragment fragment = new CartFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_cart;
    }


    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        mCartAdapter = new CartAdapter(mCards, this);
        mCartRecyclerView.setLayoutManager(new LinearLayoutManager(view.getContext(), LinearLayoutManager.VERTICAL, false));
        mCartRecyclerView.setAdapter(mCartAdapter);
        mHelper = new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(0,ItemTouchHelper.LEFT) {
            @Override
            public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
                return false;
            }

            @Override
            public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
                int position = viewHolder.getAdapterPosition();
                mCards.remove(position);
                mCartAdapter.notifyItemRemoved(position);
                calcPrice();
            }
        });
        mHelper.attachToRecyclerView(mCartRecyclerView);
        mCb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    checkAll();
                    calcPrice();
                } else {
                    for (GoodsItem mCard : mCards) {
                        mCard.setChecked(false);
                        mCard.save();
                    }
                }
                mCartAdapter.notifyDataSetChanged();
            }
        });
        getData();
    }
<commit_msg>fix swip remove shop didn't remove from db<commit_after>package com.dev.bins.shop.fragment.Cart;


import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.helper.ItemTouchHelper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;

import com.dev.bins.shop.R;
import com.dev.bins.shop.bean.Cart;
import com.dev.bins.shop.bean.GoodsItem;
import com.dev.bins.shop.fragment.BaseFragment;
import com.dev.bins.shop.widget.MyToolbar;

import org.litepal.crud.DataSupport;

import java.util.ArrayList;
import java.util.List;


import butterknife.BindView;
import rx.Observable;

import static android.R.attr.data;

/**
 * A simple {@link Fragment} subclass.
 */
public class CartFragment extends BaseFragment {
    @BindView(R.id.cart_toolbar)
    MyToolbar toolbar;

    @BindView(R.id.cart_recycler)
    RecyclerView mCartRecyclerView;

    @BindView(R.id.btn_calc)
    Button btnCalc;
    @BindView(R.id.tv_total_price)
    TextView mTvTotalPrice;
    @BindView(R.id.cb)
    CheckBox mCb;
    double mTotalPrice = 0;
    CartAdapter mCartAdapter;
    private List<GoodsItem> mCards = new ArrayList<>();
    private ItemTouchHelper mHelper;

    public CartFragment() {
        // Required empty public constructor
    }

    public static CartFragment newInstance() {

        Bundle args = new Bundle();

        CartFragment fragment = new CartFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_cart;
    }


    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        mCartAdapter = new CartAdapter(mCards, this);
        mCartRecyclerView.setLayoutManager(new LinearLayoutManager(view.getContext(), LinearLayoutManager.VERTICAL, false));
        mCartRecyclerView.setAdapter(mCartAdapter);
        mHelper = new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT) {
            @Override
            public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
                return false;
            }

            @Override
            public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
                int position = viewHolder.getAdapterPosition();
                mCards.get(position).delete();
                mCards.remove(position);
                mCartAdapter.notifyItemRemoved(position);
                calcPrice();
            }
        });
        mHelper.attachToRecyclerView(mCartRecyclerView);
        mCb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    checkAll();
                    calcPrice();
                } else {
                    for (GoodsItem mCard : mCards) {
                        mCard.setChecked(false);
                        mCard.save();
                    }
                }
                mCartAdapter.notifyDataSetChanged();
            }
        });
        getData();
    }

{'fraction_non_alphanumeric': 0.09066962428947734, 'fraction_numerical': 0.001663662830999584, 'mean_word_length': 2.665650406504065, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5396359', 'n_tokens_mistral': 2074, 'n_tokens_neox': 1959, 'n_words': 389}