add project adins

This commit is contained in:
Alfrid Sanjaya Leo Putra 2024-07-25 14:44:22 +07:00
commit f8f85d679d
5299 changed files with 625430 additions and 0 deletions

View file

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/bgGridPriority"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="@dimen/line_height"
android:background="@drawable/grid_background" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" >
<ImageView
android:id="@+id/ImgSLE"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:src="@drawable/light_red" />
<TextView
android:id="@+id/txtslatime"
android:layout_marginLeft="3dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/ImgSLE"
android:text="00:00"
android:textColor="@color/tv_white"
android:textSize="10dp" />
<ImageView
android:id="@+id/imgStsPriority"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:src="@drawable/light_red" />
<ImageView
android:id="@+id/imgPriority"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/ImgSLE"
android:src="@drawable/icon_not_priority"
android:layout_centerHorizontal="true" />
<TextView
android:id="@+id/txtPriority"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:gravity="center_horizontal"
android:layout_below="@+id/imgPriority"
android:text="@string/dummy_priority"
android:textColor="@color/tv_white"
android:textSize="10dp" />
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical" >
<TextView
android:id="@+id/txtTaskID"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/dummy_task_id"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/tv_white"
android:textSize="10dp" />
<TextView
android:id="@+id/txtName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:text="@string/dummy_header_name_2"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/tv_white" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="horizontal"
android:gravity="center_horizontal" >
<TextView
android:id="@+id/txtStatusTask"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dummy_status_task"
android:visibility="gone"
android:textColor="@color/tv_white"
android:textSize="10dp" />
<TextView
android:id="@+id/txtScheme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="center_horizontal"
android:minLines="2"
android:textColor="@color/tv_white"
android:text="@string/dummy_scheme_name"
android:textSize="10dp" />
</LinearLayout>
</LinearLayout>

View file

