@@ -7,6 +7,7 @@ import androidx.viewpager.widget.ViewPager; | |||||
import android.os.Bundle; | import android.os.Bundle; | ||||
import android.text.Editable; | import android.text.Editable; | ||||
import android.text.InputType; | |||||
import android.text.TextWatcher; | import android.text.TextWatcher; | ||||
import android.util.Log; | import android.util.Log; | ||||
import android.view.KeyEvent; | import android.view.KeyEvent; | ||||
@@ -40,6 +41,7 @@ import com.bonait.bnframework.modules.home.fragment.MakeGoodFragment; | |||||
import com.bonait.bnframework.modules.home.fragment.SheZhifragment; | import com.bonait.bnframework.modules.home.fragment.SheZhifragment; | ||||
import com.bonait.bnframework.modules.home.fragment.mode.SerialInter; | import com.bonait.bnframework.modules.home.fragment.mode.SerialInter; | ||||
import com.bonait.bnframework.modules.home.fragment.mode.SerialManage; | import com.bonait.bnframework.modules.home.fragment.mode.SerialManage; | ||||
import com.bonait.bnframework.modules.home.fragment.mode.ShaomaTest; | |||||
import com.bonait.bnframework.modules.mine.fragment.MyFragment; | import com.bonait.bnframework.modules.mine.fragment.MyFragment; | ||||
import com.bumptech.glide.Glide; | import com.bumptech.glide.Glide; | ||||
import com.qmuiteam.qmui.widget.QMUIViewPager; | import com.qmuiteam.qmui.widget.QMUIViewPager; | ||||
@@ -58,8 +60,7 @@ public class BottomNavigationMainActivity extends BaseActivity{ | |||||
@BindView(R.id.viewpager) | @BindView(R.id.viewpager) | ||||
QMUIViewPager viewPager; | QMUIViewPager viewPager; | ||||
@BindView(R.id.Test_res) | |||||
EditText shaoma_Text; | |||||
@Override | @Override | ||||
protected void onCreate(Bundle savedInstanceState) { | protected void onCreate(Bundle savedInstanceState) { | ||||
@@ -78,11 +79,14 @@ public class BottomNavigationMainActivity extends BaseActivity{ | |||||
initFragment(); | initFragment(); | ||||
Init(); | Init(); | ||||
shaoma_Text.requestFocus(); | |||||
/* shaoma_Text.requestFocus(); | |||||
shaoma_Text.setInputType(InputType.TYPE_NULL); | |||||
shaoma_Text.setOnFocusChangeListener(new View.OnFocusChangeListener() { | shaoma_Text.setOnFocusChangeListener(new View.OnFocusChangeListener() { | ||||
@Override | @Override | ||||
public void onFocusChange(View v, boolean hasFocus) { | public void onFocusChange(View v, boolean hasFocus) { | ||||
if (hasFocus) { | if (hasFocus) { | ||||
shaoma_Text.setInputType(InputType.TYPE_NULL); | |||||
} else { | } else { | ||||
shaoma_Text.clearFocus(); | shaoma_Text.clearFocus(); | ||||
shaoma_Text.requestFocus(); | shaoma_Text.requestFocus(); | ||||
@@ -100,9 +104,11 @@ public class BottomNavigationMainActivity extends BaseActivity{ | |||||
MakeGoodFragment makeGoodFragment=(MakeGoodFragment) fragmentList.get(2); | MakeGoodFragment makeGoodFragment=(MakeGoodFragment) fragmentList.get(2); | ||||
makeGoodFragment.RecipeRun(msg); | makeGoodFragment.RecipeRun(msg); | ||||
} | } | ||||
/*RecipeRun(msg);*/ | |||||
} | } | ||||
shaoma_Text.setText(""); | shaoma_Text.setText(""); | ||||
shaoma_Text.clearFocus(); | |||||
shaoma_Text.setInputType(InputType.TYPE_CLASS_TEXT); | |||||
shaoma_Text.requestFocus(); | |||||
} | } | ||||
return false; | return false; | ||||
@@ -122,7 +128,7 @@ public class BottomNavigationMainActivity extends BaseActivity{ | |||||
public void afterTextChanged(Editable s) { | public void afterTextChanged(Editable s) { | ||||
im.hideSoftInputFromWindow(shaoma_Text.getWindowToken(), 0); | im.hideSoftInputFromWindow(shaoma_Text.getWindowToken(), 0); | ||||
} | } | ||||
}); | |||||
});*/ | |||||
} | } | ||||
@@ -84,6 +84,8 @@ import com.bonait.bnframework.modules.home.adapter.loadinggood_adapter; | |||||
import com.bonait.bnframework.modules.home.adapter.wl_adapter; | import com.bonait.bnframework.modules.home.adapter.wl_adapter; | ||||
import com.bonait.bnframework.modules.home.fragment.mode.SerialInter; | import com.bonait.bnframework.modules.home.fragment.mode.SerialInter; | ||||
import com.bonait.bnframework.modules.home.fragment.mode.SerialManage; | import com.bonait.bnframework.modules.home.fragment.mode.SerialManage; | ||||
import com.bonait.bnframework.modules.home.fragment.mode.SerialPortRead; | |||||
import com.bonait.bnframework.modules.home.fragment.mode.ShaoMaSave; | |||||
import com.bonait.bnframework.modules.home.fragment.mode.ShaomaTest; | import com.bonait.bnframework.modules.home.fragment.mode.ShaomaTest; | ||||
import com.bonait.bnframework.modules.home.fragment.mode.add_makegood_control; | import com.bonait.bnframework.modules.home.fragment.mode.add_makegood_control; | ||||
import com.bonait.bnframework.modules.home.fragment.mode.add_manguan_control; | import com.bonait.bnframework.modules.home.fragment.mode.add_manguan_control; | ||||
@@ -169,17 +171,7 @@ public class MakeGoodFragment extends BaseFragment { | |||||
RelativeLayout loadgoodliebiao; | RelativeLayout loadgoodliebiao; | ||||
/** | |||||
* 获取扫码内容 | |||||
*/ | |||||
@BindView(R.id.res_text) | |||||
EditText shaoma_Text; | |||||
/** | |||||
* 扫码界面展示 | |||||
*/ | |||||
@BindView(R.id.shaoma_view) | |||||
RelativeLayout shaoma_view; | |||||
private Context context; | private Context context; | ||||
@@ -205,7 +197,6 @@ public class MakeGoodFragment extends BaseFragment { | |||||
Initdata(); | Initdata(); | ||||
Run(); | Run(); | ||||
/*ShaomaTest.Getinstance().Open(activity,this.context);*/ | /*ShaomaTest.Getinstance().Open(activity,this.context);*/ | ||||
/* SerialManage.GetInstance().init(new SerialInter() { | /* SerialManage.GetInstance().init(new SerialInter() { | ||||
@Override | @Override | ||||
@@ -475,7 +466,7 @@ public class MakeGoodFragment extends BaseFragment { | |||||
}; | }; | ||||
} | } | ||||
@OnClick({R.id.good_gengxin, R.id.cheng_clear, R.id.loadgood,R.id.no,R.id.yes}) | |||||
@OnClick({R.id.good_gengxin, R.id.cheng_clear, R.id.loadgood}) | |||||
public void onViewClicked(View view) { | public void onViewClicked(View view) { | ||||
switch (view.getId()) { | switch (view.getId()) { | ||||
case R.id.good_gengxin://刷新 | case R.id.good_gengxin://刷新 | ||||
@@ -501,10 +492,6 @@ public class MakeGoodFragment extends BaseFragment { | |||||
loadgoodliebiao.setVisibility(View.VISIBLE); | loadgoodliebiao.setVisibility(View.VISIBLE); | ||||
} | } | ||||
break; | break; | ||||
case R.id.yes: | |||||
shaoma_view.setVisibility(View.INVISIBLE); | |||||
case R.id.no: | |||||
shaoma_view.setVisibility(View.INVISIBLE); | |||||
} | } | ||||
} | } | ||||
@@ -0,0 +1,65 @@ | |||||
package com.bonait.bnframework.modules.home.fragment.mode; | |||||
import android.serialport.SerialPort; | |||||
import android.util.Log; | |||||
import org.apache.commons.codec.binary.Hex; | |||||
import java.io.BufferedInputStream; | |||||
import java.io.InputStream; | |||||
import java.math.BigInteger; | |||||
import java.nio.charset.StandardCharsets; | |||||
public class SerialPortRead { | |||||
private volatile static SerialPortRead _instance; | |||||
public static SerialPortRead Getinstance(){ | |||||
if (_instance==null){ | |||||
_instance = new SerialPortRead(); | |||||
} | |||||
return _instance; | |||||
} | |||||
public void Open(String path,int baudrate){ | |||||
try{ | |||||
SerialPort sp = SerialPort.newBuilder(path,baudrate) | |||||
.dataBits(8) | |||||
.stopBits(1) | |||||
.parity(0) | |||||
.build(); | |||||
InputStream inputStream = sp.getInputStream(); | |||||
new Thread(new Runnable() { | |||||
@Override | |||||
public void run() { | |||||
try{ | |||||
while (true){ | |||||
byte[] bytes = new byte[5]; | |||||
String myString =""; | |||||
int size = inputStream.read(bytes); | |||||
if (size>0) | |||||
Log.e("ceshi",Integer.toHexString(size)); | |||||
} | |||||
}catch (Exception e){ | |||||
} | |||||
} | |||||
}).start(); | |||||
}catch (Exception e){ | |||||
} | |||||
} | |||||
public String toHexString(byte[] bytes){ | |||||
String HexString=""; | |||||
for(byte b:bytes){ | |||||
HexString += String.format("%02x",b); | |||||
} | |||||
return HexString; | |||||
} | |||||
} |
@@ -98,8 +98,8 @@ public class ShaoMaSave implements Runnable{ | |||||
while (this.isRead){ | while (this.isRead){ | ||||
if (Thread.currentThread().isInterrupted()) continue; | if (Thread.currentThread().isInterrupted()) continue; | ||||
try{ | try{ | ||||
/*int available = inputStream.available(); | |||||
if (available == 0) continue;*/ | |||||
int available = inputStream.available(); | |||||
if (available == 0) continue; | |||||
if (inputStream == null) continue; | if (inputStream == null) continue; | ||||
byte[] received = new byte[1]; | byte[] received = new byte[1]; | ||||
String x=""; | String x=""; | ||||
@@ -77,31 +77,6 @@ | |||||
android:textStyle="bold|italic" /> | android:textStyle="bold|italic" /> | ||||
</RelativeLayout> | </RelativeLayout> | ||||
</LinearLayout> | </LinearLayout> | ||||
<LinearLayout | |||||
android:layout_width="260dp" | |||||
android:layout_height="50dp" | |||||
android:visibility="invisible" | |||||
android:orientation="horizontal" | |||||
android:gravity="center"> | |||||
<TextView | |||||
android:layout_width="wrap_content" | |||||
android:layout_weight="1" | |||||
android:layout_height="wrap_content" | |||||
android:text="扫码编号:" | |||||
android:gravity="right"/> | |||||
<EditText | |||||
android:layout_width="wrap_content" | |||||
android:layout_weight="1" | |||||
android:layout_height="wrap_content" | |||||
android:gravity="left" | |||||
android:textSize="18dp" | |||||
android:focusable="true" | |||||
android:focusableInTouchMode="true" | |||||
android:textColor="@color/black" | |||||
android:id="@+id/Test_res"/> | |||||
</LinearLayout> | |||||
</RelativeLayout> | </RelativeLayout> | ||||
<!--水印--> | <!--水印--> | ||||
@@ -191,98 +191,5 @@ | |||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:background="@color/app_color_blue" /> | android:background="@color/app_color_blue" /> | ||||
<RelativeLayout | |||||
android:id="@+id/shaoma_view" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:visibility="invisible" | |||||
android:background="#A5000000"> | |||||
<LinearLayout | |||||
android:layout_width="260dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_centerInParent="true" | |||||
android:layout_centerHorizontal="true" | |||||
android:layout_centerVertical="true" | |||||
android:background="@drawable/common_bg_with_radius_and_border" | |||||
android:orientation="vertical" | |||||
android:gravity="center"> | |||||
<TextView | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:gravity="center" | |||||
android:text="扫码结果" | |||||
android:layout_marginTop="20dp" | |||||
android:textColor="@color/blue" | |||||
android:textSize="20dp" | |||||
/> | |||||
<LinearLayout | |||||
android:layout_width="260dp" | |||||
android:layout_height="50dp" | |||||
android:orientation="horizontal" | |||||
android:gravity="center"> | |||||
<TextView | |||||
android:layout_width="wrap_content" | |||||
android:layout_weight="1" | |||||
android:layout_height="wrap_content" | |||||
android:text="扫码编号:" | |||||
android:gravity="right"/> | |||||
<EditText | |||||
android:layout_width="wrap_content" | |||||
android:layout_weight="1" | |||||
android:layout_height="wrap_content" | |||||
android:gravity="left" | |||||
android:textSize="18dp" | |||||
android:focusable="true" | |||||
android:focusableInTouchMode="true" | |||||
android:textColor="@color/black" | |||||
android:id="@+id/res_text"/> | |||||
</LinearLayout> | |||||
<View | |||||
android:layout_width="match_parent" | |||||
android:layout_height="1px" | |||||
android:layout_marginTop="15dp" | |||||
android:background="#E4E4E4" /> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="30dp" | |||||
android:orientation="horizontal"> | |||||
<Button | |||||
android:id="@+id/no" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:layout_weight="1" | |||||
android:background="@null" | |||||
android:gravity="center" | |||||
android:singleLine="true" | |||||
android:text="取消" | |||||
android:textColor="@color/colorPrimary" /> | |||||
<View | |||||
android:layout_width="1px" | |||||
android:layout_height="match_parent" | |||||
android:background="#E4E4E4" /> | |||||
<Button | |||||
android:id="@+id/yes" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:layout_weight="1" | |||||
android:background="@null" | |||||
android:gravity="center" | |||||
android:singleLine="true" | |||||
android:text="确 定" | |||||
android:textColor="@color/red_primary" /> | |||||
</LinearLayout> | |||||
</LinearLayout> | |||||
</RelativeLayout> | |||||
</com.qmuiteam.qmui.widget.QMUIWindowInsetLayout> | </com.qmuiteam.qmui.widget.QMUIWindowInsetLayout> |