YSY commit

This commit is contained in:
yadavendras
2018-10-11 18:42:13 +05:30
parent b0e2e05501
commit 1defc05bf1
14 changed files with 838 additions and 24 deletions
@@ -36,6 +36,7 @@ import cpm.com.gskmtorange.xmlGetterSetter.CategoryWisePerformaceGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.ChatMessageDownloadGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.ConfigurationContrywiseGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.ConfigurationMasterGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.DeliveryCallsGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.DisplayChecklistMasterGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.DisplayMasterGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.GapsChecklistGetterSetter;
@@ -82,7 +83,7 @@ import cpm.com.gskmtorange.xmlGetterSetter.TableBean;
*/
public class GSKOrangeDB extends SQLiteOpenHelper {
public static final String DATABASE_NAME = "GSK_ORANGE_DB37";
public static final String DATABASE_NAME = "GSK_ORANGE_DB38";
public static final int DATABASE_VERSION = 15;
TableBean tableBean;
private SQLiteDatabase db;
@@ -190,6 +191,7 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
db.execSQL(CommonString.CREATE_TABLE_AUDIT_DATA_SAVE);
db.execSQL(CommonString.CREATE_TABLE_POG_DATA_SAVE);
db.execSQL(CommonString.CREATE_TABLE_COACHING_VISIT);
db.execSQL(CommonString.CREATE_TABLE_DELIVERY_CALLS);//--Added 09.10.2018
} catch (SQLException e) {
e.printStackTrace();
@@ -6693,4 +6695,101 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
}
return list;
}
//DELIVERY_CALLS
public void InsertDeliveryCalls(DeliveryCallsGetterSetter data) {
//db.delete("DELIVERY_CALLS", null, null);
ContentValues values = new ContentValues();
try {
values.put(CommonString.KEY_STORE_NAME, data.getSTORE_NAME());
values.put(CommonString.KEY_ADDRESS, data.getADDRESS());
values.put(CommonString.KEY_IMAGE, data.getIN_TIME_IMAGE());
values.put(CommonString.KEY_IMAGE1, data.getOUT_TIME_IMAGE());
values.put(CommonString.KEY_UPLOAD_STATUS, data.getUPLOAD_STATUS());
values.put(CommonString.KEY_VISIT_DATE, data.getVISIT_DATE());
values.put(CommonString.KEY_IN_TIME, data.getIn_time());
db.insert("DELIVERY_CALLS", null, values);
} catch (Exception ex) {
Log.d("Exception ", " in DELIVERY_CALLS " + ex.toString());
}
}
public void updateDeliveryCallsOut(DeliveryCallsGetterSetter deliveryCallData, String status, String out_time_image) {
ContentValues values = new ContentValues();
try {
values.put(CommonString.KEY_IMAGE1, out_time_image);
values.put(CommonString.KEY_UPLOAD_STATUS, status);
values.put(CommonString.KEY_OUT_TIME, deliveryCallData.getOut_time());
db.update(CommonString.TABLE_DELIVERY_CALLS, values, CommonString.KEY_ID + "='" + deliveryCallData.getId() + "'", null);
} catch (Exception ex) {
}
}
// get Delivery Calls data
public ArrayList<DeliveryCallsGetterSetter> getDeliveryCallsData(String visit_date) {
ArrayList<DeliveryCallsGetterSetter> list = new ArrayList<>();
Cursor dbcursor = null;
try {
if(visit_date==null){
dbcursor = db.rawQuery("SELECT * FROM DELIVERY_CALLS ", null);
}
else {
dbcursor = db.rawQuery("SELECT * FROM DELIVERY_CALLS WHERE VISIT_DATE='" + visit_date + "'", null);
}
if (dbcursor != null) {
dbcursor.moveToFirst();
while (!dbcursor.isAfterLast()) {
DeliveryCallsGetterSetter msg = new DeliveryCallsGetterSetter();
msg.setADDRESS(dbcursor.getString(dbcursor.getColumnIndexOrThrow(CommonString.KEY_ADDRESS)));
msg.setSTORE_NAME(dbcursor.getString(dbcursor.getColumnIndexOrThrow(CommonString.KEY_STORE_NAME)));
msg.setIN_TIME_IMAGE(dbcursor.getString(dbcursor.getColumnIndexOrThrow(CommonString.KEY_IMAGE)));
msg.setOUT_TIME_IMAGE(dbcursor.getString(dbcursor.getColumnIndexOrThrow(CommonString.KEY_IMAGE1)));
msg.setUPLOAD_STATUS(dbcursor.getString(dbcursor.getColumnIndexOrThrow(CommonString.KEY_UPLOAD_STATUS)));
msg.setId(dbcursor.getString(dbcursor.getColumnIndexOrThrow(CommonString.KEY_ID)));
msg.setIn_time(dbcursor.getString(dbcursor.getColumnIndexOrThrow(CommonString.KEY_IN_TIME)));
msg.setOut_time(dbcursor.getString(dbcursor.getColumnIndexOrThrow(CommonString.KEY_OUT_TIME)));
msg.setVISIT_DATE(dbcursor.getString(dbcursor.getColumnIndexOrThrow(CommonString.KEY_VISIT_DATE)));
list.add(msg);
dbcursor.moveToNext();
}
dbcursor.close();
return list;
}
} catch (Exception e) {
Log.d("Exception ", "get Chat Message" + e.toString());
}
return list;
}
public void updateDeliveryCallsUploadStatus(String key_id) {
ContentValues values = new ContentValues();
try {
values.put(CommonString.KEY_UPLOAD_STATUS, CommonString.KEY_U);
db.update(CommonString.TABLE_DELIVERY_CALLS, values, CommonString.KEY_ID + "='" + key_id + "'", null);
} catch (Exception ex) {
}
}
}
@@ -387,12 +387,25 @@ public class MainActivity extends AppCompatActivity
}
}else if(id == R.id.nav_deviation){
Intent in = new Intent(this, StoreListActivity.class);
in.putExtra(CommonString.KEY_STORE_FLAG, CommonString.FROM_DEVIATION);
startActivity(in);
db.open();
if ( db.getSKUMasterData().size() == 0) {
Snackbar.make(webView, R.string.title_store_list_download_data, Snackbar.LENGTH_SHORT)
.setAction("Action", null).show();
// Toast.makeText(getBaseContext(), "Please Download Data First", Toast.LENGTH_LONG).show();
} else {
Intent in = new Intent(this, StoreListActivity.class);
in.putExtra(CommonString.KEY_STORE_FLAG, CommonString.FROM_DEVIATION);
startActivity(in);
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
}
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
}else if(id == R.id.nav_delivery_call){
Intent in = new Intent(this, DeliveryCallActivity.class);
startActivity(in);
@@ -236,10 +236,12 @@ public class CommonString {
public static final String CREATE_TABLE_DELIVERY_CALLS= "CREATE TABLE IF NOT EXISTS " + TABLE_DELIVERY_CALLS
+ " ("
+ KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT ,"
+ KEY_STORE_NAME+ " INTEGER,"
+ KEY_STORE_NAME+ " VARCHAR,"
+ KEY_ADDRESS + " VARCHAR,"
+ KEY_IMAGE + " VARCHAR,"
+ KEY_IMAGE1 + " VARCHAR,"
+ KEY_IN_TIME + " VARCHAR,"
+ KEY_OUT_TIME + " VARCHAR,"
+ KEY_UPLOAD_STATUS + " VARCHAR,"
+ KEY_VISIT_DATE + " VARCHAR)";
@@ -1,16 +1,60 @@
package cpm.com.gskmtorange.dailyentry;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
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.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.crashlytics.android.Crashlytics;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import cpm.com.gskmtorange.Database.GSKOrangeDB;
import cpm.com.gskmtorange.GetterSetter.StoreBean;
import cpm.com.gskmtorange.R;
import cpm.com.gskmtorange.constant.CommonString;
import cpm.com.gskmtorange.upload.UploadActivity;
import cpm.com.gskmtorange.upload.UploadImageWithRetrofit;
import cpm.com.gskmtorange.xmlGetterSetter.DeliveryCallsGetterSetter;
public class DeliveryCallActivity extends AppCompatActivity {
public class DeliveryCallActivity extends AppCompatActivity implements View.OnClickListener {
private SharedPreferences preferences;
private GSKOrangeDB database;
String visit_date, userId;
ArrayList<DeliveryCallsGetterSetter> deliveryCallsList;
RecyclerView recyclerView;
DeliveryAdapter deliveryAdapter;
FloatingActionButton fab_upload, fab;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -19,16 +63,331 @@ public class DeliveryCallActivity extends AppCompatActivity {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent in = new Intent(getApplicationContext(), DeliveryCallAddStoreActivity.class);
startActivity(in);
recyclerView = (RecyclerView) findViewById(R.id.rec_delivery_calls);
fab = (FloatingActionButton) findViewById(R.id.fab);
fab_upload = (FloatingActionButton) findViewById(R.id.fab_upload);
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
}
});
preferences = PreferenceManager.getDefaultSharedPreferences(this);
visit_date = preferences.getString(CommonString.KEY_DATE, null);
userId = preferences.getString(CommonString.KEY_USERNAME, null);
database = new GSKOrangeDB(this);
database.open();
fab.setOnClickListener(this);
fab_upload.setOnClickListener(this);
}
@Override
public void onClick(View v) {
int id = v.getId();
switch (id) {
case R.id.fab_upload:
new UploadTask().execute();
break;
case R.id.fab:
if (isCheckedIn()) {
Snackbar.make(recyclerView, getString(R.string.title_store_list_checkout_current), Snackbar.LENGTH_SHORT).show();
} else {
Intent in = new Intent(getApplicationContext(), DeliveryCallAddStoreActivity.class);
startActivity(in);
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
}
break;
}
}
class DeliveryAdapter extends RecyclerView.Adapter<DeliveryAdapter.MyViewHolder> {
private LayoutInflater inflator;
List<DeliveryCallsGetterSetter> data = Collections.emptyList();
public DeliveryAdapter(Context context, List<DeliveryCallsGetterSetter> data) {
inflator = LayoutInflater.from(context);
this.data = data;
}
@Override
public DeliveryAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = inflator.inflate(R.layout.delivery_calls_item, parent, false);
DeliveryAdapter.MyViewHolder holder = new DeliveryAdapter.MyViewHolder(view);
return holder;
}
@Override
public void onBindViewHolder(DeliveryAdapter.MyViewHolder holder, int position) {
final DeliveryCallsGetterSetter current = data.get(position);
holder.tv_store_name.setText(current.getSTORE_NAME());
holder.tv_store_address.setText(current.getADDRESS());
if (current.getUPLOAD_STATUS().equals(CommonString.KEY_CHECK_IN)) {
holder.imageview.setVisibility(View.INVISIBLE);
holder.cardView.setCardBackgroundColor(getResources().getColor(R.color.green));
} else if (current.getUPLOAD_STATUS().equals(CommonString.KEY_U)) {
holder.imageview.setVisibility(View.VISIBLE);
holder.imageview.setBackgroundResource(R.mipmap.tick);
holder.cardView.setCardBackgroundColor(getResources().getColor(R.color.colorOrange));
}else if (current.getUPLOAD_STATUS().equals(CommonString.KEY_C)) {
holder.imageview.setVisibility(View.VISIBLE);
holder.imageview.setBackgroundResource(R.mipmap.exclamation);
holder.cardView.setCardBackgroundColor(getResources().getColor(R.color.colorOrange));
} else {
holder.imageview.setVisibility(View.INVISIBLE);
holder.cardView.setCardBackgroundColor(getResources().getColor(R.color.colorOrange));
}
holder.cardView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (current.getUPLOAD_STATUS().equals(CommonString.KEY_CHECK_IN)) {
Intent in = new Intent(getApplicationContext(), DeliveryCallAddStoreActivity.class);
in.putExtra(CommonString.KEY_STORE_ID, current);
in.putExtra(CommonString.KEY_STORE_FLAG, false);
startActivity(in);
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
} else if (current.getUPLOAD_STATUS().equals(CommonString.KEY_U)) {
Snackbar.make(v, R.string.title_store_list_activity_store_already_done, Snackbar.LENGTH_LONG).setAction("Action", null).show();
} else if (current.getUPLOAD_STATUS().equals(CommonString.KEY_C)) {
Snackbar.make(v, R.string.title_store_list_activity_store_already_checkout, Snackbar.LENGTH_LONG).setAction("Action", null).show();
}
}
});
}
@Override
public int getItemCount() {
return deliveryCallsList.size();
}
class MyViewHolder extends RecyclerView.ViewHolder {
TextView tv_store_name, tv_store_address;
CardView cardView;
ImageView imageview;
public MyViewHolder(View itemView) {
super(itemView);
tv_store_name = (TextView) itemView.findViewById(R.id.tv_store_name);
tv_store_address = (TextView) itemView.findViewById(R.id.tv_store_address);
cardView = (CardView) itemView.findViewById(R.id.card_view);
imageview = (ImageView) itemView.findViewById(R.id.delivery_ico);
}
}
}
@Override
protected void onResume() {
super.onResume();
deliveryCallsList = database.getDeliveryCallsData(visit_date);
if (deliveryCallsList.size() > 0) {
//list.setAdapter(new MyAdaptor());
deliveryAdapter = new DeliveryAdapter(getApplicationContext(), deliveryCallsList);
recyclerView.setAdapter(deliveryAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
if (isCheckedIn()) {
fab_upload.setVisibility(View.GONE);
} else if (isUploadAble()) {
fab_upload.setVisibility(View.VISIBLE);
}
}
}
private Dialog dialog;
private ProgressBar pb;
private TextView percentage, message;
Object result = "";
class Data {
int value;
String name;
}
class UploadTask extends AsyncTask<Void, Data, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
dialog = new Dialog(DeliveryCallActivity.this);
dialog.setContentView(R.layout.custom);
dialog.setTitle(getString(R.string.uploaddata));
dialog.setCancelable(false);
dialog.show();
pb = (ProgressBar) dialog.findViewById(R.id.progressBar1);
percentage = (TextView) dialog.findViewById(R.id.percentage);
message = (TextView) dialog.findViewById(R.id.message);
((TextView) dialog.findViewById(R.id.tv_title)).setText(getString(R.string.uploaddata));
}
@Override
protected void onProgressUpdate(Data... values) {
// TODO Auto-generated method stub
pb.setProgress(values[0].value);
percentage.setText(values[0].value + "%");
message.setText(values[0].name);
}
@Override
protected String doInBackground(Void... voids) {
try {
Data data = new Data();
ArrayList<DeliveryCallsGetterSetter> _deliveryCallsList = database.getDeliveryCallsData(null);
for (int i = 0; i < _deliveryCallsList.size(); i++) {
if (_deliveryCallsList.get(i).getUPLOAD_STATUS().equals(CommonString.KEY_C)) {
data.value = 50;
data.name = getString(R.string.delivery_call);
publishProgress(data);
String onXML = "[DELIVERY_CALLS_DATA]"
+ "[USER_ID]" + userId + "[/USER_ID]"
+ "[VISIT_DATE]" + _deliveryCallsList.get(i).getVISIT_DATE() + "[/VISIT_DATE]"
+ "[STORE_NAME]" + _deliveryCallsList.get(i).getSTORE_NAME() + "[/STORE_NAME]"
+ "[STORE_ADDRESS]" + _deliveryCallsList.get(i).getADDRESS() + "[/STORE_ADDRESS]"
+ "[IN_TIME]" + _deliveryCallsList.get(i).getIn_time() + "[/IN_TIME]"
+ "[OUT_TIME]" + _deliveryCallsList.get(i).getOut_time() + "[/OUT_TIME]"
+ "[IN_TIME_IMAGE]" + _deliveryCallsList.get(i).getIN_TIME_IMAGE() + "[/IN_TIME_IMAGE]"
+ "[OUT_TIME_IMAGE]" + _deliveryCallsList.get(i).getOUT_TIME_IMAGE()+ "[/OUT_TIME_IMAGE]"
+ "[/DELIVERY_CALLS_DATA]";
final String delivery_xml = "[DATA]" + onXML + "[/DATA]";
SoapObject request = new SoapObject(CommonString.NAMESPACE, CommonString.METHOD_UPLOAD_STOCK_XML_DATA);
request.addProperty("XMLDATA", delivery_xml);
request.addProperty("KEYS", "DELIVERY_CALLS");
request.addProperty("USERNAME", userId);
request.addProperty("MID", 0);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(CommonString.URL);
androidHttpTransport.call(CommonString.SOAP_ACTION + CommonString.METHOD_UPLOAD_STOCK_XML_DATA, envelope);
result = envelope.getResponse();
if (!result.toString().equalsIgnoreCase(CommonString.KEY_SUCCESS)) {
return CommonString.METHOD_UPLOAD_STOCK_XML_DATA;
}
else {
database.open();
database.updateDeliveryCallsUploadStatus(_deliveryCallsList.get(i).getId());
}
}
}
return result.toString();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
Crashlytics.log(7, CommonString.MESSAGE_EXCEPTION, e.toString());
Crashlytics.logException(e.getCause());
Crashlytics.logException(new Exception(e.getCause()));
e.printStackTrace();
} catch (XmlPullParserException e) {
e.printStackTrace();
} catch (Exception e) {
Crashlytics.log(7, CommonString.MESSAGE_EXCEPTION, e.toString());
Crashlytics.logException(e.getCause());
Crashlytics.logException(new Exception(e.getCause()));
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
dialog.dismiss();
if (result.contains(CommonString.KEY_SUCCESS)) {
//db.deleteAllTables();
File f = new File(CommonString.FILE_PATH);
File fileAll[] = f.listFiles();
ArrayList<String> file_list = new ArrayList<>();
for (int i = 0; i < fileAll.length; i++) {
String name = fileAll[i].getName();
if(name.contains("CoachingVisit")){
file_list.add(name);
}
}
UploadImageWithRetrofit.uploadedFiles = 0;
UploadImageWithRetrofit.totalFiles = file_list.size();
UploadImageWithRetrofit uploadImg = new UploadImageWithRetrofit(visit_date, userId, DeliveryCallActivity.this);
uploadImg.UploadDeliveryImageRecursive(DeliveryCallActivity.this, file_list, 0);
} else {
showAlert(getString(R.string.error) + result.toString());
}
}
}
public void showAlert(String str) {
AlertDialog.Builder builder = new AlertDialog.Builder(DeliveryCallActivity.this);
builder.setTitle("Parinaam");
builder.setMessage(str).setCancelable(false)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
/* Intent i = new Intent(activity, StorelistActivity.class);
activity.startActivity(i);
activity.finish();*/
finish();
}
});
AlertDialog alert = builder.create();
alert.show();
}
boolean isCheckedIn() {
boolean flag = false;
for (int i = 0; i < deliveryCallsList.size(); i++) {
if (deliveryCallsList.get(i).getUPLOAD_STATUS().equals(CommonString.KEY_CHECK_IN)) {
flag = true;
break;
}
}
return flag;
}
boolean isUploadAble() {
boolean flag = false;
for (int i = 0; i < deliveryCallsList.size(); i++) {
if (deliveryCallsList.get(i).getUPLOAD_STATUS().equals(CommonString.KEY_C)) {
flag = true;
break;
}
}
return flag;
}
}
@@ -25,9 +25,11 @@ import com.crashlytics.android.Crashlytics;
import java.io.File;
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.xmlGetterSetter.DeliveryCallsGetterSetter;
public class DeliveryCallAddStoreActivity extends AppCompatActivity implements View.OnClickListener{
@@ -35,10 +37,12 @@ public class DeliveryCallAddStoreActivity extends AppCompatActivity implements V
ImageView img_checkin, img_checkout;
String name, address, error_msg, img_checkin_path="", img_checkout_path="";
boolean checkin_flag = true;
protected String _pathforcheck = "", _path, str, visit_date;
protected String _pathforcheck = "", _path, str, visit_date, in_time, out_time;
private SharedPreferences preferences;
Uri outputFileUri;
String gallery_package = "";
private GSKOrangeDB database;
DeliveryCallsGetterSetter deliveryCallsData;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -47,6 +51,9 @@ public class DeliveryCallAddStoreActivity extends AppCompatActivity implements V
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
database = new GSKOrangeDB(this);
database.open();
et_customer = findViewById(R.id.et_customer_name);
et_address = findViewById(R.id.et_address);
img_checkin = findViewById(R.id.img_checkin);
@@ -55,10 +62,18 @@ public class DeliveryCallAddStoreActivity extends AppCompatActivity implements V
preferences = PreferenceManager.getDefaultSharedPreferences(this);
visit_date = preferences.getString(CommonString.KEY_DATE, null);
checkin_flag = getIntent().getBooleanExtra(CommonString.KEY_STORE_FLAG, true);
deliveryCallsData = (DeliveryCallsGetterSetter) getIntent().getSerializableExtra(CommonString.KEY_STORE_ID);
if(checkin_flag){
img_checkin.setOnClickListener(this);
}
else {
et_customer.setText(deliveryCallsData.getSTORE_NAME());
et_address.setText(deliveryCallsData.getADDRESS());
et_customer.setEnabled(false);
et_address.setEnabled(false);
img_checkin.setImageDrawable(getResources().getDrawable(R.mipmap.camera_green));
img_checkout.setOnClickListener(this);
}
@@ -68,6 +83,27 @@ public class DeliveryCallAddStoreActivity extends AppCompatActivity implements V
public void onClick(View view) {
if(isValid()){
if(checkin_flag){
DeliveryCallsGetterSetter deliveryCallsGetterSetter = new DeliveryCallsGetterSetter();
deliveryCallsGetterSetter.setSTORE_NAME(name);
deliveryCallsGetterSetter.setADDRESS(address);
deliveryCallsGetterSetter.setIN_TIME_IMAGE(img_checkin_path);
deliveryCallsGetterSetter.setOUT_TIME_IMAGE(img_checkout_path);
deliveryCallsGetterSetter.setUPLOAD_STATUS(CommonString.KEY_CHECK_IN);
deliveryCallsGetterSetter.setVISIT_DATE(visit_date);
deliveryCallsGetterSetter.setIn_time(in_time);
database.InsertDeliveryCalls(deliveryCallsGetterSetter);
}
else {
deliveryCallsData.setOut_time(out_time);
database.updateDeliveryCallsOut(deliveryCallsData, CommonString.KEY_C, img_checkout_path);
}
finish();
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
}
else {
Snackbar.make(et_customer,error_msg,Snackbar.LENGTH_SHORT).show();
@@ -110,6 +146,9 @@ public class DeliveryCallAddStoreActivity extends AppCompatActivity implements V
public void onClick(View v) {
switch (v.getId()){
case R.id.img_checkin:
in_time = CommonFunctions.getCurrentTimeWithLanguage(getApplicationContext());
_pathforcheck = "CoachingVisit" + visit_date.replace("/", "")+ "InTime" + CommonFunctions.getCurrentTimeWithLanguage(getApplicationContext()).replace(":", "") + ".jpg";
_path = CommonString.FILE_PATH + _pathforcheck;
@@ -119,11 +158,13 @@ public class DeliveryCallAddStoreActivity extends AppCompatActivity implements V
case R.id.img_checkout:
out_time = CommonFunctions.getCurrentTimeWithLanguage(getApplicationContext());
_pathforcheck = "CoachingVisit" + visit_date.replace("/", "")+ "OutTime" + CommonFunctions.getCurrentTimeWithLanguage(getApplicationContext()).replace(":", "") + ".jpg";
_path = CommonString.FILE_PATH + _pathforcheck;
startCameraActivity(0);
startCameraActivity(1);
break;
}
}
@@ -326,6 +326,103 @@ public class UploadImageWithRetrofit {
}
public void UploadDeliveryImageRecursive(final Context context, final ArrayList<String> file_list, final int index) {
try {
final int[] _index = {index};
status = 0;
String filename = null, foldername = "DeliveryCallsImages";
if (_index[0] < file_list.size()) {
filename = file_list.get(_index[0]);
pd.setMessage(context.getString(R.string.uploaddata)+" - " +context.getString(R.string.image) + " (" + uploadedFiles + "/" + totalFiles + ")");
File originalFile = new File(CommonString.FILE_PATH + filename);
final File finalFile = saveBitmapToFileSmaller(originalFile);
OkHttpClient okHttpClient = new OkHttpClient();
okHttpClient.setConnectTimeout(20, TimeUnit.SECONDS);
okHttpClient.setWriteTimeout(20, TimeUnit.SECONDS);
okHttpClient.setReadTimeout(20, TimeUnit.SECONDS);
com.squareup.okhttp.RequestBody photo = com.squareup.okhttp.RequestBody.create(com.squareup.okhttp.MediaType.parse("application/octet-stream"), finalFile);
body1 = new MultipartBuilder()
.type(MultipartBuilder.FORM)
.addFormDataPart("file", finalFile.getName(), photo)
.addFormDataPart("FolderName", foldername)
.build();
adapter = new retrofit.Retrofit.Builder()
.baseUrl(CommonString.URL + "/")
.addConverterFactory(new StringConverterFactory())
.build();
PostApiForFile api = adapter.create(PostApiForFile.class);
retrofit.Call<String> call = api.getUploadImage(body1);
call.enqueue(new retrofit.Callback<String>() {
@Override
public void onResponse(retrofit.Response<String> response) {
if (response.isSuccess() && response.body().contains("Success")) {
finalFile.delete();
status = 1;
uploadedFiles++;
} else {
status = 0;
//uploadedFiles = 0;
}
if (status == 0) {
pd.dismiss();
if (!((Activity) context).isFinishing()) {
showAlert((Activity) context, context.getString(R.string.DataNot),false);
}
} else {
UploadDeliveryImageRecursive(context, file_list, ++_index[0]);
}
}
@Override
public void onFailure(Throwable t) {
if (t instanceof IOException || t instanceof SocketTimeoutException || t instanceof SocketException) {
status = -1;
//uploadedFiles = 0;
pd.dismiss();
// AlertandMessages.showAlert((Activity) context, "Network Error in upload", false);
if (!((Activity) context).isFinishing()) {
showAlert((Activity) context, context.getString(R.string.NetworkError),false);
}
}
}
});
} else {
pd.dismiss();
if (totalFiles == uploadedFiles) {
//region Coverage upload status Data
/*db = new GSKOrangeDB(context);
db.open();
db.updateDeliveryCallsUploadStatus();*/
//endregion
//pd.cancel();
//showAlert((Activity) context, context.getString(R.string.data_uploaded_successfully),true);
}
showAlert((Activity) context, context.getString(R.string.data_uploaded_successfully),true);
}
} catch (JsonSyntaxException e) {
e.printStackTrace();
showAlert((Activity) context, "Invalid Json",false);
} catch (Exception e) {
e.printStackTrace();
if (totalFiles == uploadedFiles) {
showAlert((Activity) context, context.getString(R.string.data_uploaded_successfully),true);
} else {
showAlert((Activity) context, CommonString.KEY_FAILURE,false);
}
}
}
public File saveBitmapToFileSmaller(File file) {
File file2 = file;
try {
@@ -0,0 +1,80 @@
package cpm.com.gskmtorange.xmlGetterSetter;
import java.io.Serializable;
public class DeliveryCallsGetterSetter implements Serializable{
String STORE_NAME, ADDRESS, IN_TIME_IMAGE, OUT_TIME_IMAGE, UPLOAD_STATUS, VISIT_DATE, id, in_time, out_time;
public String getSTORE_NAME() {
return STORE_NAME;
}
public void setSTORE_NAME(String STORE_NAME) {
this.STORE_NAME = STORE_NAME;
}
public String getADDRESS() {
return ADDRESS;
}
public void setADDRESS(String ADDRESS) {
this.ADDRESS = ADDRESS;
}
public String getIN_TIME_IMAGE() {
return IN_TIME_IMAGE;
}
public void setIN_TIME_IMAGE(String IN_TIME_IMAGE) {
this.IN_TIME_IMAGE = IN_TIME_IMAGE;
}
public String getOUT_TIME_IMAGE() {
return OUT_TIME_IMAGE;
}
public void setOUT_TIME_IMAGE(String OUT_TIME_IMAGE) {
this.OUT_TIME_IMAGE = OUT_TIME_IMAGE;
}
public String getUPLOAD_STATUS() {
return UPLOAD_STATUS;
}
public void setUPLOAD_STATUS(String UPLOAD_STATUS) {
this.UPLOAD_STATUS = UPLOAD_STATUS;
}
public String getVISIT_DATE() {
return VISIT_DATE;
}
public void setVISIT_DATE(String VISIT_DATE) {
this.VISIT_DATE = VISIT_DATE;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getIn_time() {
return in_time;
}
public void setIn_time(String in_time) {
this.in_time = in_time;
}
public String getOut_time() {
return out_time;
}
public void setOut_time(String out_time) {
this.out_time = out_time;
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

@@ -4,6 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".dailyentry.DeliveryCallActivity">
<android.support.design.widget.AppBarLayout
@@ -28,6 +29,15 @@
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:srcCompat="@drawable/save_icon" />
app:srcCompat="@drawable/add" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_upload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|left"
android:layout_margin="@dimen/fab_margin"
app:srcCompat="@drawable/upload"
android:visibility="gone"/>
</android.support.design.widget.CoordinatorLayout>
@@ -4,6 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".dailyentry.DeliveryCallAddStoreActivity">
<android.support.design.widget.AppBarLayout
@@ -1,11 +1,19 @@
<?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"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".dailyentry.DeliveryCallActivity"
tools:showIn="@layout/activity_delivery_call">
tools:showIn="@layout/activity_delivery_call"
android:background="@color/grey_background">
</android.support.constraint.ConstraintLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/rec_delivery_calls"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp"
/>
</LinearLayout>
@@ -0,0 +1,104 @@
<?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="wrap_content"
android:id="@+id/delivery_listview_layout">
<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"
android:layout_weight="35"
card_view:cardBackgroundColor="@color/colorOrange"
card_view:cardCornerRadius="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="10">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:id="@+id/delivery_ico"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:padding="10dp" />
</RelativeLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:layout_weight="7.5"
android:orientation="vertical">
<TextView
android:id="@+id/tv_store_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/GSKMT"
android:textColor="#1F3A6C"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_store_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/address"
android:textColor="#666666"
android:textSize="14sp"
android:textStyle="normal" />
</LinearLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.5">
<Button
android:id="@+id/chkout"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerInParent="true"
android:layout_marginRight="5dp"
android:background="@mipmap/checkout"
android:focusable="false"
android:visibility="gone"/>
<Button
android:id="@+id/btn_cancel"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerInParent="true"
android:layout_marginRight="5dp"
android:background="@mipmap/cancel_icon"
android:focusable="false"
android:visibility="gone"
/>
</RelativeLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
@@ -32,7 +32,7 @@
android:id="@+id/nav_delivery_call"
android:icon="@mipmap/baseline_local_shipping_black_48"
android:title="@string/delivery_call"
android:visible="false"
android:visible="true"
/>
<item
+1 -1
View File
@@ -376,7 +376,7 @@
<string name="select_supervisor">Select Supervisor</string>
<string name="coaching_visit">Coaching Visit</string>
<string name="please_save_data">Please save data</string>
<string name="delivery_call">Delivery Call</string>
<string name="delivery_call">Delivery Calls</string>
<string name="add_store">Add Store</string>
<string name="please_fill">Please fill</string>
<string name="address">Address</string>