@ -0,0 +1,635 @@
package com.adins.mss.base.timeline;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.adins.mss.base.GlobalData;
import com.adins.mss.base.R;
import com.adins.mss.base.crashlytics.FireCrash;
import com.adins.mss.base.errorhandler.ErrorMessageHandler;
import com.adins.mss.base.errorhandler.IShowError;
import com.adins.mss.constant.Global;
import com.adins.mss.dao.TaskH;
import com.adins.mss.dao.Timeline;
import com.adins.mss.foundation.db.dataaccess.TaskHDataAccess;
import com.adins.mss.foundation.db.dataaccess.TimelineDataAccess;
import com.adins.mss.foundation.dialog.NiftyDialogBuilder;
import com.adins.mss.foundation.formatter.Formatter;
import com.adins.mss.foundation.formatter.Tool;
import com.androidquery.AQuery;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* Created by olivia.dg on 8/28/2017.
*/
public class NewTimelineAdapter extends RecyclerView.Adapter<NewTimelineAdapter.TimelineViewHolder> implements IShowError {
public static final String PRIORITY_HIGH = "HIGH";
public static final String PRIORITY_MEDIUM = "MEDIUM";
public static final String PRIORITY_NORMAL = "NORMAL";
private static Context mContext;
protected AQuery query;
private List<Timeline> objects = null;
private List<Timeline> objectSort = new ArrayList<>();
protected static OnItemListener listener;
@Override
public int getItemViewType(int position) {
return 1;
}
public NewTimelineAdapter(Context context, List<Timeline> objects, OnItemListener listener) {
mContext = context;
this.objects = objects;
this.listener= listener;
List<String> taskId = new ArrayList<>();
for (int i = objects.size() - 1; i >= 0; i--) {
boolean wasInTimeline = false;
Timeline object = objects.get(i);
if (!taskId.isEmpty()) {
for (int j = 0; j < taskId.size(); j++) {
if (!object.getTimelineType().getTimeline_type().equalsIgnoreCase(Global.TIMELINE_TYPE_CHECKIN) &&
!object.getTimelineType().getTimeline_type().equalsIgnoreCase(Global.TIMELINE_TYPE_PUSH_NOTIFICATION)) {
if (taskId.get(j).equalsIgnoreCase(object.getUuid_task_h()))
wasInTimeline = true;
}
}
}
if (!wasInTimeline) {
objectSort.add(object);
taskId.add(object.getUuid_task_h());
}
}
}
@Override
public TimelineViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.new_timeline_item_task, parent, false);
TimelineViewHolder viewHolder = new TimelineViewHolder(v);
query = new AQuery(v);
return viewHolder;
}
@Override
public void onBindViewHolder(final TimelineViewHolder holder, final int position) {
if (objectSort.isEmpty()) {
holder.noData.setVisibility(View.VISIBLE);
holder.timelineItem.setVisibility(View.GONE);
} else {
final Timeline timeline = objectSort.get(position);
holder.timelineItem.setVisibility(View.VISIBLE);
holder.noData.setVisibility(View.GONE);
holder.mItem = timeline;
holder.bind(timeline);
holder.taskAttendance.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listener.onAttendanceClick(timeline, position);
}
});
holder.taskHeader.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listener.onItemClick(timeline, position);
}
});
}
}
public void deleteTimeline(int position) {
objectSort.remove(position);
notifyItemRemoved(position);
}
@Override
public int getItemCount() {
int count = 0;
if (objectSort.isEmpty() || objectSort == null)
count = 1;
else
count = objectSort.size();
return count;
}
@Override
public void showError(String errorSubject, String errorMsg, int notifType) {
if(notifType == ErrorMessageHandler.DIALOG_TYPE){
NiftyDialogBuilder dialogBuilder = NiftyDialogBuilder.getInstance(mContext);
dialogBuilder.withTitle(errorSubject)
.withMessage(errorMsg)
.isCancelableOnTouchOutside(true)
.show();
}
}
static class TimelineViewHolder extends RecyclerView.ViewHolder {
public final View mView;
public Timeline mItem;
ImageView timelineIcon;
TextView taskName;
TextView taskAddress;
TextView taskAgreement;
TextView taskAmount;
TextView taskOverdue;
TextView taskInstl;
TextView taskTime;
TextView txtTitle;
TextView txtDesc;
TextView attTime;
LinearLayout timelineItem;
LinearLayout taskStatus;
CardView noData;
CardView taskHeader;
CardView taskAttendance;
LinearLayout collInfo;
TextView collResult;
RecyclerView rvStatus;
public TimelineViewHolder(View itemView) {
super(itemView);
mView = itemView;
timelineIcon = (ImageView) itemView.findViewById(R.id.timelineIcon);
taskName = (TextView) itemView.findViewById(R.id.taskName);
taskAddress = (TextView) itemView.findViewById(R.id.taskAddress);
taskAgreement = (TextView) itemView.findViewById(R.id.taskAgreement);
taskAmount = (TextView) itemView.findViewById(R.id.taskAmount);
taskOverdue = (TextView) itemView.findViewById(R.id.taskOverdue);
taskInstl = (TextView) itemView.findViewById(R.id.taskInst);
taskTime = (TextView) itemView.findViewById(R.id.taskTime);
txtTitle = (TextView) itemView.findViewById(R.id.txtTitle);
txtDesc = (TextView) itemView.findViewById(R.id.txtDesc);
attTime = (TextView) itemView.findViewById(R.id.attendanceTime);
rvStatus = (RecyclerView) itemView.findViewById(R.id.rv_status);
timelineItem = (LinearLayout) itemView.findViewById(R.id.timelineItem);
taskStatus = (LinearLayout) itemView.findViewById(R.id.taskStatus);
noData = (CardView) itemView.findViewById(R.id.noData);
taskHeader = (CardView) itemView.findViewById(R.id.taskHeader);
taskAttendance = (CardView) itemView.findViewById(R.id.taskAttendance);
collInfo = (LinearLayout) itemView.findViewById(R.id.collectionInfo);
collResult = (TextView) itemView.findViewById(R.id.taskCollResult);
}
public void bind(Timeline timeline) {
mItem = timeline;
int icon = 0;
String str_dtm_crt = "";
String timelineType = timeline.getTimelineType().getTimeline_type();
String description = timeline.getDescription();
String uuid_task_h = timeline.getUuid_task_h();
Date dtm_crt = timeline.getDtm_crt();
Date today = Tool.getSystemDate();
Date now = new Date();
try {
if (dtm_crt.before(today)) {
str_dtm_crt = Formatter.formatDate(dtm_crt, Global.DATE_TIMESEC_TIMELINE_FORMAT_OLD);
} else {
long times = now.getTime() - dtm_crt.getTime();
if (times < 60000) {
str_dtm_crt = mContext.getString(R.string.moment_ago);
} else if (times < 3600000) {
times = times / 60000;
str_dtm_crt = times + " " + mContext.getString(R.string.minute_ago);
} else {
times = times / 3600000;
str_dtm_crt = times + " " + mContext.getString(R.string.hour_ago);
}
}
} catch (Exception e) {
FireCrash.log(e);
}
if (timelineType.equalsIgnoreCase(Global.TIMELINE_TYPE_CHECKIN)) {
icon = R.drawable.attendance;
} else if (timelineType.equalsIgnoreCase(Global.TIMELINE_TYPE_PUSH_NOTIFICATION)) {
icon = R.drawable.notification;
} else if (timelineType.equalsIgnoreCase(Global.TIMELINE_TYPE_VERIFICATION) || timelineType.equalsIgnoreCase(Global.TIMELINE_TYPE_VERIFIED)) {
icon = R.drawable.task_verification;
} else if (timelineType.equalsIgnoreCase(Global.TIMELINE_TYPE_APPROVAL) || timelineType.equalsIgnoreCase(Global.TIMELINE_TYPE_APPROVED)) {
icon = R.drawable.task_approval;
} else if (timelineType.equalsIgnoreCase(Global.TIMELINE_TYPE_REJECTED)) {
if (timeline.getIsVerificationTask() != null && timeline.getIsVerificationTask().equals(Global.FORM_TYPE_VERIFICATION))
icon = R.drawable.task_verification;
else
icon = R.drawable.task_approval;
}
else if (timelineType.equalsIgnoreCase(Global.TIMELINE_TYPE_CHANGED)) {
if (timeline.getIsVerificationTask() != null && timeline.getIsVerificationTask().equals(Global.FORM_TYPE_VERIFICATION))
icon = R.drawable.task_verification;
else
icon = R.drawable.task_approval;
} else {
if (timeline.getIsVerificationTask() != null && timeline.getIsVerificationTask().equals(Global.FORM_TYPE_VERIFICATION))
icon = R.drawable.task_verification;
else if (timeline.getIsVerificationTask() != null && timeline.getIsVerificationTask().equals(Global.FORM_TYPE_APPROVAL))
icon = R.drawable.task_approval;
else{
String taskPriority = timeline.getPriority();
if (taskPriority != null) {
if (timeline.getPriority().equalsIgnoreCase(PRIORITY_HIGH)) {
icon = R.drawable.task_highpriority;
} else if (timeline.getPriority().equalsIgnoreCase(PRIORITY_NORMAL)) {
icon = R.drawable.task_normalpriority;
} else if (timeline.getPriority().equalsIgnoreCase(PRIORITY_MEDIUM)) {
icon = R.drawable.task_normalpriority;
} else
icon = R.drawable.task_lowpriority;
}else {
TaskH taskH = TaskHDataAccess.getOneHeader(mContext,uuid_task_h);
if(taskH != null && taskH.getPriority() != null && !"".equals(taskH.getPriority())){
taskPriority = taskH.getPriority();
if (taskPriority != null) {
if (taskPriority.equalsIgnoreCase(PRIORITY_HIGH)) {
icon = R.drawable.task_highpriority;
} else if (taskPriority.equalsIgnoreCase(PRIORITY_NORMAL)) {
icon = R.drawable.task_normalpriority;
} else if (taskPriority.equalsIgnoreCase(PRIORITY_MEDIUM)) {
icon = R.drawable.task_normalpriority;
} else
icon = R.drawable.task_lowpriority;
}
}
else {
icon = R.drawable.task_new;
}
}
}
}
timelineIcon.setImageResource(icon);
if (timelineType.equalsIgnoreCase(Global.TIMELINE_TYPE_CHECKIN)) {
taskHeader.setVisibility(View.GONE);
taskAttendance.setVisibility(View.VISIBLE);
txtTitle.setText(mContext.getString(R.string.timeline_type_checkin));
txtDesc.setText(description + "\n" + timeline.getAttd_address());
attTime.setText(str_dtm_crt);
} else if (timelineType.equalsIgnoreCase(Global.TIMELINE_TYPE_PUSH_NOTIFICATION)) {
taskHeader.setVisibility(View.GONE);
taskAttendance.setVisibility(View.VISIBLE);
txtTitle.setText(mContext.getString(R.string.timeline_type_push_notification));
String desc = description;
String[] message = description.split("\\|");
if (message.length > 1) {
desc = message[1];
}
txtDesc.setText(desc);
attTime.setText(str_dtm_crt);
} else {
taskHeader.setVisibility(View.VISIBLE);
taskAttendance.setVisibility(View.GONE);
rvStatus.setVisibility(View.GONE);
//check timeline data if exist
if(timeline.getName() == null || timeline.getAddress() == null
|| timeline.getAgreement_no() == null || timeline.getAmount_due() == null
|| timeline.getOverdue() == null || timeline.getInstallment_no() == null){
TaskH taskH = TaskHDataAccess.getOneHeader(mContext,timeline.getUuid_task_h());
if(taskH != null){
if(taskH.getCustomer_name() != null)
timeline.setName(taskH.getCustomer_name());
if(taskH.getCustomer_address() != null)
timeline.setAddress(taskH.getCustomer_address());
if(taskH.getAppl_no() != null)
timeline.setAgreement_no(taskH.getAppl_no());
if(taskH.getInst_no() != null)
timeline.setInstallment_no(taskH.getInst_no());
if(taskH.getAmt_due() != null)
timeline.setAmount_due(taskH.getAmt_due());
if(taskH.getOd() != null)
timeline.setOverdue(taskH.getOd());
TimelineDataAccess.addOrReplace(mContext,timeline);
}
}
if (Global.APPLICATION_COLLECTION.equalsIgnoreCase(GlobalData.getSharedGlobalData().getApplication())) {
// olivia : tambahan menampilkan collection result di timeline
if (null != timeline.getCollResult() && !("").equals(timeline.getCollResult())) {
collResult.setVisibility(View.VISIBLE);
collResult.setText(timeline.getCollResult());
} else {
collResult.setVisibility(View.GONE);
}
collInfo.setVisibility(View.VISIBLE);
taskAgreement.setText(timeline.getAgreement_no());
taskAmount.setText(timeline.getAmount_due());
taskOverdue.setText(timeline.getOverdue());
taskInstl.setText(timeline.getInstallment_no());
} else {
taskAgreement.setVisibility(View.GONE);
taskAmount.setVisibility(View.GONE);
taskOverdue.setVisibility(View.GONE);
taskInstl.setVisibility(View.GONE);
}
taskName.setText(timeline.getName());
taskAddress.setText(timeline.getAddress());
taskTime.setText(str_dtm_crt);
if (timelineType.equalsIgnoreCase(Global.TIMELINE_TYPE_TASK)) {
rvStatus.setVisibility(View.GONE);
TaskH taskH = timeline.getTaskH();
// olivia : untuk task yang sudah deleted/closed warnanya jadi abu"
if (taskH == null || TaskHDataAccess.isTaskHDisabled(taskH.getStatus())) {
taskHeader.setCardBackgroundColor(mContext.getResources().getColor(R.color.timelineLine));
taskHeader.setCardElevation(0);
} else
taskHeader.setCardBackgroundColor(mContext.getResources().getColor(R.color.fontColorWhite));
} else if (timelineType.equalsIgnoreCase(Global.TIMELINE_TYPE_VERIFICATION) || timelineType.equalsIgnoreCase(Global.TIMELINE_TYPE_APPROVAL)) {
rvStatus.setVisibility(View.GONE);
TaskH taskH = timeline.getTaskH();
// olivia : untuk task yang sudah deleted/closed warnanya jadi abu"
if (taskH == null) {
taskHeader.setCardBackgroundColor(mContext.getResources().getColor(R.color.timelineLine));
taskHeader.setCardElevation(0);
} else
taskHeader.setCardBackgroundColor(mContext.getResources().getColor(R.color.fontColorWhite));
} else {
rvStatus.setVisibility(View.VISIBLE);
LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
rvStatus.setLayoutManager(layoutManager);
rvStatus.setHasFixedSize(true);
NewTimelineStatusAdapter statusAdapter = new NewTimelineStatusAdapter(mContext,timeline);
rvStatus.setAdapter(statusAdapter);
taskHeader.setCardBackgroundColor(mContext.getResources().getColor(R.color.fontColorWhite));
}
}
}
}
public interface OnItemListener {
void onItemClick(Timeline timeline, int position);
void onAttendanceClick(Timeline timeline, int position);
void onStatusClick(Timeline timeline, int position);
void onStatusLongClick(Timeline timeline, int position);
}
public List<Timeline> getObjects() {
return objects;
}
public void setObjects(List<Timeline> objects) {
this.objects = objects;
objectSort.clear();
List<String> taskId = new ArrayList<>();
for (int i = objects.size() - 1; i >= 0; i--) {
boolean wasInTimeline = false;
Timeline object = objects.get(i);
if (!taskId.isEmpty()) {
for (int j = 0; j < taskId.size(); j++) {
if (!object.getTimelineType().getTimeline_type().equalsIgnoreCase(Global.TIMELINE_TYPE_CHECKIN) &&
!object.getTimelineType().getTimeline_type().equalsIgnoreCase(Global.TIMELINE_TYPE_PUSH_NOTIFICATION)) {
if (taskId.get(j).equalsIgnoreCase(object.getUuid_task_h()))
wasInTimeline = true;
}
}
}
if (!wasInTimeline) {
objectSort.add(object);
taskId.add(object.getUuid_task_h());
}
}
}
}
class NewTimelineStatusAdapter extends RecyclerView.Adapter<NewTimelineStatusAdapter.TimelineStatusViewHolder> {
Context mContext;
Timeline timeline;
List<Timeline> timelines;
String description;
List<Integer> statusDivider = new ArrayList<>();
NewTimelineStatusAdapter(Context context, Timeline timeline){
this.mContext = context;
this.timeline = timeline;
String uuid_task_h = timeline.getUuid_task_h();
String uuid_user = timeline.getUuid_user();
timelines = TimelineDataAccess.getTimelineByTask(mContext, uuid_user, uuid_task_h);
if(timelines!=null){
for(Timeline tl: timelines){
if(tl.getTimelineType().getTimeline_type().equalsIgnoreCase(Global.TIMELINE_TYPE_FAILEDDRAFT)){
statusDivider.add(timelines.indexOf(tl));
}
}
}
}
@NonNull
@Override
public TimelineStatusViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.new_timeline_item_status_task, parent, false);
TimelineStatusViewHolder viewHolder = new TimelineStatusViewHolder(v);
return viewHolder;
}
@Override
public void onBindViewHolder(@NonNull TimelineStatusViewHolder timelineStatusViewHolder, final int position) {
timelineStatusViewHolder.bind(position);
timelineStatusViewHolder.taskStatus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NewTimelineAdapter.listener.onStatusClick(timeline, position);
}
});
timelineStatusViewHolder.taskStatus.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
NewTimelineAdapter.listener.onStatusLongClick(timeline, position);
return true;
}
});
}
@Override
public int getItemCount() {
if(statusDivider.isEmpty()){
return 1;
}else {
return statusDivider.size()+1;
}
}
public class TimelineStatusViewHolder extends RecyclerView.ViewHolder {
LinearLayout layout0;
LinearLayout layout1;
LinearLayout layout2;
LinearLayout layout3;
LinearLayout layout4;
TextView taskStatus0;
TextView taskStatus1;
TextView taskStatus2;
TextView taskStatus3;
TextView taskStatus4;
TextView taskDesc0;
TextView taskDesc1;
TextView taskDesc2;
TextView taskDesc3;
TextView taskDesc4;
TextView txtTime0;
TextView txtTime1;
TextView txtTime2;
TextView txtTime3;
TextView txtTime4;
ImageView statusIcon0;
ImageView statusIcon1;
ImageView statusIcon2;
ImageView statusIcon3;
ImageView statusIcon4;
LinearLayout taskStatus;
public TimelineStatusViewHolder(@NonNull View itemView) {
super(itemView);
taskStatus = itemView.findViewById(R.id.taskStatus);
layout0 = (LinearLayout) itemView.findViewById(R.id.taskStatusItem0);
layout1 = (LinearLayout) itemView.findViewById(R.id.taskStatusItem1);
layout2 = (LinearLayout) itemView.findViewById(R.id.taskStatusItem2);
layout3 = (LinearLayout) itemView.findViewById(R.id.taskStatusItem3);
layout4 = (LinearLayout) itemView.findViewById(R.id.taskStatusItem4);
taskStatus0 = (TextView) itemView.findViewById(R.id.txtStatus0);
taskStatus1 = (TextView) itemView.findViewById(R.id.txtStatus1);
taskStatus2 = (TextView) itemView.findViewById(R.id.txtStatus2);
taskStatus3 = (TextView) itemView.findViewById(R.id.txtStatus3);
taskStatus4 = (TextView) itemView.findViewById(R.id.txtStatus4);
taskDesc0 = (TextView) itemView.findViewById(R.id.txtDesc0);
taskDesc1 = (TextView) itemView.findViewById(R.id.txtDesc1);
taskDesc2 = (TextView) itemView.findViewById(R.id.txtDesc2);
taskDesc3 = (TextView) itemView.findViewById(R.id.txtDesc3);
taskDesc4 = (TextView) itemView.findViewById(R.id.txtDesc4);
txtTime0 = (TextView) itemView.findViewById(R.id.txtTime0);
txtTime1 = (TextView) itemView.findViewById(R.id.txtTime1);
txtTime2 = (TextView) itemView.findViewById(R.id.txtTime2);
txtTime3 = (TextView) itemView.findViewById(R.id.txtTime3);
txtTime4 = (TextView) itemView.findViewById(R.id.txtTime4);
statusIcon0 = (ImageView) itemView.findViewById(R.id.taskStatusIcon0);
statusIcon1 = (ImageView) itemView.findViewById(R.id.taskStatusIcon1);
statusIcon2 = (ImageView) itemView.findViewById(R.id.taskStatusIcon2);
statusIcon3 = (ImageView) itemView.findViewById(R.id.taskStatusIcon3);
statusIcon4 = (ImageView) itemView.findViewById(R.id.taskStatusIcon4);
}
public void bind(int position){
Date todayDate = Tool.getSystemDate();
Date date = new Date();
if (timelines != null && !timelines.isEmpty()) {
for (Timeline tl : timelines){
if(position < statusDivider.size()) {
if (statusDivider.get(position) == timelines.indexOf(tl)) {
break;
}else if(position > 0) {
if (timelines.indexOf(tl) < statusDivider.get(position-1)) {
continue;
}
}
}else{
if ((position >0) && (timelines.indexOf(tl) < statusDivider.get(position-1))) {
continue;
}
}
Date taskDate = tl.getDtm_crt();
String str_date = "";
if (taskDate != null) {
if (taskDate.before(todayDate)) {
str_date = Formatter.formatDate(taskDate, Global.DATE_TIMESEC_TIMELINE_FORMAT_OLD);
} else {
long times = date.getTime() - taskDate.getTime();
if (times < 60000) {
str_date = mContext.getString(R.string.moment_ago);
} else if (times < 3600000) {
times = times / 60000;
str_date = times + " " + mContext.getString(R.string.minute_ago);
} else {
times = times / 3600000;
str_date = times + " " + mContext.getString(R.string.hour_ago);
}
}
}
String timeline_type = tl.getTimelineType().getTimeline_type();
if (timeline_type.equalsIgnoreCase(Global.TIMELINE_TYPE_PENDING)) {
layout2.setVisibility(View.VISIBLE);
statusIcon2.setImageResource(R.drawable.task_pending);
taskStatus2.setText(mContext.getString(R.string.timeline_type_pending));
taskDesc2.setVisibility(View.VISIBLE);
description = tl.getDescription();
taskDesc2.setText(description);
txtTime2.setText(str_date);
} else if (timeline_type.equalsIgnoreCase(Global.TIMELINE_TYPE_UPLOADING)) {
layout3.setVisibility(View.VISIBLE);
statusIcon3.setImageResource(R.drawable.task_uploading);
taskStatus3.setText(mContext.getString(R.string.timeline_type_uploading));
txtTime3.setText(str_date);
} else if (timeline_type.equalsIgnoreCase(Global.TIMELINE_TYPE_SUBMITTED)) {
layout4.setVisibility(View.VISIBLE);
statusIcon4.setImageResource(R.drawable.task_submitted);
taskStatus4.setText(mContext.getString(R.string.timeline_type_submitted));
txtTime4.setText(str_date);
} else if (timeline_type.equalsIgnoreCase(Global.TIMELINE_TYPE_SAVEDRAFT)) {
layout1.setVisibility(View.VISIBLE);
statusIcon1.setImageResource(R.drawable.task_draft);
taskStatus1.setText(mContext.getString(R.string.timeline_type_savedraft));
txtTime1.setText(str_date);
} else if (timeline_type.equalsIgnoreCase(Global.TIMELINE_TYPE_FAILEDDRAFT)) {
layout0.setVisibility(View.VISIBLE);
statusIcon0.setImageResource(R.drawable.task_failed_draft);
taskStatus0.setText(mContext.getString(R.string.timeline_type_failed_draft_task));
taskDesc0.setVisibility(View.VISIBLE);
description = tl.getDescription();
taskDesc0.setText(description);
txtTime0.setText(str_date);
} else if (timeline_type.equalsIgnoreCase(Global.TIMELINE_TYPE_APPROVED)) {
layout4.setVisibility(View.VISIBLE);
statusIcon4.setImageResource(R.drawable.task_submitted);
taskStatus4.setText(mContext.getString(R.string.timeline_type_approved));
txtTime4.setText(str_date);
} else if (timeline_type.equalsIgnoreCase(Global.TIMELINE_TYPE_VERIFIED)) {
layout4.setVisibility(View.VISIBLE);
statusIcon4.setImageResource(R.drawable.task_submitted);
taskStatus4.setText(mContext.getString(R.string.timeline_type_verified));
txtTime4.setText(str_date);
} else if (timeline_type.equalsIgnoreCase(Global.TIMELINE_TYPE_REJECTED)) {
layout4.setVisibility(View.VISIBLE);
statusIcon4.setImageResource(R.drawable.task_rejected);
taskStatus4.setText(mContext.getString(R.string.timeline_type_rejected));
txtTime4.setText(str_date);
} else if (timeline_type.equalsIgnoreCase(Global.TIMELINE_TYPE_CHANGED)) {
layout4.setVisibility(View.VISIBLE);
statusIcon4.setImageResource(R.drawable.task_rejected);
taskStatus4.setText(mContext.getString(R.string.timeline_type_changed));
description = tl.getDescription();
taskDesc2.setText(description);
txtTime4.setText(str_date);
}
}
}
}
}
}

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:exitFadeDuration="@android:integer/config_mediumAnimTime">
<item android:state_pressed="true">
<shape>
<solid android:color="@color/crop__selector_pressed" />
</shape>
</item>
<item android:state_focused="true">
<shape>
<solid android:color="@color/crop__selector_focused" />
</shape>
</item>
<item android:drawable="@android:color/transparent" />
</selector>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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="wrap_content">
<ImageView
android:id="@+id/legendColorRect"
android:layout_width="20dp"
android:layout_height="10dp"
android:src="@drawable/legend_color_rect"
android:layout_marginLeft="10dp"
android:layout_marginTop="3dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/legendText"
android:layout_marginLeft="5dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/legendColorRect"
app:layout_constraintEnd_toEndOf="parent"
android:text="@string/hello_blank_fragment"
android:textSize="12sp"
android:layout_width="0dp"
android:layout_height="wrap_content" />
</androidx.constraintlayout.widget.ConstraintLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

