Commit 46679fe4 by llxqb

优化

parent 25561d28
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
<activity <activity
android:name=".DinnerActivity" android:name=".DinnerActivity"
android:screenOrientation="landscape" android:screenOrientation="landscape"
android:configChanges="orientation|screenSize|keyboardHidden"
android:windowSoftInputMode="stateHidden"> android:windowSoftInputMode="stateHidden">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
...@@ -47,14 +48,17 @@ ...@@ -47,14 +48,17 @@
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="landscape"/> android:screenOrientation="landscape"/>
<activity <activity
android:name=".OrderScanActivity" android:name=".OrderScanActivity"
android:screenOrientation="landscape" android:screenOrientation="landscape"
android:configChanges="orientation|screenSize|keyboardHidden"
android:theme="@style/ScanTheme"/> android:theme="@style/ScanTheme"/>
<activity <activity
android:name=".FaceActivity" android:name=".FaceActivity"
android:screenOrientation="landscape" android:screenOrientation="landscape"
android:configChanges="orientation|screenSize|keyboardHidden"
android:theme="@style/ScanTheme"/> android:theme="@style/ScanTheme"/>
</application> </application>
......
...@@ -19,6 +19,7 @@ import android.widget.LinearLayout; ...@@ -19,6 +19,7 @@ import android.widget.LinearLayout;
import android.widget.RadioButton; import android.widget.RadioButton;
import android.widget.RadioGroup; import android.widget.RadioGroup;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import com.iflytek.cloud.ErrorCode; import com.iflytek.cloud.ErrorCode;
import com.iflytek.cloud.InitListener; import com.iflytek.cloud.InitListener;
...@@ -55,7 +56,7 @@ import peanut.keenon.com.network.WebApiRequest; ...@@ -55,7 +56,7 @@ import peanut.keenon.com.network.WebApiRequest;
import peanut.keenon.com.network.WebRequestLoad; import peanut.keenon.com.network.WebRequestLoad;
import peanut.keenon.com.util.AppConstant; import peanut.keenon.com.util.AppConstant;
public class DinnerActivity extends Activity { public class DinnerActivity extends Activity implements View.OnClickListener {
public static final int ROBOT_START_TARGET = 1; public static final int ROBOT_START_TARGET = 1;
...@@ -78,6 +79,7 @@ public class DinnerActivity extends Activity { ...@@ -78,6 +79,7 @@ public class DinnerActivity extends Activity {
private String mAuthCode = null; private String mAuthCode = null;
private String mOpenId = null; private String mOpenId = null;
private enum RobotStatus { private enum RobotStatus {
NORMAL, NORMAL,
WALKING WALKING
...@@ -117,6 +119,9 @@ public class DinnerActivity extends Activity { ...@@ -117,6 +119,9 @@ public class DinnerActivity extends Activity {
private RadioGroupEx mTableGroup = null; private RadioGroupEx mTableGroup = null;
/**
* 当前选择的CheckBox
*/
private CheckBox mCurrentPlate = null; private CheckBox mCurrentPlate = null;
private int[] dinnerPath = new int[3]; private int[] dinnerPath = new int[3];
...@@ -198,26 +203,61 @@ public class DinnerActivity extends Activity { ...@@ -198,26 +203,61 @@ public class DinnerActivity extends Activity {
mTableGroup = findViewById(R.id.tableGroup); mTableGroup = findViewById(R.id.tableGroup);
Button btnReset = findViewById(R.id.btn_reset); Button btnReset = findViewById(R.id.btn_reset);
btnReset.setOnClickListener(new View.OnClickListener() { btnReset.setOnClickListener(this);
btnScan = findViewById(R.id.btn_scan);
btnScan.setOnClickListener(this);
mGo = findViewById(R.id.btn_go);
mGo.setOnClickListener(this);
mPickup = findViewById(R.id.btn_pickup);
mPickup.setOnClickListener(this);
initCheckChange();
mDinnerStatusValue.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
setRobotStatus(RobotStatus.NORMAL);
}
});
//startLoginThread();
startRobotThread();
merchant = findViewById(R.id.merchantLogo);
merchant.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Intent intent = new Intent(mContext, FaceActivity.class);
startActivityForResult(intent, FACE_DETECT_REQUEST_CODE);
}
});
}
/**
* 设置餐桌背景色
*/
private void setGroupColor(RadioButton radio) {
radio.setTextColor(getResources().getColor(R.color.colorWhite));
radio.setBackgroundColor(getResources().getColor(R.color.color999));
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_reset:
mTableGroup.clearCheck();
mCurrentIndex = 0;
mCurrentPlate = null;
dinnerPath[0] = 0;
dinnerPath[1] = 0;
dinnerPath[2] = 0;
top.setChecked(false); top.setChecked(false);
left.setChecked(false); left.setChecked(false);
right.setChecked(false); right.setChecked(false);
top.setText(""); top.setText("");
left.setText(""); left.setText("");
right.setText(""); right.setText("");
mCurrentPlate = null; break;
mCurrentIndex = 0; case R.id.btn_scan:
dinnerPath = null;
mTableGroup.clearCheck();
}
});
btnScan = findViewById(R.id.btn_scan);
btnScan.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(); Intent intent = new Intent();
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("totalAmount", "100.0"); bundle.putString("totalAmount", "100.0");
...@@ -225,68 +265,75 @@ public class DinnerActivity extends Activity { ...@@ -225,68 +265,75 @@ public class DinnerActivity extends Activity {
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtras(bundle); intent.putExtras(bundle);
startActivityForResult(intent, SCAN_REQUEST_CODE); startActivityForResult(intent, SCAN_REQUEST_CODE);
} break;
}); case R.id.btn_go:
mGo = findViewById(R.id.btn_go);
mGo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mCurrentPath = 0; mCurrentPath = 0;
targetData.clear(); targetData.clear();
startDelivery(); startDelivery();
} break;
}); case R.id.btn_pickup:
mPickup = findViewById(R.id.btn_pickup);
mPickup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mCurrentPath++; mCurrentPath++;
startDispatch(mCurrentPath); startDispatch(mCurrentPath);
//mDinnerStatusValue.setText("送餐中"); //mDinnerStatusValue.setText("送餐中");
} break;
}); }
}
public void initCheckChange() {
mTableGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { mTableGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(RadioGroup radioGroup, int i) { public void onCheckedChanged(RadioGroup radioGroup, int i) {
int id = radioGroup.getCheckedRadioButtonId(); int id = radioGroup.getCheckedRadioButtonId();
RadioButton radio = (RadioButton) findViewById(id); RadioButton radio = findViewById(id);
if (radio != null) { if (radio != null) {
if (mCurrentPlate == null) { if (mCurrentPlate == null) {
// top.setText(radio.getText());
// left.setText(radio.getText());
// right.setText(radio.getText());
//
// int target = Integer.valueOf(radio.getTag().toString());
// dinnerPath[0] = target;
// dinnerPath[1] = target;
// dinnerPath[2] = target;
if (mCurrentIndex == 0) { if (mCurrentIndex == 0) {
top.setText(radio.getText()); top.setText(radio.getText());
dinnerPath[0] = Integer.valueOf(radio.getTag().toString()); dinnerPath[0] = Integer.valueOf(radio.getTag().toString());
mCurrentIndex++; mCurrentIndex++;
} else if (mCurrentIndex == 1) { } else if (mCurrentIndex == 1) {
if (dinnerPath[0] == Integer.parseInt(radio.getTag().toString())) {
Toast.makeText(DinnerActivity.this, radio.getText() + getResources().getString(R.string.dinner_table_have_check), Toast.LENGTH_SHORT).show();
return;
}
left.setText(radio.getText()); left.setText(radio.getText());
dinnerPath[1] = Integer.valueOf(radio.getTag().toString()); dinnerPath[1] = Integer.valueOf(radio.getTag().toString());
mCurrentIndex++; mCurrentIndex++;
} else if (mCurrentIndex == 2) { } else if (mCurrentIndex == 2) {
if (dinnerPath[0] == Integer.parseInt(radio.getTag().toString()) || dinnerPath[1] == Integer.parseInt(radio.getTag().toString())) {
Toast.makeText(DinnerActivity.this, radio.getText() + getResources().getString(R.string.dinner_table_have_check), Toast.LENGTH_SHORT).show();
return;
}
right.setText(radio.getText()); right.setText(radio.getText());
dinnerPath[2] = Integer.valueOf(radio.getTag().toString()); dinnerPath[2] = Integer.valueOf(radio.getTag().toString());
mCurrentIndex++;
} }
} else { } else {
for (int k = 0; k < dinnerPath.length; k++) {
if (dinnerPath[k] == Integer.parseInt(radio.getTag().toString())) {
Toast.makeText(DinnerActivity.this, radio.getText() + getResources().getString(R.string.dinner_table_have_check), Toast.LENGTH_SHORT).show();
return;
}
}
mCurrentPlate.setText(radio.getText()); mCurrentPlate.setText(radio.getText());
int target = Integer.valueOf(radio.getTag().toString()); int target = Integer.valueOf(radio.getTag().toString());
dinnerPath[mCurrentIndex] = target; dinnerPath[mCurrentIndex] = target;
} }
// for (int j = 0; j < dinnerPath.length; j++) {
// if (dinnerPath[j] != 0) {
// RadioButton radio1 = findViewById(dinnerPath[j]);
// setGroupColor(radio1);
// }
// }
} }
} }
}); });
top.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { top.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
...@@ -334,26 +381,6 @@ public class DinnerActivity extends Activity { ...@@ -334,26 +381,6 @@ public class DinnerActivity extends Activity {
} }
} }
}); });
mDinnerStatusValue.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
setRobotStatus(RobotStatus.NORMAL);
}
});
//startLoginThread();
startRobotThread();
merchant = (ImageView) findViewById(R.id.merchantLogo);
merchant.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, FaceActivity.class);
startActivityForResult(intent, FACE_DETECT_REQUEST_CODE);
}
});
} }
private void startDispatch(int current) { private void startDispatch(int current) {
...@@ -835,7 +862,7 @@ public class DinnerActivity extends Activity { ...@@ -835,7 +862,7 @@ public class DinnerActivity extends Activity {
int code = mTts.startSpeaking("亲,我送餐回来啦!", mTtsListener); int code = mTts.startSpeaking("亲,我送餐回来啦!", mTtsListener);
mTableGroup.clearCheck(); mTableGroup.clearCheck();
mCurrentIndex = 0;
top.setChecked(false); top.setChecked(false);
left.setChecked(false); left.setChecked(false);
right.setChecked(false); right.setChecked(false);
......
...@@ -220,7 +220,7 @@ ...@@ -220,7 +220,7 @@
android:background="@drawable/radiobutton_background" android:background="@drawable/radiobutton_background"
android:button="@null" android:button="@null"
android:gravity="center" android:gravity="center"
android:tag="8" android:tag="9"
android:text="九号餐桌" android:text="九号餐桌"
android:textColor="@color/radiobutton_textcolor" android:textColor="@color/radiobutton_textcolor"
android:textSize="14sp" /> android:textSize="14sp" />
...@@ -246,18 +246,13 @@ ...@@ -246,18 +246,13 @@
<LinearLayout <LinearLayout
android:id="@+id/robot_plate" android:id="@+id/robot_plate"
android:layout_width="230dp" android:layout_width="match_parent"
android:layout_height="230dp" android:layout_height="230dp"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:background="@drawable/robot_load_background" android:background="@drawable/robot_load_background"
android:gravity="center" android:gravity="center"
android:orientation="vertical"> android:orientation="vertical">
<!--
<peanut.keenon.com.control.NestedRadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
-->
<RelativeLayout <RelativeLayout
android:layout_width="100dp" android:layout_width="100dp"
android:layout_height="100dp" android:layout_height="100dp"
...@@ -279,6 +274,7 @@ ...@@ -279,6 +274,7 @@
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:text="@string/dinner_top_table" android:text="@string/dinner_top_table"
android:textColor="@color/colorNormal"
android:textSize="10sp" /> android:textSize="10sp" />
</RelativeLayout> </RelativeLayout>
...@@ -294,6 +290,7 @@ ...@@ -294,6 +290,7 @@
android:layout_width="100dp" android:layout_width="100dp"
android:layout_height="100dp" android:layout_height="100dp"
android:orientation="vertical"> android:orientation="vertical">
<CheckBox <CheckBox
android:id="@+id/plate_left" android:id="@+id/plate_left"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -309,6 +306,7 @@ ...@@ -309,6 +306,7 @@
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:text="@string/dinner_left_table" android:text="@string/dinner_left_table"
android:textColor="@color/colorNormal"
android:textSize="10sp" /> android:textSize="10sp" />
</RelativeLayout> </RelativeLayout>
...@@ -317,6 +315,7 @@ ...@@ -317,6 +315,7 @@
android:layout_width="100dp" android:layout_width="100dp"
android:layout_height="100dp" android:layout_height="100dp"
android:orientation="vertical"> android:orientation="vertical">
<CheckBox <CheckBox
android:id="@+id/plate_right" android:id="@+id/plate_right"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -332,6 +331,7 @@ ...@@ -332,6 +331,7 @@
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:text="@string/dinner_right_table" android:text="@string/dinner_right_table"
android:textColor="@color/colorNormal"
android:textSize="10sp" /> android:textSize="10sp" />
</RelativeLayout> </RelativeLayout>
...@@ -384,8 +384,8 @@ ...@@ -384,8 +384,8 @@
<Button <Button
android:id="@+id/btn_reset" android:id="@+id/btn_reset"
android:layout_width="160dp" android:layout_width="100dp"
android:layout_height="80dp" android:layout_height="40dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:background="@drawable/button_background" android:background="@drawable/button_background"
...@@ -396,13 +396,14 @@ ...@@ -396,13 +396,14 @@
<Button <Button
android:id="@+id/btn_scan" android:id="@+id/btn_scan"
android:layout_width="160dp" android:layout_width="160dp"
android:layout_height="80dp" android:layout_height="40dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:background="@drawable/button_background" android:background="@drawable/button_background"
android:gravity="center" android:gravity="center"
android:text="扫一扫" android:text="扫一扫"
android:textColor="@color/colorFocus" /> android:textColor="@color/colorFocus"
android:visibility="gone" />
<TextView <TextView
android:layout_width="16dp" android:layout_width="16dp"
...@@ -412,7 +413,7 @@ ...@@ -412,7 +413,7 @@
<Button <Button
android:id="@+id/btn_go" android:id="@+id/btn_go"
android:layout_width="120dp" android:layout_width="120dp"
android:layout_height="60dp" android:layout_height="40dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:background="@drawable/button_background" android:background="@drawable/button_background"
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<color name="colorDefault">#F2F2F2</color> <color name="colorDefault">#F2F2F2</color>
<color name="colorSelected">#1d2b80</color> <color name="colorSelected">#1d2b80</color>
<color name="colorNormal">#333333</color> <color name="colorNormal">#333333</color>
<color name="color999">#999999</color>
<color name="colorFocus">#FFFFFF</color> <color name="colorFocus">#FFFFFF</color>
<color name="colorButton">#3F51B5</color> <color name="colorButton">#3F51B5</color>
......
...@@ -17,4 +17,5 @@ ...@@ -17,4 +17,5 @@
<string name="dinner_top_table">1</string> <string name="dinner_top_table">1</string>
<string name="dinner_left_table">2</string> <string name="dinner_left_table">2</string>
<string name="dinner_right_table">3</string> <string name="dinner_right_table">3</string>
<string name="dinner_table_have_check">已经被选择,请选择其它餐桌</string>
</resources> </resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment