|
|
|
@ -1,17 +1,36 @@ |
|
|
|
package com.qhclh.ytzh.work.carsmannage; |
|
|
|
|
|
|
|
import android.support.v4.app.FragmentTransaction; |
|
|
|
import android.support.v7.app.AlertDialog; |
|
|
|
import android.support.v7.widget.Toolbar; |
|
|
|
import android.view.KeyEvent; |
|
|
|
import android.view.LayoutInflater; |
|
|
|
import android.view.Menu; |
|
|
|
import android.view.MenuItem; |
|
|
|
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.TextView; |
|
|
|
|
|
|
|
import com.qhclh.ytzh.R; |
|
|
|
import com.qhclh.ytzh.bean.BreedBean; |
|
|
|
import com.qhclh.ytzh.home.RpcUrl; |
|
|
|
import com.qhclh.ytzh.tasks.ViewOnClickTask; |
|
|
|
import com.qhclh.ytzh.ui.CalendarDialogFragment; |
|
|
|
import com.qhclh.ytzh.utils.DateTimeUtil; |
|
|
|
import com.qhclh.ytzh.work.scan.BreedAdapter; |
|
|
|
|
|
|
|
import org.forks.jsonrpc.JsonRpcResult; |
|
|
|
import org.forks.jsonrpc.RpcFacade; |
|
|
|
import org.forks.jsonrpc.RpcObject; |
|
|
|
import org.greenrobot.eventbus.EventBus; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import butterknife.BindView; |
|
|
|
import butterknife.OnClick; |
|
|
|
@ -120,13 +139,13 @@ public class FumudaiCarsManageActivity extends BaseActivity1 implements Calendar |
|
|
|
|
|
|
|
|
|
|
|
private void clearAllTabState() { |
|
|
|
///< 首页 |
|
|
|
///< 鸡苗 |
|
|
|
chicks.setTextColor(this.getResources().getColor(R.color.grey666666)); |
|
|
|
chicks.setBackgroundColor(this.getResources().getColor(R.color.white)); |
|
|
|
///< 工作 |
|
|
|
///< 毛鸡 |
|
|
|
GrossChicken.setTextColor(this.getResources().getColor(R.color.grey666666)); |
|
|
|
GrossChicken.setBackgroundColor(this.getResources().getColor(R.color.white)); |
|
|
|
///< 我的 |
|
|
|
///< 饲料 |
|
|
|
feed.setTextColor(this.getResources().getColor(R.color.grey666666)); |
|
|
|
feed.setBackgroundColor(this.getResources().getColor(R.color.white)); |
|
|
|
|
|
|
|
@ -196,17 +215,155 @@ public class FumudaiCarsManageActivity extends BaseActivity1 implements Calendar |
|
|
|
case R.id.sc_time: |
|
|
|
new CalendarDialogFragment().show(getSupportFragmentManager(), "start"); |
|
|
|
break; |
|
|
|
case R.id.sc_driver: |
|
|
|
getDriver(""); |
|
|
|
break; |
|
|
|
case R.id.sc_factry: |
|
|
|
getFactry(""); |
|
|
|
break; |
|
|
|
} |
|
|
|
return super.onOptionsItemSelected(item); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onStartCalendarClick(Date date) { |
|
|
|
showToast(DateTimeUtil.FormatDate(date)); |
|
|
|
// showToast(DateTimeUtil.FormatDate(date)); |
|
|
|
EventBus.getDefault().post(new TimeEvent(date.getTime())); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onEndCalendarClick(Date date) { |
|
|
|
showToast(DateTimeUtil.FormatDate(date)); |
|
|
|
} |
|
|
|
|
|
|
|
private void getDriver(final String s) { |
|
|
|
ViewOnClickTask driverTask = new ViewOnClickTask(this,"加载中...") { |
|
|
|
List<RpcObject> rpcobj; |
|
|
|
@Override |
|
|
|
protected void successUI() { |
|
|
|
int size = rpcobj.size(); |
|
|
|
farmnameList.clear(); |
|
|
|
farmidList.clear(); |
|
|
|
breedList.clear(); |
|
|
|
|
|
|
|
if("".equals(s)) { |
|
|
|
BreedBean first = new BreedBean(); |
|
|
|
first.setId(0); |
|
|
|
first.setName("自己"); |
|
|
|
breedList.add(first); |
|
|
|
} |
|
|
|
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(0); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Object call() throws Exception { |
|
|
|
JsonRpcResult result = RpcFacade.rpcCall(RpcUrl.GetChoiceBoxWords,"B3ProduceUnitedInfos_司机",s,""); |
|
|
|
rpcobj = result.getRpcObjectList(RpcUrl.GetChoiceBoxWords_fanhui); |
|
|
|
return null; |
|
|
|
} |
|
|
|
}; |
|
|
|
driverTask.execute(); |
|
|
|
} |
|
|
|
|
|
|
|
private List<String> farmnameList = new ArrayList<>(); |
|
|
|
private List<String> farmidList= new ArrayList<>(); |
|
|
|
private List<BreedBean> breedList = new ArrayList<>(); |
|
|
|
private void getFactry(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(); |
|
|
|
|
|
|
|
if ("".equals(_breedname)) { |
|
|
|
BreedBean first = new BreedBean(); |
|
|
|
first.setId(0); |
|
|
|
first.setName("全部"); |
|
|
|
breedList.add(first); |
|
|
|
} |
|
|
|
|
|
|
|
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(1); |
|
|
|
} |
|
|
|
|
|
|
|
@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 EditText edit_search_breed; |
|
|
|
private String breedname; |
|
|
|
private AlertDialog alertDialog; |
|
|
|
private void showDialogB(final int which) { |
|
|
|
AlertDialog.Builder builder; |
|
|
|
LayoutInflater inflater = (LayoutInflater) FumudaiCarsManageActivity.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("")) { |
|
|
|
} |
|
|
|
if (which ==0){ |
|
|
|
getDriver(breedname); |
|
|
|
}else if (which == 1){ |
|
|
|
getFactry(breedname); |
|
|
|
} |
|
|
|
alertDialog.dismiss(); |
|
|
|
return true; |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
myListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { |
|
|
|
@Override |
|
|
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { |
|
|
|
if (which ==0){ |
|
|
|
EventBus.getDefault().post(new UseridBean(l)); |
|
|
|
}else if (which == 1){ |
|
|
|
EventBus.getDefault().post(new FactryidBean(l)); |
|
|
|
} |
|
|
|
|
|
|
|
alertDialog.dismiss(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
builder = new AlertDialog.Builder(this); |
|
|
|
builder.setView(layout); |
|
|
|
alertDialog = builder.create(); |
|
|
|
alertDialog.show(); |
|
|
|
|
|
|
|
} |
|
|
|
} |