View file

@ -0,0 +1,59 @@
package com.adins.mss.base.ktpValidation;
import android.content.Context;
import com.adins.mss.base.GlobalData;
import com.adins.mss.base.mainmenu.MainMenuActivity;
import com.adins.mss.base.util.GsonHelper;
import com.adins.mss.constant.Global;
import com.adins.mss.foundation.http.HttpConnectionResult;
import com.adins.mss.foundation.http.HttpCryptedConnection;
import java.io.IOException;
/**
* Created by riska.yessivirna on 8/12/2019.
*/
public class DukcapilApi {
private final Context context;
public DukcapilApi(Context context) {
this.context = context;
}
public String request(String nomorKtp, String refId) throws IOException {
JsonRequestKtpValidation request = new JsonRequestKtpValidation();
request.setFilter(nomorKtp);
request.setRefId(refId);
request.setAudit(GlobalData.getSharedGlobalData().getAuditData());
String requestJson = GsonHelper.toJson(request);
String url = GlobalData.getSharedGlobalData().getURL_DUKCAPIL_VALIDATION();
if(null==url){
MainMenuActivity.InitializeGlobalDataIfError(context);
url = GlobalData.getSharedGlobalData().getURL_DUKCAPIL_VALIDATION();
}
boolean encrypt = GlobalData.getSharedGlobalData().isEncrypt();
boolean decrypt = GlobalData.getSharedGlobalData().isDecrypt();
HttpCryptedConnection httpConn = new HttpCryptedConnection(context, encrypt, decrypt);
HttpConnectionResult serverResult = null;
try {
serverResult = httpConn.requestToServer(url, requestJson, Global.SORTCONNECTIONTIMEOUT);
} catch (Exception e) {
e.printStackTrace();
}
String responseJson ="" ;
// responseJson ="{\"result\":\"1\",\"message\":\"Data is valid!\",\"custName\":\"KELVIN WINGKIE HANDRIANTO\",\"custAddr\":\"JL TANAH TINGGI IV 53\",\"mapValue\":{\"PDDK_AKH\":\"TG\",\"KAB_NAME\":\"WIL KOTA JAKARTA PUSAT\",\"PROP_NAME\":\"Prop DKI Jakarta\",\"NAMA_LGKP\":\"KELVIN WINGKIE HANDRIANTO\",\"KEC_NAME\":\"Kec Johar Baru\",\"AGAMA\":\"03\",\"JENIS_PKRJN\":\"PELAJAR/MAHASISWA\",\"STATUS_KAWIN\":\"S\",\"TGL_LHR\":\"21041995000000\",\"TMPT_LHR_NAME\":\"JAKARTA\",\"NAMA_LGKP_IBU\":\"SUTIJANA\",\"NO_KEL\":\"3171040003\",\"KEL_NAME\":\"Kel Tanah Tinggi\",\"NO_KK\":\"3171081301091574\",\"NO_RT\":\"18\",\"NIK\":\"3171082104950002\",\"NO_KAB\":\"3171\",\"ALAMAT\":\"JL TANAH TINGGI IV 53\",\"JENIS_KLMIN\":\"M\",\"NO_RW\":\"5\",\"AGAMA_DESC\":\"KATHOLIK\",\"NO_PROP\":\"31\",\"NO_KEC\":\"3171040\",\"NO_TMPT_LHR\":\"3171\",\"IS_SUCCESS\":\"1\"},\"status\":{\"code\":0}}" ;
if(serverResult!=null && serverResult.isOK()){
try {
responseJson = serverResult.getResult();
} catch (Exception e) {
return null;
}
}
return responseJson;
}
}

