// Path: app/src/main/java/com/antest1/kcanotify/DropLogActivity.java
// public static String convertMillsToDate(long timestamp) {
//     Date d = new Date(timestamp);
//     SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd", Locale.US);
//     return dateFormat.format(d);
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String ERROR_TYPE_RESLOG = "RL";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_RESOURCELOG_VERSION = 1;


import android.app.DatePickerDialog;
import android.content.DialogInterface;
import android.graphics.PorterDuff;
import android.os.AsyncTask;
import android.os.Bundle;
import com.google.android.material.tabs.TabLayout;
import androidx.core.content.ContextCompat;
import androidx.viewpager.widget.ViewPager;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.google.gson.JsonObject;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import static com.antest1.kcanotify.DropLogActivity.convertMillsToDate;
import static com.antest1.kcanotify.KcaConstants.ERROR_TYPE_RESLOG;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_RESOURCELOG_VERSION;
        public void onClick(final View view) {
            DatePickerDialog.OnDateSetListener listener = (v, year, monthOfYear, dayOfMonth) -> {
                boolean valid_flag = true;
                String text = KcaUtils.format("%02d-%02d-%04d", monthOfYear + 1, dayOfMonth, year);
                try {
                    SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy", Locale.US);
                    long timestamp = dateFormat.parse(text).getTime();
                    long new_value = timestamp;
                    if (view.getId() == R.id.reslog_date_start) {
                        if (new_value < end_timestamp) {
                            start_timestamp = new_value;
                        } else {
                            valid_flag = false;
                        }
                    } else if (view.getId() == R.id.reslog_date_end) {
                        new_value = timestamp + (DAY_MILLISECOND - 1);
                        long time_limit = KcaUtils.getCurrentDateTimestamp(System.currentTimeMillis()) + DAY_MILLISECOND;
                        if (new_value > start_timestamp && new_value < time_limit) {
                            end_timestamp = new_value;
                        } else {
                            valid_flag = false;
                        }
                    }
                    if (valid_flag) {
                        ((TextView) view).setText(convertMillsToDate(timestamp));
                        resourceLog = resourceLogger.getResourceLogInRange(start_timestamp, end_timestamp);
                        KcaResourcelogItemAdpater.setListViewItemList(convertData(resourceLog));
                        pageAdapter.notifyDataSetChanged();
                    }
                } catch (ParseException e) {
// Path: app/src/main/java/com/antest1/kcanotify/DropLogActivity.java
// public static String convertMillsToDate(long timestamp) {
//     Date d = new Date(timestamp);
//     SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd", Locale.US);
//     return dateFormat.format(d);
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String ERROR_TYPE_RESLOG = "RL";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_RESOURCELOG_VERSION = 1;


// Path: app/src/main/java/com/antest1/kcanotify/ResourceLogActivity.java
import android.app.DatePickerDialog;
import android.content.DialogInterface;
import android.graphics.PorterDuff;
import android.os.AsyncTask;
import android.os.Bundle;
import com.google.android.material.tabs.TabLayout;
import androidx.core.content.ContextCompat;
import androidx.viewpager.widget.ViewPager;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.google.gson.JsonObject;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import static com.antest1.kcanotify.DropLogActivity.convertMillsToDate;
import static com.antest1.kcanotify.KcaConstants.ERROR_TYPE_RESLOG;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_RESOURCELOG_VERSION;

        public void onClick(final View view) {
            DatePickerDialog.OnDateSetListener listener = (v, year, monthOfYear, dayOfMonth) -> {
                boolean valid_flag = true;
                String text = KcaUtils.format("%02d-%02d-%04d", monthOfYear + 1, dayOfMonth, year);
                try {
                    SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy", Locale.US);
                    long timestamp = dateFormat.parse(text).getTime();
                    long new_value = timestamp;
                    if (view.getId() == R.id.reslog_date_start) {
                        if (new_value < end_timestamp) {
                            start_timestamp = new_value;
                        } else {
                            valid_flag = false;
                        }
                    } else if (view.getId() == R.id.reslog_date_end) {
                        new_value = timestamp + (DAY_MILLISECOND - 1);
                        long time_limit = KcaUtils.getCurrentDateTimestamp(System.currentTimeMillis()) + DAY_MILLISECOND;
                        if (new_value > start_timestamp && new_value < time_limit) {
                            end_timestamp = new_value;
                        } else {
                            valid_flag = false;
                        }
                    }
                    if (valid_flag) {
                        ((TextView) view).setText(convertMillsToDate(timestamp));
                        resourceLog = resourceLogger.getResourceLogInRange(start_timestamp, end_timestamp);
                        KcaResourcelogItemAdpater.setListViewItemList(convertData(resourceLog));
                        pageAdapter.notifyDataSetChanged();
                    }
                } catch (ParseException e) {
                    dbHelper.recordErrorLog(ERROR_TYPE_RESLOG, "", "", "", KcaUtils.getStringFromException(e));