diff --git a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/Database/GSKOrangeDB.java b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/Database/GSKOrangeDB.java index 62cc6be..a2cd2d4 100644 --- a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/Database/GSKOrangeDB.java +++ b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/Database/GSKOrangeDB.java @@ -229,7 +229,7 @@ public class GSKOrangeDB extends SQLiteOpenHelper { try { - dbcursor = db.rawQuery("SELECT DISTINCT BR.BRAND_ID, SCM.SUB_CATEGORY||'-'||BR.BRAND AS BRAND FROM MAPPING_STOCK MS INNER JOIN SKU_MASTER SM ON MS.SKU_ID = SM.SKU_ID INNER JOIN BRAND_MASTER BR ON SM.BRAND_ID=BR.BRAND_ID INNER JOIN SUB_CATEGORY_MASTER SCM ON BR.SUB_CATEGORY_ID = SCM.SUB_CATEGORY_ID WHERE MS.KEYACCOUNT_ID ='"+key_account_id +"' AND STORETYPE_ID ='" + store_type_id + "' AND CLASS_ID = "+ class_id +"'",null); + dbcursor = db.rawQuery("SELECT * FROM(SELECT DISTINCT BR.BRAND_ID, SCM.SUB_CATEGORY||'-'||BR.BRAND AS BRAND FROM MAPPING_STOCK MS INNER JOIN SKU_MASTER SM ON MS.SKU_ID = SM.SKU_ID INNER JOIN BRAND_MASTER BR ON SM.BRAND_ID=BR.BRAND_ID INNER JOIN SUB_CATEGORY_MASTER SCM ON BR.SUB_CATEGORY_ID = SCM.SUB_CATEGORY_ID WHERE MS.KEYACCOUNT_ID ='"+key_account_id +"' AND STORETYPE_ID ='" + store_type_id + "' AND CLASS_ID = '"+ class_id +"') As Brand",null); if(dbcursor != null){ dbcursor.moveToFirst(); while(!dbcursor.isAfterLast()){ @@ -269,7 +269,7 @@ public class GSKOrangeDB extends SQLiteOpenHelper { try { - dbcursor = db.rawQuery("SELECT DISTINCT SM.SKU, SM.SKU_ID, BR.BRAND_ID FROM MAPPING_STOCK MS INNER JOIN SKU_MASTER SM ON MS.SKU_ID = SM.SKU_ID INNER JOIN BRAND_MASTER BR ON SM.BRAND_ID=BR.BRAND_ID INNER JOIN SUB_CATEGORY_MASTER SCM ON BR.SUB_CATEGORY_ID = SCM.SUB_CATEGORY_ID WHERE MS.KEYACCOUNT_ID ='"+key_account_id +"' AND STORETYPE_ID ='" + store_type_id + "' AND CLASS_ID = "+ class_id +"' AND SM.BRAND_ID='"+ brand_id + "'",null); + dbcursor = db.rawQuery("SELECT DISTINCT SM.SKU, SM.SKU_ID, BR.BRAND_ID FROM MAPPING_STOCK MS INNER JOIN SKU_MASTER SM ON MS.SKU_ID = SM.SKU_ID INNER JOIN BRAND_MASTER BR ON SM.BRAND_ID=BR.BRAND_ID INNER JOIN SUB_CATEGORY_MASTER SCM ON BR.SUB_CATEGORY_ID = SCM.SUB_CATEGORY_ID WHERE MS.KEYACCOUNT_ID ='"+key_account_id +"' AND STORETYPE_ID ='" + store_type_id + "' AND CLASS_ID = '"+ class_id +"' AND SM.BRAND_ID='"+ brand_id + "'",null); if(dbcursor != null){ dbcursor.moveToFirst(); while(!dbcursor.isAfterLast()){ diff --git a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/SelectLanguageActivity.java b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/SelectLanguageActivity.java index 62cb56f..b56e1a9 100644 --- a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/SelectLanguageActivity.java +++ b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/SelectLanguageActivity.java @@ -127,10 +127,10 @@ public class SelectLanguageActivity extends AppCompatActivity implements View.On String lang ; - if(language.equals("English")){ + if(language.equalsIgnoreCase("English")){ lang = "EN"; } - else if(language.equals("UAE")) { + else if(language.equalsIgnoreCase("UAE")) { lang = "AR"; } else { diff --git a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/constant/CommonString.java b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/constant/CommonString.java index 5f114c9..e04fe24 100644 --- a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/constant/CommonString.java +++ b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/constant/CommonString.java @@ -6,8 +6,7 @@ package cpm.com.gskmtorange.constant; public class CommonString { -// webservice constants - + // webservice constants // preferenec keys public static final String KEY_USERNAME = "username"; @@ -16,7 +15,6 @@ public class CommonString { public static final String KEY_STOREVISITED_STATUS = "STOREVISITED_STATUS"; - public static final String KEY_PATH = "path"; public static final String KEY_VERSION = "APP_VERSION"; diff --git a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/dailyentry/StoreListActivity.java b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/dailyentry/StoreListActivity.java index b529723..37bdf43 100644 --- a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/dailyentry/StoreListActivity.java +++ b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/dailyentry/StoreListActivity.java @@ -80,7 +80,6 @@ public class StoreListActivity extends AppCompatActivity { public void onItemClick(AdapterView parent, View view, int position, long id) { - Toast.makeText(getApplicationContext(), "Click", Toast.LENGTH_LONG).show(); } diff --git a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/dailyentry/T2PComplianceActivity.java b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/dailyentry/T2PComplianceActivity.java index 4c5ee9b..2faee48 100644 --- a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/dailyentry/T2PComplianceActivity.java +++ b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/dailyentry/T2PComplianceActivity.java @@ -1,6 +1,8 @@ package cpm.com.gskmtorange.dailyentry; +import android.app.Activity; import android.app.Dialog; +import android.content.Context; import android.graphics.drawable.ColorDrawable; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; @@ -13,19 +15,24 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.Window; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ProgressBar; +import android.widget.Spinner; import android.widget.TextView; import android.widget.ToggleButton; import java.util.ArrayList; +import java.util.List; import cpm.com.gskmtorange.Database.GSKOrangeDB; import cpm.com.gskmtorange.R; import cpm.com.gskmtorange.xmlGetterSetter.BrandMasterGetterSetter; import cpm.com.gskmtorange.xmlGetterSetter.GapsChecklistGetterSetter; +import cpm.com.gskmtorange.xmlGetterSetter.SkuGetterSetter; import cpm.com.gskmtorange.xmlGetterSetter.SkuMasterGetterSetter; import cpm.com.gskmtorange.xmlGetterSetter.T2PGetterSetter; @@ -64,7 +71,7 @@ public class T2PComplianceActivity extends AppCompatActivity { t2PGetterSetters = db.getT2PDefaultData("1"); - if(t2PGetterSetters.size()>0){ + if (t2PGetterSetters.size() > 0) { rec_t2p.setLayoutManager(new LinearLayoutManager(getApplicationContext())); t2PAdapter = new T2PAdapter(t2PGetterSetters); rec_t2p.setAdapter(t2PAdapter); @@ -98,8 +105,8 @@ public class T2PComplianceActivity extends AppCompatActivity { @Override public void onClick(View v) { - ArrayList gapsChecklist = showGapsDialog(mItem.getDisplay_id()); - if(gapsChecklist.size()>0){ + ArrayList gapsChecklist = showGapsDialog(mItem.getDisplay_id()); + if (gapsChecklist.size() > 0) { } } @@ -146,10 +153,10 @@ public class T2PComplianceActivity extends AppCompatActivity { } } - public ArrayList showGapsDialog(String display_id){ + public ArrayList showGapsDialog(String display_id) { ArrayList gapsChecklist = db.getGapsDefaultData(display_id); - Dialog dialog = new Dialog(T2PComplianceActivity.this); + final Dialog dialog = new Dialog(T2PComplianceActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); dialog.setContentView(R.layout.gaps_dialog_layout); @@ -159,23 +166,87 @@ public class T2PComplianceActivity extends AppCompatActivity { GapsAdapter gapAdapter = new GapsAdapter(gapsChecklist); rec_gap_checklist.setAdapter(gapAdapter); - //dialog.setCancelable(false); + Button btn_save = (Button) dialog.findViewById(R.id.btn_save); + btn_save.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + dialog.cancel(); + } + }); + + dialog.setCancelable(false); dialog.show(); return gapsChecklist; } - public void showSkuDialog(){ + public void showSkuDialog() { - ArrayList brandList = db.getBrandT2PData("1", "1", "1"); - // ArrayList skuMasterGetterSetterArrayList = db.getSkuT2PData("1", "1", "1",) + final ArrayList brandList = db.getBrandT2PData("1", "1", "1"); + BrandMasterGetterSetter brand = new BrandMasterGetterSetter(); + brand.setBRAND("select"); + brandList.add(0,brand); + // ArrayList skuMasterGetterSetterArrayList = db.getSkuT2PData("1", "1", "1",) - Dialog dialog = new Dialog(T2PComplianceActivity.this); + final Dialog dialog = new Dialog(T2PComplianceActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); dialog.setContentView(R.layout.t2p_sku_dialog_layout); //pb = (ProgressBar) dialog.findViewById(R.id.progressBar1); - //dialog.setCancelable(false); + //dialog.setCancelable(false); + Spinner spinner_brand = (Spinner) dialog.findViewById(R.id.spinner_brand); + final Spinner spinner_sku = (Spinner) dialog.findViewById(R.id.spinner_sku); + Button btn_add = (Button) dialog.findViewById(R.id.btn_add); + btn_add.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + dialog.cancel(); + } + }); + + // Create custom adapter object ( see below CustomAdapter.java ) + CustomAdapter adapter = new CustomAdapter(T2PComplianceActivity.this, R.layout.custom_spinner_item, brandList); + // Set adapter to spinner + spinner_brand.setAdapter(adapter); + + ArrayList empty_list = new ArrayList<>(); + SkuGetterSetter select = new SkuGetterSetter(); + select.setSKU("Select"); + empty_list.add(select); + CustomSkuAdapter skuadapter = new CustomSkuAdapter(T2PComplianceActivity.this, R.layout.custom_spinner_item, empty_list); + spinner_sku.setAdapter(skuadapter); + + + spinner_brand.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + + if(position!=0){ + + String brand_id = brandList.get(position).getBRAND_ID().get(0); + + ArrayList sku_list = db.getSkuT2PData("1", "1", "1", brand_id); + SkuGetterSetter select = new SkuGetterSetter(); + select.setSKU("Select"); + sku_list.add(0,select); + // Create custom adapter object ( see below CustomSkuAdapter.java ) + CustomSkuAdapter skuadapter = new CustomSkuAdapter(T2PComplianceActivity.this, R.layout.custom_spinner_item, sku_list); + // Set adapter to spinner + spinner_sku.setAdapter(skuadapter); + + spinner_sku.setSelection(0); + + } + } + + @Override + public void onNothingSelected(AdapterView parent) { + + } + }); + dialog.show(); } @@ -236,4 +307,129 @@ public class T2PComplianceActivity extends AppCompatActivity { } } + + public class CustomAdapter extends ArrayAdapter { + + private Activity activity; + private ArrayList data; + BrandMasterGetterSetter tempValues = null; + LayoutInflater inflater; + + /************* + * CustomAdapter Constructor + *****************/ + public CustomAdapter( + T2PComplianceActivity activitySpinner, + int textViewResourceId, + ArrayList objects + + ) { + super(activitySpinner, textViewResourceId, objects); + + /********** Take passed values **********/ + activity = activitySpinner; + data = objects; + /*********** Layout inflator to call external xml layout () **********************/ + inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + + } + + @Override + public View getDropDownView(int position, View convertView, ViewGroup parent) { + return getCustomView(position, convertView, parent); + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + return getCustomView(position, convertView, parent); + } + + // This funtion called for each row ( Called data.size() times ) + public View getCustomView(int position, View convertView, ViewGroup parent) { + + /********** Inflate spinner_rows.xml file for each row ( Defined below ) ************/ + View row = inflater.inflate(R.layout.custom_spinner_item, parent, false); + + /***** Get each Model object from Arraylist ********/ + tempValues = null; + tempValues = (BrandMasterGetterSetter) data.get(position); + + TextView label = (TextView) row.findViewById(R.id.tv_text); + + if (position == 0) { + + // Default selected Spinner item + label.setText("Select"); + //sub.setText(""); + } else { + // Set values for spinner each row + label.setText(tempValues.getBRAND().get(0)); + } + + return row; + } + } + + public class CustomSkuAdapter extends ArrayAdapter { + + private Activity activity; + private ArrayList data; + SkuGetterSetter tempValues = null; + LayoutInflater inflater; + + /************* + * CustomAdapter Constructor + *****************/ + public CustomSkuAdapter( + T2PComplianceActivity activitySpinner, + int textViewResourceId, + ArrayList objects + + ) { + super(activitySpinner, textViewResourceId, objects); + + /********** Take passed values **********/ + activity = activitySpinner; + data = objects; + /*********** Layout inflator to call external xml layout () **********************/ + inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + + } + + @Override + public View getDropDownView(int position, View convertView, ViewGroup parent) { + return getCustomView(position, convertView, parent); + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + return getCustomView(position, convertView, parent); + } + + // This funtion called for each row ( Called data.size() times ) + public View getCustomView(int position, View convertView, ViewGroup parent) { + + /********** Inflate spinner_rows.xml file for each row ( Defined below ) ************/ + View row = inflater.inflate(R.layout.custom_spinner_item, parent, false); + + /***** Get each Model object from Arraylist ********/ + tempValues = null; + tempValues = (SkuGetterSetter) data.get(position); + + TextView label = (TextView) row.findViewById(R.id.tv_text); + + if (position == 0) { + + // Default selected Spinner item + label.setText("Select"); + //sub.setText(""); + } else { + // Set values for spinner each row + label.setText(tempValues.getSKU()); + } + + return row; + } + } + } diff --git a/GSKMTOrange/src/main/res/layout/custom_spinner_item.xml b/GSKMTOrange/src/main/res/layout/custom_spinner_item.xml new file mode 100644 index 0000000..2b9500b --- /dev/null +++ b/GSKMTOrange/src/main/res/layout/custom_spinner_item.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/GSKMTOrange/src/main/res/layout/gap_checklist_item.xml b/GSKMTOrange/src/main/res/layout/gap_checklist_item.xml index 7cd357b..0d12fc0 100644 --- a/GSKMTOrange/src/main/res/layout/gap_checklist_item.xml +++ b/GSKMTOrange/src/main/res/layout/gap_checklist_item.xml @@ -17,6 +17,7 @@ >