Commit ca06f447d706f2c68a86ca52ec14e4004da178a8

Authored by wugian
1 parent 256882e3

contorl swith by project

... ... @@ -148,11 +148,17 @@
148 148
149 149 <activity android:name=".activity.QrCodeShowActivity">
150 150 </activity>
  151 + <activity android:name=".activity.ConfigWifiActivity">
  152 + </activity>
151 153
152 154 <activity
153 155 android:name="com.xgimi.gimicinema.activity.SwitchControlActivity"
154 156 android:theme="@style/AppTheme.NoActionBar">
  157 + <!-- <intent-filter>
  158 + <action android:name="android.intent.action.MAIN"/>
155 159
  160 + <category android:name="android.intent.category.LAUNCHER"/>
  161 + </intent-filter>-->
156 162 </activity>
157 163 </application>
158 164
... ...
... ... @@ -17,7 +17,7 @@ public class Constant {
17 17 public static boolean isAdsOn = false;
18 18
19 19 public static boolean gimiAuth = true;
20   - public static int count = 2;
  20 + public static int count = 0;
21 21
22 22
23 23 public static String MOVIE_MESSAGE_NAME_NEW = "/mm.qnt";
... ...
... ... @@ -77,6 +77,12 @@ public class Utils {
77 77 return sharedPreferences.getLong(name, 0);
78 78 }
79 79
  80 + public static long getLong(Context context, String name) {
  81 + SharedPreferences sharedPreferences = context.getSharedPreferences(
  82 + Constant.XML_NAME, Context.MODE_PRIVATE);
  83 + return sharedPreferences.getLong(name, 0);
  84 + }
  85 +
80 86 public static void saveString(Context context, String name, String value) {
81 87 SharedPreferences sharedPreferences = context.getSharedPreferences(
82 88 Constant.XML_NAME, Context.MODE_PRIVATE);
... ...
... ... @@ -516,7 +516,8 @@ public class MainActivity extends Activity implements EventListener<String> {
516 516 testData();
517 517 View popupView = getLayoutInflater().inflate(R.layout.item_pop, null);
518 518
519   - popupWindow = new PopupWindow(popupView, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
  519 + popupWindow = new PopupWindow(popupView, 200,
  520 + LinearLayout.LayoutParams.WRAP_CONTENT, true);
520 521 popupWindow.setFocusable(true);
521 522 popupWindow.setOutsideTouchable(true);
522 523 popupWindow.setBackgroundDrawable(new BitmapDrawable(getResources(), (Bitmap) null));
... ...
  1 +package com.xgimi.gimicinema.activity;
  2 +
  3 +import android.app.Activity;
  4 +import android.os.Bundle;
  5 +import android.text.TextUtils;
  6 +import android.view.View;
  7 +import android.widget.Button;
  8 +import android.widget.EditText;
  9 +import android.widget.Toast;
  10 +import com.gimi.common.cinema.utils.Utils;
  11 +import com.xgimi.gimicinema.R;
  12 +
  13 +public class ConfigWifiActivity extends Activity {
  14 +
  15 + private static final String TAG = "ConfigWifiActivity";
  16 +
  17 + private EditText mEdtApSsid;
  18 + private EditText mEdtApPassword;
  19 + private Button mBtnConfig;
  20 +
  21 + @Override
  22 + protected void onCreate(Bundle savedInstanceState) {
  23 + super.onCreate(savedInstanceState);
  24 + setContentView(R.layout.activity_config_wifi);
  25 + String ssid = Utils.getString(this, "wifi-ssid");
  26 + String pwd = Utils.getString(this, "wifi-ssid-pwd");
  27 +
  28 + mEdtApSsid = (EditText) findViewById(R.id.ssid_et);
  29 + mEdtApPassword = (EditText) findViewById(R.id.pwd_et);
  30 +
  31 + mEdtApSsid.setText(ssid);
  32 + mEdtApPassword.setText(pwd);
  33 +
  34 + if (TextUtils.isEmpty(ssid)) {
  35 + mEdtApSsid.setText("LEMOMOFFICE2.4G");
  36 + mEdtApPassword.setText("88888888");
  37 + }
  38 +
  39 + mBtnConfig = (Button) findViewById(R.id.btn_save);
  40 + mBtnConfig.setOnClickListener(new View.OnClickListener() {
  41 + @Override
  42 + public void onClick(View v) {
  43 + String apSsid = mEdtApSsid.getText().toString();
  44 + String apPassword = mEdtApPassword.getText().toString();
  45 + Utils.saveString(ConfigWifiActivity.this, "wifi-ssid", apSsid);
  46 + Utils.saveString(ConfigWifiActivity.this, "wifi-ssid-pwd", apPassword);
  47 + if (!TextUtils.isEmpty(apSsid) && !TextUtils.isEmpty(apPassword)) {
  48 + Toast.makeText(ConfigWifiActivity.this, "保存成功", Toast.LENGTH_SHORT).show();
  49 + }
  50 + }
  51 + });
  52 +
  53 + }
  54 +}
... ...
... ... @@ -59,6 +59,7 @@ import com.gimi.common.cinema.model.Constant;
59 59 import com.gimi.common.cinema.model.FolderItem;
60 60 import com.gimi.common.cinema.model.LocalMovieMessage;
61 61 import com.gimi.common.cinema.model.MessageEvent;
  62 +import com.gimi.common.cinema.model.RoomInfo;
62 63 import com.gimi.common.cinema.model.RoomQrCodeInfo;
63 64 import com.gimi.common.cinema.utils.AuthUtils;
64 65 import com.gimi.common.cinema.utils.LeeImageLoader;
... ... @@ -121,15 +122,14 @@ import java.util.Date;
121 122 import java.util.List;
122 123 import java.util.Locale;
123 124
124   -import static com.qnbar.smc.service.SocketService.OPEN_DOOR_CMD;
125   -
126 125 /**
127 126 * Created by wugian on 2016/9/23
128 127 */
129 128 public class MainActivity extends BaseActivity implements IMainView, EventListener<String> {
  129 + private static final String TAG = "MainActivity";
130 130 private long switchNum = 4294967151L;
131 131 private String deviceNum = "FF:FF:FF:FF:00:FF";
132   - private static final String TAG = "MainActivity";
  132 + private String lockMac = "DC:F6:70:C1:AA:D6";
133 133 private Context context;
134 134
135 135 private ImageView controlQrCodeIv;
... ... @@ -452,6 +452,9 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
452 452
453 453 @Override
454 454 public void countDownOrderTime(int durationMinutes) {
  455 + if (durationMinutes <= 1) {
  456 + return;
  457 + }
455 458 Constant.count = durationMinutes + 1;
456 459 PollingUtils.startPollingService(context, 60, CountService.class, CountService.STATUS_ACTION);
457 460 }
... ... @@ -463,6 +466,15 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
463 466 this.info = info;
464 467 }
465 468
  469 + @Override
  470 + public void notifyGetRoomInfo(RoomInfo info) {
  471 + if (!TextUtils.isEmpty(info.getData().getMac_address())) {
  472 + lockMac = info.getData().getMac_address();
  473 + } else {
  474 + show("没有配置门禁相关网信息,使用默认信息");
  475 + }
  476 + }
  477 +
466 478
467 479 int findCount = 0;
468 480
... ... @@ -865,7 +877,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
865 877 @Subscribe(threadMode = ThreadMode.MAIN)
866 878 public void onMoonEvent(MessageEvent messageEvent) {
867 879 switch (messageEvent.getEventId()) {
868   - case OPEN_DOOR_CMD:
  880 + case SocketService.OPEN_DOOR_CMD:
869 881 openDoor();
870 882 if (rightSn) {
871 883 down();
... ... @@ -924,7 +936,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
924 936 Toast.makeText(MainActivity.this, "开门成功", Toast.LENGTH_SHORT).show();
925 937
926 938 BLEOpenRecord bleOpenRecord = new BLEOpenRecord();
927   - bleOpenRecord.setLockmac("DC:F6:70:C1:AA:D6");
  939 + bleOpenRecord.setLockmac(lockMac);
928 940 bleOpenRecord.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US).format(new Date()));
929 941 Intent intent = new Intent();
930 942 intent.setAction(GREENBluetoothLeService.ACTION_OPEN_SUCCESS);
... ... @@ -940,7 +952,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
940 952
941 953 });
942 954 String openCMD = "Open the door";
943   - GREENBLE.send(this, "DC:F6:70:C1:AA:D6", openCMD.getBytes());
  955 + GREENBLE.send(this, lockMac, openCMD.getBytes());
944 956 List<LocalMovieMessage> localMovieMessages = new NewDBManager(this).queryRandomMovies();
945 957 if (localMovieMessages != null && localMovieMessages.size() > 0) {
946 958 OpenMMUtils.openMMWithAds(this, localMovieMessages.get(0).getPlayPath(), null);
... ... @@ -952,6 +964,8 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
952 964 private boolean findSwitch = false;
953 965
954 966 void initSwitch() {
  967 + switchNum = Utils.getLong(this, "sub-device-str");
  968 + deviceNum = Utils.getString(this, "hub-num-str");
955 969 FistJni fistJni = FistJni.getInstance();
956 970 fistJni.startSdk();
957 971 fistJni.searchLocalDevice();
... ...
1 1 package com.xgimi.gimicinema.activity;
2 2
  3 +import android.app.AlertDialog;
  4 +import android.content.Context;
  5 +import android.content.DialogInterface;
  6 +import android.content.Intent;
  7 +import android.content.res.ColorStateList;
  8 +import android.graphics.Bitmap;
3 9 import android.graphics.Rect;
  10 +import android.graphics.drawable.BitmapDrawable;
4 11 import android.os.Bundle;
5 12 import android.support.v7.app.AppCompatActivity;
6 13 import android.support.v7.widget.GridLayoutManager;
7 14 import android.support.v7.widget.RecyclerView;
  15 +import android.text.TextUtils;
8 16 import android.util.Log;
  17 +import android.view.LayoutInflater;
9 18 import android.view.View;
  19 +import android.view.ViewGroup;
  20 +import android.widget.AdapterView;
  21 +import android.widget.BaseAdapter;
  22 +import android.widget.GridView;
  23 +import android.widget.LinearLayout;
  24 +import android.widget.PopupWindow;
  25 +import android.widget.TextView;
10 26 import android.widget.Toast;
11 27 import com.adroplat.fist_switch.jni.Device;
12 28 import com.adroplat.fist_switch.jni.FistJni;
13 29 import com.adroplat.fist_switch.jni.SubDevice;
14 30 import com.adroplat.fist_switch.utils.protocol.one.FistProtocol;
  31 +import com.gimi.common.cinema.utils.Utils;
15 32 import com.google.gson.Gson;
  33 +import com.qnbar.smc.model.Group;
  34 +import com.qnbar.smc.model.Groups;
16 35 import com.qnbar.switchcontrol.model.SwitchMessageEvent;
17 36 import com.xgimi.gimicinema.R;
18 37 import com.xgimi.gimicinema.adapter.DeviceListAdapter;
... ... @@ -30,8 +49,12 @@ public class SwitchControlActivity extends AppCompatActivity {
30 49 protected void onCreate(Bundle savedInstanceState) {
31 50 super.onCreate(savedInstanceState);
32 51 setContentView(R.layout.activity_switch_control);
  52 + mContext = this;
  53 +
33 54 EventBus.getDefault().register(this);
34   - //TODO save DeviceNum,SubDeviceNum
  55 + deviceStrKey = Utils.getString(mContext, "hub-key-str");
  56 + // save DeviceNum,SubDeviceNum
  57 + // 显示菜单指定所控制的HUB 及开关并保存
35 58 initList();
36 59 FistJni fistJni = FistJni.getInstance();
37 60 fistJni.startSdk();
... ... @@ -79,9 +102,18 @@ public class SwitchControlActivity extends AppCompatActivity {
79 102
80 103 @Override
81 104 public void onMenuClick(View v, int position) {
82   - deviceStrKey = FistJni.getHubs().get(position).getDeviceStrKey();
83   - toast("重设控制口令");
84   - Log.d("menu", "reset control hub:" + deviceStrKey);
  105 + testDataHub();
  106 + initPopupWindow();
  107 + if (popupWindow != null) {
  108 + if (!popupWindow.isShowing()) {
  109 + popupWindow.showAsDropDown(v);
  110 + groupListAdapter.notifyDataSetChanged();
  111 + }
  112 + }
  113 + //控制当前主机,保存控制密码
  114 +// deviceStrKey = FistJni.getHubs().get(position).getDeviceStrKey();
  115 +// toast("重设控制口令");
  116 +// Log.d("menu", "reset control hub:" + deviceStrKey);
85 117 }
86 118 });
87 119 hubRv.setAdapter(hubAdapter);
... ... @@ -125,23 +157,14 @@ public class SwitchControlActivity extends AppCompatActivity {
125 157
126 158 @Override
127 159 public void onMenuClick(View v, int position) {
128   - Device device = null;
129   - for (Device deviceCur : FistJni.getHubs()) {
130   - if (deviceCur.getDeviceStrKey().equals(deviceStrKey)) {
131   - device = deviceCur;
  160 + testDataLights();
  161 + initPopupWindow();
  162 + if (popupWindow != null) {
  163 + if (!popupWindow.isShowing()) {
  164 + popupWindow.showAsDropDown(v);
  165 + groupListAdapter.notifyDataSetChanged();
132 166 }
133 167 }
134   - if (device == null) {
135   - toast("当前控制口令出错,请重新选择控制主机按menu设置");
136   - return;
137   - }
138   -
139   - ArrayList<SubDevice> subDevices = new ArrayList<>();
140   - subDevices.add(FistJni.getSubDevices().get(position));
141   - device.setSubDevices(subDevices);
142   - FistJni.getInstance().delSub(new Gson().toJson(device));
143   - FistJni.getSubDevices().clear();
144   - switchAdapter.notifyDataSetChanged();
145 168 }
146 169 });
147 170 switchRv.setAdapter(switchAdapter);
... ... @@ -167,6 +190,43 @@ public class SwitchControlActivity extends AppCompatActivity {
167 190 fistJni.modifyPwd(new Gson().toJson(device), "123456");
168 191 }
169 192
  193 + private void showAlert() {
  194 + String promte = "配置信息不全请重新配置";
  195 + final String ssid = Utils.getString(this, "wifi-ssid");
  196 + final String pwd = Utils.getString(this, "wifi-ssid-pwd");
  197 + if (!TextUtils.isEmpty(ssid) && !TextUtils.isEmpty(pwd)) {
  198 + promte = "当前配置信息为:\n\nssid:" + ssid + "\n\npwd:" + pwd;
  199 + }
  200 +
  201 + new AlertDialog.Builder(this)
  202 + .setTitle("确认")
  203 + .setMessage(promte)
  204 + .setPositiveButton("是", new DialogInterface.OnClickListener() {
  205 + @Override
  206 + public void onClick(DialogInterface dialog, int which) {
  207 + Device device = null;
  208 + for (Device deviceCur : FistJni.getHubs()) {
  209 + if (deviceCur.getDeviceStrKey().equals(deviceStrKey)) {
  210 + device = deviceCur;
  211 + }
  212 + }
  213 + if (device == null) {
  214 + toast("没有选中控制主机,请重新选择控制主机按menu设置");
  215 + return;
  216 + }
  217 + FistJni fistJni = FistJni.getInstance();
  218 + fistJni.getlinkRouter(new Gson().toJson(device), ssid, pwd);
  219 + }
  220 + })
  221 + .setNegativeButton("重新配置", new DialogInterface.OnClickListener() {
  222 + @Override
  223 + public void onClick(DialogInterface dialog, int which) {
  224 + startActivity(new Intent(SwitchControlActivity.this, ConfigWifiActivity.class));
  225 + }
  226 + })
  227 + .show();
  228 + }
  229 +
170 230 public void getLinkStatus(View view) {
171 231 FistJni fistJni = FistJni.getInstance();
172 232 Device device = FistJni.getHubs().get(0);
... ... @@ -174,10 +234,11 @@ public class SwitchControlActivity extends AppCompatActivity {
174 234 }
175 235
176 236 public void setLinkMsg(View view) {
177   - FistJni fistJni = FistJni.getInstance();
178   - Device device = FistJni.getHubs().get(0);
179   -// fistJni.getlinkRouter(new Gson().toJson(device),"Xiaomi123","88888888");
180   - fistJni.getlinkRouter(new Gson().toJson(device), "LEMOMOFFICE2.4G", "88888888");
  237 + showAlert();
  238 +// FistJni fistJni = FistJni.getInstance();
  239 +// Device device = FistJni.getHubs().get(0);
  240 +//// fistJni.getlinkRouter(new Gson().toJson(device),"Xiaomi123","88888888");
  241 +// fistJni.getlinkRouter(new Gson().toJson(device), "LEMOMOFFICE2.4G", "88888888");
181 242 }
182 243
183 244 public void scanHubs(View view) {
... ... @@ -206,6 +267,14 @@ public class SwitchControlActivity extends AppCompatActivity {
206 267 case FistJni.DEVICE_HUBS_ONLINE_NOTIFY:
207 268 case FistProtocol.CommondType.CMD_TYPE_SEARCH_RESPONSE:
208 269 Log.d("qnbar_switch", switchMessageEvent.getMessage());
  270 + for (Device device : FistJni.getHubs()) {
  271 + if ("000000".equals(device.getDeviceStrKey())) {
  272 + FistJni.getHubs().clear();
  273 + FistJni fistJni = FistJni.getInstance();
  274 + fistJni.modifyPwd(new Gson().toJson(device), "123456");
  275 + return;
  276 + }
  277 + }
209 278 hubAdapter.notifyDataSetChanged();
210 279 break;
211 280 case FistJni.DEVICE_SWITCH_ONLINE_NOTIFY:
... ... @@ -222,6 +291,11 @@ public class SwitchControlActivity extends AppCompatActivity {
222 291 Log.d("qnbar_switch", switchMessageEvent.getMessage());
223 292 toast("子设备有变动");
224 293 break;
  294 + case FistProtocol.CommondType.CMD_MODIFY_CTRL_PWD_RESPONSE:
  295 + searchLocalDevice();
  296 + Log.d("qnbar_switch", switchMessageEvent.getMessage());
  297 + toast("控制密码已重置");
  298 + break;
225 299 default:
226 300 Log.d("qnbar_switch", "default:" + switchMessageEvent.getMessage() + "," + switchMessageEvent.getEventId());
227 301 break;
... ... @@ -229,7 +303,7 @@ public class SwitchControlActivity extends AppCompatActivity {
229 303 }
230 304
231 305 private void toast(String msg) {
232   - Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
  306 + Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
233 307 }
234 308
235 309 @Override
... ... @@ -237,4 +311,202 @@ public class SwitchControlActivity extends AppCompatActivity {
237 311 super.onDestroy();
238 312 EventBus.getDefault().unregister(this);
239 313 }
  314 +
  315 +
  316 + private PopupWindow popupWindow;
  317 + private Context mContext;
  318 + private GroupListAdapter groupListAdapter;
  319 + private LayoutInflater inflate;
  320 + private boolean isHubs;
  321 +
  322 + private void initPopupWindow() {
  323 +// testDataHub();
  324 + final View popupView = getLayoutInflater().inflate(R.layout.item_pop, null);
  325 +
  326 + popupWindow = new PopupWindow(popupView, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
  327 + popupWindow.setFocusable(true);
  328 + popupWindow.setOutsideTouchable(true);
  329 + popupWindow.setBackgroundDrawable(new BitmapDrawable(getResources(), (Bitmap) null));
  330 + inflate = getLayoutInflater();
  331 + GridView listView = (GridView) popupView.findViewById(R.id.list_groups);
  332 + TextView title = (TextView) popupView.findViewById(R.id.txt_header_title);
  333 + if (isHubs) {
  334 + title.setText("设置HUB");
  335 + } else {
  336 + title.setText("设置开关");
  337 + }
  338 + listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  339 + @Override
  340 + public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
  341 + if (isHubs) {
  342 + switch (position) {
  343 + case 0:
  344 + //get current click
  345 + //控制当前主机,保存控制密码
  346 + deviceStrKey = FistJni.getHubs().get((Integer) hubRv.getFocusedChild().getTag()).getDeviceStrKey();
  347 + String deviceNumStr = FistJni.getHubs().get(position).getStringDeviceNum();
  348 + Utils.saveString(mContext, "hub-num-str", deviceNumStr);
  349 + Utils.saveString(mContext, "hub-key-str", deviceStrKey);
  350 +// toast("重设控制口令");
  351 + toast("系统记录当前控制主机设备号,重设控制口令");
  352 + Log.d("menu", "reset control hub:" + deviceStrKey);
  353 + break;
  354 + }
  355 + } else {
  356 + switch (position) {
  357 + case 0:
  358 + long subDeviceNum = FistJni.getSubDevices().get((Integer) switchRv.getFocusedChild().getTag()).getSubDeviceNum();
  359 + Utils.saveLong(mContext, "sub-device-str", subDeviceNum);
  360 + toast("系统记录当前开关设备号,在特定时间会进行开关");
  361 + break;
  362 + case 1:
  363 + Device device = null;
  364 + for (Device deviceCur : FistJni.getHubs()) {
  365 + if (deviceCur.getDeviceStrKey().equals(deviceStrKey)) {
  366 + device = deviceCur;
  367 + }
  368 + }
  369 + if (device == null) {
  370 + toast("些开关不属于当前控制主机,请重新选择控制主机按menu设置");
  371 + return;
  372 + }
  373 + ArrayList<SubDevice> subDevices = new ArrayList<>();
  374 + subDevices.add(FistJni.getSubDevices().get((Integer) switchRv.getFocusedChild().getTag()));
  375 + device.setSubDevices(subDevices);
  376 + FistJni.getInstance().delSub(new Gson().toJson(device));
  377 + FistJni.getSubDevices().clear();
  378 + switchAdapter.notifyDataSetChanged();
  379 +
  380 + break;
  381 + }
  382 + if (popupWindow != null && popupWindow.isShowing()) {
  383 + popupWindow.dismiss();
  384 + }
  385 + }
  386 +// Group group = groupListAdapter.getItem(position);
  387 +// allocDeviceGroup(group);
  388 + }
  389 + });
  390 + groupListAdapter = new GroupListAdapter();
  391 + listView.setAdapter(groupListAdapter);
  392 + }
  393 +
  394 + class GroupListAdapter extends BaseAdapter implements
  395 + View.OnClickListener, View.OnLongClickListener {
  396 +
  397 + public GroupListAdapter() {
  398 +
  399 + }
  400 +
  401 + @Override
  402 + public boolean isEnabled(int position) {
  403 + return false;
  404 + }
  405 +
  406 + @Override
  407 + public int getCount() {
  408 + return Groups.getInstance().size();
  409 + }
  410 +
  411 + @Override
  412 + public Group getItem(int position) {
  413 + return Groups.getInstance().get(position);
  414 + }
  415 +
  416 + @Override
  417 + public long getItemId(int position) {
  418 + return 0;
  419 + }
  420 +
  421 + @Override
  422 + public View getView(int position, View convertView, ViewGroup parent) {
  423 + GroupItemHolder holder;
  424 + if (convertView == null) {
  425 + convertView = inflate.inflate(R.layout.group_item, null);
  426 + TextView txtName = (TextView) convertView
  427 + .findViewById(R.id.txt_name);
  428 + txtName.setOnLongClickListener(this);
  429 + holder = new GroupItemHolder();
  430 + holder.txtName = txtName;
  431 + convertView.setTag(holder);
  432 + } else {
  433 + holder = (GroupItemHolder) convertView.getTag();
  434 + }
  435 +
  436 + Group group = getItem(position);
  437 + if (group != null) {
  438 + if (group.textColor == null)
  439 + group.textColor = mContext.getResources()
  440 + .getColorStateList(R.color.black);
  441 + holder.txtName.setText(group.name);
  442 + holder.txtName.setTag(group.meshAddress);
  443 +
  444 + if (group.checked) {
  445 + ColorStateList color = mContext.getResources()
  446 + .getColorStateList(R.color.theme_positive_color);
  447 + holder.txtName.setTextColor(color);
  448 + } else {
  449 + ColorStateList color = mContext.getResources()
  450 + .getColorStateList(R.color.black);
  451 + holder.txtName.setTextColor(color);
  452 + }
  453 + }
  454 + return convertView;
  455 + }
  456 +
  457 + @Override
  458 + public void onClick(View view) {
  459 + }
  460 +
  461 + @Override
  462 + public boolean onLongClick(View v) {
  463 + return false;
  464 + }
  465 +
  466 + public Group get(int groupAddress) {
  467 + return Groups.getInstance().getByMeshAddress(groupAddress);
  468 + }
  469 + }
  470 +
  471 + static class GroupItemHolder {
  472 + public TextView txtName;
  473 + }
  474 +
  475 + private void testDataHub() {
  476 + isHubs = true;
  477 +
  478 + Groups.getInstance().clear();
  479 +
  480 + Group living = new Group();
  481 + living.name = "控制当前主机";
  482 + living.meshAddress = 0x8001;
  483 + living.brightness = 100;
  484 + living.temperature = 100;
  485 + living.color = 0xFFFFFF;
  486 +
  487 + Groups.getInstance().add(living);
  488 + }
  489 +
  490 + private void testDataLights() {
  491 + isHubs = false;
  492 + Groups.getInstance().clear();
  493 +
  494 + Group living = new Group();
  495 + living.name = "控制当前开关";
  496 + living.meshAddress = 0x8001;
  497 + living.brightness = 100;
  498 + living.temperature = 100;
  499 + living.color = 0xFFFFFF;
  500 +
  501 + Group family = new Group();
  502 + family.name = "移除此开关";
  503 + family.meshAddress = 0x8002;
  504 + family.brightness = 100;
  505 + family.temperature = 100;
  506 + family.color = 0xFFFFFF;
  507 +
  508 + Groups.getInstance().add(living);
  509 + Groups.getInstance().add(family);
  510 + }
  511 +
240 512 }
... ...
... ... @@ -19,6 +19,7 @@ import android.graphics.Bitmap;
19 19
20 20 import com.gimi.common.cinema.model.ClassificationItem;
21 21 import com.gimi.common.cinema.model.LocalMovieMessage;
  22 +import com.gimi.common.cinema.model.RoomInfo;
22 23 import com.gimi.common.cinema.model.RoomQrCodeInfo;
23 24
24 25 import java.util.List;
... ... @@ -58,4 +59,6 @@ public interface IMainView {
58 59 void countDownOrderTime(int durationMinutes);
59 60
60 61 void prepareRoomQrCodeInfo(RoomQrCodeInfo info);
  62 +
  63 + void notifyGetRoomInfo(RoomInfo info);
61 64 }
... ...
... ... @@ -214,11 +214,13 @@ public class MainPresenter extends BasePresenter
214 214 roomInfoModel.getRoomInfo(imei, true, new RoomInfoModelImpl.GetRoomInfoListener() {
215 215 @Override
216 216 public void onGetRoomInfoSuccess(RoomInfo info) {
  217 + mainView.notifyGetRoomInfo(info);
217 218 Log.d("room-info", "get success:" + info.toString());
218 219 }
219 220
220 221 @Override
221 222 public void onGetRoomInfoUpdate(RoomInfo info) {
  223 + mainView.notifyGetRoomInfo(info);
222 224 Log.d("room-info", "update success:" + info.toString());
223 225 }
224 226
... ... @@ -239,6 +241,7 @@ public class MainPresenter extends BasePresenter
239 241 public void onGetRoomStatusSuccess(RoomStatusInfo info) {
240 242 RoomStatusInfo.DataEntity data = info.getData();
241 243 int durationMinutes = data.getEnd_time() - data.getBegin_time();
  244 + Log.d("CountService", "durationMinutes:" + durationMinutes);
242 245 mainView.countDownOrderTime(durationMinutes);
243 246 roomInfoModel.getRoomQrCode(data.getOrder_sn(), new RoomInfoModelImpl.GetRoomQrCodeListener() {
244 247 @Override
... ...
  1 +<!--
  2 + ~ Copyright 2017 wugian
  3 + ~
  4 + ~ Licensed under the Apache License, Version 2.0 (the "License");
  5 + ~ you may not use this file except in compliance with the License.
  6 + ~ You may obtain a copy of the License at
  7 + ~
  8 + ~ http://www.apache.org/licenses/LICENSE-2.0
  9 + ~
  10 + ~ Unless required by applicable law or agreed to in writing, software
  11 + ~ distributed under the License is distributed on an "AS IS" BASIS,
  12 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + ~ See the License for the specific language governing permissions and
  14 + ~ limitations under the License.
  15 + -->
  16 +
  17 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  18 + android:layout_width="match_parent"
  19 + android:layout_height="match_parent"
  20 + android:background="@android:color/white"
  21 + android:orientation="vertical">
  22 +
  23 + <RelativeLayout
  24 + android:layout_width="match_parent"
  25 + android:layout_height="wrap_content"
  26 + >
  27 +
  28 + <ImageView
  29 + android:id="@+id/img_header_menu_left"
  30 + android:layout_width="wrap_content"
  31 + android:layout_height="wrap_content"
  32 + android:layout_alignParentStart="true"
  33 + android:layout_centerVertical="true"
  34 + android:layout_marginStart="10dp"
  35 + android:contentDescription="@null"/>
  36 +
  37 + <TextView
  38 + android:id="@+id/txt_header_title"
  39 + android:layout_width="wrap_content"
  40 + android:layout_height="wrap_content"
  41 + android:layout_alignWithParentIfMissing="false"
  42 + android:layout_centerHorizontal="true"
  43 + android:layout_centerInParent="true"
  44 + android:layout_centerVertical="true"
  45 + android:layout_marginEnd="30dp"
  46 + android:layout_marginStart="30dp"
  47 + android:gravity="center_vertical"
  48 + android:singleLine="true"
  49 + android:text="配置WIFI信息"
  50 + android:textAlignment="center"
  51 + android:textColor="@android:color/black"
  52 + android:textSize="18sp"/>
  53 + </RelativeLayout>
  54 +
  55 + <LinearLayout
  56 + android:layout_width="match_parent"
  57 + android:layout_height="wrap_content"
  58 + android:layout_marginLeft="5dp"
  59 + android:layout_marginRight="5dp"
  60 + android:layout_marginTop="15dp"
  61 + android:orientation="vertical">
  62 +
  63 +
  64 + <EditText
  65 + android:id="@+id/ssid_et"
  66 + android:layout_width="match_parent"
  67 + android:layout_height="wrap_content"
  68 + android:editable="false"
  69 + android:ems="10"
  70 + android:inputType="text"
  71 + android:labelFor="@+id/txt_mesh_name"
  72 + android:hint="ssid"/>
  73 +
  74 + <EditText
  75 + android:id="@+id/pwd_et"
  76 + android:layout_width="match_parent"
  77 + android:layout_height="wrap_content"
  78 + android:ems="10"
  79 + android:layout_marginTop="10dp"
  80 + android:inputType="textPassword"
  81 + android:labelFor="@+id/txt_mesh_password"
  82 + android:hint="password"/>
  83 +
  84 +
  85 + <Button
  86 + android:id="@+id/btn_save"
  87 + android:layout_width="match_parent"
  88 + android:layout_height="46dp"
  89 + android:layout_marginTop="15dp"
  90 + android:text="保存WIFI信息"
  91 + android:textColor="@android:color/black"
  92 + android:textSize="18sp"/>
  93 +
  94 + </LinearLayout>
  95 +
  96 +
  97 +</LinearLayout>
\ No newline at end of file
... ...
... ... @@ -30,6 +30,7 @@
30 30
31 31 <GridView
32 32 android:id="@+id/list_groups"
  33 + android:listSelector="@android:drawable/list_selector_background"
33 34 android:layout_width="match_parent"
34 35 android:layout_height="match_parent"
35 36 android:fadingEdge="none"
... ...
Please register or login to post a comment