This commit is contained in:
Gagan290
2017-01-09 12:30:14 +05:30
parent e6b6c607b5
commit 0c30da48e7
7 changed files with 813 additions and 626 deletions
@@ -1457,8 +1457,9 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
}
public void InsertAdditionalPromoData(Promo_Compliance_DataGetterSetter data) {
ContentValues values = new ContentValues();
try {
ContentValues values = new ContentValues();
values.put("STORE_ID", Integer.parseInt(data.getStore_id()));
values.put("PROMO_ID", Integer.parseInt(data.getPromo_id()));
values.put("PROMO", data.getPromo());
@@ -1504,14 +1505,16 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
return list;
}
public void InsertPromoSkuData(ArrayList<Promo_Compliance_DataGetterSetter> promoSkuListData) {
public void InsertPromoSkuData(ArrayList<Promo_Compliance_DataGetterSetter> promoSkuListData, String category_id) {
ContentValues values = new ContentValues();
try {
db.beginTransaction();
for (int i = 0; i < promoSkuListData.size(); i++) {
Promo_Compliance_DataGetterSetter data = promoSkuListData.get(i);
values.put("STORE_ID", Integer.parseInt(data.getStore_id()));
values.put("CATEGORY_ID", Integer.parseInt(category_id));
values.put("SKU_ID", Integer.parseInt(data.getSku_id()));
values.put("SKU", data.getSku());
values.put("PROMO_ID", Integer.parseInt(data.getPromo_id()));
@@ -1529,6 +1532,41 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
}
}
public boolean checkPromoComplianceData(String store_id, String category_id) {
Log.d("PromoCompliance ", "PromoCompliance data--------------->Start<------------");
ArrayList<Promo_Compliance_DataGetterSetter> list = new ArrayList<>();
Cursor dbcursor = null;
try {
dbcursor = db.rawQuery("Select * from Promo_SKU_Data " +
"where CATEGORY_ID='" + category_id + "' and STORE_ID='" + store_id + "'", null);
if (dbcursor != null) {
if (dbcursor.moveToFirst()) {
do {
Promo_Compliance_DataGetterSetter sb = new Promo_Compliance_DataGetterSetter();
sb.setSku_id(dbcursor.getString(dbcursor.getColumnIndexOrThrow("SKU_ID")));
list.add(sb);
} while (dbcursor.moveToNext());
}
dbcursor.close();
if (list.size() > 0) {
return true;
} else {
return false;
}
}
} catch (Exception e) {
Log.d("Exception ", "when fetching Records!!!!!!!!!!!!!!!!!!!!!" + e.toString());
return false;
}
Log.d("Stock_Facing ", "midday---------------------->Stop<-----------");
return false;
}
//Gagan End Method
//Non Working data
@@ -1610,34 +1648,22 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
//Gagan start new code 1
public void updatePromoComplianceSKU(String storeId, String categoryId, List<Stock_FacingGetterSetter> hashMapListHeaderData,
HashMap<Stock_FacingGetterSetter, List<Stock_FacingGetterSetter>> hashMapListChildData) {
public void updatePromoComplianceSKU(ArrayList<Promo_Compliance_DataGetterSetter> promoSkuListData,
String categoryId, String storeId) {
ContentValues values = new ContentValues();
ContentValues values1 = new ContentValues();
try {
db.beginTransaction();
for (int i = 0; i < hashMapListHeaderData.size(); i++) {
Stock_FacingGetterSetter data1 = hashMapListHeaderData.get(i);
for (int i = 0; i < promoSkuListData.size(); i++) {
Promo_Compliance_DataGetterSetter data = promoSkuListData.get(i);
values1.put("IMAGE1", data1.getImage1());
values1.put("IMAGE2", data1.getImage2());
values.put("IN_STOCK_VALUE", Integer.parseInt(data.getIn_stock()));
values.put("PROMO_ANNOUNCER_VALUE", Integer.parseInt(data.getPromo_announcer()));
values.put("RUNNING_POS_VALUE", Integer.parseInt(data.getRunning_pos()));
//db.insert(CommonString.TABLE_INSERT_STOCK_FACING_HEADER, null, values1);
db.update(CommonString.TABLE_INSERT_STOCK_FACING_HEADER, values1,
"Category_Id='" + categoryId + "' AND Store_Id='" + storeId + "' ", null);
for (int j = 0; j < hashMapListChildData.get(hashMapListHeaderData.get(i)).size(); j++) {
Stock_FacingGetterSetter data = hashMapListChildData.get(hashMapListHeaderData.get(i)).get(j);
values.put("STOCK_VALUE", data.getStock());
values.put("FACEUP_VALUE", data.getFacing());
//db.insert(CommonString.TABLE_INSERT_STOCK_FACING_CHILD, null, values);
db.update(CommonString.TABLE_INSERT_STOCK_FACING_CHILD, values,
"Brand_Id ='" + hashMapListHeaderData.get(i).getBrand_id() + "' AND SKU_ID ='" + data.getSku_id() +
"' AND Category_Id='" + categoryId + "' AND Store_Id='" + storeId + "'", null);
}
db.update(CommonString.TABLE_INSERT_PROMO_SKU, values,
"CATEGORY_ID='" + categoryId + "' AND STORE_ID='" + storeId +
"' AND SKU_ID='" + data.getSku_id() + "' AND PROMO_ID='" + data.getPromo_id() + "'", null);
}
db.setTransactionSuccessful();
db.endTransaction();
@@ -1647,5 +1673,39 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
}
public ArrayList<Promo_Compliance_DataGetterSetter> getPromoComplianceSkuAfterData(String store_id, String category_id) {
ArrayList<Promo_Compliance_DataGetterSetter> list = new ArrayList<>();
Cursor dbcursor = null;
try {
dbcursor = db.rawQuery("Select * from Promo_SKU_Data " +
"where STORE_ID='" + store_id + "' AND CATEGORY_ID='" + category_id + "'", null);
if (dbcursor != null) {
dbcursor.moveToFirst();
while (!dbcursor.isAfterLast()) {
Promo_Compliance_DataGetterSetter cd = new Promo_Compliance_DataGetterSetter();
cd.setStore_id(dbcursor.getString(dbcursor.getColumnIndexOrThrow("STORE_ID")));
cd.setSku_id(dbcursor.getString(dbcursor.getColumnIndexOrThrow("SKU_ID")));
cd.setSku(dbcursor.getString(dbcursor.getColumnIndexOrThrow("SKU")));
cd.setPromo_id(dbcursor.getString(dbcursor.getColumnIndexOrThrow("PROMO_ID")));
cd.setPromo(dbcursor.getString(dbcursor.getColumnIndexOrThrow("PROMO")));
cd.setIn_stock(dbcursor.getString(dbcursor.getColumnIndexOrThrow("IN_STOCK_VALUE")));
cd.setPromo_announcer(dbcursor.getString(dbcursor.getColumnIndexOrThrow("PROMO_ANNOUNCER_VALUE")));
cd.setRunning_pos(dbcursor.getString(dbcursor.getColumnIndexOrThrow("RUNNING_POS_VALUE")));
list.add(cd);
dbcursor.moveToNext();
}
dbcursor.close();
return list;
}
} catch (Exception e) {
Log.d("Exception ", "getPromoComplianceSkuAfterData!" + e.toString());
return list;
}
return list;
}
//Gagan end new code 1
}
@@ -303,6 +303,9 @@ public class CommonString {
+ "STORE_ID"
+ " INTEGER,"
+ "CATEGORY_ID"
+ " INTEGER,"
+ "SKU_ID"
+ " INTEGER,"
@@ -2,7 +2,10 @@ package cpm.com.gskmtorange.gsk_dailyentry;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
@@ -20,7 +23,9 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import cpm.com.gskmtorange.Database.GSKOrangeDB;
import cpm.com.gskmtorange.R;
import cpm.com.gskmtorange.constant.CommonString;
import cpm.com.gskmtorange.dailyentry.T2PComplianceActivity;
import cpm.com.gskmtorange.xmlGetterSetter.DailyDataMenuGetterSetter;
@@ -29,26 +34,47 @@ public class DailyDataMenuActivity extends AppCompatActivity {
ArrayList<DailyDataMenuGetterSetter> categoryList;
DailyDataMenuAdapter adapter;
TextView txt_categoryName;
GSKOrangeDB db;
String categoryName = "", categoryId;
private SharedPreferences preferences;
String store_id, visit_date, username, intime, date, keyAccount_id, class_id, storeType_id;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_daily_data_menu);
try {
setContentView(R.layout.activity_daily_data_menu);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
txt_categoryName = (TextView) findViewById(R.id.txt_categoryName);
recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
txt_categoryName = (TextView) findViewById(R.id.txt_categoryName);
categoryName = getIntent().getStringExtra("categoryName");
categoryId = getIntent().getStringExtra("categoryId");
db = new GSKOrangeDB(this);
db.open();
//txt_categoryName.setText("Daily Data Menu - " + categoryName);
txt_categoryName.setText(getResources().getString(R.string.title_activity_daily_main_menu) + " - " + categoryName);
//preference data
preferences = PreferenceManager.getDefaultSharedPreferences(this);
store_id = preferences.getString(CommonString.KEY_STORE_ID, null);
visit_date = preferences.getString(CommonString.KEY_DATE, null);
date = preferences.getString(CommonString.KEY_DATE, null);
username = preferences.getString(CommonString.KEY_USERNAME, null);
intime = preferences.getString(CommonString.KEY_STORE_IN_TIME, "");
keyAccount_id = preferences.getString(CommonString.KEY_KEYACCOUNT_ID, "");
class_id = preferences.getString(CommonString.KEY_CLASS_ID, "");
storeType_id = preferences.getString(CommonString.KEY_STORETYPE_ID, "");
//Intent data
categoryName = getIntent().getStringExtra("categoryName");
categoryId = getIntent().getStringExtra("categoryId");
//txt_categoryName.setText("Daily Data Menu - " + categoryName);
txt_categoryName.setText(getResources().getString(R.string.title_activity_daily_main_menu) + " - " + categoryName);
/*FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@@ -58,59 +84,79 @@ public class DailyDataMenuActivity extends AppCompatActivity {
.setAction("Action", null).show();
}
});*/
} catch (Resources.NotFoundException e) {
e.printStackTrace();
}
}
@Override
protected void onResume() {
super.onResume();
categoryList = new ArrayList<>();
try {
categoryList = new ArrayList<>();
DailyDataMenuGetterSetter data = new DailyDataMenuGetterSetter();
//data.setCategory_name("MSL Availability");
data.setCategory_name(getResources().getString(R.string.daily_data_menu_msl_availability));
data.setCategory_img(R.mipmap.msl_availability);
categoryList.add(data);
DailyDataMenuGetterSetter data = new DailyDataMenuGetterSetter();
//data.setCategory_name("MSL Availability");
data.setCategory_name(getResources().getString(R.string.daily_data_menu_msl_availability));
if (db.checkMsl_AvailabilityData(store_id, categoryId)) {
data.setCategory_img(R.mipmap.msl_availability_done);
} else {
data.setCategory_img(R.mipmap.msl_availability);
}
categoryList.add(data);
data = new DailyDataMenuGetterSetter();
data.setCategory_name(getResources().getString(R.string.daily_data_menu_stock_facing));
//data.setCategory_name("Stock & Facing");
data.setCategory_img(R.mipmap.stock_and_facing);
categoryList.add(data);
data = new DailyDataMenuGetterSetter();
//data.setCategory_name("Stock & Facing");
data.setCategory_name(getResources().getString(R.string.daily_data_menu_stock_facing));
if (db.checkStockAndFacingData(store_id, categoryId)) {
data.setCategory_img(R.mipmap.stock_and_facing_done);
} else {
data.setCategory_img(R.mipmap.stock_and_facing);
}
categoryList.add(data);
data = new DailyDataMenuGetterSetter();
data.setCategory_name(getResources().getString(R.string.daily_data_menu_t2p));
//data.setCategory_name("T2P Compliance");
data.setCategory_img(R.mipmap.t2p_compliance);
categoryList.add(data);
data = new DailyDataMenuGetterSetter();
//data.setCategory_name("T2P Compliance");
data.setCategory_name(getResources().getString(R.string.daily_data_menu_t2p));
data.setCategory_img(R.mipmap.t2p_compliance);
categoryList.add(data);
data = new DailyDataMenuGetterSetter();
data.setCategory_name(getResources().getString(R.string.daily_data_menu_additional_visibility));
//data.setCategory_name("Additional Visibility");
data.setCategory_img(R.mipmap.additional_visibility);
categoryList.add(data);
data = new DailyDataMenuGetterSetter();
//data.setCategory_name("Additional Visibility");
data.setCategory_name(getResources().getString(R.string.daily_data_menu_additional_visibility));
data.setCategory_img(R.mipmap.additional_visibility);
categoryList.add(data);
data = new DailyDataMenuGetterSetter();
data.setCategory_name(getResources().getString(R.string.daily_data_menu_promo_compliance));
//data.setCategory_name("Promo Compliance");
data.setCategory_img(R.mipmap.promo_compliance);
categoryList.add(data);
data = new DailyDataMenuGetterSetter();
//data.setCategory_name("Promo Compliance");
data.setCategory_name(getResources().getString(R.string.daily_data_menu_promo_compliance));
if (db.checkPromoComplianceData(store_id, categoryId)) {
data.setCategory_img(R.mipmap.promo_compliance_done);
} else {
data.setCategory_img(R.mipmap.promo_compliance);
}
categoryList.add(data);
/*data = new DailyDataMenuGetterSetter();
data.setCategory_name(getResources().getString(R.string.daily_data_menu_competition_tracking));
//data.setCategory_name("Competition Tracking");
data.setCategory_img(R.drawable.category);
categoryList.add(data);
/*data = new DailyDataMenuGetterSetter();
data.setCategory_name(getResources().getString(R.string.daily_data_menu_competition_tracking));
//data.setCategory_name("Competition Tracking");
data.setCategory_img(R.drawable.category);
categoryList.add(data);
data = new DailyDataMenuGetterSetter();
data.setCategory_name(getResources().getString(R.string.daily_data_menu_additional_promotions));
//data.setCategory_name("Competition Promo");
data.setCategory_img(R.drawable.category);
categoryList.add(data);*/
data = new DailyDataMenuGetterSetter();
data.setCategory_name(getResources().getString(R.string.daily_data_menu_additional_promotions));
//data.setCategory_name("Competition Promo");
data.setCategory_img(R.drawable.category);
categoryList.add(data);*/
adapter = new DailyDataMenuAdapter(DailyDataMenuActivity.this, categoryList);
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new GridLayoutManager(getApplicationContext(), 2));
adapter = new DailyDataMenuAdapter(DailyDataMenuActivity.this, categoryList);
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new GridLayoutManager(getApplicationContext(), 2));
} catch (Resources.NotFoundException e) {
e.printStackTrace();
}
}
public class DailyDataMenuAdapter extends RecyclerView.Adapter<DailyDataMenuAdapter.MyViewHolder> {
@@ -4,6 +4,7 @@ import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.os.Bundle;
import android.preference.PreferenceManager;
@@ -60,182 +61,192 @@ public class MSL_AvailabilityActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_msl__availability);
try {
setContentView(R.layout.activity_msl__availability);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
expandableListView = (ExpandableListView) findViewById(R.id.expandableListView);
txt_mslAvailabilityName = (TextView) findViewById(R.id.txt_mslAvailabilityName);
expandableListView = (ExpandableListView) findViewById(R.id.expandableListView);
txt_mslAvailabilityName = (TextView) findViewById(R.id.txt_mslAvailabilityName);
db = new GSKOrangeDB(this);
db.open();
db = new GSKOrangeDB(this);
db.open();
//preference data
preferences = PreferenceManager.getDefaultSharedPreferences(this);
store_id = preferences.getString(CommonString.KEY_STORE_ID, null);
visit_date = preferences.getString(CommonString.KEY_DATE, null);
date = preferences.getString(CommonString.KEY_DATE, null);
username = preferences.getString(CommonString.KEY_USERNAME, null);
intime = preferences.getString(CommonString.KEY_STORE_IN_TIME, "");
keyAccount_id = preferences.getString(CommonString.KEY_KEYACCOUNT_ID, "");
class_id = preferences.getString(CommonString.KEY_CLASS_ID, "");
storeType_id = preferences.getString(CommonString.KEY_STORETYPE_ID, "");
//preference data
preferences = PreferenceManager.getDefaultSharedPreferences(this);
store_id = preferences.getString(CommonString.KEY_STORE_ID, null);
visit_date = preferences.getString(CommonString.KEY_DATE, null);
date = preferences.getString(CommonString.KEY_DATE, null);
username = preferences.getString(CommonString.KEY_USERNAME, null);
intime = preferences.getString(CommonString.KEY_STORE_IN_TIME, "");
keyAccount_id = preferences.getString(CommonString.KEY_KEYACCOUNT_ID, "");
class_id = preferences.getString(CommonString.KEY_CLASS_ID, "");
storeType_id = preferences.getString(CommonString.KEY_STORETYPE_ID, "");
//Intent data
categoryName = getIntent().getStringExtra("categoryName");
categoryId = getIntent().getStringExtra("categoryId");
//Intent data
categoryName = getIntent().getStringExtra("categoryName");
categoryId = getIntent().getStringExtra("categoryId");
//txt_mslAvailabilityName.setText(categoryName);
txt_mslAvailabilityName.setText(getResources().getString(R.string.title_activity_msl__availability));
//txt_mslAvailabilityName.setText(categoryName);
txt_mslAvailabilityName.setText(getResources().getString(R.string.title_activity_msl__availability));
prepareList();
prepareList();
final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View view) {
//if (validateData(listDataHeader, listDataChild)) {
AlertDialog.Builder builder = new AlertDialog.Builder(MSL_AvailabilityActivity.this);
builder.setMessage("Are you sure you want to save")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
db.open();
if (db.checkMsl_AvailabilityData(store_id, categoryId)) {
db.updateMSL_Availability(store_id, categoryId, hashMapListHeaderData, hashMapListChildData);
} else {
db.InsertMSL_Availability(store_id, categoryId, hashMapListHeaderData, hashMapListChildData);
}
Toast.makeText(getApplicationContext(), "Data has been saved", Toast.LENGTH_LONG).show();
finish();
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
/*} else {
//if (validateData(listDataHeader, listDataChild)) {
AlertDialog.Builder builder = new AlertDialog.Builder(MSL_AvailabilityActivity.this);
builder.setMessage("Fill the value or fill 0 ")
builder.setMessage("Are you sure you want to save")
.setCancelable(false)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
db.open();
if (db.checkMsl_AvailabilityData(store_id, categoryId)) {
db.updateMSL_Availability(store_id, categoryId, hashMapListHeaderData, hashMapListChildData);
Snackbar.make(view, "Data has been updated", Snackbar.LENGTH_LONG).setAction("Action", null).show();
} else {
db.InsertMSL_Availability(store_id, categoryId, hashMapListHeaderData, hashMapListChildData);
Snackbar.make(view, "Data has been saved", Snackbar.LENGTH_LONG).setAction("Action", null).show();
}
//Toast.makeText(getApplicationContext(), "Data has been saved", Toast.LENGTH_LONG).show();
finish();
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
}*/
}
});
/*} else {
AlertDialog.Builder builder = new AlertDialog.Builder(MSL_AvailabilityActivity.this);
builder.setMessage("Fill the value or fill 0 ")
.setCancelable(false)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
AlertDialog alert = builder.create();
alert.show();
}*/
expandableListView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
int lastItem = firstVisibleItem + visibleItemCount;
if (firstVisibleItem == 0) {
fab.setVisibility(View.VISIBLE);
} else if (lastItem == totalItemCount) {
fab.setVisibility(View.INVISIBLE);
} else {
fab.setVisibility(View.VISIBLE);
}
}
});
@Override
public void onScrollStateChanged(AbsListView arg0, int arg1) {
InputMethodManager inputManager = (InputMethodManager) getApplicationContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
if (getCurrentFocus() != null) {
inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
getCurrentFocus().clearFocus();
expandableListView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
int lastItem = firstVisibleItem + visibleItemCount;
if (firstVisibleItem == 0) {
fab.setVisibility(View.VISIBLE);
} else if (lastItem == totalItemCount) {
fab.setVisibility(View.INVISIBLE);
} else {
fab.setVisibility(View.VISIBLE);
}
}
//expandableListView.invalidateViews();
}
});
@Override
public void onScrollStateChanged(AbsListView arg0, int arg1) {
InputMethodManager inputManager = (InputMethodManager) getApplicationContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
if (getCurrentFocus() != null) {
inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
getCurrentFocus().clearFocus();
}
// Listview Group click listener
expandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
@Override
public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
return false;
}
});
// Listview Group expanded listener
expandableListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
@Override
public void onGroupExpand(int groupPosition) {
InputMethodManager inputManager = (InputMethodManager) getApplicationContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
if (getWindow().getCurrentFocus() != null) {
inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
getCurrentFocus().clearFocus();
//expandableListView.invalidateViews();
}
}
});
});
// Listview Group collasped listener
expandableListView.setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() {
@Override
public void onGroupCollapse(int groupPosition) {
InputMethodManager inputManager = (InputMethodManager) getApplicationContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
if (getWindow().getCurrentFocus() != null) {
inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
getCurrentFocus().clearFocus();
// Listview Group click listener
expandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
@Override
public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
return false;
}
}
});
});
// Listview on child click listener
expandableListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition,
int childPosition, long id) {
return false;
}
});
// Listview Group expanded listener
expandableListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
@Override
public void onGroupExpand(int groupPosition) {
InputMethodManager inputManager = (InputMethodManager) getApplicationContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
if (getWindow().getCurrentFocus() != null) {
inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
getCurrentFocus().clearFocus();
}
}
});
// Listview Group collasped listener
expandableListView.setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() {
@Override
public void onGroupCollapse(int groupPosition) {
InputMethodManager inputManager = (InputMethodManager) getApplicationContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
if (getWindow().getCurrentFocus() != null) {
inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
getCurrentFocus().clearFocus();
}
}
});
// Listview on child click listener
expandableListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition,
int childPosition, long id) {
return false;
}
});
} catch (Resources.NotFoundException e) {
e.printStackTrace();
}
}
private void prepareList() {
hashMapListHeaderData = new ArrayList<>();
hashMapListChildData = new HashMap<>();
try {
hashMapListHeaderData = new ArrayList<>();
hashMapListChildData = new HashMap<>();
//Header
headerDataList = db.getMSL_AvailabilityHeaderData(categoryId);
//Header
headerDataList = db.getMSL_AvailabilityHeaderData(categoryId);
if (headerDataList.size() > 0) {
for (int i = 0; i < headerDataList.size(); i++) {
hashMapListHeaderData.add(headerDataList.get(i));
if (headerDataList.size() > 0) {
for (int i = 0; i < headerDataList.size(); i++) {
hashMapListHeaderData.add(headerDataList.get(i));
//childDataList = new ArrayList<>();
childDataList = db.getMSL_AvailabilitySKU_AfterSaveData(categoryId, headerDataList.get(i).getBrand_id());
if (!(childDataList.size() > 0)) {
childDataList = db.getMSL_AvailabilitySKUData(categoryId, headerDataList.get(i).getBrand_id());
//childDataList = new ArrayList<>();
childDataList = db.getMSL_AvailabilitySKU_AfterSaveData(categoryId, headerDataList.get(i).getBrand_id());
if (!(childDataList.size() > 0)) {
childDataList = db.getMSL_AvailabilitySKUData(categoryId, headerDataList.get(i).getBrand_id());
}
hashMapListChildData.put(hashMapListHeaderData.get(i), childDataList);
}
hashMapListChildData.put(hashMapListHeaderData.get(i), childDataList);
}
}
adapter = new ExpandableListAdapter(this, hashMapListHeaderData, hashMapListChildData);
expandableListView.setAdapter(adapter);
adapter = new ExpandableListAdapter(this, hashMapListHeaderData, hashMapListChildData);
expandableListView.setAdapter(adapter);
} catch (Exception e) {
e.printStackTrace();
}
}
public class ExpandableListAdapter extends BaseExpandableListAdapter {
@@ -9,6 +9,8 @@ import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
@@ -33,7 +35,7 @@ public class PromoComplianceActivity extends AppCompatActivity {
ToggleButton toggle_add_InStock, toggle_add_promoAnnouncer, toggle_add_runningPos;
Button btn_add;
ArrayList<Promo_Compliance_DataGetterSetter> promoSkuListData;
ArrayList<Promo_Compliance_DataGetterSetter> promoSkuListData, promoSkuListAfterData;
ArrayList<Promo_Compliance_DataGetterSetter> promoSpinnerListData;
ArrayList<Promo_Compliance_DataGetterSetter> additionalPromoListData;
@@ -46,189 +48,199 @@ public class PromoComplianceActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_promo_compliance);
try {
setContentView(R.layout.activity_promo_compliance);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
lin_promo_sku = (LinearLayout) findViewById(R.id.lin_promo_sku);
lin_addtional_promo = (LinearLayout) findViewById(R.id.lin_addtional_promo);
view_promo_sku = findViewById(R.id.view_promo_sku);
view_additional_promo = findViewById(R.id.view_additional_promo);
lin_promo_sku = (LinearLayout) findViewById(R.id.lin_promo_sku);
lin_addtional_promo = (LinearLayout) findViewById(R.id.lin_addtional_promo);
view_promo_sku = findViewById(R.id.view_promo_sku);
view_additional_promo = findViewById(R.id.view_additional_promo);
sp_promo = (Spinner) findViewById(R.id.sp_promo);
toggle_add_InStock = (ToggleButton) findViewById(R.id.toggle_add_InStock);
toggle_add_promoAnnouncer = (ToggleButton) findViewById(R.id.toggle_add_promoAnnouncer);
toggle_add_runningPos = (ToggleButton) findViewById(R.id.toggle_add_runningPos);
btn_add = (Button) findViewById(R.id.btn_add);
sp_promo = (Spinner) findViewById(R.id.sp_promo);
toggle_add_InStock = (ToggleButton) findViewById(R.id.toggle_add_InStock);
toggle_add_promoAnnouncer = (ToggleButton) findViewById(R.id.toggle_add_promoAnnouncer);
toggle_add_runningPos = (ToggleButton) findViewById(R.id.toggle_add_runningPos);
btn_add = (Button) findViewById(R.id.btn_add);
db = new GSKOrangeDB(this);
db.open();
db = new GSKOrangeDB(this);
db.open();
//preference data
preferences = PreferenceManager.getDefaultSharedPreferences(this);
store_id = preferences.getString(CommonString.KEY_STORE_ID, null);
visit_date = preferences.getString(CommonString.KEY_DATE, null);
date = preferences.getString(CommonString.KEY_DATE, null);
username = preferences.getString(CommonString.KEY_USERNAME, null);
intime = preferences.getString(CommonString.KEY_STORE_IN_TIME, "");
keyAccount_id = preferences.getString(CommonString.KEY_KEYACCOUNT_ID, "");
class_id = preferences.getString(CommonString.KEY_CLASS_ID, "");
storeType_id = preferences.getString(CommonString.KEY_STORETYPE_ID, "");
//preference data
preferences = PreferenceManager.getDefaultSharedPreferences(this);
store_id = preferences.getString(CommonString.KEY_STORE_ID, null);
visit_date = preferences.getString(CommonString.KEY_DATE, null);
date = preferences.getString(CommonString.KEY_DATE, null);
username = preferences.getString(CommonString.KEY_USERNAME, null);
intime = preferences.getString(CommonString.KEY_STORE_IN_TIME, "");
keyAccount_id = preferences.getString(CommonString.KEY_KEYACCOUNT_ID, "");
class_id = preferences.getString(CommonString.KEY_CLASS_ID, "");
storeType_id = preferences.getString(CommonString.KEY_STORETYPE_ID, "");
//Intent data
categoryName = getIntent().getStringExtra("categoryName");
categoryId = getIntent().getStringExtra("categoryId");
//Intent data
categoryName = getIntent().getStringExtra("categoryName");
categoryId = getIntent().getStringExtra("categoryId");
prepareList();
promoSkuListView();
prepareList();
promoSkuListView();
additionalPromoListData = new ArrayList<>();
//AdditionalPromoListView();
additionalPromoListData = new ArrayList<>();
AdditionalPromoListView();
final Promo_Compliance_DataGetterSetter cd = new Promo_Compliance_DataGetterSetter();
cd.setStore_id(store_id);
cd.setPromo_id("");
cd.setPromo("");
cd.setIn_stock("1");
cd.setPromo_announcer("1");
cd.setRunning_pos("1");
cd.setSp_promo("0");
final Promo_Compliance_DataGetterSetter cd = new Promo_Compliance_DataGetterSetter();
cd.setStore_id(store_id);
cd.setPromo_id("");
cd.setPromo("");
cd.setIn_stock("1");
cd.setPromo_announcer("1");
cd.setRunning_pos("1");
cd.setSp_promo("0");
toggle_add_InStock.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
cd.setIn_stock("1");
} else {
cd.setIn_stock("0");
}
}
});
if (cd.getIn_stock().equals("1")) {
toggle_add_InStock.setChecked(true);
} else {
toggle_add_InStock.setChecked(false);
}
toggle_add_promoAnnouncer.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
cd.setPromo_announcer("1");
} else {
cd.setPromo_announcer("0");
}
}
});
if (cd.getPromo_announcer().equals("1")) {
toggle_add_promoAnnouncer.setChecked(true);
} else {
toggle_add_promoAnnouncer.setChecked(false);
}
toggle_add_runningPos.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
cd.setRunning_pos("1");
} else {
cd.setRunning_pos("0");
}
}
});
if (cd.getRunning_pos().equals("1")) {
toggle_add_runningPos.setChecked(true);
} else {
toggle_add_runningPos.setChecked(false);
}
sp_promo.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String item = parent.getItemAtPosition(position).toString();
// childData.setSp_condition(position);
// childData.setConditionName(item);
for (int i = 0; i < promoSpinnerListData.size(); i++) {
if (position == i) {
cd.setSp_promo(promoSpinnerListData.get(i).getPromo_id());
cd.setPromo(promoSpinnerListData.get(i).getPromo());
cd.setPromo_id(promoSpinnerListData.get(i).getPromo_id());
toggle_add_InStock.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
cd.setIn_stock("1");
} else {
cd.setIn_stock("0");
}
}
});
if (cd.getIn_stock().equals("1")) {
toggle_add_InStock.setChecked(true);
} else {
toggle_add_InStock.setChecked(false);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
toggle_add_promoAnnouncer.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
cd.setPromo_announcer("1");
} else {
cd.setPromo_announcer("0");
}
}
});
if (cd.getPromo_announcer().equals("1")) {
toggle_add_promoAnnouncer.setChecked(true);
} else {
toggle_add_promoAnnouncer.setChecked(false);
}
});
for (int i = 0; i < promoSpinnerListData.size(); i++) {
if (cd.getSp_promo() == promoSpinnerListData.get(i).getPromo_id()) {
sp_promo.setSelection(i);
toggle_add_runningPos.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
cd.setRunning_pos("1");
} else {
cd.setRunning_pos("0");
}
}
});
if (cd.getRunning_pos().equals("1")) {
toggle_add_runningPos.setChecked(true);
} else {
toggle_add_runningPos.setChecked(false);
}
}
btn_add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(PromoComplianceActivity.this);
builder.setMessage("Are you sure you want to add")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
sp_promo.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String item = parent.getItemAtPosition(position).toString();
// childData.setSp_condition(position);
// childData.setConditionName(item);
db.InsertAdditionalPromoData(cd);
AdditionalPromoListView();
for (int i = 0; i < promoSpinnerListData.size(); i++) {
if (position == i) {
cd.setSp_promo(promoSpinnerListData.get(i).getPromo_id());
cd.setPromo(promoSpinnerListData.get(i).getPromo());
cd.setPromo_id(promoSpinnerListData.get(i).getPromo_id());
}
}
}
Snackbar.make(v, "promo is add", Snackbar.LENGTH_LONG).setAction("Action", null).show();
//Toast.makeText(getApplicationContext(), "promo is add", Toast.LENGTH_LONG).show();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
for (int i = 0; i < promoSpinnerListData.size(); i++) {
if (cd.getSp_promo() == promoSpinnerListData.get(i).getPromo_id()) {
sp_promo.setSelection(i);
}
}
});
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View view) {
AlertDialog.Builder builder = new AlertDialog.Builder(PromoComplianceActivity.this);
builder.setMessage("Are you sure you want to save")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
btn_add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(PromoComplianceActivity.this);
builder.setMessage("Are you sure you want to add")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
db.InsertPromoSkuData(promoSkuListData);
db.InsertAdditionalPromoData(cd);
AdditionalPromoListView();
Snackbar.make(view, "Data has been saved", Snackbar.LENGTH_LONG).setAction("Action", null).show();
//Toast.makeText(getApplicationContext(), "Data has been saved", Toast.LENGTH_LONG).show();
finish();
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
}
});
sp_promo.setSelection(0);
toggle_add_InStock.setChecked(true);
toggle_add_promoAnnouncer.setChecked(true);
toggle_add_runningPos.setChecked(true);
Snackbar.make(v, "promo is add", Snackbar.LENGTH_LONG).setAction("Action", null).show();
//Toast.makeText(getApplicationContext(), "promo is add", Toast.LENGTH_LONG).show();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
}
});
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View view) {
AlertDialog.Builder builder = new AlertDialog.Builder(PromoComplianceActivity.this);
builder.setMessage("Are you sure you want to save")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
if (db.checkPromoComplianceData(store_id, categoryId)) {
db.updatePromoComplianceSKU(promoSkuListData, categoryId, store_id);
Snackbar.make(view, "Data has been updated", Snackbar.LENGTH_LONG).setAction("Action", null).show();
} else {
db.InsertPromoSkuData(promoSkuListData, categoryId);
Snackbar.make(view, "Data has been saved", Snackbar.LENGTH_LONG).setAction("Action", null).show();
}
finish();
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
}
});
/*ViewTreeObserver.OnScrollChangedListener onScrollChangedListener
@@ -238,138 +250,182 @@ public class PromoComplianceActivity extends AppCompatActivity {
}
};*/
} catch (Exception e) {
e.printStackTrace();
}
}
private void prepareList() {
//Promo SKU List
promoSkuListData = db.getPromoComplianceSkuData(store_id);
try {
//Promo SKU List
promoSkuListData = db.getPromoComplianceSkuAfterData(store_id, categoryId);
if (!(promoSkuListData.size() > 0)) {
promoSkuListData = db.getPromoComplianceSkuData(store_id);
}
//Promo Spinner List
promoSpinnerListData = db.getPromoSpinnerData(store_id);
//Promo Spinner List
promoSpinnerListData = db.getPromoSpinnerData(store_id);
ArrayAdapter<String> sp_promo_adapter = new ArrayAdapter<>(PromoComplianceActivity.this, android.R.layout.simple_list_item_1);
for (int i = 0; i < promoSpinnerListData.size(); i++) {
sp_promo_adapter.add(promoSpinnerListData.get(i).getPromo());
ArrayAdapter<String> sp_promo_adapter = new ArrayAdapter<>(PromoComplianceActivity.this, android.R.layout.simple_list_item_1);
for (int i = 0; i < promoSpinnerListData.size(); i++) {
sp_promo_adapter.add(promoSpinnerListData.get(i).getPromo());
}
sp_promo.setAdapter(sp_promo_adapter);
} catch (Exception e) {
e.printStackTrace();
}
sp_promo.setAdapter(sp_promo_adapter);
}
private void promoSkuListView() {
View view;
try {
View view;
for (int i = 0; i < promoSkuListData.size(); i++) {
view = getLayoutInflater().inflate(R.layout.item_promo_sku_list, null, false);
for (int i = 0; i < promoSkuListData.size(); i++) {
view = getLayoutInflater().inflate(R.layout.item_promo_sku_list, null, false);
final Promo_Compliance_DataGetterSetter data = promoSkuListData.get(i);
final Promo_Compliance_DataGetterSetter data = promoSkuListData.get(i);
TextView txt_promoSkuName = (TextView) view.findViewById(R.id.txt_promoSkuName);
ToggleButton toggle_inStock = (ToggleButton) view.findViewById(R.id.toggle_inStock);
ToggleButton toggle_promoAnnouncer = (ToggleButton) view.findViewById(R.id.toggle_promoAnnouncer);
ToggleButton toggle_runningPos = (ToggleButton) view.findViewById(R.id.toggle_runningPos);
TextView txt_promoSkuName = (TextView) view.findViewById(R.id.txt_promoSkuName);
ToggleButton toggle_inStock = (ToggleButton) view.findViewById(R.id.toggle_inStock);
ToggleButton toggle_promoAnnouncer = (ToggleButton) view.findViewById(R.id.toggle_promoAnnouncer);
ToggleButton toggle_runningPos = (ToggleButton) view.findViewById(R.id.toggle_runningPos);
txt_promoSkuName.setText(data.getPromo());
txt_promoSkuName.setText(data.getPromo());
//In Stock
toggle_inStock.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
data.setIn_stock("1");
} else {
data.setIn_stock("0");
//In Stock
toggle_inStock.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
data.setIn_stock("1");
} else {
data.setIn_stock("0");
}
}
});
if (data.getIn_stock().equals("1")) {
toggle_inStock.setChecked(true);
} else {
toggle_inStock.setChecked(false);
}
});
if (data.getIn_stock().equals("1")) {
toggle_inStock.setChecked(true);
} else {
toggle_inStock.setChecked(false);
}
//Promo Announcer
toggle_promoAnnouncer.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
data.setPromo_announcer("1");
} else {
data.setPromo_announcer("0");
//Promo Announcer
toggle_promoAnnouncer.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
data.setPromo_announcer("1");
} else {
data.setPromo_announcer("0");
}
}
});
if (data.getPromo_announcer().equals("1")) {
toggle_promoAnnouncer.setChecked(true);
} else {
toggle_promoAnnouncer.setChecked(false);
}
});
if (data.getPromo_announcer().equals("1")) {
toggle_promoAnnouncer.setChecked(true);
} else {
toggle_promoAnnouncer.setChecked(false);
}
//Running on POS
toggle_runningPos.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
data.setRunning_pos("1");
} else {
data.setRunning_pos("0");
//Running on POS
toggle_runningPos.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
data.setRunning_pos("1");
} else {
data.setRunning_pos("0");
}
}
});
if (data.getRunning_pos().equals("1")) {
toggle_runningPos.setChecked(true);
} else {
toggle_runningPos.setChecked(false);
}
});
if (data.getRunning_pos().equals("1")) {
toggle_runningPos.setChecked(true);
} else {
toggle_runningPos.setChecked(false);
lin_promo_sku.addView(view);
}
lin_promo_sku.addView(view);
} catch (Exception e) {
e.printStackTrace();
}
}
private void AdditionalPromoListView() {
additionalPromoListData.clear();
lin_addtional_promo.removeAllViews();
try {
additionalPromoListData.clear();
lin_addtional_promo.removeAllViews();
//Additional Promo List
additionalPromoListData = db.getAdditionalPromoData();
//Additional Promo List
additionalPromoListData = db.getAdditionalPromoData();
View view;
View view;
for (int i = 0; i < additionalPromoListData.size(); i++) {
view = getLayoutInflater().inflate(R.layout.item_additional_promo_list, null, false);
for (int i = 0; i < additionalPromoListData.size(); i++) {
view = getLayoutInflater().inflate(R.layout.item_additional_promo_list, null, false);
final Promo_Compliance_DataGetterSetter data = additionalPromoListData.get(i);
final Promo_Compliance_DataGetterSetter data = additionalPromoListData.get(i);
TextView txt_promoName = (TextView) view.findViewById(R.id.txt_promoName);
TextView txt_inStock = (TextView) view.findViewById(R.id.txt_inStock);
TextView txt_promoAnnouncer = (TextView) view.findViewById(R.id.txt_promoAnnouncer);
TextView txt_runningPos = (TextView) view.findViewById(R.id.txt_runningPos);
TextView txt_promoName = (TextView) view.findViewById(R.id.txt_promoName);
TextView txt_inStock = (TextView) view.findViewById(R.id.txt_inStock);
TextView txt_promoAnnouncer = (TextView) view.findViewById(R.id.txt_promoAnnouncer);
TextView txt_runningPos = (TextView) view.findViewById(R.id.txt_runningPos);
txt_promoName.setText(data.getPromo());
txt_promoName.setText(data.getPromo());
//In Stock
if (data.getIn_stock().equals("1")) {
txt_inStock.setText("Yes");
} else {
txt_inStock.setText("No");
//In Stock
if (data.getIn_stock().equals("1")) {
txt_inStock.setText("Yes");
} else {
txt_inStock.setText("No");
}
//Promo Announcer
if (data.getPromo_announcer().equals("1")) {
txt_promoAnnouncer.setText("Yes");
} else {
txt_promoAnnouncer.setText("No");
}
//Running on POS
if (data.getRunning_pos().equals("1")) {
txt_runningPos.setText("Yes");
} else {
txt_runningPos.setText("No");
}
lin_addtional_promo.addView(view);
}
//Promo Announcer
if (data.getPromo_announcer().equals("1")) {
txt_promoAnnouncer.setText("Yes");
} else {
txt_promoAnnouncer.setText("No");
}
//Running on POS
if (data.getRunning_pos().equals("1")) {
txt_runningPos.setText("Yes");
} else {
txt_runningPos.setText("No");
}
lin_addtional_promo.addView(view);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == android.R.id.home) {
finish();
}
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
@@ -7,6 +7,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Build;
@@ -76,186 +77,196 @@ public class Stock_FacingActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_stock_facing);
try {
setContentView(R.layout.activity_stock_facing);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
db = new GSKOrangeDB(this);
db.open();
db = new GSKOrangeDB(this);
db.open();
expandableListView = (ExpandableListView) findViewById(R.id.expandableListView);
txt_stockFacingName = (TextView) findViewById(R.id.txt_stockFacingName);
expandableListView = (ExpandableListView) findViewById(R.id.expandableListView);
txt_stockFacingName = (TextView) findViewById(R.id.txt_stockFacingName);
//preference data
preferences = PreferenceManager.getDefaultSharedPreferences(this);
store_id = preferences.getString(CommonString.KEY_STORE_ID, null);
visit_date = preferences.getString(CommonString.KEY_DATE, null);
date = preferences.getString(CommonString.KEY_DATE, null);
username = preferences.getString(CommonString.KEY_USERNAME, null);
intime = preferences.getString(CommonString.KEY_STORE_IN_TIME, "");
keyAccount_id = preferences.getString(CommonString.KEY_KEYACCOUNT_ID, "");
class_id = preferences.getString(CommonString.KEY_CLASS_ID, "");
storeType_id = preferences.getString(CommonString.KEY_STORETYPE_ID, "");
//preference data
preferences = PreferenceManager.getDefaultSharedPreferences(this);
store_id = preferences.getString(CommonString.KEY_STORE_ID, null);
visit_date = preferences.getString(CommonString.KEY_DATE, null);
date = preferences.getString(CommonString.KEY_DATE, null);
username = preferences.getString(CommonString.KEY_USERNAME, null);
intime = preferences.getString(CommonString.KEY_STORE_IN_TIME, "");
keyAccount_id = preferences.getString(CommonString.KEY_KEYACCOUNT_ID, "");
class_id = preferences.getString(CommonString.KEY_CLASS_ID, "");
storeType_id = preferences.getString(CommonString.KEY_STORETYPE_ID, "");
categoryName = getIntent().getStringExtra("categoryName");
categoryId = getIntent().getStringExtra("categoryId");
categoryName = getIntent().getStringExtra("categoryName");
categoryId = getIntent().getStringExtra("categoryId");
//txt_stockFacingName.setText(categoryName);
txt_stockFacingName.setText(getResources().getString(R.string.title_activity_stock_facing));
//txt_stockFacingName.setText(categoryName);
txt_stockFacingName.setText(getResources().getString(R.string.title_activity_stock_facing));
prepareList();
prepareList();
str = CommonString.FILE_PATH + _pathforcheck;
str = CommonString.FILE_PATH + _pathforcheck;
final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
/*Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();*/
final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View view) {
/*Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();*/
if (validateData(hashMapListHeaderData, hashMapListChildData)) {
AlertDialog.Builder builder = new AlertDialog.Builder(Stock_FacingActivity.this);
builder.setMessage("Are you sure you want to save")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
db.open();
if (validateData(hashMapListHeaderData, hashMapListChildData)) {
AlertDialog.Builder builder = new AlertDialog.Builder(Stock_FacingActivity.this);
builder.setMessage("Are you sure you want to save")
.setCancelable(false)
.setPositiveButton("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);
} else {
db.InsertStock_Facing(store_id, categoryId, hashMapListHeaderData, hashMapListChildData);
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();
} else {
db.InsertStock_Facing(store_id, categoryId, hashMapListHeaderData, hashMapListChildData);
Snackbar.make(view, "Data has been saved", Snackbar.LENGTH_LONG).setAction("Action", null).show();
//Toast.makeText(getApplicationContext(), "Data has been saved", Toast.LENGTH_LONG).show();
}
finish();
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
}
Toast.makeText(getApplicationContext(), "Data has been saved", Toast.LENGTH_LONG).show();
finish();
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(Stock_FacingActivity.this);
builder.setMessage("Fill the value or fill 0 ")
.setCancelable(false)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
AlertDialog alert = builder.create();
alert.show();
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(Stock_FacingActivity.this);
builder.setMessage("Fill the value or fill 0 ")
.setCancelable(false)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
AlertDialog alert = builder.create();
alert.show();
}
}
}
});
});
expandableListView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
int lastItem = firstVisibleItem + visibleItemCount;
expandableListView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
int lastItem = firstVisibleItem + visibleItemCount;
if (firstVisibleItem == 0) {
fab.setVisibility(View.VISIBLE);
} else if (lastItem == totalItemCount) {
fab.setVisibility(View.INVISIBLE);
} else {
fab.setVisibility(View.VISIBLE);
}
}
@Override
public void onScrollStateChanged(AbsListView arg0, int arg1) {
InputMethodManager inputManager = (InputMethodManager) getApplicationContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
if (getCurrentFocus() != null) {
inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
getCurrentFocus().clearFocus();
if (firstVisibleItem == 0) {
fab.setVisibility(View.VISIBLE);
} else if (lastItem == totalItemCount) {
fab.setVisibility(View.INVISIBLE);
} else {
fab.setVisibility(View.VISIBLE);
}
}
expandableListView.invalidateViews();
}
});
@Override
public void onScrollStateChanged(AbsListView arg0, int arg1) {
InputMethodManager inputManager = (InputMethodManager) getApplicationContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
if (getCurrentFocus() != null) {
inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
getCurrentFocus().clearFocus();
}
// Listview Group click listener
expandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
@Override
public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
return false;
}
});
// Listview Group expanded listener
expandableListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
@Override
public void onGroupExpand(int groupPosition) {
InputMethodManager inputManager = (InputMethodManager) getApplicationContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
if (getWindow().getCurrentFocus() != null) {
inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
getCurrentFocus().clearFocus();
expandableListView.invalidateViews();
}
}
});
});
// Listview Group collasped listener
expandableListView.setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() {
@Override
public void onGroupCollapse(int groupPosition) {
InputMethodManager inputManager = (InputMethodManager) getApplicationContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
if (getWindow().getCurrentFocus() != null) {
inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
getCurrentFocus().clearFocus();
// Listview Group click listener
expandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
@Override
public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
return false;
}
}
});
});
// Listview on child click listener
expandableListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition,
int childPosition, long id) {
return false;
}
});
// Listview Group expanded listener
expandableListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
@Override
public void onGroupExpand(int groupPosition) {
InputMethodManager inputManager = (InputMethodManager) getApplicationContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
if (getWindow().getCurrentFocus() != null) {
inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
getCurrentFocus().clearFocus();
}
}
});
// Listview Group collasped listener
expandableListView.setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() {
@Override
public void onGroupCollapse(int groupPosition) {
InputMethodManager inputManager = (InputMethodManager) getApplicationContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
if (getWindow().getCurrentFocus() != null) {
inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
getCurrentFocus().clearFocus();
}
}
});
// Listview on child click listener
expandableListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition,
int childPosition, long id) {
return false;
}
});
} catch (Resources.NotFoundException e) {
e.printStackTrace();
}
}
private void prepareList() {
hashMapListHeaderData = new ArrayList<>();
hashMapListChildData = new HashMap<>();
try {
hashMapListHeaderData = new ArrayList<>();
hashMapListChildData = new HashMap<>();
//Header Data
headerDataList = db.getStockAndFacingHeader_AfterSaveData(categoryId);
if (!(headerDataList.size() > 0)) {
headerDataList = db.getStockAndFacingHeaderData(categoryId);
}
if (headerDataList.size() > 0) {
for (int i = 0; i < headerDataList.size(); i++) {
hashMapListHeaderData.add(headerDataList.get(i));
//Child Data
childDataList = db.getStockAndFacingSKU_AfterSaveData(categoryId, headerDataList.get(i).getBrand_id());
if (!(childDataList.size() > 0)) {
childDataList = db.getStockAndFacingSKUData(categoryId, headerDataList.get(i).getBrand_id());
}
hashMapListChildData.put(hashMapListHeaderData.get(i), childDataList);
//Header Data
headerDataList = db.getStockAndFacingHeader_AfterSaveData(categoryId);
if (!(headerDataList.size() > 0)) {
headerDataList = db.getStockAndFacingHeaderData(categoryId);
}
}
adapter = new ExpandableListAdapter(this, hashMapListHeaderData, hashMapListChildData);
expandableListView.setAdapter(adapter);
if (headerDataList.size() > 0) {
for (int i = 0; i < headerDataList.size(); i++) {
hashMapListHeaderData.add(headerDataList.get(i));
//Child Data
childDataList = db.getStockAndFacingSKU_AfterSaveData(categoryId, headerDataList.get(i).getBrand_id());
if (!(childDataList.size() > 0)) {
childDataList = db.getStockAndFacingSKUData(categoryId, headerDataList.get(i).getBrand_id());
}
hashMapListChildData.put(hashMapListHeaderData.get(i), childDataList);
}
}
adapter = new ExpandableListAdapter(this, hashMapListHeaderData, hashMapListChildData);
expandableListView.setAdapter(adapter);
} catch (Exception e) {
e.printStackTrace();
}
}
public class ExpandableListAdapter extends BaseExpandableListAdapter {
@@ -326,9 +337,9 @@ public class Stock_FacingActivity extends AppCompatActivity {
}
if (headerTitle.getImage1().equals("")) {
img_camera1.setBackgroundResource(R.drawable.ic_menu_camera);
img_camera1.setBackgroundResource(R.mipmap.camera);
} else {
img_camera1.setBackgroundResource(R.drawable.ic_menu_gallery);
img_camera1.setBackgroundResource(R.mipmap.camera_done);
}
@@ -354,9 +365,9 @@ public class Stock_FacingActivity extends AppCompatActivity {
}
if (headerTitle.getImage2().equals("")) {
img_camera2.setBackgroundResource(R.drawable.ic_menu_camera);
img_camera2.setBackgroundResource(R.mipmap.camera);
} else {
img_camera2.setBackgroundResource(R.drawable.ic_menu_gallery);
img_camera2.setBackgroundResource(R.mipmap.camera_done);
}
@@ -51,7 +51,7 @@
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginRight="10dp"
android:src="@android:drawable/btn_star_big_off" />
android:src="@mipmap/star" />
<ImageView
android:id="@+id/img_camera1"
@@ -72,7 +72,7 @@
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginRight="20dp"
android:src="@android:drawable/ic_menu_edit" />
android:src="@mipmap/no_camera" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>