Planogram pdf and Category image mapping

This commit is contained in:
yadavendras
2018-01-31 15:43:49 +05:30
parent 4da796f77a
commit d53bca0e29
27 changed files with 1423 additions and 94 deletions
+10 -6
View File
@@ -1,8 +1,8 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '25.0.0'
compileSdkVersion 26
buildToolsVersion '26.0.2'
useLibrary 'org.apache.http.legacy'
@@ -40,13 +40,17 @@ dependencies {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.google.android.gms:play-services-location:9.8.0'
compile 'com.google.android.gms:play-services-maps:9.8.0'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.google.android.gms:play-services-appindexing:9.8.0'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.google.code.gson:gson:2.7'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha4'
+7 -1
View File
@@ -220,7 +220,13 @@
<activity
android:name=".dailyentry.PlanogramPDFActivity"
android:label="@string/title_activity_planogram_pdf"
android:theme="@style/AppTheme.NoActionBar"></activity>
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".dailyentry.StockDataActivity"
android:label="@string/title_activity_stock_data"
android:configChanges="screenSize|orientation|keyboardHidden"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="adjustPan"></activity>
</application>
</manifest>
@@ -4322,6 +4322,11 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
ContentValues values1 = new ContentValues();
try {
db.delete(CommonString.TABLE_INSERT_CATEGORY_PICTURE,
"Store_Id='" + gettersetter.getStore_ID() + "' And categoryId='" + categoryId + "' ", null);
db.delete(CommonString.TABLE_INSERT_CATEGORY_PICTURE_LIST,
"Store_Id='" + gettersetter.getStore_ID() + "' And categoryId='" + categoryId + "' ", null);
values.put("Store_Id", gettersetter.getStore_ID());
values.put("categoryId", categoryId);
values.put("CategoryImage1", gettersetter.getCategoryImage1());
@@ -5471,4 +5476,54 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
Log.d("Exception ", " in MAPPING_COUNTRYWISE_PLANOGRAM " + ex.toString());
}
}
//Stock N Facing
public ArrayList<MSL_AvailabilityStockFacingGetterSetter> getStockFacingHeaderData(
String category_id, String keyAccount_id, String storeType_id, String class_id) {
ArrayList<MSL_AvailabilityStockFacingGetterSetter> list = new ArrayList<>();
Cursor dbcursor = null;
try {
dbcursor = db.rawQuery("Select DISTINCT SB.SUB_CATEGORY_ID,SB.SUB_CATEGORY,BR.BRAND_ID,BR.BRAND,BR.COMPANY_ID ," +
" (SELECT SUM(SOS_TARGET) FROM MAPPING_SOS_TARGET WHERE STORE_ID = 1 AND BRAND_ID = BR.BRAND_ID)AS SOS_TARGET " +
"from MAPPING_STOCK M " +
"inner join SKU_MASTER SK " +
"on M.SKU_ID=SK.SKU_ID " +
"inner join BRAND_MASTER BR " +
"on SK.BRAND_ID=BR.BRAND_ID " +
"inner join SUB_CATEGORY_MASTER SB " +
"on BR.SUB_CATEGORY_ID=SB.SUB_CATEGORY_ID " +
"inner join CATEGORY_MASTER CA " +
"on SB.CATEGORY_ID=CA.CATEGORY_ID " +
"where CA.CATEGORY_ID='" + category_id + "' AND M.KEYACCOUNT_ID = '" + keyAccount_id +
"' AND M.STORETYPE_ID = '" + storeType_id + "' AND M.CLASS_ID = '" + class_id + "' AND BR.COMPANY_ID='"+ 1 +"' "+
"order by SB.SUB_CATEGORY,BR.COMPANY_ID,BR.BRAND", null);
if (dbcursor != null) {
dbcursor.moveToFirst();
while (!dbcursor.isAfterLast()) {
MSL_AvailabilityStockFacingGetterSetter cd = new MSL_AvailabilityStockFacingGetterSetter();
cd.setSub_category_id(dbcursor.getString(dbcursor.getColumnIndexOrThrow("SUB_CATEGORY_ID")));
cd.setSub_category(dbcursor.getString(dbcursor.getColumnIndexOrThrow("SUB_CATEGORY")));
cd.setBrand_id(dbcursor.getString(dbcursor.getColumnIndexOrThrow("BRAND_ID")));
cd.setBrand(dbcursor.getString(dbcursor.getColumnIndexOrThrow("BRAND")));
cd.setCompany_id(dbcursor.getString(dbcursor.getColumnIndexOrThrow("COMPANY_ID")));
list.add(cd);
dbcursor.moveToNext();
}
dbcursor.close();
return list;
}
} catch (Exception e) {
Log.d("Exception ", "get MSL_AvailabilityHeader!" + e.toString());
return list;
}
return list;
}
}
@@ -128,7 +128,7 @@ public class LoginActivity extends AppCompatActivity {
e.printStackTrace();
}
tv_version.setText("Version/Versiyon - " + app_ver+"T3");
tv_version.setText("Version/Versiyon - " + app_ver+"T6");
preferences = PreferenceManager.getDefaultSharedPreferences(this);
editor = preferences.edit();
@@ -434,7 +434,7 @@ public class LoginActivity extends AppCompatActivity {
+ "[/PASSWORD]" + "[IN_TIME]" + CommonFunctions.getCurrentTimeWithLanguage(getApplicationContext())
+ "[/IN_TIME]" + "[LATITUDE]" + lat
+ "[/LATITUDE]" + "[LONGITUDE]" + lon
+ "[/LONGITUDE]" + "[APP_VERSION]" + app_ver+"T3"
+ "[/LONGITUDE]" + "[APP_VERSION]" + app_ver+"T6"
+ "[/APP_VERSION]" + "[ATT_MODE]OnLine[/ATT_MODE]"
+ "[NETWORK_STATUS]" + "LoginStatus"
+ "[/NETWORK_STATUS]" + "[/USER_DATA][/DATA]";
@@ -543,6 +543,7 @@ public class LoginActivity extends AppCompatActivity {
editor.putString(CommonString.KEY_PATH, lgs.getAPP_PATH());
editor.putString(CommonString.KEY_DATE, lgs.getCURRENTDATE());
editor.putString(CommonString.KEY_COUNTRY_ID, lgs.getCOUNTRY_ID());
//editor.putString(CommonString.KEY_DATE, "01/21/2017");
editor.commit();
@@ -19,6 +19,7 @@ public class CommonString {
public static final String KEY_USERNAME = "username";
public static final String KEY_PASSWORD = "password";
public static final String KEY_DATE = "date";
public static final String KEY_COUNTRY_ID = "COUNTRY_ID";
public static final String KEY_STOREVISITED_STATUS = "STOREVISITED_STATUS";
@@ -94,13 +94,13 @@ public class AdditionalVisibility extends AppCompatActivity implements View.OnCl
ArrayList<SkuGetterSetter> empty_list = new ArrayList<>();
String _pathforcheck1, _pathforcheck2, _pathforcheck3, _path, str, msg;
private SharedPreferences preferences;
String store_id, date, intime, img_str1, img_str2, img_str3, togglevalue = "1", CATEGORY_ID, camera_allow, store_type_id, class_id, key_account_id;
String store_id, date, intime, img_str1="", img_str2="", img_str3="", togglevalue = "1", CATEGORY_ID, camera_allow, store_type_id, class_id, key_account_id;
ImageView img_cam, img_clicked;
Button btn_add, btn_close;
EditText Edt_txt;
MyAdaptorStock adapterData;
ListView listviewlay;
String errormsg, categoryName, categoryId;
String errormsg, categoryName, categoryId,country_id;
MyAdaptorAdditionalStock adapteradditional;
AddittionalGetterSetter adGt, newadd;
LinearLayout brandlayout, diaplylayout, cameralayout;
@@ -130,6 +130,9 @@ public class AdditionalVisibility extends AppCompatActivity implements View.OnCl
store_type_id = preferences.getString(CommonString.KEY_STORETYPE_ID, "");
class_id = preferences.getString(CommonString.KEY_CLASS_ID, "");
key_account_id = preferences.getString(CommonString.KEY_KEYACCOUNT_ID, "");
country_id = preferences.getString(CommonString.KEY_COUNTRY_ID, "");
CommonFunctions.updateLangResources(getApplicationContext(), preferences.getString(CommonString.KEY_LANGUAGE, ""));
categoryName = getIntent().getStringExtra("categoryName");
@@ -1613,7 +1616,7 @@ public class AdditionalVisibility extends AppCompatActivity implements View.OnCl
errormsg = getResources().getString(R.string.title_activity_select_dropdown);
} else if (camera_allow.equals("1")) {
if (imageu == null || imageu.equalsIgnoreCase("")) {
if (!country_id.equals("6") && (imageu == null || imageu.equalsIgnoreCase(""))) {
flag = false;
errormsg = getResources().getString(R.string.title_activity_take_image);
@@ -47,7 +47,7 @@ public class CategoryPicture extends AppCompatActivity {
String _pathforcheck1, _pathforcheck2, _pathforcheck3, _pathforcheck4, Camerapath1, Camerapath2, _path, CaMpath, str, msg, categoryName, categoryId;
ImageView im1, im2, im3, im4;
ListView listview;
String store_id, date, intime, img_str1, img_str2, img_str3, img_str4, togglevalue = "1", CATEGORY_ID, camera_allow, store_type_id, class_id, key_account_id;
String store_id, date, intime, img_str1="", img_str2="", img_str3="", img_str4="", togglevalue = "1", CATEGORY_ID, camera_allow, store_type_id, class_id, key_account_id;
private SharedPreferences preferences;
Uri outputFileUri;
String gallery_package = "";
@@ -98,55 +98,44 @@ public class CategoryPicture extends AppCompatActivity {
adddata = db.getCategoryPictureData(store_id, categoryId);
categoryImagesAllowed = db.getCategoryPictureAllowedData(categoryId);
if(categoryImagesAllowed.size()>0){
setCamAllowImage(categoryImagesAllowed.get(0).isImg_cam1(), im1);
setCamAllowImage(categoryImagesAllowed.get(0).isImg_cam2(), im2);
setCamAllowImage(categoryImagesAllowed.get(0).isImg_cam2(), im3);
setCamAllowImage(categoryImagesAllowed.get(0).isImg_cam3(), im4);
}
if (adddata.size() != 0) {
for (int k = 0; k < adddata.size(); k++) {
String key_id = adddata.get(k).getKEY_ID();
String key_id = adddata.get(0).getKEY_ID();
listdat = db.getCategoryPictureListData(store_id, categoryId, key_id);
String image1 = adddata.get(k).getCategoryImage1();
String image2 = adddata.get(k).getCategoryImage2();
String image3 = adddata.get(k).getCategoryImage3();
String image4 = adddata.get(k).getCategoryImage4();
String image1 = adddata.get(0).getCategoryImage1();
String image2 = adddata.get(0).getCategoryImage2();
String image3 = adddata.get(0).getCategoryImage3();
String image4 = adddata.get(0).getCategoryImage4();
if (image1 != null) {
if (image1 != null && !image1.equals("")) {
im1.setBackgroundResource(R.mipmap.camera_green);
img_str1 = image1;
} else {
im1.setBackgroundResource(R.drawable.camera_orange_star_green);
}
if (image2 != null) {
if (image2 != null && !image2.equals("")) {
im2.setBackgroundResource(R.mipmap.camera_green);
img_str2 = image2;
} else {
im2.setBackgroundResource(R.mipmap.camera_orange);
}
if (image3 != null) {
if (image3 != null && !image3.equals("")) {
im3.setBackgroundResource(R.mipmap.camera_green);
img_str3 = image3;
} else {
im3.setBackgroundResource(R.mipmap.camera_orange);
}
if (image4 != null) {
if (image4 != null && !image4.equals("")) {
im4.setBackgroundResource(R.mipmap.camera_green);
img_str4 = image4;
} else {
im4.setBackgroundResource(R.mipmap.camera_orange);
}
}
} else {
listdat = db.getCategoryPicturedata(categoryId, key_account_id, store_type_id, class_id);
@@ -156,13 +145,6 @@ public class CategoryPicture extends AppCompatActivity {
adapteradditional = new CategoryPicture.CategoryAdapter(CategoryPicture.this, listdat);
listview.setAdapter(adapteradditional);
if(categoryImagesAllowed.size()>0){
setCamAllowImage(categoryImagesAllowed.get(0).isImg_cam1(), im1);
setCamAllowImage(categoryImagesAllowed.get(0).isImg_cam2(), im2);
setCamAllowImage(categoryImagesAllowed.get(0).isImg_cam2(), im3);
setCamAllowImage(categoryImagesAllowed.get(0).isImg_cam3(), im4);
}
fab.setOnClickListener(new View.OnClickListener() {
@Override
@@ -556,11 +538,34 @@ public class CategoryPicture extends AppCompatActivity {
boolean validateData(CategoryPictureGetterSetter data, ArrayList<CategoryPictureGetterSetter> list) {
boolean flag = true;
String cameraImage1 = data.getCategoryImage1();
if(categoryImagesAllowed.get(0).isImg_cam1()){
if(data.getCategoryImage1().equals("")){
flag = false;
}
}
if(flag){
if(categoryImagesAllowed.get(0).isImg_cam2()){
if(data.getCategoryImage2().equals("")){
flag = false;
}
}
}
if (cameraImage1 == null) {
flag = false;
if(flag){
if(categoryImagesAllowed.get(0).isImg_cam3()){
if(data.getCategoryImage3().equals("")){
flag = false;
}
}
}
if(flag){
if(categoryImagesAllowed.get(0).isImg_cam4()){
if(data.getCategoryImage4().equals("")){
flag = false;
}
}
}
@@ -658,7 +663,7 @@ public class CategoryPicture extends AppCompatActivity {
img_cam.setBackgroundResource(R.drawable.camera_orange_star_green);
}
else{
img_cam.setBackgroundResource(R.mipmap.camera_green);
img_cam.setBackgroundResource(R.mipmap.camera_orange);
}
}
}
@@ -14,10 +14,15 @@ import android.preference.PreferenceManager;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
@@ -42,6 +47,8 @@ import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.text.DecimalFormat;
import java.util.Collections;
import java.util.List;
import cpm.com.gskmtorange.Database.GSKOrangeDB;
import cpm.com.gskmtorange.R;
@@ -62,6 +69,11 @@ public class PlanogramPDFActivity extends AppCompatActivity {
private SharedPreferences preferences = null;
FloatingActionButton fab;
MappingPlanogramCountrywiseGetterSetter document;
MyRecyclerAdapter adapter;
RecyclerView rec;
String Path = Environment.getExternalStorageDirectory().toString() + "/Planogram_Documents/";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -71,6 +83,8 @@ public class PlanogramPDFActivity extends AppCompatActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
rec = (RecyclerView) findViewById(R.id.rec);
fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
@@ -121,7 +135,7 @@ public class PlanogramPDFActivity extends AppCompatActivity {
data = new Data();
String resultHttp = "";
boolean flag = true;
// JCP
try {
@@ -158,7 +172,7 @@ public class PlanogramPDFActivity extends AppCompatActivity {
xpp.next();
eventType = xpp.getEventType();
MappingPlanogramCountrywiseGetterSetter document = XMLHandlers.MAPPING_COUNTRYWISE_PLANOGRAM_XMLHandler(xpp, eventType);
document = XMLHandlers.MAPPING_COUNTRYWISE_PLANOGRAM_XMLHandler(xpp, eventType);
if (document.getCOUNTRY_ID().size() > 0) {
resultHttp = CommonString.KEY_SUCCESS;
@@ -178,10 +192,13 @@ public class PlanogramPDFActivity extends AppCompatActivity {
File folder = new File(extStorageDirectory, "Planogram_Documents");
folder.mkdir();
boolean flag = downloadFile(document.getFILE_PATH().get(0), document.getPLANOGRAM_URL().get(0), folder);
for(int i = 0; i<document.getFILE_PATH().size();i++){
flag = downloadFile(document.getFILE_PATH().get(i), document.getPLANOGRAM_URL().get(i), folder);
if(flag)
return CommonString.KEY_SUCCESS+ ":"+ folder.getAbsolutePath()+"/"+document.getPLANOGRAM_URL().get(0);
if(!flag)
//return CommonString.KEY_SUCCESS+ ":"+ folder.getAbsolutePath()+"/"+document.getPLANOGRAM_URL().get(0);
return getString(R.string.Download_pdf_Error);
}
}
@@ -194,13 +211,26 @@ public class PlanogramPDFActivity extends AppCompatActivity {
} catch (XmlPullParserException e) {
e.printStackTrace();
resultHttp = getString(R.string.nonetwork);
flag = false;
} catch (SoapFault soapFault) {
soapFault.printStackTrace();
resultHttp = getString(R.string.nonetwork);
flag = false;
} catch (IOException e) {
e.printStackTrace();
resultHttp = getString(R.string.nonetwork);
flag = false;
}
catch ( Exception e){
resultHttp = getString(R.string.nonetwork);
flag = false;
}
return resultHttp;
if(flag)
return CommonString.KEY_SUCCESS;
else
return resultHttp;
}
@Override
@@ -211,17 +241,15 @@ public class PlanogramPDFActivity extends AppCompatActivity {
if (result.contains(CommonString.KEY_SUCCESS)) {
String file_path = result.substring(result.indexOf(":")+1);
if(document.getPLANOGRAM_URL().size()>0){
adapter = new MyRecyclerAdapter(getApplicationContext(), document);
rec.setAdapter(adapter);
rec.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
}
File file = new File(file_path);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file),"application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);
finish();
} else {
Toast.makeText(getApplicationContext(), "Downloaded Failed", Toast.LENGTH_SHORT).show();
Snackbar.make(fab, result, Toast.LENGTH_SHORT).show();
}
//finish();
@@ -345,4 +373,74 @@ public class PlanogramPDFActivity extends AppCompatActivity {
return isConnected;
}
class MyRecyclerAdapter extends RecyclerView.Adapter<MyRecyclerAdapter.MyViewHolder> {
private LayoutInflater inflator;
MappingPlanogramCountrywiseGetterSetter data = new MappingPlanogramCountrywiseGetterSetter();
public MyRecyclerAdapter(Context context, MappingPlanogramCountrywiseGetterSetter data) {
inflator = LayoutInflater.from(context);
this.data = data;
}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = inflator.inflate(R.layout.pdf_planogram_item, parent, false);
MyRecyclerAdapter.MyViewHolder holder = new MyRecyclerAdapter.MyViewHolder(view);
return holder;
}
@Override
public void onBindViewHolder(MyViewHolder holder, final int position) {
//final MappingPlanogramCountrywiseGetterSetter current = data.get(position);
final String name = data.getPLANOGRAM_URL().get(position);
holder.name.setText(name);
//holder.detail.setText(current.getDocument_descriiption().get(0));
holder.parent_layout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String file_path = Path + name;
File file = new File(file_path);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file),"application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);
//finish();
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
}
});
}
@Override
public int getItemCount() {
return document.getFILE_PATH().size();
}
class MyViewHolder extends RecyclerView.ViewHolder {
TextView name, detail;
LinearLayout parent_layout;
public MyViewHolder(View itemView) {
super(itemView);
name = (TextView) itemView.findViewById(R.id.tv_name);
detail = (TextView) itemView.findViewById(R.id.tv_details);
parent_layout = (LinearLayout) itemView.findViewById(R.id.layout_parent);
}
}
}
}
@@ -0,0 +1,770 @@
package cpm.com.gskmtorange.dailyentry;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.design.widget.FloatingActionButton;
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.InputFilter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.AbsListView;
import android.widget.BaseExpandableListAdapter;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ExpandableListView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.ToggleButton;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import cpm.com.gskmtorange.Database.GSKOrangeDB;
import cpm.com.gskmtorange.R;
import cpm.com.gskmtorange.constant.CommonFunctions;
import cpm.com.gskmtorange.constant.CommonString;
import cpm.com.gskmtorange.gsk_dailyentry.MSL_Availability_StockFacingActivity;
import cpm.com.gskmtorange.xmlGetterSetter.MSL_AvailabilityStockFacingGetterSetter;
public class StockDataActivity extends AppCompatActivity {
GSKOrangeDB db;
String categoryName, categoryId, storeId, Error_Message = "";
String store_id, visit_date, username, intime, date, keyAccount_id, class_id, storeType_id;
boolean isDialogOpen = true;
private SharedPreferences preferences;
int scrollPosition = 0;
ExpandableListView expandableListView;
ExpandableListAdapter adapter;
ArrayList<MSL_AvailabilityStockFacingGetterSetter> headerDataList;
ArrayList<MSL_AvailabilityStockFacingGetterSetter> childDataList;
List<MSL_AvailabilityStockFacingGetterSetter> hashMapListHeaderData;
HashMap<MSL_AvailabilityStockFacingGetterSetter, List<MSL_AvailabilityStockFacingGetterSetter>> hashMapListChildData;
List<Integer> checkHeaderArray = new ArrayList<>();
boolean checkflag = true;
FloatingActionButton fab;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_stock_data);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
preferences = PreferenceManager.getDefaultSharedPreferences(this);
CommonFunctions.updateLangResources(getApplicationContext(), preferences.getString(CommonString.KEY_LANGUAGE, ""));
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, "");
expandableListView = (ExpandableListView) findViewById(R.id.expandableListView);
db = new GSKOrangeDB(this);
db.open();
//Intent data
categoryName = getIntent().getStringExtra("categoryName");
categoryId = getIntent().getStringExtra("categoryId");
//txt_mslAvailabilityName.setText(getResources().getString(R.string.title_activity_msl__availability));
toolbar.setTitle(getResources().getString(R.string.title_activity_stock_data));
fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
expandableListView.clearFocus();
if (validateData(hashMapListHeaderData, hashMapListChildData)) {
AlertDialog.Builder builder = new AlertDialog.Builder(StockDataActivity.this);
builder.setMessage(getResources().getString(R.string.check_save_message))
.setCancelable(false)
.setPositiveButton(getResources().getString(R.string.yes), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
db.open();
if (db.checkMsl_Availability_StockFacingData(store_id, categoryId)) {
db.updateMSL_Availability_StockFacing(store_id, categoryId, hashMapListHeaderData, hashMapListChildData);
Snackbar.make(expandableListView, getResources().getString(R.string.update_message), Snackbar.LENGTH_LONG).setAction("Action", null).show();
} else {
db.InsertMSL_Availability_StockFacing(store_id, categoryId, hashMapListHeaderData, hashMapListChildData);
Snackbar.make(expandableListView, getResources().getString(R.string.save_message), Snackbar.LENGTH_LONG).setAction("Action", null).show();
}
finish();
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
}
})
.setNegativeButton(getResources().getString(R.string.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(StockDataActivity.this);
builder.setMessage(Error_Message)
.setCancelable(false)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
expandableListView.smoothScrollToPosition(scrollPosition);
if (!expandableListView.isGroupExpanded(scrollPosition)) {
expandableListView.expandGroup(scrollPosition);
}
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) {
expandableListView.invalidate();
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.invalidateViews();
}
});
// 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();
}
}
});
// 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;
}
});
}
@Override
protected void onResume() {
super.onResume();
prepareList();
}
private void prepareList() {
try {
hashMapListHeaderData = new ArrayList<>();
hashMapListChildData = new HashMap<>();
//Header
headerDataList = db.getStockFacingHeaderData(categoryId, keyAccount_id, storeType_id, class_id);
if (headerDataList.size() > 0) {
for (int i = 0; i < headerDataList.size(); i++) {
hashMapListHeaderData.add(headerDataList.get(i));
//childDataList = new ArrayList<>();
childDataList = db.getMSL_Availability_StockFacingSKU_AfterSaveData(categoryId, headerDataList.get(i).getBrand_id(), store_id);
if (!(childDataList.size() > 0)) {
childDataList = db.getMSL_Availability_StockFacingSKUData(categoryId, headerDataList.get(i).getBrand_id(), keyAccount_id, storeType_id, class_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 {
private Context _context;
private List<MSL_AvailabilityStockFacingGetterSetter> _listDataHeader;
private HashMap<MSL_AvailabilityStockFacingGetterSetter, List<MSL_AvailabilityStockFacingGetterSetter>> _listDataChild;
public ExpandableListAdapter(Context context, List<MSL_AvailabilityStockFacingGetterSetter> listDataHeader,
HashMap<MSL_AvailabilityStockFacingGetterSetter, List<MSL_AvailabilityStockFacingGetterSetter>> listChildData) {
this._context = context;
this._listDataHeader = listDataHeader;
this._listDataChild = listChildData;
}
@Override
public Object getGroup(int groupPosition) {
return this._listDataHeader.get(groupPosition);
}
@Override
public int getGroupCount() {
return this._listDataHeader.size();
}
@Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
@Override
public View getGroupView(final int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
MSL_AvailabilityStockFacingGetterSetter headerTitle = (MSL_AvailabilityStockFacingGetterSetter) getGroup(groupPosition);
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) this._context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.item_msl_availability_stock_facing_header, null, false);
}
TextView txt_categoryHeader = (TextView) convertView.findViewById(R.id.txt_categoryHeader);
RelativeLayout rel_header = (RelativeLayout) convertView.findViewById(R.id.rel_categoryHeader);
ImageView img_camera = (ImageView) convertView.findViewById(R.id.img_camera);
CardView card_view = (CardView) convertView.findViewById(R.id.card_view);
txt_categoryHeader.setTypeface(null, Typeface.BOLD);
if (headerTitle.getCompany_id().equals("1")) {
txt_categoryHeader.setTextColor(getResources().getColor(R.color.colorPrimaryDark));
} else {
txt_categoryHeader.setTextColor(getResources().getColor(R.color.black));
}
txt_categoryHeader.setText(headerTitle.getSub_category() + "-" + headerTitle.getBrand());
if (!checkflag) {
if (checkHeaderArray.contains(groupPosition)) {
card_view.setCardBackgroundColor(getResources().getColor(android.R.color.holo_red_dark));
} else {
card_view.setCardBackgroundColor(getResources().getColor(R.color.grey_background));
}
}
//empty check color change
/*if (headerTitle.getCompany_id().equals("1")) {
if (!checkflag) {
if (checkHeaderArray.contains(groupPosition)) {
//card_view.setCardBackgroundColor(getResources().getColor(android.R.color.holo_red_dark));
txt_categoryHeader.setTextColor(getResources().getColor(android.R.color.holo_red_dark));
} else {
txt_categoryHeader.setTextColor(getResources().getColor(R.color.colorPrimaryDark));
}
}
} else {
if (!checkflag) {
if (checkHeaderArray.contains(groupPosition)) {
txt_categoryHeader.setTextColor(getResources().getColor(android.R.color.holo_red_dark));
} else {
txt_categoryHeader.setTextColor(getResources().getColor(R.color.black));
}
}
}*/
return convertView;
}
@Override
public Object getChild(int groupPosition, int childPosititon) {
return this._listDataChild.get(this._listDataHeader.get(groupPosition)).get(childPosititon);
}
@Override
public int getChildrenCount(int groupPosition) {
return this._listDataChild.get(this._listDataHeader.get(groupPosition)).size();
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
@Override
public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild,
View convertView, ViewGroup parent) {
final MSL_AvailabilityStockFacingGetterSetter childData =
(MSL_AvailabilityStockFacingGetterSetter) getChild(groupPosition, childPosition);
ViewHolder holder = null;
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) this._context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.stock_facing_child, null, false);
holder = new ViewHolder();
holder.cardView = (CardView) convertView.findViewById(R.id.card_view);
holder.lin_category = (LinearLayout) convertView.findViewById(R.id.lin_category);
holder.txt_skuName = (TextView) convertView.findViewById(R.id.txt_skuName);
//holder.txt_mbq = (TextView) convertView.findViewById(R.id.txt_mbq);
//holder.toggle_available = (ToggleButton) convertView.findViewById(R.id.toggle_available)
holder.facing = (EditText) convertView.findViewById(R.id.ed_facing);
//holder.facing.setFilters(new InputFilter[]{new DecimalDigitsInputFilter(6, 1)});
holder.stock = (EditText) convertView.findViewById(R.id.ed_stock);
holder.stock_view = convertView.findViewById(R.id.stock_view);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.txt_skuName.setText(childData.getSku());
//holder.txt_mbq.setText(childData.getMbq());
if (childData.getCompany_id().equals("1") && childData.getMust_have().equals("1")) {
holder.lin_category.setBackgroundColor(getResources().getColor(R.color.colorOrange));
/* holder.txt_mbq.setVisibility(View.VISIBLE);
holder.toggle_available.setVisibility(View.VISIBLE);
holder.facing.setVisibility(View.VISIBLE);
if (childData.getToggleValue().equals("1")) {
holder.stock.setVisibility(View.GONE);
holder.stock_view.setVisibility(View.GONE);
} else {
holder.stock.setVisibility(View.VISIBLE);
holder.stock_view.setVisibility(View.VISIBLE);
}*/
} else {
holder.lin_category.setBackgroundColor(getResources().getColor(R.color.white));
/* holder.txt_mbq.setVisibility(View.GONE);
holder.toggle_available.setVisibility(View.GONE);
holder.facing.setVisibility(View.VISIBLE);*/
/* holder.stock.setVisibility(View.GONE);
holder.stock_view.setVisibility(View.GONE);*/
}
if (childData.getCompany_id().equals("1")) {
if (childData.getMust_have().equals("1")) {
holder.txt_skuName.setTextColor(getResources().getColor(R.color.colorPrimary));
} else {
holder.txt_skuName.setTextColor(getResources().getColor(R.color.blue));
}
} else {
holder.txt_skuName.setTextColor(getResources().getColor(R.color.black));
}
/* if (childData.getCompany_id().equals("1") && childData.getMust_have().equals("1")) {
holder.lin_category.setBackgroundColor(getResources().getColor(R.color.colorOrange));
} else {
holder.lin_category.setBackgroundColor(getResources().getColor(R.color.white));
*//*holder.txt_mbq.setVisibility(View.GONE);
holder.toggle_available.setVisibility(View.GONE);
holder.facing.setVisibility(View.VISIBLE);
holder.stock.setVisibility(View.GONE);*//*
}*/
/* holder.toggle_available.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
childData.setToggleValue("1");
finalHolder.stock.setVisibility(View.GONE);
*//*childData.setStock("");
childData.setFacing("");*//*
} else {
*//* childData.setStock("");
childData.setFacing("");*//*
childData.setToggleValue("0");
finalHolder.stock.setVisibility(View.VISIBLE);
//If MBQ Value is 0
if (Integer.parseInt(childData.getMbq()) == 0) {
childData.setStock("0");
childData.setFacing("0");
}*//* else {
if (finalHolder.facing.getText().toString() != null && !finalHolder.facing.getText().toString().equals("")) {
if (Integer.parseInt(finalHolder.facing.getText().toString()) >= 0
&& Integer.parseInt(finalHolder.facing.getText().toString()) >= Integer.parseInt(childData.getMbq())) {
childData.setFacing("");
finalHolder.facing.setText("");
}
}
}*//*
}
expandableListView.clearFocus();
expandableListView.invalidateViews();
}
});
if (childData.getToggleValue().equals("1")) {
holder.toggle_available.setChecked(true);
finalHolder.stock.setVisibility(View.GONE);
childData.setStock("");
} else {
holder.toggle_available.setChecked(false);
finalHolder.stock.setVisibility(View.VISIBLE);
}
*/
final ViewHolder finalHolder = holder;
holder.stock.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
final EditText caption = (EditText) v;
String edStock = caption.getText().toString().replaceFirst("^0+(?!$)", "");
/*if (!childData.getFacing().equals("") && Integer.parseInt(stock) >= 0 && Integer.parseInt(childData.getFacing()) < Integer.parseInt(stock)) {
}*/
if (!edStock.equals("")) {
String stock = edStock;
if (!childData.getFacing().equals("")) {
if (Integer.parseInt(stock) >= 0 && Double.parseDouble(childData.getFacing()) <= Integer.parseInt(stock)) {
childData.setStock(stock);
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(StockDataActivity.this);
builder.setMessage(getString(R.string.check_faceup))
.setCancelable(false)
.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
finalHolder.stock.setText("");
dialog.dismiss();
}
});
AlertDialog alert = builder.create();
alert.show();
}
} else {
childData.setStock(stock);
}
} else {
childData.setStock("");
}
}
});
holder.stock.setText(childData.getStock());
final ViewHolder finalHolder1 = holder;
holder.facing.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
final EditText caption = (EditText) v;
boolean isFill = false;
String edFaceup = caption.getText().toString().replaceFirst("^0+(?!$)", "");
if (edFaceup != null && !edFaceup.equals("")) {
if (!childData.getStock().equals("")) {
if (Double.parseDouble(edFaceup) <= Integer.parseInt(childData.getStock())) {
isFill = true;
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(StockDataActivity.this);
builder.setMessage(getString(R.string.check_faceup))
.setCancelable(false)
.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
finalHolder1.facing.setText("");
dialog.dismiss();
}
});
AlertDialog alert = builder.create();
alert.show();
}
} else {
childData.setFacing(edFaceup);
}
if (isFill) {
childData.setFacing(edFaceup);
}
} else {
childData.setFacing("");
}
}
});
holder.facing.setText(childData.getFacing());
//empty check color change
if (!checkflag) {
boolean tempflag = false;
if (childData.getCompany_id().equals("1")) {
/* if (childData.getToggleValue().equals("0")) {
if (holder.stock.getText().toString().equals("")) {
holder.stock.setBackgroundColor(getResources().getColor(R.color.white));
holder.stock.setHintTextColor(getResources().getColor(android.R.color.holo_red_dark));
holder.stock.setHint(getString(R.string.empty));
tempflag = true;
}
*//* if (holder.facing.getText().toString().equals("")) {
holder.facing.setBackgroundColor(getResources().getColor(R.color.white));
holder.facing.setHintTextColor(getResources().getColor(android.R.color.holo_red_dark));
holder.facing.setHint(getString(R.string.empty));
tempflag = true;
}*//*
} else {
if (childData.getMust_have().equals("1")) {
if (holder.facing.getText().toString().equals("")) {
holder.facing.setBackgroundColor(getResources().getColor(R.color.white));
holder.facing.setHintTextColor(getResources().getColor(android.R.color.holo_red_dark));
holder.facing.setHint(getString(R.string.empty));
*//* if (childData.getCompany_id().equals("1") && !childData.getMust_have().equals("0")) {
}else{
holder.facing.setHint("");
}*//*
tempflag = true;
}
} else {
holder.facing.setHint("");
}
}*/
if (tempflag) {
//holder.cardView.setCardBackgroundColor(getResources().getColor(android.R.color.holo_red_dark));
holder.lin_category.setBackgroundColor(getResources().getColor(android.R.color.holo_red_dark));
} else {
//holder.cardView.setCardBackgroundColor(getResources().getColor(R.color.white));
if (childData.getCompany_id().equals("1") && childData.getMust_have().equals("1")) {
holder.lin_category.setBackgroundColor(getResources().getColor(R.color.colorOrange));
} else {
holder.lin_category.setBackgroundColor(getResources().getColor(R.color.white));
}
}
} else {
/* if (holder.facing.getText().toString().equals("")) {
holder.facing.setBackgroundColor(getResources().getColor(R.color.white));
holder.facing.setHintTextColor(getResources().getColor(android.R.color.holo_red_dark));
holder.facing.setHint(getString(R.string.empty));
tempflag = true;
}*/
if (tempflag) {
//holder.cardView.setCardBackgroundColor(getResources().getColor(android.R.color.holo_red_dark));
holder.lin_category.setBackgroundColor(getResources().getColor(android.R.color.holo_red_dark));
} else {
//holder.cardView.setCardBackgroundColor(getResources().getColor(R.color.white));
if (childData.getCompany_id().equals("1") && childData.getMust_have().equals("1")) {
holder.lin_category.setBackgroundColor(getResources().getColor(R.color.colorOrange));
} else {
holder.lin_category.setBackgroundColor(getResources().getColor(R.color.white));
}
}
}
}
return convertView;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
}
public class ViewHolder {
CardView cardView;
TextView txt_skuName;
LinearLayout lin_category;
EditText stock;
EditText facing;
View stock_view;
}
boolean validateData(List<MSL_AvailabilityStockFacingGetterSetter> listDataHeader,
HashMap<MSL_AvailabilityStockFacingGetterSetter, List<MSL_AvailabilityStockFacingGetterSetter>> listDataChild) {
boolean flag = true;
checkHeaderArray.clear();
for (int i = 0; i < listDataHeader.size(); i++) {
for (int j = 0; j < listDataChild.get(listDataHeader.get(i)).size(); j++) {
MSL_AvailabilityStockFacingGetterSetter data = listDataChild.get(listDataHeader.get(i)).get(j);
String stock = data.getStock();
String faceup = data.getFacing();
if (faceup.equals("")) {
if (!checkHeaderArray.contains(i)) {
checkHeaderArray.add(i);
}
//expandableListView.smoothScrollToPosition(i);
scrollPosition = i;
flag = false;
Error_Message = getResources().getString(R.string.faceup_value);
break;
} else if (stock.equals("")) {
if (!checkHeaderArray.contains(i)) {
checkHeaderArray.add(i);
}
//expandableListView.smoothScrollToPosition(i);
scrollPosition = i;
flag = false;
Error_Message = getResources().getString(R.string.stock_value);
break;
}
//Company_id
/* if (listDataChild.get(listDataHeader.get(i)).get(j).getCompany_id().equals("1")) {
if (data.getMust_have().equals("1")) {
*//*if (!camera_allow.equalsIgnoreCase("1")) {
if (!(planogramShelfHeaderDataList.size() > 0)) {
flag = false;
Error_Message = getResources().getString(R.string.stock_planogram_data_noCamera_data);
break;
}
}*//*
if (faceup.equals("")) {
if (!checkHeaderArray.contains(i)) {
checkHeaderArray.add(i);
}
//expandableListView.smoothScrollToPosition(i);
scrollPosition = i;
flag = false;
Error_Message = getResources().getString(R.string.faceup_value);
break;
} else {
if (data.getToggleValue().equals("0")) {
if (stock.equals("")) {
if (!checkHeaderArray.contains(i)) {
checkHeaderArray.add(i);
}
//expandableListView.smoothScrollToPosition(i);
scrollPosition = i;
flag = false;
Error_Message = getResources().getString(R.string.stock_value);
break;
}
}
}
}
} else {
if (faceup.equals("")) {
if (!checkHeaderArray.contains(i)) {
checkHeaderArray.add(i);
}
//expandableListView.smoothScrollToPosition(i);
scrollPosition = i;
flag = false;
Error_Message = getResources().getString(R.string.faceup_value);
break;
}
}*/
}
if (flag == false) {
checkflag = false;
break;
} else {
checkflag = true;
}
}
adapter.notifyDataSetChanged();
return checkflag;
}
}
@@ -78,7 +78,7 @@ public class T2PComplianceActivity extends AppCompatActivity {
RecyclerView rec_t2p;
MyAdaptorStock adapterData;
String categoryName, categoryId;
String store_id, visit_date, username, intime, date, keyAccount_id, class_id, storeType_id, camera_allow;
String store_id, visit_date, username, intime, date, keyAccount_id, class_id, storeType_id, camera_allow, country_id;
String str = CommonString.FILE_PATH,
path = "", path1 = "", path2 = "",
_pathforcheck = "", _pathforcheck1 = "", _pathforcheck2 = "",
@@ -128,6 +128,7 @@ public class T2PComplianceActivity extends AppCompatActivity {
class_id = preferences.getString(CommonString.KEY_CLASS_ID, "");
storeType_id = preferences.getString(CommonString.KEY_STORETYPE_ID, "");
camera_allow = preferences.getString(CommonString.KEY_CAMERA_ALLOW, "");
country_id = preferences.getString(CommonString.KEY_COUNTRY_ID, "");
rec_t2p = (RecyclerView) findViewById(R.id.rec_t2p);
@@ -1111,7 +1112,7 @@ public class T2PComplianceActivity extends AppCompatActivity {
flag = false;
error_msg = getResources().getString(R.string.fill_gaps_data);
break;
} else if (camera_allow.equals("1") && (t2PGetterSetters.get(i).getImage().equals("") &&
} else if (!country_id.equals("6") && camera_allow.equals("1") && (t2PGetterSetters.get(i).getImage().equals("") &&
t2PGetterSetters.get(i).getImage1().equals("") &&
t2PGetterSetters.get(i).getImage2().equals(""))) {
flag = false;
@@ -106,6 +106,7 @@ public class ServiceActivityFragment extends Fragment {
}
else{
showExportDialog();
//restoreBackup();
}
@@ -163,6 +164,33 @@ public class ServiceActivityFragment extends Fragment {
}
}
public void restoreBackup(){
try {
File sd = Environment.getExternalStorageDirectory();
File data = Environment.getDataDirectory();
if (sd.canWrite()) {
String currentDBPath = "//data//cpm.com.gskmtorange//databases//" + GSKOrangeDB.DATABASE_NAME;
String backupDBPath = "GSKMT_ORANGE_Database_backup.dat";
File currentDB = new File(data, currentDBPath);
File backupDB = new File(sd, backupDBPath);
if (currentDB.exists()) {
FileChannel src = new FileInputStream(backupDB).getChannel();
FileChannel dst = new FileOutputStream(currentDB).getChannel();
dst.transferFrom(src, 0, src.size());
src.close();
dst.close();
Toast.makeText(getActivity(), "Database Restored successfully", Toast.LENGTH_SHORT).show();
}
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
public void showExportDialog(){
String path;
AlertDialog.Builder builder1 = new AlertDialog.Builder(getActivity());
@@ -33,6 +33,7 @@ import cpm.com.gskmtorange.constant.CommonString;
import cpm.com.gskmtorange.dailyentry.AdditionalVisibility;
import cpm.com.gskmtorange.dailyentry.CategoryPicture;
import cpm.com.gskmtorange.dailyentry.CreateSelfActivity;
import cpm.com.gskmtorange.dailyentry.StockDataActivity;
import cpm.com.gskmtorange.dailyentry.T2PComplianceActivity;
import cpm.com.gskmtorange.xmlGetterSetter.DailyDataMenuGetterSetter;
@@ -44,7 +45,7 @@ public class DailyDataMenuActivity extends AppCompatActivity {
GSKOrangeDB db;
String categoryName = "", categoryId;
String store_id, visit_date, username, intime, date, keyAccount_id, class_id, storeType_id, camera_allow;
String store_id, visit_date, username, intime, date, keyAccount_id, class_id, storeType_id, camera_allow, country_id;
private SharedPreferences preferences;
ArrayList<CategoryPictureGetterSetter> category_camera_list;
@@ -77,6 +78,7 @@ public class DailyDataMenuActivity extends AppCompatActivity {
class_id = preferences.getString(CommonString.KEY_CLASS_ID, "");
storeType_id = preferences.getString(CommonString.KEY_STORETYPE_ID, "");
camera_allow = preferences.getString(CommonString.KEY_CAMERA_ALLOW, "");
country_id = preferences.getString(CommonString.KEY_COUNTRY_ID, "");
//Intent data
categoryName = getIntent().getStringExtra("categoryName");
categoryId = getIntent().getStringExtra("categoryId");
@@ -110,18 +112,35 @@ public class DailyDataMenuActivity extends AppCompatActivity {
categoryList = new ArrayList<>();
DailyDataMenuGetterSetter data = new DailyDataMenuGetterSetter();
data = new DailyDataMenuGetterSetter();
data.setCategory_name(getResources().getString(R.string.daily_data_menu_msl_availability));
if (db.isMappingStockDataStockFacing(categoryId, keyAccount_id, storeType_id, class_id)) {
if (db.checkMsl_Availability_StockFacingData(store_id, categoryId)) {
data.setCategory_img(R.mipmap.msl_availability_done);
if(country_id.equals("6") && categoryId.equals("3")){
data = new DailyDataMenuGetterSetter();
data.setCategory_name(getResources().getString(R.string.daily_data_menu_stock_facing));
if (db.isMappingStockDataStockFacing(categoryId, keyAccount_id, storeType_id, class_id)) {
if (db.checkMsl_Availability_StockFacingData(store_id, categoryId)) {
data.setCategory_img(R.mipmap.msl_availability_done);
} else {
data.setCategory_img(R.mipmap.msl_availability);
}
} else {
data.setCategory_img(R.mipmap.msl_availability);
data.setCategory_img(R.mipmap.msl_availability_grey);
}
} else {
data.setCategory_img(R.mipmap.msl_availability_grey);
categoryList.add(data);
}
else {
data = new DailyDataMenuGetterSetter();
data.setCategory_name(getResources().getString(R.string.daily_data_menu_msl_availability));
if (db.isMappingStockDataStockFacing(categoryId, keyAccount_id, storeType_id, class_id)) {
if (db.checkMsl_Availability_StockFacingData(store_id, categoryId)) {
data.setCategory_img(R.mipmap.msl_availability_done);
} else {
data.setCategory_img(R.mipmap.msl_availability);
}
} else {
data.setCategory_img(R.mipmap.msl_availability_grey);
}
categoryList.add(data);
}
categoryList.add(data);
/*data.setCategory_name(getResources().getString(R.string.daily_data_menu_msl_availability));
@@ -219,7 +238,6 @@ public class DailyDataMenuActivity extends AppCompatActivity {
/*data = new DailyDataMenuGetterSetter();
data.setCategory_name(getResources().getString(R.string.daily_data_menu_competition_tracking));
//data.setCategory_name("Competition Tracking");
@@ -329,9 +347,14 @@ public class DailyDataMenuActivity extends AppCompatActivity {
} else {
holder.categoryName.setTextColor(getResources().getColor(R.color.grey_background));
}
}else if (dailyData.getCategory_name().equalsIgnoreCase(getResources().getString(R.string.daily_data_menu_stock_facing))) {
if (db.isMappingStockDataStockFacing(categoryId, keyAccount_id, storeType_id, class_id)) {
holder.categoryName.setTextColor(getResources().getColor(R.color.colorPrimaryDark));
} else {
holder.categoryName.setTextColor(getResources().getColor(R.color.grey_background));
}
}
holder.lay_menu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@@ -399,6 +422,14 @@ public class DailyDataMenuActivity extends AppCompatActivity {
startActivity(intent);
}
}else if (dailyData.getCategory_name().equalsIgnoreCase(getResources().getString(R.string.daily_data_menu_stock_facing))) {
if (db.isMappingStockDataStockFacing(categoryId, keyAccount_id, storeType_id, class_id)) {
Intent intent = new Intent(DailyDataMenuActivity.this, StockDataActivity.class);
intent.putExtra("categoryName", dailyData.getCategory_name());
intent.putExtra("categoryId", categoryId);
startActivity(intent);
}
}
}
@@ -80,7 +80,7 @@ public class MSL_Availability_StockFacingActivity extends AppCompatActivity {
GSKOrangeDB db;
String categoryName, categoryId, storeId, Error_Message = "";
String store_id, visit_date, username, intime, date, keyAccount_id, class_id, storeType_id, camera_allow;
String store_id, visit_date, username, intime, date, keyAccount_id, class_id, storeType_id, camera_allow, country_id;
boolean isDialogOpen = true;
private SharedPreferences preferences;
int scrollPosition = 0;
@@ -128,6 +128,7 @@ public class MSL_Availability_StockFacingActivity extends AppCompatActivity {
class_id = preferences.getString(CommonString.KEY_CLASS_ID, "");
storeType_id = preferences.getString(CommonString.KEY_STORETYPE_ID, "");
camera_allow = preferences.getString(CommonString.KEY_CAMERA_ALLOW, "");
country_id = preferences.getString(CommonString.KEY_COUNTRY_ID, "");
//Intent data
categoryName = getIntent().getStringExtra("categoryName");
@@ -1017,8 +1018,11 @@ public class MSL_Availability_StockFacingActivity extends AppCompatActivity {
faceint = 5;
edFaceup = String.valueOf(num + faceint / 10.0);
finalHolder2.facing.setText(edFaceup);
}
}
/*Double faceup = Double.parseDouble(edFaceup);
DecimalFormat twoDForm = new DecimalFormat(".#");
faceup= Double.valueOf(twoDForm.format(faceup));*/
@@ -1147,7 +1151,15 @@ public class MSL_Availability_StockFacingActivity extends AppCompatActivity {
if (isFill) {
if (!edFaceup.equals("")) {
String faceup = edFaceup.replaceFirst("^0+(?!$)", "");
String faceup = "";
if(edFaceup.equals("0")){
faceup = edFaceup;
}
else{
faceup = edFaceup.replaceFirst("^0+(?!$)", "");
//faceup = new DecimalFormat("##.#").format(Double.parseDouble(faceup));
}
// String str2 = PerfectDecimal(faceup, 3, 1);
childData.setFacing(faceup);
} else {
@@ -246,7 +246,7 @@ public class PreviousDataUploadActivity extends AppCompatActivity {
for (int i = 0; i < coverageList.size(); i++) {
storeData = db.getSpecificStoreData(date, coverageList.get(i).getStoreId());
storeData = db.getSpecificStoreData(coverageList.get(i).getVisitDate(), coverageList.get(i).getStoreId());
if (storeData.getSTORE_ID() != null) {
if (storeData.getCHECKOUT_STATUS().equals(CommonString.KEY_Y) ||
@@ -1501,10 +1501,11 @@ public class PreviousDataUploadActivity extends AppCompatActivity {
}*/
dialog.dismiss();
db.deleteAllTables();
if (result.contains(CommonString.KEY_SUCCESS)) {
//db.deleteAllTables();
showAlert(getString(R.string.menu_upload_data));
db.deleteAllTables();
//showAlert(getString(R.string.menu_upload_data));
} else {
showAlert(getString(R.string.error) + result.toString());
@@ -9,7 +9,7 @@ import java.util.ArrayList;
public class LoginGetterSetter implements Serializable{
String RIGHT_NAME, APP_VERSION, APP_PATH, CURRENTDATE;
String RIGHT_NAME, APP_VERSION, APP_PATH, CURRENTDATE,COUNTRY_ID;
ArrayList<String> CULTURE_ID = new ArrayList<>();
ArrayList<String> CULTURE_NAME = new ArrayList<>();
@@ -71,4 +71,12 @@ public class LoginGetterSetter implements Serializable{
public void setNOTICE_URL(String NOTICE_URL) {
this.NOTICE_URL.add(NOTICE_URL);
}
public String getCOUNTRY_ID() {
return COUNTRY_ID;
}
public void setCOUNTRY_ID(String COUNTRY_ID) {
this.COUNTRY_ID = COUNTRY_ID;
}
}
@@ -8,7 +8,7 @@ import java.io.Serializable;
public class MSL_AvailabilityStockFacingGetterSetter implements Serializable{
String sub_category_id, sub_category, brand_id, brand,
sku_id, sku, mrp, sku_sequence, toggleValue, mbq, category_id, facing, stock,company_id,must_have;
sku_id, sku, mrp, sku_sequence, toggleValue, mbq, category_id, facing="", stock,company_id,must_have;
public String getSub_category_id() {
return sub_category_id;
@@ -95,6 +95,9 @@ public class XMLHandlers {
lgs.setNOTICE_URL(xpp.nextText());
}
if (xpp.getName().equals("COUNTRY_ID")) {
lgs.setCOUNTRY_ID(xpp.nextText());
}
}
xpp.next();
}
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="cpm.com.gskmtorange.dailyentry.StockDataActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_stock_data" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:srcCompat="@drawable/save_icon" />
</android.support.design.widget.CoordinatorLayout>
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
@@ -8,4 +8,11 @@
tools:context="cpm.com.gskmtorange.dailyentry.PlanogramPDFActivity"
tools:showIn="@layout/activity_planogram_pdf">
</android.support.constraint.ConstraintLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/rec"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="cpm.com.gskmtorange.dailyentry.StockDataActivity"
tools:showIn="@layout/activity_stock_data">
<ExpandableListView
android:id="@+id/expandableListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:cacheColorHint="#00000000"
android:divider="@null"
android:dividerHeight="0dp"
android:scrollingCache="false" />
</android.support.constraint.ConstraintLayout>
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/cardview_shadow_end_color">
<android.support.v7.widget.CardView
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_marginTop="2dp"
card_view:cardBackgroundColor="@color/white"
card_view:cardCornerRadius="5dp">
<LinearLayout
android:id="@+id/layout_parent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:orientation="horizontal"
android:padding="10sp"
android:weightSum="10">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:id="@+id/storelistviewxml_storeico"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:layout_marginRight="6sp"
android:layout_weight="1"
android:background="@mipmap/ic_import_contacts_black_48dp" />
</RelativeLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="9"
android:orientation="vertical">
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title"
android:textColor="#1F3A6C"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/storelistviewxml_storename"
android:layout_below="@+id/storelistviewxml_storename"
android:text="Details"
android:textColor="#666666"
android:textSize="10sp"
android:textStyle="normal" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
@@ -0,0 +1,158 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
card_view:cardCornerRadius="10dp"
android:elevation="5dp">
<LinearLayout
android:id="@+id/lin_category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:weightSum="5">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="2.5"
android:orientation="vertical">
<TextView
android:id="@+id/txt_skuName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingLeft="10dp"
android:paddingRight="15dp"
android:paddingTop="5dp"
android:text="SKU Name Value "
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#222" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1">
<!-- <LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".25"
android:orientation="vertical">
<TextView
android:id="@+id/txt_mbq"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="0"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#222"
android:textColorHint="#666" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".25"
android:orientation="vertical">
<ToggleButton
android:id="@+id/toggle_available"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/toggle_selector_background"
android:textOff="@string/no"
android:textOn="@string/yes" />
</LinearLayout>
-->
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight=".5"
android:gravity="center_vertical"
android:orientation="vertical">
<EditText
android:id="@+id/ed_facing"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:gravity="center"
android:inputType="numberDecimal"
android:maxLength="6"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:hint="@string/stock_facing_faceup"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#222"
android:textColorHint="#666" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/black" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="5dp"
android:layout_weight=".5"
android:gravity="center_vertical"
android:orientation="vertical">
<EditText
android:id="@+id/ed_stock"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:gravity="center"
android:inputType="number"
android:maxLength="5"
android:hint="@string/stock"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#222"
android:textColorHint="#666"
/>
<View
android:id="@+id/stock_view"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/black" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</LinearLayout>
Binary file not shown.

After

Width:  |  Height:  |  Size: 603 B

@@ -182,7 +182,7 @@
<string name="title_activity_store_wise_performance">أداء المتجر</string>
<string name="success">نجاح</string>
<string name="category_performance_t2p">مواد الدعاية في المتاجر</string>
<string name="daily_data_menu_t2p">T2P -المتاح او المتوفر الشهري</string>
<string name="daily_data_menu_t2p">أدوات العرض</string>
<string name="title_activity_t2_pcompliance"> T2P - مطابقة مواد الدعاية لقوانين الشركة</string>
<string name="t2p_data_uploading">تحميل بيانات مواد الدعاية T2P</string>
<string name="title_activity_t2p_brand__avaibility">تواجد مواد الدعاية</string>
+3 -1
View File
@@ -57,7 +57,7 @@
<string name="menu_daily_route_plan">Daily Route Plan</string>
<string name="menu_daily_download">Daily Data Download</string>
<string name="menu_upload_data">Upload Data</string>
<string name="menu_upload_data">Data Uploaded Successfully</string>
<string name="menu_geotag">Geo Tag</string>
<string name="menu_export">Data Export</string>
@@ -329,5 +329,7 @@
<string name="select_option">Select an option</string>
<string name="title_activity_planogram_pdf">Planogram Document</string>
<string name="Download_pdf_Error">File not downloaded</string>
<string name="title_activity_stock_data">Stock</string>
</resources>
+3 -1
View File
@@ -2,10 +2,11 @@
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@@ -14,6 +15,7 @@ buildscript {
allprojects {
repositories {
google()
jcenter()
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
#Wed Apr 12 12:10:11 IST 2017
#Thu Jan 18 12:31:40 IST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip