|
|
@@ -0,0 +1,391 @@
|
|
|
+package com.uas.yuejiahong.activity;
|
|
|
+
|
|
|
+import android.content.Intent;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.support.v4.app.Fragment;
|
|
|
+import android.util.Log;
|
|
|
+import android.view.KeyEvent;
|
|
|
+import android.view.View;
|
|
|
+import android.view.WindowManager;
|
|
|
+import android.widget.Button;
|
|
|
+import android.widget.ImageView;
|
|
|
+import android.widget.RelativeLayout;
|
|
|
+import android.widget.TextView;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.android.volley.Request;
|
|
|
+import com.android.volley.toolbox.StringRequest;
|
|
|
+import com.uas.yuejiahong.R;
|
|
|
+import com.uas.yuejiahong.bean.StorageInBillBean;
|
|
|
+import com.uas.yuejiahong.fragment.BaseFragment;
|
|
|
+import com.uas.yuejiahong.fragment.IndexSettingFragment;
|
|
|
+import com.uas.yuejiahong.fragment.IndexWareHouseContentFragment;
|
|
|
+import com.uas.yuejiahong.fragment.JltStorageInFilterListFragment;
|
|
|
+import com.uas.yuejiahong.fragment.StorageInAddDetailFragment;
|
|
|
+import com.uas.yuejiahong.fragment.StorageInAddFragment;
|
|
|
+import com.uas.yuejiahong.fragment.StorageInAddListFragment;
|
|
|
+import com.uas.yuejiahong.fragment.StorageOutFilterListFragment;
|
|
|
+import com.uas.yuejiahong.global.GloableParams;
|
|
|
+import com.uas.yuejiahong.interfaces.BackHandlerInterface;
|
|
|
+import com.uas.yuejiahong.tools.DataSourceManager;
|
|
|
+import com.uas.yuejiahong.util.CameraUtil;
|
|
|
+import com.uas.yuejiahong.util.FastjsonUtil;
|
|
|
+import com.uas.yuejiahong.util.HttpCallback;
|
|
|
+import com.uas.yuejiahong.util.HttpParams;
|
|
|
+import com.uas.yuejiahong.util.VollyRequest;
|
|
|
+
|
|
|
+public class FunctionActivity extends BaseActivity implements View.OnClickListener, BackHandlerInterface {
|
|
|
+ private Button btnBack, mSearchBtn, mMoreBtn;
|
|
|
+ private TextView mSubmitBtn;
|
|
|
+ private RelativeLayout mActionBarLayout;
|
|
|
+ static TextView actionBarTextView;
|
|
|
+ private ImageView mPrintImageView, mScanImageView, mSmtQueryImageView, mListImageView;
|
|
|
+ public BaseFragment mFragment;
|
|
|
+ private StringRequest mStringRequest;
|
|
|
+
|
|
|
+ public static final String TAG_INMAKE = "inmakeFragment";
|
|
|
+ public static final String TAG_OUTMAKE = "outmakeFragment";
|
|
|
+ public static final String TAG_SCMAKE_SMT = "smtFragment";
|
|
|
+ public static final String TAG_SCMAKE_PREPARE = "scmakeFragment";
|
|
|
+ public static final String TAG_SCMAKE_FEEDER = "pfmakeFragment";
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onCreate(Bundle savedInstanceState) {
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
+ getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
|
|
|
+ setContentView(R.layout.activity_function);
|
|
|
+ //获取组件
|
|
|
+ btnBack = (Button) findViewById(R.id.btn_actionbar_withback);
|
|
|
+ mSearchBtn = (Button) findViewById(R.id.btn_actionbar_right);
|
|
|
+ mMoreBtn = (Button) findViewById(R.id.btn_actionbar_more);
|
|
|
+ mSubmitBtn = (TextView) findViewById(R.id.btn_actionbar_submit);
|
|
|
+ mPrintImageView = (ImageView) findViewById(R.id.btn_actionbar_print_iv);
|
|
|
+ mScanImageView = (ImageView) findViewById(R.id.btn_actionbar_scan_iv);
|
|
|
+ mSmtQueryImageView = (ImageView) findViewById(R.id.btn_actionbar_smt_query_iv);
|
|
|
+ mListImageView = (ImageView) findViewById(R.id.btn_actionbar_list_icon_iv);
|
|
|
+
|
|
|
+ actionBarTextView = (TextView) findViewById(R.id.tv_actionbar_withback);
|
|
|
+ mActionBarLayout = (RelativeLayout) findViewById(R.id.include_menuactionbar);
|
|
|
+
|
|
|
+ //添加监听事件
|
|
|
+ btnBack.setOnClickListener(this);
|
|
|
+
|
|
|
+ //获取用户选择的功能名称
|
|
|
+ Intent intent = getIntent();
|
|
|
+ String funName = intent.getStringExtra(DataSourceManager.KEY_GRID_ITEMNAME);
|
|
|
+ //加载对应的Fragment
|
|
|
+ //防止系统内存不足将activity回收时产生Fragment重叠的问题
|
|
|
+ if (savedInstanceState == null) {
|
|
|
+ switch (funName) {
|
|
|
+ //入库
|
|
|
+ case GloableParams.GRIDNAME_INOUT_STORAGE:
|
|
|
+// mFragment = new StorageInAddFragment();
|
|
|
+// getLastestProdinout();
|
|
|
+ mFragment = new JltStorageInFilterListFragment();
|
|
|
+ break;
|
|
|
+ //出库
|
|
|
+ case GloableParams.GRIDNAME_SHOPCONTENT:
|
|
|
+ mFragment = new StorageOutFilterListFragment();
|
|
|
+ break;
|
|
|
+ //仓库管理
|
|
|
+ case GloableParams.GRIDNAME_keg_storageR:
|
|
|
+ mFragment = new IndexWareHouseContentFragment();
|
|
|
+ break;
|
|
|
+ //设置
|
|
|
+ case GloableParams.GRIDNAME_SETTING:
|
|
|
+ mFragment = new IndexSettingFragment();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //添加Fragment
|
|
|
+ getSupportFragmentManager().beginTransaction()
|
|
|
+ .add(R.id.container_function_fragment, mFragment).commitAllowingStateLoss();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getLastestProdinout() {
|
|
|
+ progressDialog.show();
|
|
|
+ VollyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
+ new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_PDAIO_IN_GETLATESTPRODINOUT)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .tag("getlastestprodinout")
|
|
|
+ .flag(0)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ try {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ String result = o.toString();
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ boolean success = FastjsonUtil.getBoolean(resultObject, "success");
|
|
|
+ JSONObject dataObject = resultObject.getJSONObject("data");
|
|
|
+ if (success && dataObject != null) {
|
|
|
+ String pi_class = FastjsonUtil.getText(dataObject, "PI_CLASS");
|
|
|
+ String pi_whcode = FastjsonUtil.getText(dataObject, "PI_WHCODE");
|
|
|
+ String pi_cardcode = FastjsonUtil.getText(dataObject, "PI_CARDCODE");
|
|
|
+ long pi_id = FastjsonUtil.getLong(dataObject, "PI_ID");
|
|
|
+ String pi_inoutno = FastjsonUtil.getText(dataObject, "PI_INOUTNO");
|
|
|
+ String pi_status = FastjsonUtil.getText(dataObject, "PI_STATUS");
|
|
|
+ String pi_invostatus = FastjsonUtil.getText(dataObject, "PI_INVOSTATUS");
|
|
|
+
|
|
|
+ jumpToStorageInAddDetail(pi_class, pi_whcode, pi_cardcode, pi_id, pi_inoutno, pi_status, pi_invostatus, StorageInAddDetailFragment.PAGE_FUNCTION_ACTIVITY);
|
|
|
+ } else {
|
|
|
+ storageInAddFinish();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ storageInAddFinish();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ storageInAddFinish();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void jumpToStorageInAddDetail(String pi_class, String pi_whcode, String pi_cardcode, long pi_id, String pi_inoutno, String pi_status, String pi_invostatus, int whichPage) {
|
|
|
+ mFragment = new StorageInAddDetailFragment();
|
|
|
+ Bundle bundle = new Bundle();
|
|
|
+ bundle.putString("pi_class", pi_class);
|
|
|
+ bundle.putString("pi_whcode", pi_whcode);
|
|
|
+ bundle.putString("pi_cardcode", pi_cardcode);
|
|
|
+ bundle.putLong("pi_id", pi_id);
|
|
|
+ bundle.putString("pi_inoutno", pi_inoutno);
|
|
|
+ bundle.putString("pi_status", pi_status);
|
|
|
+ bundle.putString("pi_invostatus", pi_invostatus);
|
|
|
+ bundle.putInt("whichPage", whichPage);
|
|
|
+ mFragment.setArguments(bundle);
|
|
|
+ getSupportFragmentManager().beginTransaction()
|
|
|
+ .add(R.id.container_function_fragment, mFragment).commitAllowingStateLoss();
|
|
|
+
|
|
|
+ ((StorageInAddDetailFragment) mFragment).setOnStorageInAddListener(new StorageInAddDetailFragment.OnStorageInAddListener() {
|
|
|
+ @Override
|
|
|
+ public void onStorageInAdd() {
|
|
|
+ storageInAddFinish();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ if (whichPage == StorageInAddDetailFragment.PAGE_STORAGE_IN_ADD
|
|
|
+ || whichPage == StorageInAddDetailFragment.PAGE_STORAGE_IN_ADD_FINISH) {
|
|
|
+ ((StorageInAddDetailFragment) mFragment).setOnStorageInToListListener(new StorageInAddDetailFragment.OnStorageInToListListener() {
|
|
|
+ @Override
|
|
|
+ public void onStorageInToList() {
|
|
|
+ StorageInAddListFragment storageInAddListFragment = new StorageInAddListFragment();
|
|
|
+ Bundle bundle = new Bundle();
|
|
|
+ bundle.putInt("whichPage", StorageInAddListFragment.PAGE_STORAGE_ADD);
|
|
|
+ storageInAddListFragment.setArguments(bundle);
|
|
|
+ getSupportFragmentManager().beginTransaction()
|
|
|
+ .add(R.id.container_function_fragment, storageInAddListFragment).commitAllowingStateLoss();
|
|
|
+
|
|
|
+ storageInAddListFragment.setOnListSelectListener(new StorageInAddListFragment.OnListSelectListener() {
|
|
|
+ @Override
|
|
|
+ public void onListSelect(StorageInBillBean storageInBillBean) {
|
|
|
+ Fragment fragment = new StorageInAddDetailFragment();
|
|
|
+ Bundle bundle = new Bundle();
|
|
|
+ bundle.putString("pi_class", storageInBillBean.getPI_CLASS());
|
|
|
+ bundle.putString("pi_whcode", storageInBillBean.getPI_WHCODE());
|
|
|
+ bundle.putString("pi_cardcode", storageInBillBean.getPI_CARDCODE());
|
|
|
+ bundle.putLong("pi_id", storageInBillBean.getPI_ID());
|
|
|
+ bundle.putString("pi_inoutno", storageInBillBean.getPI_INOUTNO());
|
|
|
+ bundle.putString("pi_status", storageInBillBean.getPI_STATUS());
|
|
|
+ bundle.putString("pi_invostatus", storageInBillBean.getPI_INVOSTATUS());
|
|
|
+ bundle.putInt("whichPage", StorageInAddDetailFragment.PAGE_STORAGE_IN_LIST);
|
|
|
+ fragment.setArguments(bundle);
|
|
|
+ getSupportFragmentManager().beginTransaction()
|
|
|
+ .add(R.id.container_function_fragment, mFragment).commitAllowingStateLoss();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void storageInAddFinish() {
|
|
|
+ mFragment = new StorageInAddFragment();
|
|
|
+ getSupportFragmentManager().beginTransaction()
|
|
|
+ .add(R.id.container_function_fragment, mFragment).commitAllowingStateLoss();
|
|
|
+
|
|
|
+ ((StorageInAddFragment) mFragment).setOnFinishListener(new StorageInAddFragment.OnFinishListener() {
|
|
|
+ @Override
|
|
|
+ public void onFinish(String pi_class, String pi_whcode, String pi_cardcode, long pi_id, String pi_inoutno, String pi_status, String pi_invostatus) {
|
|
|
+ jumpToStorageInAddDetail(pi_class, pi_whcode, pi_cardcode, pi_id, pi_inoutno, pi_status, pi_invostatus, StorageInAddDetailFragment.PAGE_STORAGE_IN_ADD_FINISH);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initViews() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initEvents() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initDatas() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //设置Actionbar标题
|
|
|
+ public static void setTitle(String title) {
|
|
|
+ actionBarTextView.setText(title);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setActionBarVisible(boolean isVisible) {
|
|
|
+ if (isVisible) {
|
|
|
+ mActionBarLayout.setVisibility(View.VISIBLE);
|
|
|
+ } else {
|
|
|
+ mActionBarLayout.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setSearchBtnVisible(boolean isVisible) {
|
|
|
+ if (isVisible) {
|
|
|
+ mSearchBtn.setVisibility(View.VISIBLE);
|
|
|
+ } else {
|
|
|
+ mSearchBtn.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setMoreBtnVisible(boolean isVisible) {
|
|
|
+ if (isVisible) {
|
|
|
+ mMoreBtn.setVisibility(View.VISIBLE);
|
|
|
+ } else {
|
|
|
+ mMoreBtn.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setSubmitBtnVisible(boolean isVisible) {
|
|
|
+ if (isVisible) {
|
|
|
+ mSubmitBtn.setVisibility(View.VISIBLE);
|
|
|
+ } else {
|
|
|
+ mSubmitBtn.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setPrintIvVisible(boolean isVisible) {
|
|
|
+ if (isVisible) {
|
|
|
+ mPrintImageView.setVisibility(View.VISIBLE);
|
|
|
+ } else {
|
|
|
+ mPrintImageView.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setScanIvVisible(boolean isVisible) {
|
|
|
+ if (isVisible && CameraUtil.hasCamera()) {
|
|
|
+ mScanImageView.setVisibility(View.VISIBLE);
|
|
|
+ } else {
|
|
|
+ mScanImageView.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setSmtQueryIvVisible(boolean isVisible) {
|
|
|
+ if (isVisible && CameraUtil.hasCamera()) {
|
|
|
+ mSmtQueryImageView.setVisibility(View.VISIBLE);
|
|
|
+ } else {
|
|
|
+ mSmtQueryImageView.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setListIconIvVisible(boolean isVisible) {
|
|
|
+ if (isVisible) {
|
|
|
+ mListImageView.setVisibility(View.VISIBLE);
|
|
|
+ } else {
|
|
|
+ mListImageView.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ /*if (mFragment instanceof MaterialCollectionFragment) {
|
|
|
+ if (((MaterialCollectionFragment) mFragment).onFragmentBackPressed()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (mFragment instanceof IOCOutMakeMaterialOper) {
|
|
|
+ if (((IOCOutMakeMaterialOper) mFragment).onFragmentBackPressed()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (mFragment instanceof FinishedGoodsCollectFragment) {
|
|
|
+ if (((FinishedGoodsCollectFragment) mFragment).onFragmentBackPressed()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (mFragment instanceof FinishedGoodsOutCollectFragment) {
|
|
|
+ if (((FinishedGoodsOutCollectFragment) mFragment).onFragmentBackPressed()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+ if (mFragment.onFragmentBackPressed()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ backEvent();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void backEvent() {
|
|
|
+ if (getSupportFragmentManager().getBackStackEntryCount() == 0) {
|
|
|
+ finish();
|
|
|
+ } else {
|
|
|
+ getSupportFragmentManager().popBackStack();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //键盘后退
|
|
|
+ @Override
|
|
|
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
+ Log.e("Functivity", "1onKeyDown:" + keyCode);
|
|
|
+// if(keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0){
|
|
|
+// //入库单页面:重新采集:确认对话框
|
|
|
+// if(IOCInMakeMaterialFragment.CONFIRM_DIALOG_ISSHOWING){
|
|
|
+// IOCInMakeMaterialFragment.CONFIRM_DIALOG_ISSHOWING = false;
|
|
|
+// IOCInMakeMaterialFragment mFragment = (IOCInMakeMaterialFragment) getSupportFragmentManager().findFragmentByTag(TAG_INMAKE);
|
|
|
+// mFragment.closeConfirmDialog();
|
|
|
+// return true;
|
|
|
+// }
|
|
|
+// if(mFragment.POPWIN_IS_SHOWING){
|
|
|
+// Log.e("POPWIN_IS_SHOWING")
|
|
|
+// mFragment.POPWIN_IS_SHOWING = false;
|
|
|
+ if (mFragment.onKeyDown(keyCode, event)) {
|
|
|
+ Log.e("FunctionActivity", "onKeydown is true");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+// return true;
|
|
|
+// }
|
|
|
+// }
|
|
|
+ Log.e("FunctionActivity", "onKeydown is false");
|
|
|
+ return super.onKeyDown(keyCode, event);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onBackPressed() {
|
|
|
+ /*if ((mFragment instanceof MaterialCollectionFragment) && ((MaterialCollectionFragment) mFragment).onFragmentBackPressed()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if ((mFragment instanceof IOCOutMakeMaterialOper) && ((IOCOutMakeMaterialOper) mFragment).onFragmentBackPressed()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if ((mFragment instanceof FinishedGoodsCollectFragment) && ((FinishedGoodsCollectFragment) mFragment).onFragmentBackPressed()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if ((mFragment instanceof FinishedGoodsOutCollectFragment) && ((FinishedGoodsOutCollectFragment) mFragment).onFragmentBackPressed()) {
|
|
|
+ return;
|
|
|
+ }*/
|
|
|
+ if (mFragment.onFragmentBackPressed()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ super.onBackPressed();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setSelectedFragment(BaseFragment baseFragment) {
|
|
|
+ mFragment = baseFragment;
|
|
|
+ }
|
|
|
+}
|