View file

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/librarynameS2"
android:text="@string/library_name"
android:fontFamily="sans-serif-condensed"
android:textStyle="normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"/>
<TextView
android:id="@+id/libraryversionS2"
android:text="@string/library_version"
android:fontFamily="sans-serif-condensed"
android:textStyle="normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginTop="4dp"
android:gravity="left|bottom"
android:maxLines="1"
android:textSize="12sp"/>
<TextView
android:id="@+id/librarycreatorS2"
android:text="@string/library_creator"
android:fontFamily="sans-serif-condensed"
android:textStyle="normal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:gravity="right"
android:maxLines="2"
android:textSize="14sp"/>
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_marginTop="4dp"
android:background="@color/tv_gray"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="4dp">
<TextView
android:id="@+id/descriptionS2"
android:text="@string/description"
android:fontFamily="sans-serif-condensed"
android:textStyle="normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:maxLines="20">
</TextView>
</LinearLayout>
</LinearLayout>

View file

@ -0,0 +1,505 @@
package zj.com.cn.bluetooth.sdk;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothServerSocket;
import android.bluetooth.BluetoothSocket;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import com.adins.mss.base.crashlytics.FireCrash;
import com.adins.mss.foundation.camerainapp.helper.Logger;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.UUID;
/**
* This class does all the work for setting up and managing Bluetooth
* connections with other devices. It has a thread that listens for
* incoming connections, a thread for connecting with a device, and a
* thread for performing data transmissions when connected.
*/
public class BluetoothService {
// Constants that indicate the current connection state
public static final int STATE_NONE = 0; // we're doing nothing
public static final int STATE_LISTEN = 1; // now listening for incoming connections
public static final int STATE_CONNECTING = 2; // now initiating an outgoing connection
public static final int STATE_CONNECTED = 3; // now connected to a remote device
// Debugging
private static final String TAG = "BluetoothService";
private static final boolean DEBUG = true;
// Name for the SDP record when creating server socket
private static final String NAME = "ZJPrinter";
//UUID must be this
// Unique UUID for this application
private static final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
public static String ErrorMessage = "No_Error_Message";
private static BluetoothSocket mSocket = null;
// Member fields
private BluetoothAdapter mAdapter;
private Handler mHandler;
private AcceptThread mAcceptThread;
private ConnectThread mConnectThread;
private ConnectedThread mConnectedThread;
private int mState;
/**
* Constructor. Prepares a new BTPrinter session.
*
* @param context The UI Activity Context
* @param handler A Handler to send messages back to the UI Activity
*/
public BluetoothService(Context context, Handler handler) {
mAdapter = BluetoothAdapter.getDefaultAdapter();
mState = STATE_NONE;
mHandler = handler;
}
public static BluetoothSocket getmSocket() {
return mSocket;
}
public static void setmSocket(BluetoothSocket mSocket) {
mSocket = mSocket;
}
/**
* Return the current connection state.
*/
public synchronized int getState() {
return mState;
}
/**
* Set the current state of the connection
*
* @param state An integer defining the current connection state
*/
private synchronized void setState(int state) {
// if (DEBUG) Logger.d(TAG, "setState() " + mState + " -> " + state);
mState = state;
// Give the new state to the Handler so the UI Activity can update
mHandler.obtainMessage(Main_Activity1.MESSAGE_STATE_CHANGE, state, -1).sendToTarget();
}
/**
* Start the service. Specifically start AcceptThread to begin a
* session in listening (server) mode. Called by the Activity onResume()
*/
public synchronized void start() {
// if (DEBUG) Logger.d(TAG, "start");
// Cancel any thread attempting to make a connection
if (mConnectThread != null) {
mConnectThread.cancel();
mConnectThread = null;
}
// Cancel any thread currently running a connection
if (mConnectedThread != null) {
mConnectedThread.cancel();
mConnectedThread = null;
}
// Start the thread to listen on a BluetoothServerSocket
if (mAcceptThread == null) {
mAcceptThread = new AcceptThread();
mAcceptThread.start();
}
setState(STATE_LISTEN);
}
/**
* Start the ConnectThread to initiate a connection to a remote device.
*
* @param device The BluetoothDevice to connect
*/
public synchronized void connect(BluetoothDevice device) {
// if (DEBUG) Logger.d(TAG, "connect to: " + device);
// Cancel any thread attempting to make a connection
if (mState == STATE_CONNECTING) {
if (mConnectThread != null) {
mConnectThread.cancel();
mConnectThread = null;
}
}
// Cancel any thread currently running a connection
if (mConnectedThread != null) {
mConnectedThread.cancel();
mConnectedThread = null;
}
// Start the thread to connect with the given device
mConnectThread = new ConnectThread(device);
mConnectThread.start();
setState(STATE_CONNECTING);
}
/**
* Start the ConnectedThread to begin managing a Bluetooth connection
*
* @param socket The BluetoothSocket on which the connection was made
* @param device The BluetoothDevice that has been connected
*/
public synchronized void connected(BluetoothSocket socket, BluetoothDevice device) {
// if (DEBUG) Logger.d(TAG, "connected");
// Cancel the thread that completed the connection
if (mConnectThread != null) {
mConnectThread.cancel();
mConnectThread = null;
}
// Cancel any thread currently running a connection
if (mConnectedThread != null) {
mConnectedThread.cancel();
mConnectedThread = null;
}
// Cancel the accept thread because we only want to connect to one device
if (mAcceptThread != null) {
mAcceptThread.cancel();
mAcceptThread = null;
}
// Start the thread to manage the connection and perform transmissions
mConnectedThread = new ConnectedThread(socket);
mConnectedThread.start();
// Send the name of the connected device back to the UI Activity
Message msg = mHandler.obtainMessage(Main_Activity1.MESSAGE_DEVICE_NAME);
Bundle bundle = new Bundle();
bundle.putString(Main_Activity1.DEVICE_NAME, device.getName());
msg.setData(bundle);
mHandler.sendMessage(msg);
setState(STATE_CONNECTED);
}
/**
* Stop all threads
*/
public synchronized void stop() {
// if (DEBUG) Logger.d(TAG, "stop");
setState(STATE_NONE);
if (mConnectThread != null) {
mConnectThread.cancel();
mConnectThread = null;
}
if (mConnectedThread != null) {
mConnectedThread.cancel();
mConnectedThread = null;
}
if (mAcceptThread != null) {
mAcceptThread.cancel();
mAcceptThread = null;
}
}
/**
* Write to the ConnectedThread in an unsynchronized manner
*
* @param out The bytes to write
* @see ConnectedThread#write(byte[])
*/
public void write(byte[] out) {
// Create temporary object
ConnectedThread r;
// Synchronize a copy of the ConnectedThread
synchronized (this) {
if (mState != STATE_CONNECTED) return;
r = mConnectedThread;
}
r.write(out);
}
/**
* Indicate that the connection attempt failed and notify the UI Activity.
*/
private void connectionFailed() {
setState(STATE_LISTEN);
// Send a failure message back to the Activity
Message msg = mHandler.obtainMessage(Main_Activity1.MESSAGE_TOAST);
Bundle bundle = new Bundle();
bundle.putString(Main_Activity1.TOAST, "Unable to connect device");
msg.setData(bundle);
mHandler.sendMessage(msg);
}
/**
* Indicate that the connection was lost and notify the UI Activity.
*/
private void connectionLost() {
//setState(STATE_LISTEN);
// Send a failure message back to the Activity
Message msg = mHandler.obtainMessage(Main_Activity1.MESSAGE_TOAST);
Bundle bundle = new Bundle();
bundle.putString(Main_Activity1.TOAST, "Device connection was lost");
msg.setData(bundle);
mHandler.sendMessage(msg);
}
/**
* This thread runs while listening for incoming connections. It behaves
* like a server-side client. It runs until a connection is accepted
* (or until cancelled).
*/
private class AcceptThread extends Thread {
// The local server socket
private final BluetoothServerSocket mmServerSocket;
public AcceptThread() {
BluetoothServerSocket tmp = null;
// Create a new listening server socket
try {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME, MY_UUID);
} catch (IOException e) {
// Logger.e(TAG, "listen() failed", e);
FireCrash.log(e);
}
mmServerSocket = tmp;
}
@Override
public void run() {
// if (DEBUG) Logger.d(TAG, "BEGIN mAcceptThread" + this);
setName("AcceptThread");
BluetoothSocket socket = null;
// Listen to the server socket if we're not connected
while (mState != STATE_CONNECTED) {
try {
// This is a blocking call and will only return on a
// successful connection or an exception
if (mmServerSocket != null){
socket = mmServerSocket.accept();
}
} catch (IOException e) {
// Logger.e(TAG, "accept() failed", e);
FireCrash.log(e);
break;
}
// If a connection was accepted
if (socket != null) {
synchronized (BluetoothService.this) {
switch (mState) {
case STATE_LISTEN:
case STATE_CONNECTING:
// Situation normal. Start the connected thread.
connected(socket, socket.getRemoteDevice());
mSocket = socket;
break;
case STATE_NONE:
case STATE_CONNECTED:
// Either not ready or already connected. Terminate new socket.
try {
socket.close();
} catch (IOException e) {
// Logger.e(TAG, "Could not close unwanted socket", e);
FireCrash.log(e);
}
break;
}
}
}
}
if (DEBUG) Log.i(TAG, "END mAcceptThread");
}
public void cancel() {
// if (DEBUG) Logger.d(TAG, "cancel " + this);
try {
if (mmServerSocket != null){
mmServerSocket.close();
}
} catch (IOException e) {
// Logger.e(TAG, "close() of server failed", e);
FireCrash.log(e);
}
}
}
/**
* This thread runs while attempting to make an outgoing connection
* with a device. It runs straight through; the connection either
* succeeds or fails.
*/
private class ConnectThread extends Thread {
private final BluetoothSocket mmSocket;
private final BluetoothDevice mmDevice;
public ConnectThread(BluetoothDevice device) {
mmDevice = device;
BluetoothSocket tmp = null;
// Get a BluetoothSocket for a connection with the
// given BluetoothDevice
try {
tmp = device.createRfcommSocketToServiceRecord(MY_UUID);
} catch (IOException e) {
// Logger.e(TAG, "create() failed", e);
FireCrash.log(e);
}
mmSocket = tmp;
}
@Override
public void run() {
Log.i(TAG, "BEGIN mConnectThread");
setName("ConnectThread");
// Always cancel discovery because it will slow down a connection
mAdapter.cancelDiscovery();
// Make a connection to the BluetoothSocket
try {
// This is a blocking call and will only return on a
// successful connection or an exception
mmSocket.connect();
} catch (IOException e) {
connectionFailed();
// Close the socket
try {
mmSocket.close();
} catch (IOException e2) {
// Logger.e(TAG, "unable to close() socket during connection failure", e2);
FireCrash.log(e);
}
// Start the service over to restart listening mode
BluetoothService.this.start();
return;
}
// Reset the ConnectThread because we're done
synchronized (BluetoothService.this) {
mConnectThread = null;
}
// Start the connected thread
connected(mmSocket, mmDevice);
}
public void cancel() {
try {
mmSocket.close();
} catch (IOException e) {
// Logger.e(TAG, "close() of connect socket failed", e);
FireCrash.log(e);
}
}
}
/**
* This thread runs during a connection with a remote device.
* It handles all incoming and outgoing transmissions.
*/
private class ConnectedThread extends Thread {
private final BluetoothSocket mmSocket;
private final InputStream mmInStream;
private final OutputStream mmOutStream;
public ConnectedThread(BluetoothSocket socket) {
// Logger.d(TAG, "create ConnectedThread");
mmSocket = socket;
InputStream tmpIn = null;
OutputStream tmpOut = null;
// Get the BluetoothSocket input and output streams
try {
tmpIn = socket.getInputStream();
tmpOut = socket.getOutputStream();
} catch (IOException e) {
// Logger.e(TAG, "temp sockets not created", e);
FireCrash.log(e);
}
mmInStream = tmpIn;
mmOutStream = tmpOut;
}
@Override
public void run() {
Log.i(TAG, "BEGIN mConnectedThread");
int bytes;
// Keep listening to the InputStream while connected
while (true) {
try {
byte[] buffer = new byte[256];
// Read from the InputStream
bytes = mmInStream.read(buffer);
if (bytes > 0) {
// Send the obtained bytes to the UI Activity
mHandler.obtainMessage(Main_Activity1.MESSAGE_READ, bytes, -1, buffer)
.sendToTarget();
} else {
// Logger.e(TAG, "disconnected");
connectionLost();
//add by chongqing jinou
if (mState != STATE_NONE) {
// Logger.e(TAG, "disconnected");
// Start the service over to restart listening mode
BluetoothService.this.start();
}
break;
}
} catch (IOException e) {
// Logger.e(TAG, "disconnected", e);
connectionLost();
//add by chongqing jinou
if (mState != STATE_NONE) {
// Start the service over to restart listening mode
BluetoothService.this.start();
}
break;
}
}
}
/**
* Write to the connected OutStream.
*
* @param buffer The bytes to write
*/
public void write(byte[] buffer) {
try {
mmOutStream.write(buffer);
mmOutStream.flush();//清空缓存
/* if (buffer.length > 3000) //
{
byte[] readata = new byte[1];
SPPReadTimeout(readata, 1, 5000);
}*/
Log.i("BTPWRITE", new String(buffer, "GBK"));
// Share the sent message back to the UI Activity
mHandler.obtainMessage(Main_Activity1.MESSAGE_WRITE, -1, -1, buffer)
.sendToTarget();
} catch (IOException e) {
FireCrash.log(e);
}
}
public void cancel() {
try {
mmSocket.close();
} catch (IOException e) {
FireCrash.log(e);
}
}
}
}

