2021-08-02 18:14:45 +05:30
|
|
|
package com.smi.SickleCell;
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.MainThread;
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
|
import androidx.appcompat.app.AppCompatDelegate;
|
|
|
|
|
import androidx.core.app.ActivityCompat;
|
|
|
|
|
import androidx.core.content.ContextCompat;
|
|
|
|
|
|
|
|
|
|
import android.Manifest;
|
|
|
|
|
import android.content.ContentValues;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.content.SharedPreferences;
|
|
|
|
|
import android.content.pm.PackageManager;
|
|
|
|
|
import android.net.Uri;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.os.Environment;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.widget.AdapterView;
|
|
|
|
|
import android.widget.ArrayAdapter;
|
|
|
|
|
import android.widget.Button;
|
|
|
|
|
import android.widget.Spinner;
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
import com.google.android.gms.tasks.OnCompleteListener;
|
|
|
|
|
import com.google.android.gms.tasks.Task;
|
|
|
|
|
import com.google.firebase.database.DatabaseReference;
|
|
|
|
|
import com.google.firebase.database.FirebaseDatabase;
|
|
|
|
|
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.Calendar;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
|
|
public class MainActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener{
|
|
|
|
|
private Button confirmatory,screening;
|
|
|
|
|
|
|
|
|
|
private static final int REQUEST_CODE_PICK_FILE = 300;
|
|
|
|
|
String FilePath;
|
|
|
|
|
private TextView result;
|
|
|
|
|
float number1;
|
|
|
|
|
float number2;
|
|
|
|
|
private String TestRandomKey,saveCurrentDate, saveCurrentTime;
|
|
|
|
|
private DatabaseReference TestRef;
|
|
|
|
|
private TextView result_confirmatory;
|
|
|
|
|
String device;
|
|
|
|
|
String result_test;
|
|
|
|
|
String result_test1;
|
|
|
|
|
String targetUri;
|
|
|
|
|
|
|
|
|
|
String directory_path;
|
|
|
|
|
float value;
|
|
|
|
|
int flag=0;
|
|
|
|
|
|
|
|
|
|
File file=null;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
|
|
|
|
setContentView(R.layout.activity_main);
|
|
|
|
|
String directory_path = Environment.getExternalStorageDirectory().getPath() + "/SickleCell/";
|
|
|
|
|
|
|
|
|
|
screening=findViewById(R.id.screening);
|
|
|
|
|
confirmatory=findViewById(R.id.confirmatory);
|
|
|
|
|
TestRef = FirebaseDatabase.getInstance().getReference().child("Test_Data");
|
|
|
|
|
|
|
|
|
|
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
|
|
|
|
|
Spinner Spinner_gender = findViewById(R.id.spinner_device);
|
|
|
|
|
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
|
|
|
|
|
R.array.instrument, android.R.layout.simple_spinner_item);
|
|
|
|
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
|
|
|
|
Spinner_gender.setAdapter(adapter);
|
|
|
|
|
Spinner_gender.setOnItemSelectedListener(this);
|
|
|
|
|
result=findViewById(R.id.result);
|
|
|
|
|
result_confirmatory=findViewById(R.id.result_confirmatory);
|
|
|
|
|
|
|
|
|
|
if(ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
ActivityCompat.requestPermissions(this,new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},23);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
directory_path = Environment.getExternalStorageDirectory().getPath() + "/SickleCell/";
|
|
|
|
|
File file = new File(directory_path);
|
|
|
|
|
if (!file.exists()) {
|
|
|
|
|
file.mkdirs();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
|
|
|
|
directory_path = Environment.getExternalStorageDirectory().getPath() + "/SickleCell/";
|
|
|
|
|
File file = new File(directory_path);
|
|
|
|
|
if (!file.exists()) {
|
|
|
|
|
file.mkdirs();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// Request permission from the user
|
|
|
|
|
ActivityCompat.requestPermissions(this,
|
|
|
|
|
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
directory_path = Environment.getExternalStorageDirectory().getPath() + "/SickleCell/";
|
|
|
|
|
File file = new File(directory_path);
|
|
|
|
|
if (!file.exists()) {
|
|
|
|
|
file.mkdirs();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
directory_path = Environment.getExternalStorageDirectory().getPath() + "/SickleCell/";
|
|
|
|
|
file = new File(directory_path);
|
|
|
|
|
if (!file.exists()) {
|
|
|
|
|
file.mkdirs();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
screening.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
flag=1;
|
|
|
|
|
createfolder();
|
|
|
|
|
|
|
|
|
|
selectCSVFile();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
confirmatory.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
flag=2;
|
|
|
|
|
createfolder();
|
|
|
|
|
|
|
|
|
|
selectCSVFile();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void selectCSVFile(){
|
|
|
|
|
if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
|
|
|
|
|
|
|
|
|
ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 23);
|
|
|
|
|
}
|
|
|
|
|
Uri uri = Uri.parse((Environment.getExternalStorageDirectory().getPath() + "/SickleCell/"));
|
|
|
|
|
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
|
|
|
|
intent.setDataAndType(uri, "*/*");
|
|
|
|
|
|
|
|
|
|
// intent.setType("*/*");
|
|
|
|
|
startActivityForResult(intent,REQUEST_CODE_PICK_FILE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
|
|
|
switch (requestCode) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case REQUEST_CODE_PICK_FILE: {
|
|
|
|
|
if (resultCode == RESULT_OK) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Log.e("file",data.getData().getPath());
|
|
|
|
|
|
|
|
|
|
FilePath = data.getData().getPath();
|
|
|
|
|
Log.e("Filepath",FilePath);
|
|
|
|
|
|
|
|
|
|
String filename1=FilePath.substring(FilePath.lastIndexOf("/")+1);
|
|
|
|
|
|
|
|
|
|
Log.e("file",filename1);
|
|
|
|
|
|
|
|
|
|
String s = FilePath;
|
|
|
|
|
|
|
|
|
|
directory_path = Environment.getExternalStorageDirectory().getPath() + "/SickleCell/";
|
|
|
|
|
targetUri = directory_path+filename1;
|
|
|
|
|
|
|
|
|
|
if(flag==1)
|
|
|
|
|
{
|
|
|
|
|
ImportCSV(new File(targetUri));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if(flag==2)
|
|
|
|
|
{
|
|
|
|
|
ImportCSV2(new File(targetUri));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void ImportCSV(File from) {
|
|
|
|
|
ContentValues cv = new ContentValues();
|
|
|
|
|
result_confirmatory.setText("");
|
|
|
|
|
result.setText("");
|
|
|
|
|
try {
|
|
|
|
|
InputStream inputStream = new FileInputStream(from);
|
|
|
|
|
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String line;
|
|
|
|
|
if(device.equals("TestRight"))
|
|
|
|
|
{
|
|
|
|
|
result_confirmatory.setText("");
|
|
|
|
|
result.setText("");
|
|
|
|
|
Log.e("device", "Test right");
|
|
|
|
|
|
|
|
|
|
while ((line = br.readLine()) != null) {
|
|
|
|
|
String[] values = line.split(",");
|
|
|
|
|
if (values[0].equals("427.084")) {
|
|
|
|
|
|
|
|
|
|
number1 = Float.parseFloat(String.valueOf(values[1]));
|
|
|
|
|
|
|
|
|
|
Log.e("number1", String.valueOf(number1));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if(values[0].equals("555.035"))
|
|
|
|
|
{
|
|
|
|
|
number2 = Float.parseFloat(String.valueOf(values[1]));
|
|
|
|
|
Log.e("number2", String.valueOf(number2));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
value= number2/number1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Log.e("value",String.valueOf(value));
|
|
|
|
|
if(value<0.16)
|
|
|
|
|
{
|
|
|
|
|
result_confirmatory.setText("");
|
|
|
|
|
result.setText("Negative");
|
|
|
|
|
result_test=result.getText().toString();
|
|
|
|
|
result_test1=result_confirmatory.getText().toString();
|
2021-08-03 12:39:46 +05:30
|
|
|
SaveTestInfoToDatabase();
|
2021-08-02 18:14:45 +05:30
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result.setText("Positive");
|
|
|
|
|
result_confirmatory.setText("");
|
|
|
|
|
result_test=result.getText().toString();
|
|
|
|
|
result_test1=result_confirmatory.getText().toString();
|
2021-08-03 12:39:46 +05:30
|
|
|
SaveTestInfoToDatabase();
|
2021-08-02 18:14:45 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (device.equals("Denovix"))
|
|
|
|
|
{
|
|
|
|
|
result_confirmatory.setText("");
|
|
|
|
|
result.setText("");
|
|
|
|
|
Log.e("device", "denovix");
|
|
|
|
|
|
|
|
|
|
while ((line = br.readLine()) != null) {
|
|
|
|
|
String[] values = line.split(",");
|
|
|
|
|
if (values[2].equals("427.084")) {
|
|
|
|
|
|
|
|
|
|
number1 = Float.parseFloat(String.valueOf(values[3]));
|
|
|
|
|
|
|
|
|
|
Log.e("number1", String.valueOf(number1));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if(values[2].equals("555.035"))
|
|
|
|
|
{
|
|
|
|
|
number2 = Float.parseFloat(String.valueOf(values[3]));
|
|
|
|
|
Log.e("number2", String.valueOf(number2));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
value=number2/number1;
|
|
|
|
|
Log.e("value",String.valueOf(value));
|
|
|
|
|
if(value<0.16)
|
|
|
|
|
{
|
|
|
|
|
result.setText("Negative");
|
|
|
|
|
result_test=result.getText().toString();
|
|
|
|
|
result_test1=result_confirmatory.getText().toString();
|
2021-08-03 12:39:46 +05:30
|
|
|
SaveTestInfoToDatabase();
|
2021-08-02 18:14:45 +05:30
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result.setText("Positive");
|
|
|
|
|
result_test=result.getText().toString();
|
|
|
|
|
result_test1=result_confirmatory.getText().toString();
|
2021-08-03 12:39:46 +05:30
|
|
|
SaveTestInfoToDatabase();
|
2021-08-02 18:14:45 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} catch (IOException ex) {
|
|
|
|
|
throw new RuntimeException("Error in reading CSV file: " + ex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
private void ImportCSV2(File from) {
|
|
|
|
|
result_confirmatory.setText("");
|
|
|
|
|
result.setText("");
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
InputStream inputStream = new FileInputStream(from);
|
|
|
|
|
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String line;
|
|
|
|
|
if(device.equals("TestRight"))
|
|
|
|
|
{
|
|
|
|
|
result_confirmatory.setText("");
|
|
|
|
|
result.setText("");
|
|
|
|
|
Log.e("device", "Test right");
|
|
|
|
|
|
|
|
|
|
while ((line = br.readLine()) != null) {
|
|
|
|
|
String[] values = line.split(",");
|
|
|
|
|
|
|
|
|
|
if (values[0].equals("427.084")) {
|
|
|
|
|
number1 = Float.parseFloat(String.valueOf(values[1]));
|
|
|
|
|
Log.e("number1", String.valueOf(number1));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if(values[0].equals("555.035"))
|
|
|
|
|
{
|
|
|
|
|
number2 = Float.parseFloat(String.valueOf(values[1]));
|
|
|
|
|
Log.e("number2", String.valueOf(number2));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
value=number2/number1;
|
|
|
|
|
Log.e("value",String.valueOf(value));
|
|
|
|
|
if(value<0.16)
|
|
|
|
|
{
|
|
|
|
|
result.setText("Negative");
|
|
|
|
|
result_test=result.getText().toString();
|
|
|
|
|
result_test1=result_confirmatory.getText().toString();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result.setText("Positive");
|
|
|
|
|
result_test=result.getText().toString();
|
|
|
|
|
result_test1=result_confirmatory.getText().toString();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(value>=0.16 && value < 0.24)
|
|
|
|
|
{
|
|
|
|
|
result_confirmatory.setText("Sickle Cell Trait");
|
|
|
|
|
result_test=result.getText().toString();
|
|
|
|
|
result_test1=result_confirmatory.getText().toString();
|
2021-08-03 12:39:46 +05:30
|
|
|
SaveTestInfoToDatabase();
|
2021-08-02 18:14:45 +05:30
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if( value >=0.24)
|
|
|
|
|
{
|
|
|
|
|
result_confirmatory.setText("Sickle-Cell Disease");
|
|
|
|
|
result_test=result.getText().toString();
|
|
|
|
|
result_test1=result_confirmatory.getText().toString();
|
2021-08-03 12:39:46 +05:30
|
|
|
SaveTestInfoToDatabase();
|
2021-08-02 18:14:45 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (device.equals("Denovix"))
|
|
|
|
|
{
|
|
|
|
|
result_confirmatory.setText("");
|
|
|
|
|
result.setText("");
|
|
|
|
|
Log.e("device", "denovix");
|
|
|
|
|
|
|
|
|
|
while ((line = br.readLine()) != null) {
|
|
|
|
|
String[] values = line.split(",");
|
|
|
|
|
if (values[2].equals("427.084")) {
|
|
|
|
|
number1 = Float.parseFloat(String.valueOf(values[3]));
|
|
|
|
|
Log.e("number1", String.valueOf(number1));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if(values[2].equals("555.035"))
|
|
|
|
|
{
|
|
|
|
|
number2 = Float.parseFloat(String.valueOf(values[3]));
|
|
|
|
|
Log.e("number2", String.valueOf(number2));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
value=number2/number1;
|
|
|
|
|
Log.e("value",String.valueOf(value));
|
|
|
|
|
if(value<0.16)
|
|
|
|
|
{
|
|
|
|
|
result.setText("Negative");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result.setText("Positive");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(value>=0.16 && value < 0.24)
|
|
|
|
|
{
|
|
|
|
|
result_confirmatory.setText("Sickle Cell Trait ");
|
2021-08-03 12:39:46 +05:30
|
|
|
SaveTestInfoToDatabase();
|
2021-08-02 18:14:45 +05:30
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if( value >0.24)
|
|
|
|
|
{
|
|
|
|
|
result_confirmatory.setText("Sickle-Cell Disease");
|
2021-08-03 12:39:46 +05:30
|
|
|
SaveTestInfoToDatabase();
|
2021-08-02 18:14:45 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (IOException ex) {
|
|
|
|
|
throw new RuntimeException("Error in reading CSV file: " + ex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
|
|
|
|
if(parent.getId() == R.id.spinner_device)
|
|
|
|
|
{
|
|
|
|
|
device = parent.getItemAtPosition(position).toString();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onNothingSelected(AdapterView<?> parent) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
private void createfolder()
|
|
|
|
|
{
|
|
|
|
|
directory_path = Environment.getExternalStorageDirectory().getPath() + "/SickleCell/";
|
|
|
|
|
file = new File(directory_path);
|
|
|
|
|
if (!file.exists()) {
|
|
|
|
|
file.mkdirs();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-08-03 12:39:46 +05:30
|
|
|
private void SaveTestInfoToDatabase()
|
2021-08-02 18:14:45 +05:30
|
|
|
{
|
|
|
|
|
HashMap<String, Object> productMap = new HashMap<>();
|
|
|
|
|
productMap.put("Value", String.valueOf(value));
|
|
|
|
|
productMap.put("number1", String.valueOf(number1));
|
|
|
|
|
productMap.put("number2",String.valueOf(number2));
|
|
|
|
|
productMap.put("Device",device);
|
|
|
|
|
productMap.put("Result",result_test);
|
|
|
|
|
productMap.put("Result Confirmatory",result_test1);
|
|
|
|
|
productMap.put("Directory Path",directory_path);
|
|
|
|
|
productMap.put("Full Path",targetUri);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// productMap("Result",String.valueOf(result.getText().toString()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat currentDate = new SimpleDateFormat("MMM dd, yyyy");
|
|
|
|
|
|
|
|
|
|
saveCurrentDate = currentDate.format(calendar.getTime());
|
|
|
|
|
saveCurrentDate = saveCurrentDate .replaceAll("[^A-Za-z0-9 ]","");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat currentTime = new SimpleDateFormat("h:mm a");
|
|
|
|
|
saveCurrentTime = currentTime.format(calendar.getTime());
|
|
|
|
|
|
|
|
|
|
TestRandomKey = saveCurrentDate + saveCurrentTime+String.valueOf( Math.random());
|
|
|
|
|
TestRandomKey = TestRandomKey .replaceAll("[^A-Za-z0-9 ]","");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TestRef.child(TestRandomKey).updateChildren(productMap)
|
|
|
|
|
.addOnCompleteListener(new OnCompleteListener<Void>() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onComplete(@NonNull Task<Void> task)
|
|
|
|
|
{
|
|
|
|
|
if (task.isSuccessful()) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Toast.makeText(MainActivity.this, "Test Result added in backend successfully ", Toast.LENGTH_SHORT).show();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
String message = task.getException().toString();
|
|
|
|
|
Toast.makeText(MainActivity.this, "Error: " + message, Toast.LENGTH_SHORT).show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|