<commit_before>package com.rehivetech.beeeon.gui.fragment;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.TextView;

import com.avast.android.dialogs.fragment.ListDialogFragment;
import com.avast.android.dialogs.iface.IListDialogListener;
import com.rehivetech.beeeon.R;
import com.rehivetech.beeeon.controller.Controller;
import com.rehivetech.beeeon.gui.activity.DeviceDetailActivity;
import com.rehivetech.beeeon.gui.activity.ModuleGraphActivity;
import com.rehivetech.beeeon.gui.adapter.DeviceModuleAdapter;
import com.rehivetech.beeeon.gui.dialog.NumberPickerDialogFragment;
import com.rehivetech.beeeon.household.device.Device;
import com.rehivetech.beeeon.household.device.Module;
import com.rehivetech.beeeon.household.device.values.BaseValue;
import com.rehivetech.beeeon.household.device.values.EnumValue;
import com.rehivetech.beeeon.threading.CallbackTask;
import com.rehivetech.beeeon.threading.task.ActorActionTask;

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

/**
 * @author martin on 15.8.2015.
 */
public class DeviceDetailGroupModuleFragment extends BaseApplicationFragment implements IListDialogListener, DeviceModuleAdapter.ItemClickListener {

	private static final String TAG = DeviceDetailGroupModuleFragment.class.getSimpleName();

	private static final String KEY_GROUP_NAME = "group_name";
	private static final String KEY_GATE_ID = "gate_id";
	private static final String KEY_DEVICE_ID = "device_id";

	private static final int REQUEST_SET_ACTUATOR = 7894;

	private String mGateId;
	private String mDeviceId;
	private String mGroupName;

	private Device mDevice;
	private String mModuleId;

	private DeviceDetailActivity mActivity;
	private View mView;
	private DeviceModuleAdapter mModuleAdapter;

	private RecyclerView mRecyclerView;
	private TextView mEmptyListView;

	public static DeviceDetailGroupModuleFragment newInstance(String gateId, String deviceId, String groupName) {
		Bundle args = new Bundle();
		args.putString(KEY_GATE_ID, gateId);
		args.putString(KEY_DEVICE_ID, deviceId);
		args.putString(KEY_GROUP_NAME, groupName);

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

	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
		mActivity = (DeviceDetailActivity) activity;
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mGateId = getArguments().getString(KEY_GATE_ID);
		mDeviceId = getArguments().getString(KEY_DEVICE_ID);
		mGroupName = getArguments().getString(KEY_GROUP_NAME);
		mDevice = Controller.getInstance(mActivity).getDevicesModel().getDevice(mGateId, mDeviceId);
		mModuleId = "-1";
	}

	@Nullable
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		mView = inflater.inflate(R.layout.fragment_device_detail_group_module, container, false);

