Compare commits

...

2 Commits

@ -22,9 +22,10 @@
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/activity_sign_up.xml" value="0.10235507246376811" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/buttom.xml" value="0.10235507246376811" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/fragment_my.xml" value="0.10235507246376811" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/my_fragment1.xml" value="0.2" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/my_fragment1.xml" value="0.1" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/my_fragment2.xml" value="0.18489583333333334" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/my_fragment3.xml" value="0.18489583333333334" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/pickup.xml" value="0.5" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/tab1.xml" value="0.10235507246376811" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/top.xml" value="0.3717105263157895" />
</map>

@ -29,6 +29,7 @@ android {
dependencies {
implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.logistics" >
package="com.example.logistics"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
@ -24,6 +25,10 @@
</intent-filter>
</activity>
<activity android:name=".ui.SignUpActivity" />
<activity
android:name="com.journeyapps.barcodescanner.CaptureActivity"
android:screenOrientation="portrait"
tools:replace="screenOrientation" />
</application>
</manifest>

@ -1,19 +1,31 @@
package com.example.logistics.ui;
import androidx.fragment.app.Fragment;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import com.example.logistics.R;
import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;
import com.journeyapps.barcodescanner.CaptureActivity;
public class MyFragment2 extends Fragment implements View.OnClickListener{
private Button mButton;
private Context mContext;
public MyFragment2(){
}
@ -22,13 +34,72 @@ public class MyFragment2 extends Fragment implements View.OnClickListener{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.my_fragment2,container,false);
mButton = (Button)view.findViewById(R.id.Pick_Button);
mButton.setOnClickListener(this);
return view;
}
@Override
public void onClick(View view) {
switch(view.getId()){
case R.id.Pick_Button:
new IntentIntegrator(getActivity())
.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE)// 扫码的类型,一维码,二维码,一/二维码,默认为一/二维码
.setPrompt("请对准摄像头")
.setCameraId(0)
.setBeepEnabled(false)
.setCaptureActivity(CaptureActivity.class)
.initiateScan();
}
}
@Override
@SuppressLint("MissingSuperCall")
public void onActivityResult(int requestCode, int resultCode, Intent data) {
IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
if(result != null) {
if(result.getContents() != null) {
//Toast.makeText(mContext, "Scanned: " + result.getContents(), Toast.LENGTH_LONG).show();
pickup(result.getContents());
}
}
}
public void pickup(String result){
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
View view2 = View.inflate(mContext, R.layout.pickup, null);
EditText PickUpCode = (EditText) view2.findViewById(R.id.pk_PickUp);
EditText PhoneNum = (EditText) view2.findViewById(R.id.pk_PhoneNum);
Button button = (Button) view2.findViewById(R.id.pk_button);
builder.setTitle("取件").setView(view2);
builder.create().show();
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String pickupcode = PickUpCode.getText().toString().trim();
String phonenum = PhoneNum.getText().toString().trim();
String QR_pickup = result.split(" ")[0];
String QR_phone = result.split(" ")[1];
if(pickupcode.equals(QR_pickup) && pickupcode.equals(QR_phone)){
Toast.makeText(mContext, "取件成功", Toast.LENGTH_LONG).show();
}else{
Toast.makeText(mContext, "取件失败", Toast.LENGTH_LONG).show();
}
}
});
}
}

@ -5,10 +5,22 @@
android:orientation="vertical"
android:padding="5dp">
<TextView
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="50sp"
android:text="frag2" />
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center">
<Button
android:id="@+id/Pick_Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/button_shape"
android:width="200dp"
android:height="200dp"
android:text="取件"
android:textColor="@color/white"
android:textSize="38dp"/>
</LinearLayout>
</LinearLayout>

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:layout_width="200dp"
android:layout_height="wrap_content"
android:id="@+id/pk_PickUp"
android:hint="请输入取件码"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:layout_width="200dp"
android:layout_height="wrap_content"
android:id="@+id/pk_PhoneNum"
android:hint="请输入手机尾号后四位"
/>
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="取件"
android:id="@+id/pk_button"/>
</LinearLayout>
Loading…
Cancel
Save