package kz.arta.synergy.workflow.mobile.android.registry;

import android.app.ActionBar;
import android.app.Activity;
import android.os.Bundle;

import kz.arta.synergy.workflow.mobile.android.R;
import kz.arta.synergy.workflow.mobile.android.common.ActivityConst;
import kz.arta.synergy.workflow.mobile.android.common.components.SearchEditText;
import kz.arta.synergy.workflow.mobile.android.common.models.Person;

/**
 * Created by neox on 18.01.17.
 * Поиск записей реестра
 */
public class RegistrySearchActivity extends Activity {

    private String registryID;
    private Person person;

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.registry_search_activity);

        ActionBar actionBar = getActionBar();
        if (actionBar != null) {
            actionBar.hide();
        }

        registryID = getIntent().getStringExtra(ActivityConst.REGISTRY);
        person = (Person) getIntent().getSerializableExtra(ActivityConst.PERSON);

        Bundle bundle = new Bundle();
        bundle.putSerializable(ActivityConst.PERSON, person);
        bundle.putString(ActivityConst.REGISTRY, registryID);

        final FragmentRegistryList fragmentRegistryList = new FragmentRegistryList();
        fragmentRegistryList.setArguments(bundle);

        getFragmentManager().beginTransaction().add(R.id.fragment_search_container, fragmentRegistryList).commit();

        SearchEditText searchEditText = (SearchEditText)findViewById(R.id.registry_search_activity_edit_text);
        searchEditText.setListener(new SearchEditText.SearchTextListener() {
            @Override
            public void onTextChanged(String s) {
                fragmentRegistryList.getData(s);
            }
        });
    }
}