		mEmptyListView = (TextView) mView.findViewById(R.id.device_detrail_module_list_empty_view);
		initLayout();
		return mView;
	}

	private void initLayout() {

		mRecyclerView = (RecyclerView) mView.findViewById(R.id.device_detail_modules_list);
		mRecyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
		mModuleAdapter = new DeviceModuleAdapter(mActivity, getModulesByGroup(), this);
		mModuleAdapter.setUseFirstItemSpace(true);
		mRecyclerView.setAdapter(mModuleAdapter);

		if (mModuleAdapter.getItemCount() == 0) {
			mRecyclerView.setVisibility(View.GONE);
			mEmptyListView.setVisibility(View.VISIBLE);
		}

	}

	private void updateLayout() {
		mDevice = Controller.getInstance(mActivity).getDevicesModel().getDevice(mGateId, mDeviceId);
		if (mDevice == null)
			return;

		mModuleAdapter.swapModules(mDevice.getVisibleModules());
	}

	@Override
	public void onItemClick(String moduleId) {
		Log.d(TAG, "onItemClick:" + moduleId);<commit_msg>Fix reload list of modules on actuator change<commit_after>package com.rehivetech.beeeon.gui.fragment;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.TextView;

import com.avast.android.dialogs.fragment.ListDialogFragment;
import com.avast.android.dialogs.iface.IListDialogListener;
import com.rehivetech.beeeon.R;
import com.rehivetech.beeeon.controller.Controller;
import com.rehivetech.beeeon.gui.activity.DeviceDetailActivity;
import com.rehivetech.beeeon.gui.activity.ModuleGraphActivity;
import com.rehivetech.beeeon.gui.adapter.DeviceModuleAdapter;
import com.rehivetech.beeeon.gui.dialog.NumberPickerDialogFragment;
import com.rehivetech.beeeon.household.device.Device;
import com.rehivetech.beeeon.household.device.Module;
import com.rehivetech.beeeon.household.device.values.BaseValue;
import com.rehivetech.beeeon.household.device.values.EnumValue;
import com.rehivetech.beeeon.threading.CallbackTask;
import com.rehivetech.beeeon.threading.task.ActorActionTask;

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

/**
 * @author martin on 15.8.2015.
 */
public class DeviceDetailGroupModuleFragment extends BaseApplicationFragment implements IListDialogListener, DeviceModuleAdapter.ItemClickListener {

	private static final String TAG = DeviceDetailGroupModuleFragment.class.getSimpleName();

	private static final String KEY_GROUP_NAME = "group_name";
	private static final String KEY_GATE_ID = "gate_id";
	private static final String KEY_DEVICE_ID = "device_id";

	private static final int REQUEST_SET_ACTUATOR = 7894;

	private String mGateId;
	private String mDeviceId;
	private String mGroupName;

	private Device mDevice;
	private String mModuleId;

	private DeviceDetailActivity mActivity;
	private View mView;
	private DeviceModuleAdapter mModuleAdapter;

	private RecyclerView mRecyclerView;
	private TextView mEmptyListView;

	public static DeviceDetailGroupModuleFragment newInstance(String gateId, String deviceId, String groupName) {
		Bundle args = new Bundle();
		args.putString(KEY_GATE_ID, gateId);
		args.putString(KEY_DEVICE_ID, deviceId);
		args.putString(KEY_GROUP_NAME, groupName);

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

	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
		mActivity = (DeviceDetailActivity) activity;
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mGateId = getArguments().getString(KEY_GATE_ID);
		mDeviceId = getArguments().getString(KEY_DEVICE_ID);
		mGroupName = getArguments().getString(KEY_GROUP_NAME);
		mDevice = Controller.getInstance(mActivity).getDevicesModel().getDevice(mGateId, mDeviceId);
		mModuleId = "-1";
	}

	@Nullable
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		mView = inflater.inflate(R.layout.fragment_device_detail_group_module, container, false);

		mEmptyListView = (TextView) mView.findViewById(R.id.device_detrail_module_list_empty_view);
		initLayout();
		return mView;
	}

	private void initLayout() {

		mRecyclerView = (RecyclerView) mView.findViewById(R.id.device_detail_modules_list);
		mRecyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
		mModuleAdapter = new DeviceModuleAdapter(mActivity, getModulesByGroup(), this);
		mModuleAdapter.setUseFirstItemSpace(true);
		mRecyclerView.setAdapter(mModuleAdapter);

		if (mModuleAdapter.getItemCount() == 0) {
			mRecyclerView.setVisibility(View.GONE);
			mEmptyListView.setVisibility(View.VISIBLE);
		}

	}

	private void updateLayout() {
		mDevice = Controller.getInstance(mActivity).getDevicesModel().getDevice(mGateId, mDeviceId);
		if (mDevice == null)
			return;

		mModuleAdapter.swapModules(getModulesByGroup());
		mModuleAdapter.setUseFirstItemSpace(true);
	}

	@Override
	public void onItemClick(String moduleId) {
		Log.d(TAG, "onItemClick:" + moduleId);
{'fraction_non_alphanumeric': 0.09321936005544645, 'fraction_numerical': 0.0034654037195333254, 'mean_word_length': 6.641659311562224, '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': '22768', 'n_tokens_mistral': 2832, 'n_tokens_neox': 2645, 'n_words': 493}