11 changed files with 284 additions and 137 deletions
Unified View
Diff Options
-
2app/build.gradle
-
20app/src/main/AndroidManifest.xml
-
65app/src/main/java/com/jda/app/main/view/activity/DemoActivity.java
-
30app/src/main/java/com/jda/app/main/view/activity/LoginActivity.java
-
7app/src/main/java/com/jda/app/main/view/activity/NfcTestActivity.java
-
83app/src/main/java/com/jda/app/main/view/activity/PrinterTestActivity.java
-
150app/src/main/res/layout/activity_login.xml
-
35app/src/main/res/layout/activity_pound_machine.xml
-
16app/src/main/res/layout/activity_test_print.xml
-
10app/src/main/res/layout/item_pound_msg.xml
-
3config.gradle
@ -0,0 +1,65 @@ |
|||||
|
package com.jda.app.main.view.activity; |
||||
|
import com.jda.app.main.R; |
||||
|
|
||||
|
import com.jda.app.main.utils.PoundManager; |
||||
|
import android.graphics.Color; |
||||
|
import android.support.v7.app.AppCompatActivity; |
||||
|
import android.os.Bundle; |
||||
|
import android.view.KeyEvent; |
||||
|
import android.widget.TextView; |
||||
|
public class DemoActivity extends AppCompatActivity { |
||||
|
TextView tv_hint; |
||||
|
TextView tv_num; |
||||
|
TextView tv_ic_card; |
||||
|
|
||||
|
@Override |
||||
|
protected void onCreate(Bundle savedInstanceState) { |
||||
|
super.onCreate(savedInstanceState); |
||||
|
setContentView(R.layout.activity_pound_machine); |
||||
|
initView(); |
||||
|
initListener(); |
||||
|
} |
||||
|
|
||||
|
private void initListener() { |
||||
|
PoundManager.getInstance().setPoundStatusListener(new PoundManager.PoundStatusListener() { |
||||
|
@Override |
||||
|
public void onTick(double lastValidWeightNum, PoundManager.PoundStatus status) { |
||||
|
runOnUiThread(new Runnable() { |
||||
|
@Override |
||||
|
public void run() { |
||||
|
tv_num.setText(String.valueOf(lastValidWeightNum)); |
||||
|
tv_hint.setText(status.getStatusStr()); |
||||
|
tv_num.setTextColor(status == PoundManager.PoundStatus.STABLE ? Color.rgb(0, 255, 0) : Color.rgb(255, 0, 0)); |
||||
|
tv_hint.setTextColor(status == PoundManager.PoundStatus.STABLE ? Color.rgb(0, 255, 0) : Color.rgb(255, 0, 0)); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
}).init(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
protected void onDestroy() { |
||||
|
super.onDestroy(); |
||||
|
PoundManager.getInstance().onDestroy(); |
||||
|
} |
||||
|
|
||||
|
StringBuilder temStringBuilder = new StringBuilder(); |
||||
|
|
||||
|
@Override |
||||
|
public boolean onKeyDown(int keyCode, KeyEvent event) { |
||||
|
if (keyCode == KeyEvent.KEYCODE_ENTER) { |
||||
|
tv_ic_card.setText("用户信息:"+temStringBuilder.toString()); |
||||
|
temStringBuilder = new StringBuilder(); |
||||
|
return true; |
||||
|
} |
||||
|
temStringBuilder.append(event.getKeyCode()); |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
private void initView() { |
||||
|
tv_hint = findViewById(R.id.tv_hint); |
||||
|
tv_num = findViewById(R.id.tv_num); |
||||
|
tv_ic_card = findViewById(R.id.tv_ic_card); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,83 @@ |
|||||
|
package com.jda.app.main.view.activity; |
||||
|
|
||||
|
import android.support.v7.app.AppCompatActivity; |
||||
|
import android.os.Bundle; |
||||
|
import android.util.Log; |
||||
|
import android.view.View; |
||||
|
import android.widget.Button; |
||||
|
import com.jda.app.main.R; |
||||
|
import com.jda.app.main.utils.PrinterManager; |
||||
|
import java.util.LinkedHashMap; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
public class PrinterTestActivity extends AppCompatActivity { |
||||
|
Button bt; |
||||
|
PrinterManager printerManager; |
||||
|
|
||||
|
@Override |
||||
|
protected void onCreate(Bundle savedInstanceState) { |
||||
|
super.onCreate(savedInstanceState); |
||||
|
setContentView(R.layout.activity_test_print); |
||||
|
initView(); |
||||
|
intListener(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
protected void onResume() { |
||||
|
super.onResume(); |
||||
|
printerManager.registerListener(this); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
protected void onPause() { |
||||
|
super.onPause(); |
||||
|
printerManager.unregisterListener(this); |
||||
|
} |
||||
|
|
||||
|
private void initView() { |
||||
|
bt = findViewById(R.id.bt); |
||||
|
} |
||||
|
|
||||
|
private void intListener() { |
||||
|
printerManager = PrinterManager.getInstance(); |
||||
|
printerManager.setPrinterStatusListener(new PrinterManager.PrinterStatusListener() { |
||||
|
@Override |
||||
|
public void onStatusChange(PrinterManager.PrinterStatus status) { |
||||
|
|
||||
|
} |
||||
|
}); |
||||
|
printerManager.open(this); |
||||
|
|
||||
|
|
||||
|
bt.setOnClickListener(new View.OnClickListener() { |
||||
|
@Override |
||||
|
public void onClick(View v) { |
||||
|
|
||||
|
Map<String, String> map = new LinkedHashMap<>(); |
||||
|
map.put("磅单号", "202101210002"); |
||||
|
map.put("人员编号", "1020210231"); |
||||
|
map.put("供货人", "老王"); |
||||
|
map.put("车牌", "粤A34HH4"); |
||||
|
map.put("进场日期", "2021-1-30"); |
||||
|
map.put("出厂日期", "2021-1-31"); |
||||
|
map.put("产品类型", "黄纸皮"); |
||||
|
map.put("毛重(KG)", "140.0"); |
||||
|
map.put("皮重(KG)", "70.0"); |
||||
|
map.put("净重(KG)", "70.0"); |
||||
|
map.put("扣重(KG)", "0.0"); |
||||
|
map.put("扣点", "0.0"); |
||||
|
map.put("单价(元/KG)", "1.8"); |
||||
|
map.put("金额(元)", "26.0"); |
||||
|
if (printerManager.getPrinterStatus() == PrinterManager.PrinterStatus.CONNECTED) { |
||||
|
boolean result = printerManager.printData("千鸟互联钟落潭工厂", map); |
||||
|
if (result) { |
||||
|
Log.v("wztest", "打印成功"); |
||||
|
} else { |
||||
|
Log.v("wztest", "打印失败"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -1,128 +1,46 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
<?xml version="1.0" encoding="utf-8"?> |
||||
|
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
||||
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
android:layout_width="match_parent" |
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
android:layout_height="match_parent" |
||||
android:background="#FFFFFF"> |
android:background="#FFFFFF"> |
||||
|
|
||||
<ImageView |
|
||||
android:id="@+id/mImgExit" |
|
||||
android:layout_width="wrap_content" |
|
||||
android:layout_height="wrap_content" |
|
||||
android:layout_alignParentRight="true" |
|
||||
android:padding="@dimen/dp_15" |
|
||||
android:src="@drawable/ic_login_exit" /> |
|
||||
|
|
||||
<TextView |
|
||||
android:id="@+id/mTxtTitle" |
|
||||
android:layout_width="match_parent" |
|
||||
android:layout_height="@dimen/dp_40" |
|
||||
android:layout_marginTop="@dimen/dp_30" |
|
||||
android:gravity="bottom" |
|
||||
android:paddingLeft="@dimen/dp_40" |
|
||||
android:text="登录" |
|
||||
android:textColor="@color/cl_333333" |
|
||||
android:textSize="24sp" |
|
||||
android:textStyle="bold" /> |
|
||||
|
|
||||
|
|
||||
<RelativeLayout |
|
||||
android:id="@+id/mLayoutMobile" |
|
||||
android:layout_width="match_parent" |
|
||||
android:layout_height="@dimen/dp_60" |
|
||||
android:layout_below="@+id/mTxtTitle" |
|
||||
android:layout_marginTop="@dimen/dp_10" |
|
||||
android:paddingLeft="@dimen/dp_40" |
|
||||
android:paddingRight="@dimen/dp_40"> |
|
||||
|
|
||||
<EditText |
|
||||
android:id="@+id/mEdtMobile" |
|
||||
android:layout_width="match_parent" |
|
||||
android:layout_height="@dimen/dp_32" |
|
||||
android:layout_centerVertical="true" |
|
||||
android:layout_marginRight="@dimen/dp_20" |
|
||||
android:background="@drawable/shape_input_area_white_bottomline" |
|
||||
android:hint="请输入账号" |
|
||||
android:inputType="phone" |
|
||||
android:maxLength="11" |
|
||||
android:paddingLeft="@dimen/dp_8" |
|
||||
android:paddingRight="@dimen/dp_8" |
|
||||
android:textSize="@dimen/sp_16" /> |
|
||||
<!-- android:layout_toLeftOf="@+id/mBtnSmsCode"--> |
|
||||
|
|
||||
<!-- <com.jda.app.main.widget.CountDownButton--> |
|
||||
<!-- android:id="@+id/mBtnSmsCode"--> |
|
||||
<!-- android:layout_width="@dimen/dp_100"--> |
|
||||
<!-- android:layout_height="@dimen/dp_32"--> |
|
||||
<!-- android:layout_alignParentRight="true"--> |
|
||||
<!-- android:layout_centerVertical="true"--> |
|
||||
<!-- android:background="@drawable/bg_ffffff_666666_5"--> |
|
||||
<!-- android:clickable="true"--> |
|
||||
<!-- android:gravity="center"--> |
|
||||
<!-- android:text="获取验证码"--> |
|
||||
<!-- android:textColor="@color/cl_666666"--> |
|
||||
<!-- android:textSize="@dimen/sp_14" />--> |
|
||||
</RelativeLayout> |
|
||||
|
|
||||
<RelativeLayout |
|
||||
android:id="@+id/mLayoutSmscode" |
|
||||
android:layout_width="match_parent" |
|
||||
android:layout_height="wrap_content" |
|
||||
android:layout_below="@+id/mLayoutMobile" |
|
||||
android:layout_marginTop="@dimen/sp_12" |
|
||||
android:focusable="true" |
|
||||
android:paddingLeft="@dimen/dp_40" |
|
||||
android:paddingRight="@dimen/dp_40"> |
|
||||
|
|
||||
<EditText |
|
||||
android:id="@+id/et_pwd" |
|
||||
android:layout_width="match_parent" |
|
||||
android:layout_height="@dimen/dp_32" |
|
||||
android:layout_centerVertical="true" |
|
||||
android:layout_marginRight="@dimen/dp_20" |
|
||||
android:background="@drawable/shape_input_area_white_bottomline" |
|
||||
android:hint="请输入密码" |
|
||||
android:inputType="textPassword" |
|
||||
android:maxLength="11" |
|
||||
android:paddingLeft="@dimen/dp_8" |
|
||||
android:paddingRight="@dimen/dp_8" |
|
||||
android:textSize="@dimen/sp_16" /> |
|
||||
|
|
||||
</RelativeLayout> |
|
||||
|
|
||||
|
|
||||
<Button |
|
||||
android:id="@+id/mBtnLogin" |
|
||||
|
<LinearLayout |
||||
android:layout_width="match_parent" |
android:layout_width="match_parent" |
||||
android:layout_height="@dimen/dp_44" |
|
||||
android:layout_below="@id/mLayoutSmscode" |
|
||||
android:layout_centerHorizontal="true" |
|
||||
android:layout_marginLeft="@dimen/dp_32" |
|
||||
android:layout_marginRight="@dimen/dp_32" |
|
||||
android:layout_marginTop="@dimen/dp_48" |
|
||||
android:background="@drawable/shape_button_normal" |
|
||||
android:enabled="false" |
|
||||
android:text="登录" |
|
||||
android:textColor="@color/white" |
|
||||
android:textSize="@dimen/sp_18" /> |
|
||||
|
android:layout_height="match_parent" |
||||
|
android:gravity="center" |
||||
|
android:orientation="vertical"> |
||||
|
|
||||
<LinearLayout |
|
||||
android:id="@+id/mLayoutProtocol" |
|
||||
android:layout_width="wrap_content" |
|
||||
android:layout_height="wrap_content" |
|
||||
android:layout_below="@id/mBtnLogin" |
|
||||
android:layout_centerHorizontal="true" |
|
||||
android:layout_marginBottom="@dimen/dp_40" |
|
||||
android:layout_marginTop="@dimen/dp_20"> |
|
||||
<Button |
|
||||
android:id="@+id/bt_check_env" |
|
||||
|
<LinearLayout |
||||
|
android:id="@+id/mLayoutProtocol" |
||||
android:layout_width="wrap_content" |
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
android:layout_height="wrap_content" |
||||
android:background="@color/transparent" |
|
||||
android:gravity="center" |
|
||||
android:text="设备检测" |
|
||||
android:textColor="@color/color_4476f0" |
|
||||
android:textSize="@dimen/sp_12" /> |
|
||||
|
android:layout_centerHorizontal="true" |
||||
|
android:layout_marginTop="@dimen/dp_20" |
||||
|
android:layout_marginBottom="@dimen/dp_40" |
||||
|
android:orientation="vertical"> |
||||
|
|
||||
|
<Button |
||||
|
android:id="@+id/bt_check_rs232" |
||||
|
android:layout_width="wrap_content" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:background="@color/transparent" |
||||
|
android:gravity="center" |
||||
|
android:text="串口和RFID卡测试" |
||||
|
android:textColor="@color/color_4476f0" |
||||
|
android:textSize="@dimen/sp_12" /> |
||||
|
|
||||
|
<Button |
||||
|
android:id="@+id/bt_check_card" |
||||
|
android:layout_width="wrap_content" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:background="@color/transparent" |
||||
|
android:gravity="center" |
||||
|
android:text="打印机测试" |
||||
|
android:textColor="@color/color_4476f0" |
||||
|
android:textSize="@dimen/sp_12" /> |
||||
|
</LinearLayout> |
||||
|
|
||||
</LinearLayout> |
</LinearLayout> |
||||
</RelativeLayout> |
|
||||
|
</ScrollView> |
||||
@ -0,0 +1,35 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="match_parent" |
||||
|
android:orientation="vertical"> |
||||
|
<TextView |
||||
|
android:id="@+id/tv_num" |
||||
|
android:textSize="@dimen/dp_40" |
||||
|
android:layout_gravity="center" |
||||
|
android:gravity="center" |
||||
|
android:hint="0.0" |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:padding="@dimen/dp_20"/> |
||||
|
<TextView |
||||
|
android:id="@+id/tv_hint" |
||||
|
android:textSize="@dimen/dp_20" |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_gravity="center" |
||||
|
android:gravity="center" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:padding="@dimen/dp_20" |
||||
|
android:hint="等待地磅" |
||||
|
android:textColor="@color/color_4476f0" /> |
||||
|
<TextView |
||||
|
android:id="@+id/tv_ic_card" |
||||
|
android:textSize="@dimen/dp_20" |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_gravity="center" |
||||
|
android:gravity="center" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:padding="@dimen/dp_20" |
||||
|
android:hint="用户信息" |
||||
|
android:textColor="@color/color_4476f0" /> |
||||
|
</LinearLayout> |
||||
@ -0,0 +1,16 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
|
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
|
xmlns:tools="http://schemas.android.com/tools" |
||||
|
android:layout_width="match_parent" |
||||
|
android:orientation="vertical" |
||||
|
android:gravity="center" |
||||
|
android:layout_height="match_parent" |
||||
|
tools:context="com.jda.app.main.view.activity.PrinterTestActivity"> |
||||
|
<Button |
||||
|
android:id="@+id/bt" |
||||
|
android:text="打印" |
||||
|
android:layout_width="wrap_content" |
||||
|
android:layout_height="wrap_content"/> |
||||
|
|
||||
|
</LinearLayout> |
||||
@ -0,0 +1,10 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:orientation="vertical"> |
||||
|
<TextView |
||||
|
android:id="@+id/tv_info" |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="wrap_content"/> |
||||
|
</LinearLayout> |
||||
Write
Preview
Loading…
Cancel
Save