<commit_before>package com.chaincloud.chaincloudv.fragment;

import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;

import com.chaincloud.chaincloudv.R;
import com.chaincloud.chaincloudv.api.Api;
import com.chaincloud.chaincloudv.api.result.BooleanResult;
import com.chaincloud.chaincloudv.api.result.TxRequest;
import com.chaincloud.chaincloudv.api.result.TxStatus;
import com.chaincloud.chaincloudv.api.service.ChainCloudHotSendService;
import com.chaincloud.chaincloudv.dao.ChannelDao;
import com.chaincloud.chaincloudv.dao.ORMLiteDBHelper;
import com.chaincloud.chaincloudv.event.UpdateChannelState;
import com.chaincloud.chaincloudv.model.Channel;
import com.chaincloud.chaincloudv.service.WorkService;
import com.chaincloud.chaincloudv.service.WorkService_;
import com.chaincloud.chaincloudv.util.DateTimeUtil;
import com.chaincloud.chaincloudv.util.crypto.BitcoinUtils;
import com.chaincloud.chaincloudv.util.crypto.ECKey;
import com.google.gson.Gson;
import com.j256.ormlite.android.apptools.OpenHelperManager;
import com.j256.ormlite.dao.Dao;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Background;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.UiThread;
import org.androidannotations.annotations.ViewById;

import java.sql.SQLException;
import java.util.Date;
import java.util.UUID;

import de.greenrobot.event.EventBus;
import retrofit.RetrofitError;

/**
 * Created by zhumingu on 16/6/20.
 */
@EFragment(R.layout.fragment_message)
public class MessageFragment extends Fragment implements WorkService.MsgListener {

    private final static int MAX_LOG_LINE = 100;

    private WorkService.WorkBinder binder;

    @ViewById
    TextView tvChannelId, tvLog;

    @ViewById
    ScrollView svLog;


    @AfterViews
    void init(){
        initChannelId();
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);

        EventBus.getDefault().register(this);
    }

    @Override
    public void onDetach() {
        super.onDetach();

        EventBus.getDefault().unregister(this);
    }

    @Click
    void btnBind(){
        if(binder == null) {
            getActivity().bindService(new Intent(getActivity(), WorkService_.class),
                    conn, Service.BIND_AUTO_CREATE);
        }

        showMsg("绑定服务");
    }

    @Click
    void btnUnbind(){
        if(binder != null) {
            binder.unBinder();

            getActivity().unbindService(conn);

            binder = null;
        }

        showMsg("解绑服务");
    }

    @Click
    void btnWorkStart(){
        if (binder != null) {
            binder.startLoop();

            showMsg("开始loop");
        }else {
            showMsg("请先绑定服务");
        }
    }

    @Click
    void btnWorkStop(){
        if (binder != null) {
            binder.stopLoop();
        }

        showMsg("停止Loop");
    }

    @Click
    void btnWorkTest(){<commit_msg>show confirm when close loop<commit_after>package com.chaincloud.chaincloudv.fragment;

import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;

import com.chaincloud.chaincloudv.R;
import com.chaincloud.chaincloudv.api.Api;
import com.chaincloud.chaincloudv.api.result.BooleanResult;
import com.chaincloud.chaincloudv.api.result.TxRequest;
import com.chaincloud.chaincloudv.api.result.TxStatus;
import com.chaincloud.chaincloudv.api.service.ChainCloudHotSendService;
import com.chaincloud.chaincloudv.dao.ChannelDao;
import com.chaincloud.chaincloudv.dao.ORMLiteDBHelper;
import com.chaincloud.chaincloudv.event.UpdateChannelState;
import com.chaincloud.chaincloudv.model.Channel;
import com.chaincloud.chaincloudv.service.WorkService;
import com.chaincloud.chaincloudv.service.WorkService_;
import com.chaincloud.chaincloudv.ui.base.dialog.DialogAlert_;
import com.chaincloud.chaincloudv.util.DateTimeUtil;
import com.chaincloud.chaincloudv.util.crypto.BitcoinUtils;
import com.chaincloud.chaincloudv.util.crypto.ECKey;
import com.google.gson.Gson;
import com.j256.ormlite.android.apptools.OpenHelperManager;
import com.j256.ormlite.dao.Dao;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Background;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.UiThread;
import org.androidannotations.annotations.ViewById;

import java.sql.SQLException;
import java.util.Date;
import java.util.UUID;

import de.greenrobot.event.EventBus;
import retrofit.RetrofitError;

/**
 * Created by zhumingu on 16/6/20.
 */
@EFragment(R.layout.fragment_message)
public class MessageFragment extends Fragment implements WorkService.MsgListener {

    private final static int MAX_LOG_LINE = 100;

    private WorkService.WorkBinder binder;

    @ViewById
    TextView tvChannelId, tvLog;

    @ViewById
    ScrollView svLog;


    @AfterViews
    void init(){
        initChannelId();
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);

        EventBus.getDefault().register(this);
    }

    @Override
    public void onDetach() {
        super.onDetach();

        EventBus.getDefault().unregister(this);
    }

    @Click
    void btnBind(){
        if(binder == null) {
            getActivity().bindService(new Intent(getActivity(), WorkService_.class),
                    conn, Service.BIND_AUTO_CREATE);
        }

        showMsg("绑定服务");
    }

    @Click
    void btnUnbind(){
        if(binder != null) {
            binder.unBinder();

            getActivity().unbindService(conn);

            binder = null;
        }

        showMsg("解绑服务");
    }

    @Click
    void btnWorkStart(){
        if (binder != null) {
            binder.startLoop();

            showMsg("开始loop");
        }else {
            showMsg("请先绑定服务");
        }
    }

    @Click
    void btnWorkStop(){
        DialogAlert_.builder()
                .msg("确定关闭Loop吗？")
                .build()
                .setRunnable(new Runnable() {
                    @Override
                    public void run() {
                        if (binder != null) {
                            binder.stopLoop();
                        }

                        showMsg("停止Loop");
                    }
                })
                .show(getFragmentManager());
    }

    @Click
    void btnWorkTest(){
{'fraction_non_alphanumeric': 0.10409916889702775, 'fraction_numerical': 0.004225947316523454, 'mean_word_length': 3.0804597701149423, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5047481', 'n_tokens_mistral': 2136, 'n_tokens_neox': 2077, 'n_words': 355}