Compare commits
3 Commits
a77cba5456
...
35d14a481c
Author | SHA1 | Date |
---|---|---|
|
35d14a481c | 9 months ago |
|
5670124f6d | 9 months ago |
|
00a9e04425 | 9 months ago |
43 changed files with 1509 additions and 79 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,215 @@ |
|||||||
|
package com.project.survey.dialog; |
||||||
|
|
||||||
|
import android.app.Dialog; |
||||||
|
import android.content.Context; |
||||||
|
import android.text.InputType; |
||||||
|
import android.text.TextUtils; |
||||||
|
import android.view.LayoutInflater; |
||||||
|
import android.view.View; |
||||||
|
import android.view.ViewGroup; |
||||||
|
import android.widget.TextView; |
||||||
|
|
||||||
|
import com.bingce.ui.CleanableEditText; |
||||||
|
import com.project.survey.R; |
||||||
|
import com.project.survey.util.CommonUtils; |
||||||
|
|
||||||
|
|
||||||
|
public class CustomInputListDialog extends Dialog { |
||||||
|
|
||||||
|
public CustomInputListDialog(Context context, int themeResId) { |
||||||
|
super(context, themeResId); |
||||||
|
} |
||||||
|
|
||||||
|
/* Builder */ |
||||||
|
public static class Builder { |
||||||
|
private TextView tvTitle,btnCancel,btnConfirm; |
||||||
|
private CleanableEditText editText01, editText02, editText03; |
||||||
|
private View mLayout; |
||||||
|
private View.OnClickListener mButtonCancelClickListener; |
||||||
|
private setOnConfirmClickListener mButtonConfirmClickListener; |
||||||
|
private int inputFormat; |
||||||
|
public static int INPUT_TYPE_TEXT = 0; |
||||||
|
public static int INPUT_TYPE_DECIMAL = 1; |
||||||
|
public static int INPUT_TYPE_INTEGER = 2; |
||||||
|
public static int INPUT_TYPE_PM_DECIMAL = 3; |
||||||
|
public static int INPUT_TYPE_PM_INTEGER = 4; |
||||||
|
private CustomInputListDialog mDialog; |
||||||
|
|
||||||
|
public Builder(Context context) { |
||||||
|
mDialog = new CustomInputListDialog(context, R.style.gif_dialog); |
||||||
|
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
||||||
|
// 加载布局文件
|
||||||
|
mLayout = inflater.inflate(R.layout.layout_edit_input_list_dialog, null, false); |
||||||
|
// 添加布局文件到 Dialog
|
||||||
|
mDialog.addContentView(mLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); |
||||||
|
|
||||||
|
tvTitle = mLayout.findViewById(R.id.tv_title); |
||||||
|
editText01 = mLayout.findViewById(R.id.editText01); |
||||||
|
editText02 = mLayout.findViewById(R.id.editText02); |
||||||
|
editText03 = mLayout.findViewById(R.id.editText03); |
||||||
|
btnCancel = mLayout.findViewById(R.id.tv_cancel); |
||||||
|
btnConfirm = mLayout.findViewById(R.id.tv_confirm); |
||||||
|
} |
||||||
|
|
||||||
|
public Builder setInputFormat(int inputFormat){ |
||||||
|
this.inputFormat = inputFormat; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 设置 Dialog 标题 |
||||||
|
*/ |
||||||
|
public Builder setTitle(String title) { |
||||||
|
tvTitle.setText(title); |
||||||
|
tvTitle.setVisibility(View.VISIBLE); |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 设置 默认值 |
||||||
|
* @param editTextContent |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public Builder setInputText01(String editTextContent) { |
||||||
|
editText01.setText(editTextContent); |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder setInputText01(double editTextContent) { |
||||||
|
editText01.setText(String.valueOf(editTextContent)); |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 设置 hint |
||||||
|
*/ |
||||||
|
public Builder setInputHint01(String editHint) { |
||||||
|
editText01.setHint(editHint); |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 设置 默认值 |
||||||
|
* @param editTextContent |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public Builder setInputText02(String editTextContent) { |
||||||
|
editText02.setText(editTextContent); |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder setInputText02(double editTextContent) { |
||||||
|
editText02.setText(String.valueOf(editTextContent)); |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 设置 hint |
||||||
|
*/ |
||||||
|
public Builder setInputHint02(String editHint) { |
||||||
|
editText02.setHint(editHint); |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 设置 默认值 |
||||||
|
* @param editTextContent |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public Builder setInputText03(String editTextContent) { |
||||||
|
editText03.setText(editTextContent); |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder setInputText03(double editTextContent) { |
||||||
|
editText03.setText(String.valueOf(editTextContent)); |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 设置 hint |
||||||
|
*/ |
||||||
|
public Builder setInputHint03(String editHint) { |
||||||
|
editText03.setHint(editHint); |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 设置取消按钮文字和监听 |
||||||
|
*/ |
||||||
|
public Builder setButtonCancel(String text) { |
||||||
|
btnCancel.setText(text); |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder setButtonCancel(View.OnClickListener listener) { |
||||||
|
mButtonCancelClickListener = listener; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 设置确认按钮文字和监听 |
||||||
|
*/ |
||||||
|
public Builder setButtonConfirm(setOnConfirmClickListener listener) { |
||||||
|
mButtonConfirmClickListener = listener; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public CustomInputListDialog create() { |
||||||
|
|
||||||
|
switch (inputFormat){ |
||||||
|
case 1: //正小数限制
|
||||||
|
editText01.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); |
||||||
|
editText02.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); |
||||||
|
editText03.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); |
||||||
|
break; |
||||||
|
case 2: //正整数限制
|
||||||
|
editText01.setInputType(InputType.TYPE_CLASS_NUMBER); |
||||||
|
editText02.setInputType(InputType.TYPE_CLASS_NUMBER); |
||||||
|
editText03.setInputType(InputType.TYPE_CLASS_NUMBER); |
||||||
|
break; |
||||||
|
case 3: //正负小数限制
|
||||||
|
editText01.setInputType(InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); |
||||||
|
editText02.setInputType(InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); |
||||||
|
editText03.setInputType(InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); |
||||||
|
break; |
||||||
|
case 4: //正负整数限制
|
||||||
|
editText01.setInputType(InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_CLASS_NUMBER); |
||||||
|
editText02.setInputType(InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_CLASS_NUMBER); |
||||||
|
editText03.setInputType(InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_CLASS_NUMBER); |
||||||
|
break; |
||||||
|
} |
||||||
|
|
||||||
|
btnCancel.setOnClickListener(view -> { |
||||||
|
CommonUtils.hideSoftInput(); |
||||||
|
mDialog.dismiss(); |
||||||
|
if (mButtonCancelClickListener != null) { |
||||||
|
mButtonCancelClickListener.onClick(view); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
btnConfirm.setOnClickListener(view -> { |
||||||
|
String inputText01 = editText01.getText().toString(); |
||||||
|
String inputText02 = editText02.getText().toString(); |
||||||
|
String inputText03 = editText03.getText().toString(); |
||||||
|
if (!TextUtils.isEmpty(inputText01) && !TextUtils.isEmpty(inputText02) && !TextUtils.isEmpty(inputText03)) { |
||||||
|
CommonUtils.hideSoftInput(); |
||||||
|
mDialog.dismiss(); |
||||||
|
} |
||||||
|
if (mButtonConfirmClickListener != null) { |
||||||
|
mButtonConfirmClickListener.OnConfirmClick(inputText01, inputText02, inputText03); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
mDialog.setContentView(mLayout); |
||||||
|
mDialog.setCancelable(true); |
||||||
|
mDialog.setCanceledOnTouchOutside(false); |
||||||
|
return mDialog; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public interface setOnConfirmClickListener{ |
||||||
|
void OnConfirmClick(String editText01, String editText02, String editText03); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,171 @@ |
|||||||
|
package com.project.survey.ui.lofting.pointlofting.record; |
||||||
|
|
||||||
|
import android.content.Context; |
||||||
|
import android.content.Intent; |
||||||
|
import android.os.Bundle; |
||||||
|
import android.view.Menu; |
||||||
|
import android.view.MenuItem; |
||||||
|
|
||||||
|
import androidx.annotation.Nullable; |
||||||
|
|
||||||
|
import com.bingce.activity.AutoLandscapeBingCeActivity; |
||||||
|
import com.bingce.data.cache.CachedCurrentJob; |
||||||
|
import com.bingce.data.cache.CachedCurrentProject; |
||||||
|
import com.bingce.utils.IntentUtil; |
||||||
|
import com.bingce.utils.StringUtil; |
||||||
|
import com.bingce.utils.ThreadPoolUtil; |
||||||
|
import com.bingce.utils.Util; |
||||||
|
import com.project.survey.R; |
||||||
|
import com.project.survey.databinding.ActivityRecordDetailBinding; |
||||||
|
import com.project.survey.ui.lofting.pointlofting.record.util.IRecordsUtils; |
||||||
|
import com.project.survey.ui.lofting.pointlofting.record.util.RecordDetailActivityRemarksUtils; |
||||||
|
import com.project.survey.ui.lofting.pointlofting.record.util.RecordDetailData; |
||||||
|
import com.project.survey.ui.lofting.pointlofting.record.util.RecordsUtilsFactory; |
||||||
|
|
||||||
|
import java.util.Date; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
import blankj.utilcode.util.ToastUtils; |
||||||
|
|
||||||
|
public class RecordDetailActivity extends AutoLandscapeBingCeActivity { |
||||||
|
private RecordDetailData mCurrentData = null; |
||||||
|
private ActivityRecordDetailBinding binding; |
||||||
|
|
||||||
|
private final Map<Integer, IRecordsUtils> recordsUtilsMap = RecordsUtilsFactory.buildUtils(this, null); |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void onBingCeCreate(@Nullable Bundle savedInstanceState) { |
||||||
|
binding = ActivityRecordDetailBinding.inflate(getLayoutInflater()); |
||||||
|
setContentView(binding.getRoot()); |
||||||
|
|
||||||
|
setSupportActionBar(binding.toolbar); |
||||||
|
if (getSupportActionBar() != null) |
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true); |
||||||
|
|
||||||
|
int mType = IntentUtil.intExtra(getIntent(), KEY_TYPE); |
||||||
|
String recordId = IntentUtil.stringExtra(getIntent(), KEY_ID); |
||||||
|
if (StringUtil.isEmpty(recordId)) { |
||||||
|
ToastUtils.showShort(R.string.no_record); |
||||||
|
finish(); |
||||||
|
return; |
||||||
|
} |
||||||
|
IRecordsUtils recordsUtils = recordsUtilsMap.get(mType); |
||||||
|
|
||||||
|
ThreadPoolUtil.execute(() -> { |
||||||
|
if (recordsUtils != null) { |
||||||
|
RecordDetailData detailData = recordsUtils.findRecordDetailInWorkerThread(recordId); |
||||||
|
setRecord(detailData); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
//设置标题
|
||||||
|
if (recordsUtils != null) { |
||||||
|
setTitle(getString(R.string.record_detail) + "-" + recordsUtils.name()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
protected void setRecord(RecordDetailData results) { |
||||||
|
if (results != null) { |
||||||
|
mCurrentData = results; |
||||||
|
} else { |
||||||
|
ToastUtils.showShort(R.string.no_record); |
||||||
|
return; |
||||||
|
} |
||||||
|
StringBuilder stringBuilder = new StringBuilder(); |
||||||
|
for (Map.Entry<String, String> entry : results.keyValueMap.entrySet()) { |
||||||
|
stringBuilder.append(entry.getKey()).append(":").append(entry.getValue()).append("\n"); |
||||||
|
} |
||||||
|
runOnUiThread(() -> { |
||||||
|
if (results.deviceInfoData != null && results.deviceInfoData.tsStatusData != null) { |
||||||
|
stringBuilder.append(getString(R.string.hr)).append(":").append(Util.formatDouble2StringDotAuto(results.deviceInfoData.tsStatusData.hr)); |
||||||
|
} |
||||||
|
binding.activityRecordDetailTextview.setText(stringBuilder.toString()); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean onCreateOptionsMenu(Menu menu) { |
||||||
|
getMenuInflater().inflate(R.menu.menu_record_detail, menu); |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
protected void nextRecord(int mType, Date date) { |
||||||
|
if (mCurrentData == null) { |
||||||
|
ToastUtils.showShort(R.string.no_record); |
||||||
|
return; |
||||||
|
} |
||||||
|
ThreadPoolUtil.execute(() -> { |
||||||
|
String projectId = CachedCurrentProject.currentProjectId(); |
||||||
|
String jobId = CachedCurrentJob.currentJobId(projectId); |
||||||
|
IRecordsUtils recordsUtils = recordsUtilsMap.get(mType); |
||||||
|
if (recordsUtils != null) { |
||||||
|
RecordDetailData recordDetailData = recordsUtils.findOtherRecordDetailInWorkerThread( |
||||||
|
projectId, jobId, date, true); |
||||||
|
setRecord(recordDetailData); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
protected void lastRecord(int mType, Date date) { |
||||||
|
if (mCurrentData == null) { |
||||||
|
ToastUtils.showShort(R.string.no_record); |
||||||
|
return; |
||||||
|
} |
||||||
|
ThreadPoolUtil.execute(() -> { |
||||||
|
String projectId = CachedCurrentProject.currentProjectId(); |
||||||
|
String jobId = CachedCurrentJob.currentJobId(projectId); |
||||||
|
IRecordsUtils recordsUtils = recordsUtilsMap.get(mType); |
||||||
|
if (recordsUtils != null) { |
||||||
|
RecordDetailData recordDetailData = recordsUtils.findOtherRecordDetailInWorkerThread( |
||||||
|
projectId, jobId, date, false); |
||||||
|
setRecord(recordDetailData); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean onOptionsItemSelected(MenuItem item) { |
||||||
|
int mType = IntentUtil.intExtra(getIntent(), KEY_TYPE); |
||||||
|
switch (item.getItemId()) { |
||||||
|
case android.R.id.home: |
||||||
|
finish(); |
||||||
|
break; |
||||||
|
case R.id.menu_record_detail_page_down: { |
||||||
|
Date date = mCurrentData != null ? mCurrentData.date : null; |
||||||
|
nextRecord(mType, date); |
||||||
|
} |
||||||
|
break; |
||||||
|
case R.id.menu_record_detail_page_up: { |
||||||
|
Date date = mCurrentData != null ? mCurrentData.date : null; |
||||||
|
lastRecord(mType, date); |
||||||
|
} |
||||||
|
break; |
||||||
|
case R.id.menu_record_detail_edit_remarks: { |
||||||
|
if (mCurrentData != null) { |
||||||
|
RecordDetailActivityRemarksUtils.changeRemarks(this, mCurrentData.remarks, remarks -> { |
||||||
|
ThreadPoolUtil.execute(() -> { |
||||||
|
IRecordsUtils recordsUtils = recordsUtilsMap.get(mType); |
||||||
|
if (recordsUtils != null) { |
||||||
|
mCurrentData = recordsUtils.updateRemarksInWorkerThread(mCurrentData.recordId, remarks); |
||||||
|
//更新界面--主要是remarks
|
||||||
|
setRecord(mCurrentData); |
||||||
|
} |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
} |
||||||
|
break; |
||||||
|
} |
||||||
|
return super.onOptionsItemSelected(item); |
||||||
|
} |
||||||
|
|
||||||
|
protected static final String KEY_TYPE = "TYPE"; |
||||||
|
protected static final String KEY_ID = "recordId"; |
||||||
|
|
||||||
|
public static void start(Context context, int type, String recordId) { |
||||||
|
Intent intent = startActivityIntent(context, RecordDetailActivity.class); |
||||||
|
intent.putExtra(KEY_TYPE, type); |
||||||
|
intent.putExtra(KEY_ID, recordId); |
||||||
|
context.startActivity(intent); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,29 @@ |
|||||||
|
package com.project.survey.ui.lofting.pointlofting.record.util; |
||||||
|
|
||||||
|
import android.content.Context; |
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity; |
||||||
|
|
||||||
|
import com.bingce.device.ui.dialog.DialogUtil; |
||||||
|
import com.bingce.list.SwipeDeletePagingListLayoutHelper; |
||||||
|
import com.bingce.utils.AppCompatActivityProviderUtils; |
||||||
|
import com.bingce.utils.IProvider; |
||||||
|
import com.bingce.utils.ThreadPoolUtil; |
||||||
|
import com.project.survey.R; |
||||||
|
|
||||||
|
|
||||||
|
abstract class AbstractListUtils extends AppCompatActivityProviderUtils implements IRecordsUtils { |
||||||
|
|
||||||
|
AbstractListUtils(IProvider<AppCompatActivity> activityIProvider) { |
||||||
|
super(activityIProvider); |
||||||
|
} |
||||||
|
|
||||||
|
protected void requestDelete(Context context, int index, String recordId, SwipeDeletePagingListLayoutHelper.IOnDeleteListener listener) { |
||||||
|
DialogUtil.mNullCancelAlertDialog(context, null, R.string.confirm_delete, (dialogInterface, i) -> { |
||||||
|
ThreadPoolUtil.execute(() -> { |
||||||
|
deleteSingleRecordInWorkerThread(recordId); |
||||||
|
}); |
||||||
|
listener.completeDelete(index); |
||||||
|
}); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,32 @@ |
|||||||
|
package com.project.survey.ui.lofting.pointlofting.record.util; |
||||||
|
|
||||||
|
import androidx.recyclerview.widget.RecyclerView; |
||||||
|
|
||||||
|
import com.bingce.data.base.user.UserConfig; |
||||||
|
import com.project.survey.ui.lofting.pointlofting.record.RecordsActivity; |
||||||
|
|
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
public interface IRecordsUtils { |
||||||
|
void update(RecyclerView recyclerView, boolean ascOrder,//asc升序 des,降序
|
||||||
|
UserConfig userConfig, |
||||||
|
String currentProjectId, String currentJobId, String currentRoadId, |
||||||
|
RecordsActivityFilterParameter parameter); |
||||||
|
|
||||||
|
void clearInWorkerThread(RecordsActivityFilterParameter parameter, Runnable completeCallback); |
||||||
|
|
||||||
|
void exportRecord2ExcelAsync(final String name, boolean ascOrder,//asc升序 des,降序
|
||||||
|
final RecordsActivityFilterParameter filterParameter, |
||||||
|
final RecordsActivityHeaders headers, boolean isExportRtkStatus, boolean isExportHr, |
||||||
|
final RecordsActivity.IExportSuccess exportSuccess); |
||||||
|
|
||||||
|
void deleteSingleRecordInWorkerThread(String recordId); |
||||||
|
|
||||||
|
String name(); |
||||||
|
|
||||||
|
RecordDetailData findRecordDetailInWorkerThread(String recordId); |
||||||
|
|
||||||
|
RecordDetailData findOtherRecordDetailInWorkerThread(String projectId, String jobId, Date date, boolean nextOrLast); |
||||||
|
|
||||||
|
RecordDetailData updateRemarksInWorkerThread(String recordId, String remarks); |
||||||
|
} |
@ -0,0 +1,149 @@ |
|||||||
|
package com.project.survey.ui.lofting.pointlofting.record.util; |
||||||
|
|
||||||
|
import android.app.ProgressDialog; |
||||||
|
import android.content.Context; |
||||||
|
|
||||||
|
import androidx.annotation.UiThread; |
||||||
|
|
||||||
|
import com.bingce.data.DeviceInfoDataUtils; |
||||||
|
import com.bingce.data.cache.CachedCurrentJob; |
||||||
|
import com.bingce.data.cache.CachedCurrentProject; |
||||||
|
import com.bingce.data.database.PointStakeDb; |
||||||
|
import com.bingce.data.surveyor.surveydata.pointstake.PointStakeConstants; |
||||||
|
import com.bingce.data.surveyor.surveydata.pointstake.PointStakeRecord; |
||||||
|
import com.bingce.poi.excel.ExcelExportHelper; |
||||||
|
import com.bingce.rtk.model.GnssPosition; |
||||||
|
import com.bingce.utils.DateUtils; |
||||||
|
import com.bingce.utils.FileUtil; |
||||||
|
import com.bingce.utils.Util; |
||||||
|
import com.project.survey.R; |
||||||
|
import com.project.survey.util.ExportPathUtils; |
||||||
|
import com.project.survey.util.Utils; |
||||||
|
import com.techyourchance.threadposter.BackgroundThreadPoster; |
||||||
|
import com.techyourchance.threadposter.UiThreadPoster; |
||||||
|
|
||||||
|
import java.io.File; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
import blankj.utilcode.util.ToastUtils; |
||||||
|
|
||||||
|
public class KnownPointRecordExporter { |
||||||
|
private final BackgroundThreadPoster mBackgroundThreadPoster = new BackgroundThreadPoster(); |
||||||
|
private final UiThreadPoster mUiThreadPoster = new UiThreadPoster(); |
||||||
|
private ProgressDialog mProgressDialog; |
||||||
|
|
||||||
|
public KnownPointRecordExporter() { |
||||||
|
} |
||||||
|
|
||||||
|
@UiThread |
||||||
|
public void exportKnownPointSetting2ExcelAsync( |
||||||
|
final String name, boolean ascOrder, |
||||||
|
String[] mHeaders61, |
||||||
|
String[] mHeaders62, |
||||||
|
String[] mHeaders63, |
||||||
|
boolean isExportRtkStatus, |
||||||
|
boolean isExportHr, |
||||||
|
Context context, |
||||||
|
RecordsActivityFilterParameter parameter, |
||||||
|
ICallback callback) { |
||||||
|
mProgressDialog = new ProgressDialog(context); |
||||||
|
mProgressDialog.setMessage(context.getString(R.string.export_records)); |
||||||
|
mProgressDialog.show(); |
||||||
|
|
||||||
|
mBackgroundThreadPoster.post(() -> { |
||||||
|
String projectId = CachedCurrentProject.currentProjectId(); |
||||||
|
String jobId = CachedCurrentJob.currentJobId(projectId); |
||||||
|
List<PointStakeRecord> results = PointStakeDb.getInstance().rawQueryListData( |
||||||
|
Utils.findRecordsListByRoadNameKRemarksDate( |
||||||
|
PointStakeConstants.DB_NAME, projectId, jobId, ascOrder, parameter.road, parameter.k, parameter.remarks, parameter.start, parameter.end)); |
||||||
|
if (results == null || results.isEmpty()) { |
||||||
|
ToastUtils.showShort(R.string.export_result_empty); |
||||||
|
hideLoading(context, null, null); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
List<List<String>> exportResult = new ArrayList<>(); |
||||||
|
String[] headers = mHeaders61; |
||||||
|
if (isExportRtkStatus) { |
||||||
|
String[] temp = new String[headers.length + mHeaders62.length]; |
||||||
|
System.arraycopy(headers, 0, temp, 0, headers.length); |
||||||
|
System.arraycopy(mHeaders62, 0, temp, headers.length, mHeaders62.length); |
||||||
|
headers = temp; |
||||||
|
} |
||||||
|
if (isExportHr) { |
||||||
|
String[] temp = new String[headers.length + mHeaders63.length]; |
||||||
|
System.arraycopy(headers, 0, temp, 0, headers.length); |
||||||
|
System.arraycopy(mHeaders63, 0, temp, headers.length, mHeaders63.length); |
||||||
|
headers = temp; |
||||||
|
} |
||||||
|
|
||||||
|
for (int i = 0; i < results.size(); i++) { |
||||||
|
ArrayList<String> rowResult = new ArrayList<>(); |
||||||
|
rowResult.add(results.get(i).roadName); |
||||||
|
rowResult.add(results.get(i).pointName); |
||||||
|
rowResult.add(Util.formatDouble2StringDotAuto(results.get(i).designX)); |
||||||
|
rowResult.add(Util.formatDouble2StringDotAuto(results.get(i).designY)); |
||||||
|
rowResult.add(Util.formatDouble2StringDotAuto(results.get(i).designZ)); |
||||||
|
rowResult.add(Util.formatDouble2StringDotAuto(results.get(i).measuredX)); |
||||||
|
rowResult.add(Util.formatDouble2StringDotAuto(results.get(i).measuredY)); |
||||||
|
rowResult.add(Util.formatDouble2StringDotAuto(results.get(i).measuredZ)); |
||||||
|
rowResult.add(results.get(i).distance); |
||||||
|
rowResult.add(results.get(i).moveUpDown); |
||||||
|
rowResult.add(results.get(i).moveK); |
||||||
|
rowResult.add(results.get(i).moveD); |
||||||
|
rowResult.add(results.get(i).moveWestEast); |
||||||
|
rowResult.add(results.get(i).moveNorthSouth); |
||||||
|
rowResult.add(results.get(i).moveForeBack); |
||||||
|
rowResult.add(results.get(i).moveLeftRight); |
||||||
|
rowResult.add(results.get(i).remarks); |
||||||
|
rowResult.add(DateUtils.toFull(results.get(i).createDate)); |
||||||
|
if (isExportRtkStatus) { |
||||||
|
rowResult.add(DeviceInfoDataUtils.posTypeString(results.get(i).deviceInfoData, GnssPosition::posTypeString)); |
||||||
|
rowResult.add(DeviceInfoDataUtils.stationTypeString(results.get(i).deviceInfoData)); |
||||||
|
rowResult.add(DeviceInfoDataUtils.satelliteString(context, results.get(i).deviceInfoData)); |
||||||
|
rowResult.add(DeviceInfoDataUtils.hrmsString(results.get(i).deviceInfoData)); |
||||||
|
rowResult.add(DeviceInfoDataUtils.vrmsString(results.get(i).deviceInfoData)); |
||||||
|
rowResult.add(DeviceInfoDataUtils.diffAgeString(context, results.get(i).deviceInfoData)); |
||||||
|
rowResult.add(DeviceInfoDataUtils.electricityString(context, results.get(i).deviceInfoData)); |
||||||
|
} |
||||||
|
if (isExportHr) { |
||||||
|
rowResult.add(DeviceInfoDataUtils.hrString(results.get(i).deviceInfoData)); |
||||||
|
} |
||||||
|
exportResult.add(rowResult); |
||||||
|
} |
||||||
|
if (!exportResult.isEmpty()) { |
||||||
|
File exportFolder = new File(FileUtil.getSDPath(), context.getString(R.string.surveyor_exported_file) |
||||||
|
+ "/" + context.getString(R.string.record) + "/" + context.getString(R.string.known_point_staking)); |
||||||
|
//过滤重名文件,如果有重名,添加后缀
|
||||||
|
String exportFileName = ExportPathUtils.filterDuplicateFileName(exportFolder, name, "xls"); |
||||||
|
|
||||||
|
new ExcelExportHelper().exportExcelForBigDataAndSave(headers, exportResult, |
||||||
|
context.getString(R.string.known_point_staking), |
||||||
|
ExcelExportHelper.MORE_SHEET_FLAG, |
||||||
|
FileUtil.getSDPath() + "/" + context.getString(R.string.surveyor_exported_file) |
||||||
|
+ "/" + context.getString(R.string.record) + "/" + context.getString(R.string.known_point_staking), |
||||||
|
exportFileName); |
||||||
|
hideLoading(context, exportFileName, callback); |
||||||
|
} else { |
||||||
|
ToastUtils.showShort(R.string.export_result_empty); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
private void hideLoading(Context activity, String name, ICallback callback) { |
||||||
|
mUiThreadPoster.post(() -> { |
||||||
|
mProgressDialog.dismiss(); |
||||||
|
File path = |
||||||
|
new File(FileUtil.getSDPath() + "/" + activity.getString(R.string.surveyor_exported_file) |
||||||
|
+ "/" + activity.getString(R.string.record) + "/" + activity.getString(R.string.known_point_staking) + "/" + name + ".xls"); |
||||||
|
if (path.exists()) { |
||||||
|
callback.onSuccess(path); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
public interface ICallback { |
||||||
|
void onSuccess(File file); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,194 @@ |
|||||||
|
package com.project.survey.ui.lofting.pointlofting.record.util; |
||||||
|
|
||||||
|
import android.view.ViewGroup; |
||||||
|
|
||||||
|
import androidx.annotation.NonNull; |
||||||
|
import androidx.appcompat.app.AppCompatActivity; |
||||||
|
import androidx.recyclerview.widget.DiffUtil; |
||||||
|
import androidx.recyclerview.widget.RecyclerView; |
||||||
|
|
||||||
|
import com.bingce.data.base.user.UserConfig; |
||||||
|
import com.bingce.data.cache.CachedCurrentJob; |
||||||
|
import com.bingce.data.cache.CachedCurrentProject; |
||||||
|
import com.bingce.data.database.DBQueryConstant; |
||||||
|
import com.bingce.data.database.PointStakeDb; |
||||||
|
import com.bingce.data.surveyor.surveydata.pointstake.PointStakeConstants; |
||||||
|
import com.bingce.data.surveyor.surveydata.pointstake.PointStakeRecord; |
||||||
|
import com.bingce.list.SwipeDeletePagingListLayoutHelper; |
||||||
|
import com.bingce.utils.DateUtils; |
||||||
|
import com.bingce.utils.FileUtil; |
||||||
|
import com.bingce.utils.IProvider; |
||||||
|
import com.bingce.utils.StringUtil; |
||||||
|
import com.bingce.utils.Util; |
||||||
|
import com.project.survey.R; |
||||||
|
import com.project.survey.databinding.RecyclerviewItemRecordsBinding; |
||||||
|
import com.project.survey.ui.lofting.pointlofting.record.RecordDetailActivity; |
||||||
|
import com.project.survey.ui.lofting.pointlofting.record.RecordsActivity; |
||||||
|
|
||||||
|
import java.util.Date; |
||||||
|
import java.util.LinkedHashMap; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
import com.project.survey.util.StoragePermissionUtils; |
||||||
|
import com.project.survey.util.Utils; |
||||||
|
|
||||||
|
|
||||||
|
class PointStakeListUtils extends AbstractListUtils { |
||||||
|
private final DiffUtil.ItemCallback<PointStakeRecord> callback = new Utils.ItemCallback<>(); |
||||||
|
|
||||||
|
PointStakeListUtils(IProvider<AppCompatActivity> activityIProvider) { |
||||||
|
super(activityIProvider); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void update(RecyclerView recyclerView, boolean ascOrder,//asc升序 des,降序
|
||||||
|
UserConfig userConfig, |
||||||
|
String currentProjectId, String currentJobId, String currentRoadId, |
||||||
|
RecordsActivityFilterParameter parameter) { |
||||||
|
String road = parameter.road; |
||||||
|
String k = parameter.k; |
||||||
|
String remarks = parameter.remarks; |
||||||
|
Date start = parameter.start; |
||||||
|
Date end = parameter.end; |
||||||
|
SwipeDeletePagingListLayoutHelper.setup(activity(), activity(), recyclerView, callback, |
||||||
|
() -> PointStakeDb.getInstance().rawQueryPagingSource( |
||||||
|
Utils.findRecordsListByRoadNameKRemarksDate( |
||||||
|
PointStakeConstants.DB_NAME, currentProjectId, currentJobId, ascOrder, road, k, remarks, start, end)), |
||||||
|
new SwipeDeletePagingListLayoutHelper.IViewHolder0<PointStakeRecord, RecordItemVH>() { |
||||||
|
@Override |
||||||
|
public RecordItemVH newItemContentVH(@NonNull ViewGroup parent, int viewType) { |
||||||
|
return new RecordItemVH(RecyclerviewItemRecordsBinding.inflate(getLayoutInflater())); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void doBindContent(RecordItemVH viewHolder, PointStakeRecord record, int position) { |
||||||
|
if (record == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
String remarks = StringUtil.isEmpty(record.remarks) ? "" : record.remarks; |
||||||
|
RecyclerViewItemData data = new RecyclerViewItemData(record.id, |
||||||
|
record.pointName, |
||||||
|
record.roadName, |
||||||
|
Util.formatDouble2StringDotAuto(record.designX), |
||||||
|
Util.formatDouble2StringDotAuto(record.designY), |
||||||
|
Util.formatDouble2StringDotAuto(record.designZ), |
||||||
|
getString(R.string.remarks) + ":" + (remarks.length() > 8 ? remarks.substring(0, 8) + "..." : remarks), |
||||||
|
DateUtils.toFull(record.createDate)); |
||||||
|
viewHolder.doBinder(data); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onItemClicked(int index, PointStakeRecord instance) { |
||||||
|
RecordDetailActivity.start(activity(), RecordTypeConstants.TYPE_POINT_STAKE, instance.id); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onDelete(int index, PointStakeRecord instance, SwipeDeletePagingListLayoutHelper.IOnDeleteListener listener) { |
||||||
|
requestDelete(activity(), index, instance.id, listener); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void clearInWorkerThread(RecordsActivityFilterParameter parameter, Runnable completeCallback) { |
||||||
|
String projectId = CachedCurrentProject.currentProjectId(); |
||||||
|
String jobId = CachedCurrentJob.currentJobId(projectId); |
||||||
|
List<PointStakeRecord> records = PointStakeDb.getInstance().rawQueryListData( |
||||||
|
Utils.findRecordsListByRoadNameKRemarksDate( |
||||||
|
PointStakeConstants.DB_NAME, projectId, jobId, false, parameter.road, parameter.k, parameter.remarks, parameter.start, parameter.end)); |
||||||
|
PointStakeDb.getInstance().delete(records); |
||||||
|
// activity().runOnUiThread(mProgressDialog::dismiss);
|
||||||
|
if (completeCallback != null) { |
||||||
|
completeCallback.run(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void exportRecord2ExcelAsync( |
||||||
|
String name, boolean ascOrder, |
||||||
|
RecordsActivityFilterParameter filterParameter, RecordsActivityHeaders headers, boolean isExportRtkStatus, boolean isExportHr, RecordsActivity.IExportSuccess exportSuccess) { |
||||||
|
StoragePermissionUtils.checkStoragePermission(context(), () -> { |
||||||
|
KnownPointRecordExporter exporter = new KnownPointRecordExporter(); |
||||||
|
exporter.exportKnownPointSetting2ExcelAsync(name, ascOrder, |
||||||
|
headers.mHeaders61, |
||||||
|
headers.mHeaders62, |
||||||
|
headers.mHeaders63, |
||||||
|
isExportRtkStatus, |
||||||
|
isExportHr, |
||||||
|
context(), |
||||||
|
filterParameter, |
||||||
|
file -> { |
||||||
|
FileUtil.scanFile(context(), file); |
||||||
|
// showExportSuccessDialog(file);
|
||||||
|
exportSuccess.showExportSuccessDialog(file); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void deleteSingleRecordInWorkerThread(String recordId) { |
||||||
|
PointStakeDb.getInstance().deleteById(recordId); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String name() { |
||||||
|
return getString(R.string.known_point_staking); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public RecordDetailData findRecordDetailInWorkerThread(String recordId) { |
||||||
|
PointStakeRecord results = PointStakeDb.getInstance() |
||||||
|
.rawQueryData(DBQueryConstant.findById(PointStakeConstants.DB_NAME, recordId)); |
||||||
|
return convert(results); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public RecordDetailData findOtherRecordDetailInWorkerThread(String projectId, String jobId, Date date, boolean nextOrLast) { |
||||||
|
PointStakeRecord results = PointStakeDb.getInstance() |
||||||
|
.rawQueryData(Utils.findOtherRecord(PointStakeConstants.DB_NAME, projectId, jobId, date, nextOrLast)); |
||||||
|
return convert(results); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public RecordDetailData updateRemarksInWorkerThread(String recordId, String remarks) { |
||||||
|
PointStakeRecord results = PointStakeDb.getInstance() |
||||||
|
.rawQueryData(DBQueryConstant.findById(PointStakeConstants.DB_NAME, recordId)); |
||||||
|
if (results != null) { |
||||||
|
results.remarks = remarks; |
||||||
|
PointStakeDb.getInstance().save(results); |
||||||
|
} |
||||||
|
return convert(results); |
||||||
|
} |
||||||
|
|
||||||
|
private RecordDetailData convert(PointStakeRecord results) { |
||||||
|
if (results == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
LinkedHashMap<String, String> map = new LinkedHashMap<>(); |
||||||
|
map.put(getString(R.string.road_name), results.roadName); |
||||||
|
map.put(getString(R.string.point_name), results.pointName); |
||||||
|
map.put(getString(R.string.design_x), Util.formatDouble2StringDotAuto(results.designX)); |
||||||
|
map.put(getString(R.string.design_y), Util.formatDouble2StringDotAuto(results.designY)); |
||||||
|
map.put(getString(R.string.design_z), Util.formatDouble2StringDotAuto(results.designZ)); |
||||||
|
map.put(getString(R.string.measured_x), Util.formatDouble2StringDotAuto(results.measuredX)); |
||||||
|
map.put(getString(R.string.measured_y), Util.formatDouble2StringDotAuto(results.measuredY)); |
||||||
|
map.put(getString(R.string.measured_z), Util.formatDouble2StringDotAuto(results.measuredZ)); |
||||||
|
map.put(getString(R.string.distance), results.distance); |
||||||
|
map.put(getString(R.string.move_up_down), results.moveUpDown); |
||||||
|
if (!StringUtil.isEmpty(results.moveK) || !StringUtil.isEmpty(results.moveD)) { |
||||||
|
map.put(getString(R.string.move_k), results.moveK); |
||||||
|
map.put(getString(R.string.move_d), results.moveD); |
||||||
|
} |
||||||
|
if (!StringUtil.isEmpty(results.moveWestEast) || !StringUtil.isEmpty(results.moveNorthSouth)) { |
||||||
|
map.put(getString(R.string.move_west_east), results.moveWestEast); |
||||||
|
map.put(getString(R.string.move_north_south), results.moveNorthSouth); |
||||||
|
} |
||||||
|
if (!StringUtil.isEmpty(results.moveForeBack) || !StringUtil.isEmpty(results.moveLeftRight)) { |
||||||
|
map.put(getString(R.string.move_fore_back), results.moveForeBack); |
||||||
|
map.put(getString(R.string.move_left_right), results.moveLeftRight); |
||||||
|
} |
||||||
|
map.put(getString(R.string.remarks), results.remarks); |
||||||
|
map.put(getString(R.string.record_time), DateUtils.toFull(results.createDate)); |
||||||
|
return new RecordDetailData(results.id, map, results.deviceInfoData, results.createDate, results.remarks); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
package com.project.survey.ui.lofting.pointlofting.record.util; |
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity; |
||||||
|
|
||||||
|
import java.util.LinkedHashMap; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
public class RecordsUtilsFactory { |
||||||
|
public static Map<Integer, IRecordsUtils> buildUtils(AppCompatActivity appCompatActivity) { |
||||||
|
return buildUtils(appCompatActivity, recordType -> RecordTypeConstants.TYPE_MEASURING_TAPE != recordType); |
||||||
|
} |
||||||
|
|
||||||
|
public static Map<Integer, IRecordsUtils> buildUtils(AppCompatActivity appCompatActivity, IFilter filter) { |
||||||
|
return new LinkedHashMap<Integer, IRecordsUtils>() {{ |
||||||
|
if (filter == null || filter.isValidate(RecordTypeConstants.TYPE_POINT_STAKE)) { |
||||||
|
put(RecordTypeConstants.TYPE_POINT_STAKE, new PointStakeListUtils(() -> appCompatActivity)); |
||||||
|
} |
||||||
|
}}; |
||||||
|
} |
||||||
|
|
||||||
|
public interface IFilter { |
||||||
|
boolean isValidate(int recordType); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,94 @@ |
|||||||
|
package com.project.survey.ui.lofting.pointlofting.record.util |
||||||
|
|
||||||
|
import androidx.activity.viewModels |
||||||
|
import androidx.annotation.WorkerThread |
||||||
|
import androidx.appcompat.app.AppCompatActivity |
||||||
|
import androidx.fragment.app.Fragment |
||||||
|
import androidx.fragment.app.viewModels |
||||||
|
import androidx.lifecycle.ViewModel |
||||||
|
import androidx.lifecycle.viewModelScope |
||||||
|
import com.bingce.data.base.user.UserConfig |
||||||
|
import com.bingce.data.database.DBQueryConstant |
||||||
|
import com.bingce.data.database.RoadDb |
||||||
|
import com.bingce.data.surveyor.designdata.road.RoadConstants |
||||||
|
import com.bingce.data.surveyor.designdata.road.RoadRecord |
||||||
|
import com.bingce.http.measuringtape.tryLoadMeasuringTapeRecord |
||||||
|
import com.bingce.data.sync.utils.loadCurrentJobId |
||||||
|
import com.bingce.data.sync.utils.loadCurrentProjectId |
||||||
|
import com.bingce.data.sync.utils.loadCurrentRoadId |
||||||
|
import com.bingce.data.sync.utils.loadUserConfig |
||||||
|
import kotlinx.coroutines.Dispatchers |
||||||
|
import kotlinx.coroutines.launch |
||||||
|
|
||||||
|
class RecordsViewModelKt : ViewModel() { |
||||||
|
fun loadRecordBaseInfo(callback: ILoadProjectJobRoadCallback) { |
||||||
|
viewModelScope.launch(Dispatchers.IO) { |
||||||
|
val data = loadRecordBaseData() ?: return@launch |
||||||
|
val roadName = RoadDb.getInstance().rawQueryData( |
||||||
|
DBQueryConstant.findById(RoadConstants.DB_NAME, data.roadId) |
||||||
|
)?.name ?: return@launch |
||||||
|
|
||||||
|
callback.onLoadedInWorkThread(data.projectId, data.jobId, data.roadId, roadName) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
fun loadRecordBaseData(callback: ILoadProjectIdJobIdRoadRecordCallback) { |
||||||
|
viewModelScope.launch(Dispatchers.IO) { |
||||||
|
val data = loadRecordBaseData() ?: return@launch |
||||||
|
val roadRecord = RoadDb.getInstance().rawQueryData( |
||||||
|
DBQueryConstant.findById(RoadConstants.DB_NAME, data.roadId) |
||||||
|
) ?: return@launch |
||||||
|
|
||||||
|
callback.onLoadedInWorkThread(data.projectId, data.jobId, roadRecord) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@WorkerThread |
||||||
|
fun loadRecordBaseData(): RecordBaseData? { |
||||||
|
val userConfig = loadUserConfig() |
||||||
|
|
||||||
|
val projectId = loadCurrentProjectId(true, userConfig) ?: return null |
||||||
|
val jobId = loadCurrentJobId(projectId, true, userConfig) ?: return null |
||||||
|
val roadId = loadCurrentRoadId(projectId, true, userConfig) ?: return null |
||||||
|
return RecordBaseData(projectId, jobId, roadId) |
||||||
|
} |
||||||
|
|
||||||
|
fun loadMeasuringTapeRecord(userConfig: UserConfig?, roadId: String) { |
||||||
|
viewModelScope.launch(Dispatchers.IO) { |
||||||
|
tryLoadMeasuringTapeRecord(userConfig, roadId) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
interface ILoadProjectJobRoadCallback { |
||||||
|
@WorkerThread |
||||||
|
fun onLoadedInWorkThread( |
||||||
|
currentProjectId: String, |
||||||
|
currentJobId: String, |
||||||
|
currentRoadId: String, |
||||||
|
currentRoadName: String |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
interface ILoadProjectIdJobIdRoadRecordCallback { |
||||||
|
@WorkerThread |
||||||
|
fun onLoadedInWorkThread( |
||||||
|
currentProjectId: String, |
||||||
|
currentJobId: String, |
||||||
|
currentRoad: RoadRecord |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
data class RecordBaseData( |
||||||
|
val projectId: String, |
||||||
|
val jobId: String, |
||||||
|
val roadId: String, |
||||||
|
) |
||||||
|
|
||||||
|
class HolderInFragment(fragment: Fragment) { |
||||||
|
val viewModel: RecordsViewModelKt by fragment.viewModels() |
||||||
|
} |
||||||
|
|
||||||
|
class HolderInActivity(activity: AppCompatActivity) { |
||||||
|
val viewModel: RecordsViewModelKt by activity.viewModels() |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,49 @@ |
|||||||
|
package com.project.survey.util; |
||||||
|
|
||||||
|
import android.content.Context; |
||||||
|
|
||||||
|
import com.bingce.utils.FileUtil; |
||||||
|
import com.project.survey.R; |
||||||
|
|
||||||
|
import java.io.File; |
||||||
|
|
||||||
|
|
||||||
|
public class ExportPathUtils { |
||||||
|
public static File exportFolder(Context context, String folderName) { |
||||||
|
File exportFolder = new File(FileUtil.getSDPath(), context.getString(R.string.surveyor_exported_file)); |
||||||
|
if (!exportFolder.exists() && !exportFolder.mkdirs()) { |
||||||
|
return backupExportFolder(context, folderName); |
||||||
|
} |
||||||
|
File folder = new File(exportFolder, folderName); |
||||||
|
if (!folder.exists() && !folder.mkdirs()) { |
||||||
|
return backupExportFolder(context, folderName); |
||||||
|
} |
||||||
|
return folder; |
||||||
|
} |
||||||
|
|
||||||
|
private static File backupExportFolder(Context context, String folderName) { |
||||||
|
File cachedFolder = new File(context.getExternalCacheDir(), folderName); |
||||||
|
if (!cachedFolder.exists() && !cachedFolder.mkdirs()) { |
||||||
|
return context.getExternalCacheDir(); |
||||||
|
} |
||||||
|
return cachedFolder; |
||||||
|
} |
||||||
|
|
||||||
|
public static String filterDuplicateFileName(File folder, String fileName, String fileSuffix) { |
||||||
|
if (folder == null || !folder.exists() || folder.isFile()) { |
||||||
|
return fileName; |
||||||
|
} |
||||||
|
File file = new File(folder, fileName + "." + fileSuffix); |
||||||
|
if (!file.exists() || file.isDirectory()) { |
||||||
|
return fileName; |
||||||
|
} |
||||||
|
int index = 1; |
||||||
|
while (true) { |
||||||
|
file = new File(folder, fileName + "_" + index + "." + fileSuffix); |
||||||
|
if (!file.exists() || file.isDirectory()) { |
||||||
|
return fileName + "_" + index; |
||||||
|
} |
||||||
|
index++; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,37 @@ |
|||||||
|
package com.project.survey.util; |
||||||
|
|
||||||
|
import android.content.Context; |
||||||
|
|
||||||
|
import com.hjq.permissions.OnPermissionCallback; |
||||||
|
import com.hjq.permissions.Permission; |
||||||
|
import com.hjq.permissions.XXPermissions; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
import blankj.utilcode.util.ToastUtils; |
||||||
|
|
||||||
|
public class StoragePermissionUtils { |
||||||
|
public static void checkStoragePermission(Context context, Runnable onGetPermissionCallback) { |
||||||
|
XXPermissions.with(context) |
||||||
|
.permission(Permission.MANAGE_EXTERNAL_STORAGE) |
||||||
|
.request(new OnPermissionCallback() { |
||||||
|
@Override |
||||||
|
public void onGranted(List<String> permissions, boolean all) { |
||||||
|
if (onGetPermissionCallback != null) { |
||||||
|
onGetPermissionCallback.run(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onDenied(List<String> permissions, boolean never) { |
||||||
|
if (never) { |
||||||
|
ToastUtils.showShort("请手动授予文件读写权限"); |
||||||
|
// 如果是被永久拒绝就跳转到应用权限系统设置页面
|
||||||
|
XXPermissions.startPermissionActivity(context, permissions); |
||||||
|
} else { |
||||||
|
checkStoragePermission(context, onGetPermissionCallback); |
||||||
|
} |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,65 @@ |
|||||||
|
package com.project.survey.util; |
||||||
|
|
||||||
|
import androidx.annotation.NonNull; |
||||||
|
import androidx.recyclerview.widget.DiffUtil; |
||||||
|
import androidx.sqlite.db.SimpleSQLiteQuery; |
||||||
|
|
||||||
|
import com.bingce.data.database.DBQueryConstant; |
||||||
|
import com.bingce.data.surveyor.BCSurveyWithDeviceInfoRecord; |
||||||
|
import com.project.survey.App; |
||||||
|
|
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
public class Utils { |
||||||
|
|
||||||
|
static abstract class AbstractItemCallback<T> extends DiffUtil.ItemCallback<T> { |
||||||
|
protected abstract String idOf(@NonNull T t); |
||||||
|
|
||||||
|
@Override |
||||||
|
final public boolean areItemsTheSame(@NonNull T oldItem, @NonNull T newItem) { |
||||||
|
// return oldItem.id.equals(newItem.id);
|
||||||
|
return idOf(oldItem).equals(idOf(newItem)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
final public boolean areContentsTheSame(@NonNull T oldItem, @NonNull T newItem) { |
||||||
|
// return oldItem.id.equals(newItem.id);
|
||||||
|
return idOf(oldItem).equals(idOf(newItem)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static class ItemCallback<T extends BCSurveyWithDeviceInfoRecord> extends AbstractItemCallback<T> { |
||||||
|
@Override |
||||||
|
protected String idOf(@NonNull T t) { |
||||||
|
return t.id; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static SimpleSQLiteQuery findRecordsListByRoadNameKRemarksDate( |
||||||
|
String DB_NAME, String projectId, String jobId, boolean ascOrder,//asc升序 des,降序
|
||||||
|
String roadName, String k, String remarks, Date start, Date end) { |
||||||
|
if (((App) blankj.utilcode.util.Utils.getApp()).isShowAllRecordInCurrentProject) { |
||||||
|
return DBQueryConstant.findRecordsListByProjectRoadNameKRemarksDate(DB_NAME, projectId, ascOrder, roadName, k, remarks, start, end); |
||||||
|
} else { |
||||||
|
return DBQueryConstant.findRecordsListByJobRoadNameKRemarksDate(DB_NAME, jobId, ascOrder, roadName, k, remarks, start, end); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static SimpleSQLiteQuery findRecordsListByRoadNameKRemarksDate( |
||||||
|
String DB_NAME, String projectId, String jobId, boolean ascOrder,//asc升序 des,降序
|
||||||
|
String roadName, String k, String remarks, Date start, Date end, String tcsType) { |
||||||
|
if (((App) blankj.utilcode.util.Utils.getApp()).isShowAllRecordInCurrentProject) { |
||||||
|
return DBQueryConstant.findRecordsListByProjectRoadNameKRemarksDate(DB_NAME, projectId, ascOrder, roadName, k, remarks, start, end, tcsType); |
||||||
|
} else { |
||||||
|
return DBQueryConstant.findRecordsListByJobRoadNameKRemarksDate(DB_NAME, jobId, ascOrder, roadName, k, remarks, start, end, tcsType); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static SimpleSQLiteQuery findOtherRecord(String DB_NAME, String projectId, String jobId, Date date, boolean nextOrLast) { |
||||||
|
if (((App) blankj.utilcode.util.Utils.getApp()).isShowAllRecordInCurrentProject) { |
||||||
|
return DBQueryConstant.findOtherRecordInProject(DB_NAME, projectId, date, nextOrLast); |
||||||
|
} else { |
||||||
|
return DBQueryConstant.findOtherRecordInJob(DB_NAME, jobId, date, nextOrLast); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,12 @@ |
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:width="800dp" |
||||||
|
android:height="800dp" |
||||||
|
android:viewportWidth="512" |
||||||
|
android:viewportHeight="512"> |
||||||
|
<path |
||||||
|
android:pathData="M463.08,207.19L432.92,237.36L384,188.44L384,426.67L341.33,426.67L341.33,188.44L292.42,237.36L262.25,207.19L362.67,106.67L463.08,207.19ZM170.67,170.67L64,170.67L64,213.33L170.67,213.33L170.67,170.67ZM213.33,277.33L64,277.33L64,320L213.33,320L213.33,277.33ZM64,426.67L256,426.67L256,384L64,384L64,426.67Z" |
||||||
|
android:strokeWidth="1" |
||||||
|
android:fillColor="#3333AA" |
||||||
|
android:fillType="evenOdd" |
||||||
|
android:strokeColor="#00000000"/> |
||||||
|
</vector> |
@ -0,0 +1,31 @@ |
|||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent" |
||||||
|
android:orientation="vertical"> |
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar |
||||||
|
android:id="@+id/toolbar" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="?android:attr/actionBarSize" |
||||||
|
android:background="?colorPrimary" |
||||||
|
android:minHeight="?android:attr/actionBarSize" |
||||||
|
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" |
||||||
|
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /> |
||||||
|
|
||||||
|
<androidx.core.widget.NestedScrollView |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="0dp" |
||||||
|
android:layout_weight="1" |
||||||
|
android:paddingStart="@dimen/activity_horizontal_margin" |
||||||
|
android:paddingTop="@dimen/activity_vertical_margin" |
||||||
|
android:paddingEnd="@dimen/activity_horizontal_margin" |
||||||
|
android:paddingBottom="@dimen/activity_vertical_margin"> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:id="@+id/activity_record_detail_textview" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:textAppearance="@style/MyTextAppearanceTitle" /> |
||||||
|
</androidx.core.widget.NestedScrollView> |
||||||
|
</LinearLayout> |
@ -0,0 +1,124 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:orientation="vertical" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent" |
||||||
|
android:gravity="center" > |
||||||
|
|
||||||
|
<LinearLayout |
||||||
|
android:layout_width="280dp" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:orientation="vertical" |
||||||
|
android:background="@drawable/rectangle_radius_all_7_white_full"> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:id="@+id/tv_title" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="50dp" |
||||||
|
android:gravity="center" |
||||||
|
android:text="Title" |
||||||
|
android:textSize="14sp" |
||||||
|
android:textColor="@color/black" |
||||||
|
android:textStyle="bold"/> |
||||||
|
|
||||||
|
<LinearLayout |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:orientation="vertical" |
||||||
|
android:background="@color/color_EBEBEB"> |
||||||
|
|
||||||
|
<com.bingce.ui.CleanableEditText |
||||||
|
android:id="@+id/editText01" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="48dp" |
||||||
|
android:layout_marginTop="30dp" |
||||||
|
android:layout_marginBottom="10dp" |
||||||
|
android:layout_marginLeft="20dp" |
||||||
|
android:layout_marginRight="20dp" |
||||||
|
android:drawableRight="@mipmap/icon_clear" |
||||||
|
android:ellipsize="end" |
||||||
|
android:gravity="center_vertical" |
||||||
|
android:imeOptions="actionNext" |
||||||
|
android:maxLines="1" |
||||||
|
android:paddingLeft="10dp" |
||||||
|
android:paddingRight="5dp" |
||||||
|
android:singleLine="true" |
||||||
|
android:textSize="@dimen/NormalTextSize" |
||||||
|
android:textColor="@color/black" |
||||||
|
android:textColorHint="@color/color_999999" |
||||||
|
android:background="@drawable/rectangle_radius_all_7_white_full"/> |
||||||
|
|
||||||
|
<com.bingce.ui.CleanableEditText |
||||||
|
android:id="@+id/editText02" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="48dp" |
||||||
|
android:layout_marginBottom="10dp" |
||||||
|
android:layout_marginLeft="20dp" |
||||||
|
android:layout_marginRight="20dp" |
||||||
|
android:drawableRight="@mipmap/icon_clear" |
||||||
|
android:ellipsize="end" |
||||||
|
android:gravity="center_vertical" |
||||||
|
android:imeOptions="actionNext" |
||||||
|
android:maxLines="1" |
||||||
|
android:paddingLeft="10dp" |
||||||
|
android:paddingRight="5dp" |
||||||
|
android:singleLine="true" |
||||||
|
android:textSize="@dimen/NormalTextSize" |
||||||
|
android:textColor="@color/black" |
||||||
|
android:textColorHint="@color/color_999999" |
||||||
|
android:background="@drawable/rectangle_radius_all_7_white_full"/> |
||||||
|
|
||||||
|
<com.bingce.ui.CleanableEditText |
||||||
|
android:id="@+id/editText03" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="48dp" |
||||||
|
android:layout_marginBottom="30dp" |
||||||
|
android:layout_marginLeft="20dp" |
||||||
|
android:layout_marginRight="20dp" |
||||||
|
android:drawableRight="@mipmap/icon_clear" |
||||||
|
android:ellipsize="end" |
||||||
|
android:gravity="center_vertical" |
||||||
|
android:imeOptions="actionDone" |
||||||
|
android:maxLines="1" |
||||||
|
android:paddingLeft="10dp" |
||||||
|
android:paddingRight="5dp" |
||||||
|
android:singleLine="true" |
||||||
|
android:textSize="@dimen/NormalTextSize" |
||||||
|
android:textColor="@color/black" |
||||||
|
android:textColorHint="@color/color_999999" |
||||||
|
android:background="@drawable/rectangle_radius_all_7_white_full"/> |
||||||
|
|
||||||
|
</LinearLayout> |
||||||
|
|
||||||
|
<LinearLayout |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="50dp" |
||||||
|
android:orientation="horizontal"> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:id="@+id/tv_cancel" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent" |
||||||
|
android:layout_weight="1" |
||||||
|
android:text="@string/cancel" |
||||||
|
android:textColor="@color/red" |
||||||
|
android:gravity="center" |
||||||
|
android:textStyle="bold" |
||||||
|
android:textSize="@dimen/NormalTextSize" /> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:id="@+id/tv_confirm" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent" |
||||||
|
android:layout_weight="1" |
||||||
|
android:text="@string/confirm" |
||||||
|
android:gravity="center" |
||||||
|
android:textColor="@color/color_575757" |
||||||
|
android:textStyle="bold" |
||||||
|
android:textSize="@dimen/NormalTextSize" /> |
||||||
|
|
||||||
|
</LinearLayout> |
||||||
|
|
||||||
|
</LinearLayout> |
||||||
|
|
||||||
|
</LinearLayout> |
@ -0,0 +1,27 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?><!-- |
||||||
|
/* //device/apps/common/assets/res/any/layout/simple_spinner_item.xml |
||||||
|
** |
||||||
|
** Copyright 2008, The Android Open Source Project |
||||||
|
** |
||||||
|
** Licensed under the Apache License, Version 2.0 (the "License") |
||||||
|
** you may not use this file except in compliance with the License. |
||||||
|
** You may obtain a copy of the License at |
||||||
|
** |
||||||
|
** http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
** |
||||||
|
** Unless required by applicable law or agreed to in writing, software |
||||||
|
** distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
** See the License for the specific language governing permissions and |
||||||
|
** limitations under the License. |
||||||
|
*/ |
||||||
|
--> |
||||||
|
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:id="@android:id/text1" |
||||||
|
style="?android:attr/spinnerDropDownItemStyle" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="48dp" |
||||||
|
android:background="?colorPrimary" |
||||||
|
android:ellipsize="marquee" |
||||||
|
android:singleLine="true" |
||||||
|
android:textColor="#ffffff" /> |
@ -0,0 +1,20 @@ |
|||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"> |
||||||
|
|
||||||
|
<!-- <item--> |
||||||
|
<!-- android:id="@+id/menu_record_filter"--> |
||||||
|
<!-- android:title="@string/filter"--> |
||||||
|
<!-- app:showAsAction="ifRoom" />--> |
||||||
|
<item |
||||||
|
android:id="@+id/menu_record_export" |
||||||
|
android:title="@string/export_points" |
||||||
|
app:showAsAction="ifRoom" /> |
||||||
|
<item |
||||||
|
android:id="@+id/menu_record_clear" |
||||||
|
android:title="@string/clear_records" |
||||||
|
app:showAsAction="never" /> |
||||||
|
<item |
||||||
|
android:id="@+id/menu_record_sort" |
||||||
|
android:title="@string/sort" |
||||||
|
app:showAsAction="never" /> |
||||||
|
</menu> |
@ -0,0 +1,17 @@ |
|||||||
|
<menu 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" |
||||||
|
tools:mContext="com.bingce.surveyor.activity.project.records.RecordDetailActivity"> |
||||||
|
<item |
||||||
|
android:id="@+id/menu_record_detail_page_up" |
||||||
|
android:title="@string/page_up" |
||||||
|
app:showAsAction="ifRoom" /> |
||||||
|
<item |
||||||
|
android:id="@+id/menu_record_detail_page_down" |
||||||
|
android:title="@string/page_down" |
||||||
|
app:showAsAction="ifRoom" /> |
||||||
|
<item |
||||||
|
android:id="@+id/menu_record_detail_edit_remarks" |
||||||
|
android:title="@string/edit_remarks" |
||||||
|
app:showAsAction="never" /> |
||||||
|
</menu> |
Loading…
Reference in new issue