From c10d4013549a3e89af50e5b7eac6d5e63435e1d6 Mon Sep 17 00:00:00 2001 From: Gagan290 Date: Fri, 13 Jan 2017 15:49:51 +0530 Subject: [PATCH] Merge branch 'master' of https://github.com/CPM-INDIA-SALES-AND-MARKETING-PVT-LTD/GSKORANGEV1 into GG_Update_Manifest # Conflicts: # GSKMTOrange/src/main/AndroidManifest.xml --- .../gsk_dailyentry/Stock_FacingActivity.java | 439 +++++++++++++----- 1 file changed, 319 insertions(+), 120 deletions(-) diff --git a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/gsk_dailyentry/Stock_FacingActivity.java b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/gsk_dailyentry/Stock_FacingActivity.java index fa5688d..018f79c 100644 --- a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/gsk_dailyentry/Stock_FacingActivity.java +++ b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/gsk_dailyentry/Stock_FacingActivity.java @@ -2,6 +2,7 @@ package cpm.com.gskmtorange.gsk_dailyentry; import android.app.AlertDialog; import android.app.Dialog; +import android.content.ActivityNotFoundException; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; @@ -25,6 +26,8 @@ import android.support.design.widget.Snackbar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.CardView; import android.support.v7.widget.Toolbar; +import android.text.Editable; +import android.text.TextWatcher; import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; @@ -78,6 +81,8 @@ public class Stock_FacingActivity extends AppCompatActivity { boolean isDialogOpen = true; boolean checkflag = true; String store_id, visit_date, username, intime, date, keyAccount_id, class_id, storeType_id, camera_allow; + Uri outputFileUri = null; + String gallery_package = ""; private SharedPreferences preferences; @Override @@ -128,18 +133,18 @@ public class Stock_FacingActivity extends AppCompatActivity { if (validateData(hashMapListHeaderData, hashMapListChildData)) { AlertDialog.Builder builder = new AlertDialog.Builder(Stock_FacingActivity.this); - builder.setMessage("Are you sure you want to save") + builder.setMessage(getResources().getString(R.string.check_save_message)) .setCancelable(false) - .setPositiveButton("Yes", new DialogInterface.OnClickListener() { + .setPositiveButton(getResources().getString(R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { db.open(); if (db.checkStockAndFacingData(store_id, categoryId)) { db.updateStockAndFacing(store_id, categoryId, hashMapListHeaderData, hashMapListChildData); - Snackbar.make(view, "Data has been updated", Snackbar.LENGTH_LONG).setAction("Action", null).show(); + Snackbar.make(view, getResources().getString(R.string.update_message), Snackbar.LENGTH_LONG).setAction("Action", null).show(); } else { db.InsertStock_Facing(store_id, categoryId, hashMapListHeaderData, hashMapListChildData); - Snackbar.make(view, "Data has been saved", Snackbar.LENGTH_LONG).setAction("Action", null).show(); + Snackbar.make(view, getResources().getString(R.string.save_message), Snackbar.LENGTH_LONG).setAction("Action", null).show(); //Toast.makeText(getApplicationContext(), "Data has been saved", Toast.LENGTH_LONG).show(); } @@ -147,7 +152,7 @@ public class Stock_FacingActivity extends AppCompatActivity { overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out); } }) - .setNegativeButton("No", new DialogInterface.OnClickListener() { + .setNegativeButton(getResources().getString(R.string.no), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } @@ -156,9 +161,10 @@ public class Stock_FacingActivity extends AppCompatActivity { alert.show(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(Stock_FacingActivity.this); - builder.setMessage("Fill the value or fill 0 ") + //builder.setMessage(getResources().getString(R.string.empty_field)) + builder.setMessage(Error_Message) .setCancelable(false) - .setPositiveButton("OK", new DialogInterface.OnClickListener() { + .setPositiveButton(getResources().getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } @@ -214,6 +220,8 @@ public class Stock_FacingActivity extends AppCompatActivity { inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); getCurrentFocus().clearFocus(); } + + fab.setVisibility(View.INVISIBLE); } }); @@ -227,6 +235,8 @@ public class Stock_FacingActivity extends AppCompatActivity { inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); getCurrentFocus().clearFocus(); } + + fab.setVisibility(View.INVISIBLE); } }); @@ -289,10 +299,45 @@ public class Stock_FacingActivity extends AppCompatActivity { String stock = listDataChild.get(listDataHeader.get(i)).get(j).getStock(); String faceup = listDataChild.get(listDataHeader.get(i)).get(j).getFacing(); - //Camera allow enable - if (camera_allow.equalsIgnoreCase("1")) { + //Company_id + if (listDataChild.get(listDataHeader.get(i)).get(j).getCompany_id().equals("1")) { + //Camera allow enable + if (camera_allow.equalsIgnoreCase("1")) { - if (!imagePath.equals("") || !imagePath1.equals("")) { + if (!imagePath.equals("") || !imagePath1.equals("")) { + if (!stock.equals("0")) { + if (stock.equals("") || faceup.equals("")) { + if (!checkHeaderArray.contains(i)) { + checkHeaderArray.add(i); + } + + flag = false; + Error_Message = getResources().getString(R.string.fill_data); + break; + } + } else { + if (stock.equals("")) { + if (!checkHeaderArray.contains(i)) { + checkHeaderArray.add(i); + } + + flag = false; + Error_Message = getResources().getString(R.string.fill_data); + break; + } + } + } else { + if (!checkHeaderArray.contains(i)) { + checkHeaderArray.add(i); + } + + flag = false; + Error_Message = getResources().getString(R.string.click_image); + break; + } + + } else { + //Camera allow disable if (!stock.equals("0")) { if (stock.equals("") || faceup.equals("")) { if (!checkHeaderArray.contains(i)) { @@ -314,40 +359,17 @@ public class Stock_FacingActivity extends AppCompatActivity { break; } } - } else { + } + } else { + if (faceup.equals("")) { if (!checkHeaderArray.contains(i)) { checkHeaderArray.add(i); } flag = false; - Error_Message = "Please click either 1 image"; + Error_Message = "Please fill all the data"; break; } - - } else { - //Camera allow disable - if (!stock.equals("0")) { - if (stock.equals("") || faceup.equals("")) { - if (!checkHeaderArray.contains(i)) { - checkHeaderArray.add(i); - } - - flag = false; - Error_Message = "Please fill all the data"; - break; - } - } else { - if (stock.equals("")) { - if (!checkHeaderArray.contains(i)) { - checkHeaderArray.add(i); - } - - flag = false; - Error_Message = "Please fill all the data"; - break; - } - } - } } @@ -365,16 +387,8 @@ public class Stock_FacingActivity extends AppCompatActivity { } private void startCameraActivity1(int position) { - try { - /*Log.e("Stock and Facing ", "startCameraActivity()"); - File file = new File(path); - Uri outputFileUri = Uri.fromFile(file); - - Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); - intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); - startActivityForResult(intent, position);*/ - - Log.i("Stock & Facing ", "startCameraActivity()"); + /*try { + Log.e("Stock & Facing ", "startCameraActivity()"); File file = new File(path); Uri outputFileUri = Uri.fromFile(file); @@ -383,8 +397,8 @@ public class Stock_FacingActivity extends AppCompatActivity { List list = packageManager.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES); for (int n = 0; n < list.size(); n++) { if ((list.get(n).flags & ApplicationInfo.FLAG_SYSTEM) == 1) { - /*Log.e("TAG", "Installed Applications : " + list.get(n).loadLabel(packageManager).toString()); - Log.e("TAG", "package name : " + list.get(n).packageName);*/ + *//*Log.e("TAG", "Installed Applications : " + list.get(n).loadLabel(packageManager).toString()); + Log.e("TAG", "package name : " + list.get(n).packageName);*//* if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (list.get(n).loadLabel(packageManager).toString().equalsIgnoreCase("Camera")) { @@ -406,21 +420,58 @@ public class Stock_FacingActivity extends AppCompatActivity { startActivityForResult(intent, 1); //startActivityForResult(intent, position); + } catch (Exception e) { + e.printStackTrace(); + }*/ + + try { + Log.e("MakeMachine", "startCameraActivity()"); + File file = new File(path); + outputFileUri = Uri.fromFile(file); + + String defaultCameraPackage = ""; + final PackageManager packageManager = getPackageManager(); + List list = packageManager.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES); + for (int n = 0; n < list.size(); n++) { + if ((list.get(n).flags & ApplicationInfo.FLAG_SYSTEM) == 1) { + //Log.e("TAG", "Installed Applications : " + list.get(n).loadLabel(packageManager).toString()); + //Log.e("TAG", "package name : " + list.get(n).packageName); + + //temp value in case camera is gallery app above jellybean + if (list.get(n).loadLabel(packageManager).toString().equalsIgnoreCase("Gallery")) { + gallery_package = list.get(n).packageName; + } + if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + if (list.get(n).loadLabel(packageManager).toString().equalsIgnoreCase("Camera")) { + defaultCameraPackage = list.get(n).packageName; + break; + } + } else { + if (list.get(n).loadLabel(packageManager).toString().equalsIgnoreCase("Camera")) { + defaultCameraPackage = list.get(n).packageName; + break; + } + } + } + } + + Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); + intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); + intent.setPackage(defaultCameraPackage); + startActivityForResult(intent, 1); + } catch (ActivityNotFoundException e) { + e.printStackTrace(); + Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); + intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); + intent.setPackage(gallery_package); + startActivityForResult(intent, 1); } catch (Exception e) { e.printStackTrace(); } } private void startCameraActivity2(int position) { - try { - /*Log.e("Stock and Facing ", "startCameraActivity()"); - File file = new File(path); - Uri outputFileUri = Uri.fromFile(file); - - Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); - intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); - startActivityForResult(intent, position);*/ - + /*try { Log.i("Stock & Facing ", "startCameraActivity()"); File file = new File(path); Uri outputFileUri = Uri.fromFile(file); @@ -430,8 +481,8 @@ public class Stock_FacingActivity extends AppCompatActivity { List list = packageManager.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES); for (int n = 0; n < list.size(); n++) { if ((list.get(n).flags & ApplicationInfo.FLAG_SYSTEM) == 1) { - /*Log.e("TAG", "Installed Applications : " + list.get(n).loadLabel(packageManager).toString()); - Log.e("TAG", "package name : " + list.get(n).packageName);*/ + *//*Log.e("TAG", "Installed Applications : " + list.get(n).loadLabel(packageManager).toString()); + Log.e("TAG", "package name : " + list.get(n).packageName);*//* if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (list.get(n).loadLabel(packageManager).toString().equalsIgnoreCase("Camera")) { @@ -451,7 +502,51 @@ public class Stock_FacingActivity extends AppCompatActivity { intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); intent.setPackage(defaultCameraPackage); startActivityForResult(intent, 2); - //startActivityForResult(intent, position); + } catch (Exception e) { + e.printStackTrace(); + }*/ + + try { + Log.e("MakeMachine", "startCameraActivity()"); + File file = new File(path); + outputFileUri = Uri.fromFile(file); + + String defaultCameraPackage = ""; + final PackageManager packageManager = getPackageManager(); + List list = packageManager.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES); + for (int n = 0; n < list.size(); n++) { + if ((list.get(n).flags & ApplicationInfo.FLAG_SYSTEM) == 1) { + //Log.e("TAG", "Installed Applications : " + list.get(n).loadLabel(packageManager).toString()); + //Log.e("TAG", "package name : " + list.get(n).packageName); + + //temp value in case camera is gallery app above jellybean + if (list.get(n).loadLabel(packageManager).toString().equalsIgnoreCase("Gallery")) { + gallery_package = list.get(n).packageName; + } + if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + if (list.get(n).loadLabel(packageManager).toString().equalsIgnoreCase("Camera")) { + defaultCameraPackage = list.get(n).packageName; + break; + } + } else { + if (list.get(n).loadLabel(packageManager).toString().equalsIgnoreCase("Camera")) { + defaultCameraPackage = list.get(n).packageName; + break; + } + } + } + } + + Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); + intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); + intent.setPackage(defaultCameraPackage); + startActivityForResult(intent, 2); + } catch (ActivityNotFoundException e) { + e.printStackTrace(); + Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); + intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); + intent.setPackage(gallery_package); + startActivityForResult(intent, 2); } catch (Exception e) { e.printStackTrace(); } @@ -530,7 +625,24 @@ public class Stock_FacingActivity extends AppCompatActivity { int id = item.getItemId(); if (id == android.R.id.home) { - finish(); + android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(Stock_FacingActivity.this); + builder.setTitle(getResources().getString(R.string.dialog_title)); + builder.setMessage(getResources().getString(R.string.data_will_be_lost)).setCancelable(false) + .setPositiveButton(getResources().getString(R.string.ok), new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + + finish(); + } + }) + .setNegativeButton(getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + + } + }); + android.app.AlertDialog alert = builder.create(); + alert.show(); + //finish(); } //Planogram Dialog @@ -582,15 +694,15 @@ public class Stock_FacingActivity extends AppCompatActivity { //super.onBackPressed(); android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(Stock_FacingActivity.this); - builder.setTitle("Parinaam"); + builder.setTitle(getResources().getString(R.string.dialog_title)); builder.setMessage(getResources().getString(R.string.data_will_be_lost)).setCancelable(false) - .setPositiveButton("OK", new DialogInterface.OnClickListener() { + .setPositiveButton(getResources().getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { finish(); } }) - .setNegativeButton("Cancel ", new DialogInterface.OnClickListener() { + .setNegativeButton(getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { @@ -649,8 +761,16 @@ public class Stock_FacingActivity extends AppCompatActivity { if (headerTitle.getCompany_id().equals("1")) { txt_stockFaceupHeader.setTextColor(getResources().getColor(R.color.colorPrimaryDark)); + + txt_sosHeader.setVisibility(View.VISIBLE); + img_camera1.setVisibility(View.VISIBLE); + img_camera2.setVisibility(View.VISIBLE); } else { txt_stockFaceupHeader.setTextColor(getResources().getColor(R.color.black)); + + txt_sosHeader.setVisibility(View.GONE); + img_camera1.setVisibility(View.GONE); + img_camera2.setVisibility(View.GONE); } //Camera allow enable @@ -662,7 +782,8 @@ public class Stock_FacingActivity extends AppCompatActivity { //String date = new Date().toLocaleString().toString(); //String tempDate = new Date().toLocaleString().toString().replace(' ', '_').replace(',', '_').replace(':', '-'); - _pathforcheck = "Stock_Cam1_" + store_id + "_" + headerTitle.getBrand_id() + "_" + visit_date.replace("/", "") + "_" + getCurrentTime().replace(":", "") + ".jpg"; + _pathforcheck = "Stock_Cam1_" + store_id + "_" + headerTitle.getBrand_id() + + "_" + visit_date.replace("/", "") + "_" + getCurrentTime().replace(":", "") + ".jpg"; child_position = groupPosition; path = str + _pathforcheck; @@ -690,7 +811,8 @@ public class Stock_FacingActivity extends AppCompatActivity { //String date = new Date().toLocaleString().toString(); //String tempDate = new Date().toLocaleString().toString().replace(' ', '_').replace(',', '_').replace(':', '-'); - _pathforcheck = "Stock_Cam2_" + store_id + "_" + headerTitle.getBrand_id() + "_" + visit_date.replace("/", "") + "_" + getCurrentTime().replace(":", "") + ".jpg"; + _pathforcheck = "Stock_Cam2_" + store_id + "_" + headerTitle.getBrand_id() + + "_" + visit_date.replace("/", "") + "_" + getCurrentTime().replace(":", "") + ".jpg"; child_position = groupPosition; path = str + _pathforcheck; @@ -716,11 +838,29 @@ public class Stock_FacingActivity extends AppCompatActivity { img_camera2.setBackgroundResource(R.mipmap.camera_grey); } - if (!checkflag) { - if (checkHeaderArray.contains(groupPosition)) { - txt_stockFaceupHeader.setTextColor(getResources().getColor(android.R.color.holo_red_dark)); - } else { - txt_stockFaceupHeader.setTextColor(getResources().getColor(R.color.black)); + if (headerTitle.getCompany_id().equals("1")) { + if (!checkflag) { + if (checkHeaderArray.contains(groupPosition)) { + txt_stockFaceupHeader.setTextColor(getResources().getColor(android.R.color.holo_red_dark)); + } else { + txt_stockFaceupHeader.setTextColor(getResources().getColor(R.color.colorPrimaryDark)); + /*if (headerTitle.getCompany_id().equals("1")) { + } else { + txt_stockFaceupHeader.setTextColor(getResources().getColor(R.color.black)); + }*/ + } + } + } else { + if (!checkflag) { + if (checkHeaderArray.contains(groupPosition)) { + txt_stockFaceupHeader.setTextColor(getResources().getColor(android.R.color.holo_red_dark)); + } else { + /*if (headerTitle.getCompany_id().equals("1")) { + txt_stockFaceupHeader.setTextColor(getResources().getColor(R.color.colorPrimaryDark)); + } else {*/ + txt_stockFaceupHeader.setTextColor(getResources().getColor(R.color.black)); + //} + } } } @@ -768,8 +908,10 @@ public class Stock_FacingActivity extends AppCompatActivity { if (childData.getCompany_id().equals("1")) { holder.txt_skuName.setTextColor(getResources().getColor(R.color.colorPrimaryDark)); + holder.ed_stock.setVisibility(View.VISIBLE); } else { holder.txt_skuName.setTextColor(getResources().getColor(R.color.black)); + holder.ed_stock.setVisibility(View.GONE); } @@ -806,6 +948,43 @@ public class Stock_FacingActivity extends AppCompatActivity { } }); + /*holder.ed_stock.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + + } + + @Override + public void afterTextChanged(Editable s) { + //final EditText caption = (EditText) v; + String edStock = s.toString(); + + if (!edStock.equals("")) { + String stock = edStock.replaceFirst("^0+(?!$)", ""); + childData.setStock(stock); + + if (edStock.equals("0")) { + childData.setFacing("0"); + + finalHolder.ed_facing.setEnabled(false); + } else { + childData.setFacing(childData.getFacing()); + finalHolder.ed_facing.setEnabled(true); + } + } else { + childData.setStock(""); + finalHolder.ed_facing.setEnabled(true); + } + + expandableListView.invalidateViews(); + } + });*/ + holder.ed_stock.setText(childData.getStock()); holder.ed_facing.setOnFocusChangeListener(new View.OnFocusChangeListener() { @@ -814,44 +993,49 @@ public class Stock_FacingActivity extends AppCompatActivity { final EditText caption = (EditText) v; final String edFaceup = caption.getText().toString().replaceFirst("^0+(?!$)", ""); - if (!childData.getStock().equals("")) { - if (!edFaceup.equals("")) { - if (Integer.parseInt(edFaceup) <= Integer.parseInt(childData.getStock())) { - childData.setFacing(edFaceup); - } else { - if (isDialogOpen) { - isDialogOpen = !isDialogOpen; - AlertDialog.Builder builder = new AlertDialog.Builder(Stock_FacingActivity.this); - builder.setMessage("Faceup can not be greater than stock value") - .setCancelable(false) - .setPositiveButton("OK", new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - dialog.dismiss(); - isDialogOpen = !isDialogOpen; - } - }); - AlertDialog alert = builder.create(); - alert.show(); + if (childData.getCompany_id().equals("1")) { + if (!childData.getStock().equals("")) { + if (!edFaceup.equals("")) { + if (Integer.parseInt(edFaceup) <= Integer.parseInt(childData.getStock())) { + childData.setFacing(edFaceup); + } else { + if (isDialogOpen) { + isDialogOpen = !isDialogOpen; + AlertDialog.Builder builder = new AlertDialog.Builder(Stock_FacingActivity.this); + builder.setMessage("Faceup can not be greater than stock value") + .setCancelable(false) + .setPositiveButton("OK", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + dialog.dismiss(); + isDialogOpen = !isDialogOpen; + } + }); + AlertDialog alert = builder.create(); + alert.show(); + } } + } else { + childData.setFacing(""); } } else { - childData.setFacing(""); + if (isDialogOpen) { + isDialogOpen = !isDialogOpen; + AlertDialog.Builder builder = new AlertDialog.Builder(Stock_FacingActivity.this); + builder.setMessage("First fill the stock value") + .setCancelable(false) + .setPositiveButton("OK", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + dialog.dismiss(); + isDialogOpen = !isDialogOpen; + } + }); + AlertDialog alert = builder.create(); + alert.show(); + } } } else { - if (isDialogOpen) { - isDialogOpen = !isDialogOpen; - AlertDialog.Builder builder = new AlertDialog.Builder(Stock_FacingActivity.this); - builder.setMessage("First fill the stock value") - .setCancelable(false) - .setPositiveButton("OK", new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - dialog.dismiss(); - isDialogOpen = !isDialogOpen; - } - }); - AlertDialog alert = builder.create(); - alert.show(); - } + childData.setFacing(edFaceup); + childData.setStock("0"); } } }); @@ -861,24 +1045,39 @@ public class Stock_FacingActivity extends AppCompatActivity { if (!checkflag) { boolean tempflag = false; - if (holder.ed_stock.getText().toString().equals("")) { - holder.ed_stock.setBackgroundColor(getResources().getColor(R.color.white)); - holder.ed_stock.setHintTextColor(getResources().getColor(android.R.color.holo_red_dark)); - holder.ed_stock.setHint("Empty"); - tempflag = true; - } + if (childData.getCompany_id().equals("1")) { + if (holder.ed_stock.getText().toString().equals("")) { + holder.ed_stock.setBackgroundColor(getResources().getColor(R.color.white)); + holder.ed_stock.setHintTextColor(getResources().getColor(android.R.color.holo_red_dark)); + holder.ed_stock.setHint("Empty"); + tempflag = true; + } - if (holder.ed_facing.getText().toString().equals("")) { - holder.ed_facing.setBackgroundColor(getResources().getColor(R.color.white)); - holder.ed_facing.setHintTextColor(getResources().getColor(android.R.color.holo_red_dark)); - holder.ed_facing.setHint("Empty"); - tempflag = true; - } + if (holder.ed_facing.getText().toString().equals("")) { + holder.ed_facing.setBackgroundColor(getResources().getColor(R.color.white)); + holder.ed_facing.setHintTextColor(getResources().getColor(android.R.color.holo_red_dark)); + holder.ed_facing.setHint("Empty"); + tempflag = true; + } - if (tempflag) { - holder.cardView.setCardBackgroundColor(getResources().getColor(android.R.color.holo_red_dark)); + if (tempflag) { + holder.cardView.setCardBackgroundColor(getResources().getColor(android.R.color.holo_red_dark)); + } else { + holder.cardView.setCardBackgroundColor(getResources().getColor(R.color.white)); + } } else { - holder.cardView.setCardBackgroundColor(getResources().getColor(R.color.white)); + if (holder.ed_facing.getText().toString().equals("")) { + holder.ed_facing.setBackgroundColor(getResources().getColor(R.color.white)); + holder.ed_facing.setHintTextColor(getResources().getColor(android.R.color.holo_red_dark)); + holder.ed_facing.setHint("Empty"); + tempflag = true; + } + + if (tempflag) { + holder.cardView.setCardBackgroundColor(getResources().getColor(android.R.color.holo_red_dark)); + } else { + holder.cardView.setCardBackgroundColor(getResources().getColor(R.color.white)); + } } }