Browse Source

选择养殖场 重新写升级

master
lh 8 years ago
parent
commit
15ea2ab093
8 changed files with 246 additions and 3 deletions
  1. +1
    -1
      app/build.gradle
  2. +26
    -0
      app/src/main/java/com/qhclh/ytzh/bean/BreedBean.java
  3. +68
    -0
      app/src/main/java/com/qhclh/ytzh/work/scan/BreedAdapter.java
  4. +95
    -2
      app/src/main/java/com/qhclh/ytzh/work/scan/FumudaiScanResultActivity.java
  5. +10
    -0
      app/src/main/res/drawable/bg_green_normal.xml
  6. +14
    -0
      app/src/main/res/layout/item_breed.xml
  7. +31
    -0
      app/src/main/res/layout/show_breed.xml
  8. +1
    -0
      app/src/main/res/values/colors.xml

+ 1
- 1
app/build.gradle View File

@ -10,7 +10,7 @@ android {
minSdkVersion 15 minSdkVersion 15
targetSdkVersion 26 targetSdkVersion 26
versionCode 1 versionCode 1
versionName "1.1.3"
versionName "1.1.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk { ndk {


+ 26
- 0
app/src/main/java/com/qhclh/ytzh/bean/BreedBean.java View File

@ -0,0 +1,26 @@
package com.qhclh.ytzh.bean;
/**
* Created by 青花瓷 on 2018/1/23.
*/
public class BreedBean {
private long id;
private String name;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

+ 68
- 0
app/src/main/java/com/qhclh/ytzh/work/scan/BreedAdapter.java View File

@ -0,0 +1,68 @@
package com.qhclh.ytzh.work.scan;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.qhclh.ytzh.R;
import com.qhclh.ytzh.bean.BreedBean;
import java.util.List;
/**
* Created by 青花瓷 on 2018/1/23.
*/
public class BreedAdapter extends BaseAdapter {
private Context context;
private List<BreedBean> list;
private LayoutInflater layoutInflater;
public BreedAdapter(Context context, List<BreedBean> list) {
this.context = context;
this.list = list;
layoutInflater = LayoutInflater.from(context);
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int i) {
return list.get(i);
}
@Override
public long getItemId(int i) {
return list.get(i).getId();
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
ViewHolder viewHolder;
BreedBean message = list.get(i);
if (view == null){
view = layoutInflater.inflate(R.layout.item_breed,viewGroup,false);
viewHolder = new ViewHolder();
viewHolder.item_breed_name = view.findViewById(R.id.item_breed_name);
view.setTag(viewHolder);
}else {
viewHolder = (ViewHolder) view.getTag();
}
viewHolder.item_breed_name.setText(message.getName());
return view;
}
private class ViewHolder{
private TextView item_breed_name;
}
}

+ 95
- 2
app/src/main/java/com/qhclh/ytzh/work/scan/FumudaiScanResultActivity.java View File

@ -1,16 +1,25 @@
package com.qhclh.ytzh.work.scan; package com.qhclh.ytzh.work.scan;
import android.Manifest; import android.Manifest;
import android.app.AlertDialog;
import android.content.Intent; import android.content.Intent;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView;
import com.google.zxing.integration.android.IntentIntegrator; import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult; import com.google.zxing.integration.android.IntentResult;
import com.qhclh.ytzh.R; import com.qhclh.ytzh.R;
import com.qhclh.ytzh.base.BaseActivity; import com.qhclh.ytzh.base.BaseActivity;
import com.qhclh.ytzh.bean.BreedBean;
import com.qhclh.ytzh.bean.ScanBean; import com.qhclh.ytzh.bean.ScanBean;
import com.qhclh.ytzh.home.RpcUrl; import com.qhclh.ytzh.home.RpcUrl;
import com.qhclh.ytzh.tasks.ViewOnClickTask; import com.qhclh.ytzh.tasks.ViewOnClickTask;
@ -75,13 +84,51 @@ public class FumudaiScanResultActivity extends BaseActivity {
} }
} }
private List<String> farmnameList = new ArrayList<>();
private List<String> farmidList= new ArrayList<>();
private List<BreedBean> breedList = new ArrayList<>();
private void getBreed(final String breedname) {
ViewOnClickTask farmTask = new ViewOnClickTask(this,"加载中...") {
List<RpcObject> rpcobj;
@Override
protected void successUI() {
int size = rpcobj.size();
farmnameList.clear();
farmidList.clear();
breedList.clear();
for (int i=0;i<size;i++){
farmnameList.add(rpcobj.get(i).getString("Item2"));
farmidList.add(rpcobj.get(i).getString("Item1"));
BreedBean breed = new BreedBean();
breed.setId(Long.parseLong(rpcobj.get(i).getString("Item1")));
breed.setName(rpcobj.get(i).getString("Item2"));
breedList.add(breed);
}
showDialogB();
}
@Override
public Object call() throws Exception {
JsonRpcResult result = RpcFacade.rpcCall(RpcUrl.GetChoiceBoxWords,"B3ProduceUnitedInfos_养殖场",breedname,"");
rpcobj = result.getRpcObjectList(RpcUrl.GetChoiceBoxWords_fanhui);
return null;
}
};
farmTask.execute();
}
private RpcObject rpcObj; private RpcObject rpcObj;
private void getactive() { private void getactive() {
ViewOnClickTask getactiveTask = new ViewOnClickTask(this,"加载中...") { ViewOnClickTask getactiveTask = new ViewOnClickTask(this,"加载中...") {
@Override @Override
protected void successUI() { protected void successUI() {
dongtaiQuanxian();
if (rpcObj == null){
getBreed("");
}else {
dongtaiQuanxian();
}
} }
@Override @Override
@ -132,6 +179,52 @@ public class FumudaiScanResultActivity extends BaseActivity {
integrator.initiateScan(); integrator.initiateScan();
} }
private EditText edit_search_breed;
private AlertDialog alertDialog;
private String breedname;
private long breedid;
private void showDialogB() {
AlertDialog.Builder builder;
LayoutInflater inflater = (LayoutInflater) FumudaiScanResultActivity.this.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.show_breed, (ViewGroup) findViewById(R.id.layout_view));
ListView myListView = (ListView) layout.findViewById(R.id.show_list_breed);
edit_search_breed = (EditText) layout.findViewById(R.id.edit_search_breed);
BreedAdapter adapter = new BreedAdapter(this,breedList);
myListView.setAdapter(adapter);
///< edittext搜索
edit_search_breed.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
if (i == EditorInfo.IME_ACTION_DONE || (keyEvent != null && keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
breedname = textView.getText().toString();
if (breedname.equals("")) {
}
getBreed(breedname);
return true;
}
return false;
}
});
myListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
breedid=l;
showToast("已经选择了"+farmnameList.get(i));
alertDialog.dismiss();
dongtaiQuanxian();
}
});
builder = new AlertDialog.Builder(this);
builder.setView(layout);
alertDialog = builder.create();
alertDialog.show();
}
///< 回调获取扫描得到的条码值 ///< 回调获取扫描得到的条码值
@Override @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) { public void onActivityResult(int requestCode, int resultCode, Intent data) {
@ -224,7 +317,7 @@ public class FumudaiScanResultActivity extends BaseActivity {
@Override @Override
public Object call() throws Exception { public Object call() throws Exception {
JsonRpcResult result = RpcFacade.rpcCall(RpcUrl.ChickTransportLogRpc_LeaveHatchery,scanStr);
JsonRpcResult result = RpcFacade.rpcCall(RpcUrl.ChickTransportLogRpc_LeaveHatchery,scanStr,breedid);
rpcObj = result.getRpcObject(RpcUrl.ChickTransportLogRpc_fanhui); rpcObj = result.getRpcObject(RpcUrl.ChickTransportLogRpc_fanhui);
return null; return null;
} }


+ 10
- 0
app/src/main/res/drawable/bg_green_normal.xml View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!--<solid android:color="@color/green_2eab71_90"/>-->
<corners android:radius="@dimen/px_8"/>
<stroke
android:width="@dimen/dp_1"
android:color="@color/green_2eab71_90"/>
</shape>

+ 14
- 0
app/src/main/res/layout/item_breed.xml View File

@ -0,0 +1,14 @@
<?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/item_breed_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/dp_6"
android:textSize="@dimen/text_size_16" />
</LinearLayout>

+ 31
- 0
app/src/main/res/layout/show_breed.xml View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:id="@+id/layout_view"
android:padding="@dimen/dp_10"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="请选择养殖场"
android:textColor="@color/black"
android:textSize="@dimen/text_size_18"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/edit_search_breed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionDone"
android:background="@drawable/bg_green_normal"
android:hint="请输入养殖场进行搜索"
android:maxLines="1"
android:inputType="text"
android:padding="10dp" />
<ListView
android:id="@+id/show_list_breed"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
</LinearLayout>

+ 1
- 0
app/src/main/res/values/colors.xml View File

@ -40,4 +40,5 @@
<color name="greydp">#dbdbdb</color> <color name="greydp">#dbdbdb</color>
<color name="blue05b0f9">#05b0f9</color> <color name="blue05b0f9">#05b0f9</color>
<color name="green_2eab71_90">#E62eab71</color>
</resources> </resources>

Loading…
Cancel
Save