View file

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.adins.mss.base">
<!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.ACCESS_GPS" />
<uses-permission android:name="android.permission.ACCESS_ASSISTED_GPS" />
<uses-feature
android:name="android.hardware.camera.front"
android:required="false" />
<uses-feature
android:name="android.hardware.camera.flash"
android:required="false" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> <!-- External storage for caching. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /><!-- My Location -->
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> <!-- agar aplikasi tidak dikill -->
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<application>
<receiver
android:name="com.receivers.BackupReceiver"
android:enabled="true"
android:exported="false"></receiver>
<service
android:name="com.services.MainServices"
android:foregroundServiceType="location"
android:exported="false" /> <!-- broadcast receiver -->
<receiver
android:name="com.services.ServiceAutoRestart"
android:directBootAware="true"
android:exported="true"
android:process=":remote">
<intent-filter>
<action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<activity
android:name=".dynamicform.form.DynamicQuestionActivity"
android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".dynamicform.form.questions.DrawingCanvasActivity"
android:configChanges="orientation|keyboard|keyboardHidden|screenSize" />
<activity android:name=".dynamicform.form.questions.ImageViewerActivity" />
<activity
android:name="com.adins.mss.printer.main_winson"
android:label="@string/title_activity_main_winson" />
<activity
android:name="zj.com.cn.bluetooth.sdk.Main_Activity1"
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="portrait" />
<activity
android:name="zj.com.cn.bluetooth.sdk.DeviceListActivity"
android:configChanges="orientation|keyboardHidden"
android:label="@string/select_device"
android:theme="@android:style/Theme.Dialog" /> <!-- LOOKUP ONLINE -->
<activity
android:name=".dynamicform.form.questions.viewholder.LookupFilterActivity"
android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".dynamicform.form.questions.viewholder.LookupCriteriaOnlineActivity"
android:configChanges="orientation|keyboard|keyboardHidden|screenSize" /> <!-- <activity android:name=".NewMainActivity" /> -->
<activity android:name=".NewChangePasswordActivity" />
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
<service
android:name="com.services.MssJobScheduler"
android:permission="android.permission.BIND_JOB_SERVICE">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</service>
<service
android:name="com.services.plantask.StartVisitJob"
android:exported="false"/>
<service
android:name="com.services.plantask.ChangePlanService"
android:exported="false"/>
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
</application>
</manifest>