Commit 6cf45268 by Jemsheer K D

Order Info Page

parent 1df5b1b9
......@@ -46,7 +46,7 @@
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
......
package in.techware.carrefour.activity.info;
import android.arch.lifecycle.Observer;
import android.arch.lifecycle.ViewModelProviders;
import android.content.Context;
import android.content.Intent;
......@@ -11,22 +12,14 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import java.util.HashMap;
import in.techware.carrefour.R;
import in.techware.carrefour.activity.BaseAppCompatNoDrawerActivity;
import in.techware.carrefour.app.App;
import in.techware.carrefour.config.Config;
import in.techware.carrefour.dialogs.PopupMessage;
import in.techware.carrefour.dialogs.ProductInfoUnitDialog;
import in.techware.carrefour.listeners.BarcodeUpdateListener;
import in.techware.carrefour.listeners.ProductInfoListener;
import in.techware.carrefour.model.FamilyBean;
import in.techware.carrefour.model.MenuBean;
import in.techware.carrefour.model.ProductInfoBean;
import in.techware.carrefour.net.DataManager;
import in.techware.carrefour.util.AppConstants;
import in.techware.carrefour.util.BarcodeUtil;
import in.techware.carrefour.util.TimeUtil;
......@@ -81,6 +74,8 @@ public class ProductInfoActivity extends BaseAppCompatNoDrawerActivity {
initToolbar();
initViews();
initViewModelCallbacks();
handleKeyboard();
// populateViewModel();
......@@ -140,6 +135,8 @@ public class ProductInfoActivity extends BaseAppCompatNoDrawerActivity {
etxtBarcode.requestFocus();
}
clearViews();
btnUnit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -185,11 +182,7 @@ public class ProductInfoActivity extends BaseAppCompatNoDrawerActivity {
viewModel.setBarcode(BarcodeUtil.getFormattedBarcode(barcode));
setProgressScreenVisibility(true, true);
if (App.isNetworkAvailable()) {
fetchProductInfoFromWS();
} else {
fetchProductInfoFromFile();
}
viewModel.fetchProductInfo();
}
return true;
......@@ -209,15 +202,25 @@ public class ProductInfoActivity extends BaseAppCompatNoDrawerActivity {
viewModel.setBarcode(barcode);
setProgressScreenVisibility(true, true);
if (App.isNetworkAvailable()) {
fetchProductInfoFromWS();
} else {
fetchProductInfoFromFile();
}
viewModel.fetchProductInfo();
}
};
addBarcodeUpdateListener(barcodeUpdateListener);
}
private void initViewModelCallbacks() {
viewModel.isFetchingFinished().observe(this, new Observer<Boolean>() {
@Override
public void onChanged(Boolean isFetchingFinished) {
if (isFetchingFinished) {
populateProductInfo();
}
}
});
}
......@@ -379,45 +382,8 @@ public class ProductInfoActivity extends BaseAppCompatNoDrawerActivity {
}
}
private void fetchProductInfoFromWS() {
HashMap<String, String> urlParams = new HashMap<>();
urlParams.put("StoreID", Config.getInstance().getAppSettingsBean().getStoreID());
int type = AppConstants.PRODUCT_INFO_TYPE_NORMAL;
if (viewModel.getBarcode().startsWith("21")) {
urlParams.put("BarCode", viewModel.getBarcode().substring(0, 7));
type = AppConstants.PRODUCT_INFO_TYPE_MARKET;
} else {
urlParams.put("BarCode", viewModel.getBarcode());
}
DataManager.fetchProductInfo(urlParams, type, new ProductInfoListener() {
@Override
public void onLoadCompleted(ProductInfoBean productInfoBean) {
viewModel.setProductInfoBean(ProductInfoUtil.parseProductInfo(productInfoBean));
if (viewModel.getProductInfoBean() != null) {
setData();
} else {
PopupMessage popupMessage = new PopupMessage(ProductInfoActivity.this);
popupMessage.show(getString(R.string.message_item_not_found), 0, getString(R.string.btn_ok));
clearViews();
}
setProgressScreenVisibility(false, false);
}
@Override
public void onLoadFailed(String error) {
Toast.makeText(ProductInfoActivity.this, error, Toast.LENGTH_SHORT).show();
clearViews();
setProgressScreenVisibility(false, false);
}
});
}
private void fetchProductInfoFromFile() {
if (Config.getInstance().getProductInfoList() != null && !Config.getInstance().getProductInfoList().isEmpty()) {
viewModel.setProductInfoBean(Config.getInstance().searchProductInfo(viewModel.getBarcode()));
private void populateProductInfo() {
if (viewModel.getProductInfoBean() != null) {
setData();
} else {
......@@ -427,7 +393,6 @@ public class ProductInfoActivity extends BaseAppCompatNoDrawerActivity {
}
setProgressScreenVisibility(false, false);
}
}
private void onProductInfoUnitClick(View view) {
view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
......@@ -461,6 +426,7 @@ public class ProductInfoActivity extends BaseAppCompatNoDrawerActivity {
//mVibrator.vibrate(25);
startActivity(new Intent(getApplicationContext(), LabelActivity.class)
.putExtra("menuBean", viewModel.getSelectedMenuBean())
.putExtra("bean", viewModel.getProductInfoBean())
.putExtra("barcode", viewModel.getBarcode()));
finish();
......@@ -471,6 +437,7 @@ public class ProductInfoActivity extends BaseAppCompatNoDrawerActivity {
//mVibrator.vibrate(25);
startActivity(new Intent(getApplicationContext(), OrderInfoActivity.class)
.putExtra("menuBean", viewModel.getSelectedMenuBean())
.putExtra("bean", viewModel.getProductInfoBean())
.putExtra("barcode", viewModel.getBarcode()));
finish();
......@@ -481,6 +448,7 @@ public class ProductInfoActivity extends BaseAppCompatNoDrawerActivity {
//mVibrator.vibrate(25);
startActivity(new Intent(getApplicationContext(), WeekMovementActivity.class)
.putExtra("menuBean", viewModel.getSelectedMenuBean())
.putExtra("bean", viewModel.getProductInfoBean())
.putExtra("barcode", viewModel.getBarcode()));
finish();
......
package `in`.techware.carrefour.viewModels
import `in`.techware.carrefour.app.App
import `in`.techware.carrefour.config.Config
import `in`.techware.carrefour.listeners.ProductInfoListener
import `in`.techware.carrefour.model.MenuBean
import `in`.techware.carrefour.model.ProductInfoBean
import `in`.techware.carrefour.net.DataManager
import `in`.techware.carrefour.util.AppConstants
import `in`.techware.carrefour.util.menuUtils.ProductInfoUtil
import android.arch.lifecycle.MutableLiveData
import android.arch.lifecycle.ViewModel
import android.widget.Toast
import java.util.*
import kotlin.collections.set
/**
* Created by Jemsheer K D on 27 July, 2018.
......@@ -17,7 +27,8 @@ class ProductInfoViewModel : ViewModel() {
var selectedMenuBean: MenuBean? = null
var productInfoList: ArrayList<ProductInfoBean> = ArrayList()
var isFetchingFinished: MutableLiveData<Boolean> = MutableLiveData()
fun setData(bean: ProductInfoBean) {
......@@ -29,25 +40,51 @@ class ProductInfoViewModel : ViewModel() {
productInfoBean = null
}
fun indexOf(productInfoBean: ProductInfoBean): Int {
for (bean in productInfoList) {
if (bean.barcode == productInfoBean.barcode) {
return productInfoList.indexOf(bean)
fun fetchProductInfo() {
isFetchingFinished.value = false
if (App.isNetworkAvailable()) {
fetchProductInfoFromWS()
} else {
fetchProductInfoFromFile()
}
}
return -1
private fun fetchProductInfoFromWS() {
val urlParams = HashMap<String, String>()
urlParams["StoreID"] = Config.getInstance().appSettingsBean.storeID
var type = AppConstants.PRODUCT_INFO_TYPE_NORMAL
if (barcode.startsWith("21")) {
urlParams["BarCode"] = barcode.substring(0, 7)
type = AppConstants.PRODUCT_INFO_TYPE_MARKET
} else {
urlParams["BarCode"] = barcode
}
fun lastIndex(): Int {
return productInfoList.size - 1
DataManager.fetchProductInfo(urlParams, type, object : ProductInfoListener {
override fun onLoadCompleted(productInfoBeanWS: ProductInfoBean) {
productInfoBean = ProductInfoUtil.parseProductInfo(productInfoBeanWS)
isFetchingFinished.value = true
}
fun indexOf(barcode: String): Int {
for (bean in productInfoList) {
if (bean.barcode == barcode) {
return productInfoList.indexOf(bean)
override fun onLoadFailed(error: String) {
Toast.makeText(App.getInstance(), error, Toast.LENGTH_SHORT).show()
productInfoBean = null
isFetchingFinished.value = true
}
})
}
private fun fetchProductInfoFromFile() {
if (Config.getInstance().productInfoList != null && !Config.getInstance().productInfoList.isEmpty()) {
productInfoBean = Config.getInstance().searchProductInfo(barcode)
isFetchingFinished.value = true
} else {
productInfoBean = null
isFetchingFinished.value = true
}
return -1
}
}
\ No newline at end of file
......@@ -136,19 +136,19 @@
<string name="label_survey_placeholder">Label Survey</string>
<string name="label_today_selling_price">Today Selling Price</string>
<string name="label_zone">Zone</string>
<string name="last_recept_date_value">Last reception date</string>
<string name="lpo_type_value">Supplier LPO Type</string>
<string name="label_last_reception_date">Last reception date</string>
<string name="label_supplier_lpo_type">Supplier LPO Type</string>
<string name="main_menu_placeholder">Main Menu</string>
<string name="main_page_placeholder">Main Page</string>
<string name="next_delivery_value">Next delivery date</string>
<string name="next_ordering_value">Next ordering date</string>
<string name="label_next_delivery_date">Next delivery date</string>
<string name="label_next_ordering_date">Next ordering date</string>
<string name="offsite_storage_in_label">Off-Site Storage IN</string>
<string name="offsite_storage_out_label">Off-Site Storage OUT</string>
<string name="order_info_label">Order Info</string>
<string name="order_placeholder">Order</string>
<string name="password_label">Password</string>
<string name="pcb_value">PCB</string>
<string name="pending_orders_value">Pending Orders</string>
<string name="label_pcb">PCB</string>
<string name="label_pending_orders">Pending Orders</string>
<string name="percentage_progress_label">46%</string>
<string name="pit_number_placeholder">PIT Number</string>
<string name="price_label">Price</string>
......@@ -161,11 +161,11 @@
<string name="shelf_print_label">Print Shelf Label</string>
<string name="spinner_arrow">\u02C5</string>
<string name="spinner_prompt">1-Freshness, Quality</string>
<string name="stock_min_value">Stock minimum</string>
<string name="label_stock_minimum">Stock minimum</string>
<string name="stock_take_placeholder">Stock Take</string>
<string name="store_placeholder">456</string>
<string name="supplier_dc_value">SUPPLIER or DC</string>
<string name="supplier_lead_time_value">Supplier Lead Time</string>
<string name="label_supplier_or_dc">SUPPLIER or DC</string>
<string name="label_supplier_lead_time">Supplier Lead Time</string>
<string name="title_expiry_action">Expiry Action</string>
<string name="title_file_transfer">File Transfer</string>
<string name="title_get_orders">Get Orders</string>
......@@ -867,6 +867,8 @@
<string name="sample_unit">Composed/Pack</string>
<string name="label_updated_on">Updated On-</string>
<string name="message_item_not_found">Item not found</string>
<string name="btn_main_page">Main Page</string>
<string name="title_order_info">Order Info</string>
<string-array name="menu_home">
......
......@@ -11,7 +11,7 @@ buildscript {
maven { url "https://jitpack.io" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0-alpha11'
classpath 'com.android.tools.build:gradle:3.3.0-alpha12'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'io.fabric.tools:gradle:1+'
......
#Fri Sep 14 10:22:14 IST 2018
#Thu Sep 27 11:09:58 IST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment