@Override
 public void run() {
   super.run();
   String[] array = CommonUtil.getCityList(myProvince);
   if (array == null) CommonUtil.sendNetWorkErrorMessage(myHandler);
   else {
     Message msg = new Message();
     msg.obj = array;
     msg.what = ConstantValues.InstructionCode.USERSET_HANDLER_CITY;
     myHandler.sendMessage(msg);
   }
 }
Esempio n. 2
0
 @Override
 public void handleMessage(Message msg) {
   super.handleMessage(msg);
   switch (msg.what) {
     case ConstantValues.InstructionCode.ERROR_NETWORK:
       Toast.makeText(myContext, "网络连接失败", Toast.LENGTH_LONG).show();
       break;
     case ConstantValues.InstructionCode.SHAKE_HANDLER_USER_GAME_NOT_SET:
       Toast.makeText(myContext, "请先设置自己的解密游戏设置", Toast.LENGTH_LONG).show();
       break;
     case ConstantValues.InstructionCode.HANDLER_WAIT_FOR_DATA:
       myContext.sensorManager.unregisterListener(myContext.shakelistener);
       myContext.locationClient.start();
       break;
     case ConstantValues.InstructionCode.HANDLER_SUCCESS_GET_DATA:
       gUserShakeDataList = (ArrayList<UserShakeData>) msg.obj;
       if (gUserShakeDataList.size() == 1) {
         Toast.makeText(myContext, "很抱歉您的附近没有其他用户。", Toast.LENGTH_SHORT).show();
         return;
       }
       myContext.gShakeBall.startZoominAnimation();
       break;
     case ConstantValues.InstructionCode.SHAKE_HANDLER_MAP_SHOW:
       myContext.gShakeBall.setVisibility(View.GONE);
       myContext.gShakeBallLayout.setVisibility(View.GONE);
       myContext.mapView.setVisibility(View.VISIBLE);
       myContext.userDataListView.setVisibility(View.VISIBLE);
       myContext.userDataListView.bringToFront();
       myContext.gFemaleSelect.bringToFront();
       myContext.gMaleSelect.bringToFront();
       myContext.findViewById(R.id.lj_map_linear).bringToFront();
       myContext.findViewById(R.id.lj_map_male_female_layout).bringToFront();
       myContext.findViewById(R.id.lj_map_male_female_layout).setVisibility(View.VISIBLE);
       locateUsers(gUserShakeDataList);
       initUserShakeData();
       if (UserGuide.isNeedUserGuide(myContext, UserGuide.MAP_ACTIVITY)) setupUserGuide();
       else {
         myContext.gFemaleSelect.setOnClickListener(gSexClickListener);
         myContext.gMaleSelect.setOnClickListener(gSexClickListener);
       }
       break;
     case ConstantValues.InstructionCode.SHAKE_HANDLER_SHAKE_SENSOR:
       myContext.sensorManager.unregisterListener(myContext.shakelistener);
       myContext.vibrator.vibrate(ConstantValues.InstructionCode.VIBRATE_TIME);
       float[] values = (float[]) msg.obj;
       float x = values[0];
       float y = values[1];
       float z = values[2];
       myContext.gShakeBall.setRotateAnimation(Math.abs((int) (10000 / z * 2)));
       myContext.gShakeBall.setVelocity((int) (x * 1.5), (int) (y * 1.5));
       myContext.gShakeBall.setStartRotate(true);
       break;
     case ConstantValues.InstructionCode.SHAKE_HANDLER_MARKER_CLICK:
       Marker marker = (Marker) msg.obj;
       Bundle data = marker.getExtraInfo();
       if (data == null) return;
       int index = data.getInt("index");
       myContext.userDataListView.setDataOfIndex(index);
       UserShakeData userShakeData = null; // gUserShakeDataList.get(indexs);
       if (gSexStatus == SEX_MALE) userShakeData = gUserShakeDataListMale.get(index);
       else if (gSexStatus == SEX_FEMALE) userShakeData = gUserShakeDataListFemale.get(index);
       else userShakeData = gUserShakeDataList.get(index);
       LatLng cenpt = new LatLng(userShakeData.getLatitude(), userShakeData.getLongitude());
       locatePotin(cenpt);
       break;
     case ConstantValues.InstructionCode.SHAKE_HANDLER_GAME:
       int id = msg.arg1;
       int type = msg.arg2;
       Intent intent = new Intent();
       switch (type) {
         case 1:
           intent.setClass(myContext, ActivityEightPuzzleGame.class);
           intent.putExtra("userID", id);
           intent.putExtra("nickname", msg.obj.toString());
           break;
         case 2:
           intent.setClass(myContext, ActivitySongPuzzle.class);
           intent.putExtra("userID", id);
           break;
         case 3:
           if (!CommonUtil.isSdkVersionValid()) {
             Toast.makeText(myContext, "此游戏类型暂时仅对Android 4.4及以上用户开放", Toast.LENGTH_SHORT).show();
             return;
           }
           intent.setClass(myContext, ActivityBazingaBall.class);
           intent.putExtra("userID", id);
           break;
       }
       myContext.startActivityForResult(intent, ActivityShake.REQUEST_CODE_BEGINGAME);
       break;
     case ConstantValues.InstructionCode.SHAKE_HANDLER_CHANGE_MARK:
       int indexs = msg.arg1;
       UserShakeData userShakeDatas = null; // gUserShakeDataList.get(indexs);
       if (gSexStatus == SEX_MALE) userShakeDatas = gUserShakeDataListMale.get(indexs);
       else if (gSexStatus == SEX_FEMALE) userShakeDatas = gUserShakeDataListFemale.get(indexs);
       else userShakeDatas = gUserShakeDataList.get(indexs);
       LatLng cenpts = new LatLng(userShakeDatas.getLatitude(), userShakeDatas.getLongitude());
       locatePotin(cenpts);
       break;
     case ConstantValues.InstructionCode.SHAKE_HANDLER_COLLISION:
       myContext.vibrator.vibrate(ConstantValues.InstructionCode.VIBRATE_TIME);
       break;
   }
 }