Quellcode durchsuchen

Penambahan kategori pekerjaan di status working permit (API Baru)

ilhamitubagoes vor 4 Jahren
Ursprung
Commit
2271c7aff0

+ 18 - 0
.idea/codeStyles/Project.xml

@@ -1,5 +1,23 @@
1 1
 <component name="ProjectCodeStyleConfiguration">
2 2
   <code_scheme name="Project" version="173">
3
+    <JetCodeStyleSettings>
4
+      <option name="PACKAGES_TO_USE_STAR_IMPORTS">
5
+        <value>
6
+          <package name="java.util" alias="false" withSubpackages="false" />
7
+          <package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
8
+          <package name="io.ktor" alias="false" withSubpackages="true" />
9
+        </value>
10
+      </option>
11
+      <option name="PACKAGES_IMPORT_LAYOUT">
12
+        <value>
13
+          <package name="" alias="false" withSubpackages="true" />
14
+          <package name="java" alias="false" withSubpackages="true" />
15
+          <package name="javax" alias="false" withSubpackages="true" />
16
+          <package name="kotlin" alias="false" withSubpackages="true" />
17
+          <package name="" alias="true" withSubpackages="true" />
18
+        </value>
19
+      </option>
20
+    </JetCodeStyleSettings>
3 21
     <codeStyleSettings language="XML">
4 22
       <indentOptions>
5 23
         <option name="CONTINUATION_INDENT_SIZE" value="4" />

+ 116 - 0
app/src/main/java/com/fusi24/entryPermitScanner/adapter/ProblemWorkingAdapter.java

@@ -0,0 +1,116 @@
1
+package com.fusi24.entryPermitScanner.adapter;
2
+
3
+import android.content.Context;
4
+import android.view.LayoutInflater;
5
+import android.view.View;
6
+import android.view.ViewGroup;
7
+
8
+import androidx.annotation.NonNull;
9
+import androidx.recyclerview.widget.LinearLayoutManager;
10
+import androidx.recyclerview.widget.RecyclerView;
11
+
12
+import com.annimon.stream.Collectors;
13
+import com.annimon.stream.Stream;
14
+import com.fusi24.entryPermitScanner.R;
15
+import com.fusi24.entryPermitScanner.data.entity.DataGroup;
16
+import com.fusi24.entryPermitScanner.data.entity.workingpermit.DataResultPermit;
17
+
18
+import java.util.ArrayList;
19
+import java.util.List;
20
+
21
+
22
+public class ProblemWorkingAdapter extends RecyclerView.Adapter<ProblemWorkingAdapter.ViewHolder>{
23
+
24
+    private Context context;
25
+    private List<DataResultPermit> resultPermits;
26
+    private List<DataGroup> groupList;
27
+    private RecyclerView.RecycledViewPool viewPool = new RecyclerView.RecycledViewPool();
28
+
29
+    public ProblemWorkingAdapter(Context context) {
30
+        this.context = context;
31
+        this.resultPermits = new ArrayList<>();
32
+        this.groupList = new ArrayList<>();
33
+    }
34
+
35
+    public List<DataResultPermit> getResultPermits() {
36
+        return resultPermits;
37
+    }
38
+
39
+    public void setResultPermits(List<DataResultPermit> resultPermits) {
40
+        this.resultPermits = resultPermits;
41
+    }
42
+
43
+    public void updateResultPermits(List<DataResultPermit> resultPermits){
44
+        setResultPermits(resultPermits);
45
+    }
46
+
47
+    static class ViewHolder extends RecyclerView.ViewHolder {
48
+
49
+        private com.fusi24.entryPermitScanner.databinding.RowGroupBinding binding;
50
+
51
+        ViewHolder(com.fusi24.entryPermitScanner.databinding.RowGroupBinding itemBinding) {
52
+            super(itemBinding.getRoot());
53
+            this.binding = itemBinding;
54
+        }
55
+    }
56
+
57
+
58
+    @NonNull
59
+    @Override
60
+    public ProblemWorkingAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
61
+        com.fusi24.entryPermitScanner.databinding.RowGroupBinding itemBinding = com.fusi24.entryPermitScanner.databinding.
62
+                RowGroupBinding.inflate(LayoutInflater.from(context), parent, false);
63
+        return new ViewHolder(itemBinding);
64
+    }
65
+
66
+    @Override
67
+    public void onBindViewHolder(@NonNull ProblemWorkingAdapter.ViewHolder holder, int position) {
68
+
69
+        DataResultPermit permit = resultPermits.get(position);
70
+        holder.binding.tvGroupName.setText(permit.getWorkingType().getName());
71
+
72
+        if (permit.getProblems().size() == 0){
73
+            holder.binding.tvMessage.setVisibility(View.VISIBLE);
74
+            holder.binding.tvMessage.setText(permit.getMessage());
75
+        }
76
+
77
+        groupList = Stream.of(permit.getProblems())
78
+                .map(v -> v.getDataDocumentType().getGroup())
79
+                .distinctBy(DataGroup::getId)
80
+                .collect(Collectors.toList());
81
+
82
+        // Create layout manager with initial prefetch item count
83
+        LinearLayoutManager layoutManager = new LinearLayoutManager(
84
+                holder.binding.rvSubGroup.getContext(),
85
+                LinearLayoutManager.VERTICAL, false);
86
+
87
+        layoutManager.setInitialPrefetchItemCount(groupList.size());
88
+
89
+        //Create Sub Item View Adapter
90
+        ProblemGroupAdapter groupAdapter = new ProblemGroupAdapter(context);
91
+        holder.binding.rvSubGroup.setLayoutManager(layoutManager);
92
+        holder.binding.rvSubGroup.setAdapter(groupAdapter);
93
+        holder.binding.rvSubGroup.setRecycledViewPool(viewPool);
94
+
95
+        groupAdapter.updateGroupList(groupList);
96
+        groupAdapter.updateProblemList(permit.getProblems());
97
+        groupAdapter.notifyDataSetChanged();
98
+
99
+        holder.binding.ivIconGroup.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_person_hand_right_up));
100
+        holder.binding.rlGroup.setOnClickListener(v -> {
101
+            // Set Layout
102
+            if(holder.binding.rvSubGroup.getVisibility() == View.GONE){
103
+                holder.binding.rvSubGroup.setVisibility(View.VISIBLE);
104
+                holder.binding.ivChevron.setImageDrawable(context.getDrawable(R.drawable.chevron_up));
105
+            } else {
106
+                holder.binding.rvSubGroup.setVisibility(View.GONE);
107
+                holder.binding.ivChevron.setImageDrawable(context.getDrawable(R.drawable.chevron_down));
108
+            }
109
+        });
110
+    }
111
+
112
+    @Override
113
+    public int getItemCount() {
114
+        return resultPermits.size();
115
+    }
116
+}

+ 5 - 0
app/src/main/java/com/fusi24/entryPermitScanner/data/DataManager.java

@@ -7,6 +7,7 @@ import com.fusi24.entryPermitScanner.data.entity.DataDevice;
7 7
 import com.fusi24.entryPermitScanner.data.entity.DataEntryPermit;
8 8
 import com.fusi24.entryPermitScanner.data.entity.DataResultRfid;
9 9
 import com.fusi24.entryPermitScanner.data.entity.DataUser;
10
+import com.fusi24.entryPermitScanner.data.entity.workingpermit.DataWorkingPermit;
10 11
 
11 12
 import java.util.List;
12 13
 
@@ -40,4 +41,8 @@ public class DataManager {
40 41
         return restService.checkRfidCard(numberRfid, permitId, rfidDeviceId, checkTypeId, longLat, userId, expand);
41 42
     }
42 43
 
44
+    public Observable<DataWorkingPermit> checkPermitCard(String numberRfid, Integer permitId, String rfidDeviceId, Integer checkTypeId, String longLat, Integer userId, String[] expand) {
45
+        return restService.checkPermitCard(numberRfid, permitId, rfidDeviceId, checkTypeId, longLat, userId, expand);
46
+    }
47
+
43 48
 }

+ 10 - 0
app/src/main/java/com/fusi24/entryPermitScanner/data/api/RestService.java

@@ -8,6 +8,7 @@ import com.fusi24.entryPermitScanner.data.entity.DataEntryPermit;
8 8
 import com.fusi24.entryPermitScanner.data.entity.DataResultRfid;
9 9
 import com.fusi24.entryPermitScanner.data.entity.DataSite;
10 10
 import com.fusi24.entryPermitScanner.data.entity.DataUser;
11
+import com.fusi24.entryPermitScanner.data.entity.workingpermit.DataWorkingPermit;
11 12
 
12 13
 import java.util.List;
13 14
 
@@ -46,4 +47,13 @@ public interface RestService {
46 47
                                              @Query("checkedBy") Integer userId,
47 48
                                              @Query("expand") String[] expand);
48 49
 
50
+    @GET(Constant.SID2_ENDPOINT + "/employee/permit/check/rfid/{number_rfid}")
51
+    Observable<DataWorkingPermit> checkPermitCard(@Path("number_rfid") String numberRfid,
52
+                                                  @Query("entryPermitId") Integer permitId,
53
+                                                  @Query("rfidDeviceId") String rfidDeviceId,
54
+                                                  @Query("checkTypeId") Integer checkTypeId,
55
+                                                  @Query("longLat") String longLat,
56
+                                                  @Query("checkedBy") Integer userId,
57
+                                                  @Query("expand") String[] expand);
58
+
49 59
 }

+ 38 - 1
app/src/main/java/com/fusi24/entryPermitScanner/data/entity/DataCompany.java

@@ -1,6 +1,9 @@
1 1
 package com.fusi24.entryPermitScanner.data.entity;
2 2
 
3
-public class DataCompany {
3
+import android.os.Parcel;
4
+import android.os.Parcelable;
5
+
6
+public class DataCompany implements Parcelable {
4 7
 
5 8
     private Integer id;
6 9
     private String code;
@@ -29,4 +32,38 @@ public class DataCompany {
29 32
     public void setName(String name) {
30 33
         this.name = name;
31 34
     }
35
+
36
+
37
+    @Override
38
+    public int describeContents() {
39
+        return 0;
40
+    }
41
+
42
+    @Override
43
+    public void writeToParcel(Parcel dest, int flags) {
44
+        dest.writeValue(this.id);
45
+        dest.writeString(this.code);
46
+        dest.writeString(this.name);
47
+    }
48
+
49
+    public DataCompany() {
50
+    }
51
+
52
+    protected DataCompany(Parcel in) {
53
+        this.id = (Integer) in.readValue(Integer.class.getClassLoader());
54
+        this.code = in.readString();
55
+        this.name = in.readString();
56
+    }
57
+
58
+    public static final Parcelable.Creator<DataCompany> CREATOR = new Parcelable.Creator<DataCompany>() {
59
+        @Override
60
+        public DataCompany createFromParcel(Parcel source) {
61
+            return new DataCompany(source);
62
+        }
63
+
64
+        @Override
65
+        public DataCompany[] newArray(int size) {
66
+            return new DataCompany[size];
67
+        }
68
+    };
32 69
 }

+ 48 - 1
app/src/main/java/com/fusi24/entryPermitScanner/data/entity/DataEmployee.java

@@ -1,6 +1,9 @@
1 1
 package com.fusi24.entryPermitScanner.data.entity;
2 2
 
3
-public class DataEmployee {
3
+import android.os.Parcel;
4
+import android.os.Parcelable;
5
+
6
+public class DataEmployee implements Parcelable {
4 7
 
5 8
     private Integer id;
6 9
     private String code;
@@ -74,4 +77,48 @@ public class DataEmployee {
74 77
     public void setFunctionalPosition(DataFunctionalPosition functionalPosition) {
75 78
         this.functionalPosition = functionalPosition;
76 79
     }
80
+
81
+
82
+    @Override
83
+    public int describeContents() {
84
+        return 0;
85
+    }
86
+
87
+    @Override
88
+    public void writeToParcel(Parcel dest, int flags) {
89
+        dest.writeValue(this.id);
90
+        dest.writeString(this.code);
91
+        dest.writeString(this.sidCode);
92
+        dest.writeString(this.name);
93
+        dest.writeString(this.urlPhoto);
94
+        dest.writeParcelable(this.company, flags);
95
+        dest.writeParcelable(this.structuralPosition, flags);
96
+        dest.writeParcelable(this.functionalPosition, flags);
97
+    }
98
+
99
+    public DataEmployee() {
100
+    }
101
+
102
+    protected DataEmployee(Parcel in) {
103
+        this.id = (Integer) in.readValue(Integer.class.getClassLoader());
104
+        this.code = in.readString();
105
+        this.sidCode = in.readString();
106
+        this.name = in.readString();
107
+        this.urlPhoto = in.readString();
108
+        this.company = in.readParcelable(DataCompany.class.getClassLoader());
109
+        this.structuralPosition = in.readParcelable(DataStructuralPosition.class.getClassLoader());
110
+        this.functionalPosition = in.readParcelable(DataFunctionalPosition.class.getClassLoader());
111
+    }
112
+
113
+    public static final Parcelable.Creator<DataEmployee> CREATOR = new Parcelable.Creator<DataEmployee>() {
114
+        @Override
115
+        public DataEmployee createFromParcel(Parcel source) {
116
+            return new DataEmployee(source);
117
+        }
118
+
119
+        @Override
120
+        public DataEmployee[] newArray(int size) {
121
+            return new DataEmployee[size];
122
+        }
123
+    };
77 124
 }

+ 38 - 1
app/src/main/java/com/fusi24/entryPermitScanner/data/entity/DataFunctionalPosition.java

@@ -1,6 +1,9 @@
1 1
 package com.fusi24.entryPermitScanner.data.entity;
2 2
 
3
-public class DataFunctionalPosition {
3
+import android.os.Parcel;
4
+import android.os.Parcelable;
5
+
6
+public class DataFunctionalPosition implements Parcelable {
4 7
 
5 8
     private Integer id;
6 9
     private String name;
@@ -29,4 +32,38 @@ public class DataFunctionalPosition {
29 32
     public void setDescription(String description) {
30 33
         this.description = description;
31 34
     }
35
+
36
+
37
+    @Override
38
+    public int describeContents() {
39
+        return 0;
40
+    }
41
+
42
+    @Override
43
+    public void writeToParcel(Parcel dest, int flags) {
44
+        dest.writeValue(this.id);
45
+        dest.writeString(this.name);
46
+        dest.writeString(this.description);
47
+    }
48
+
49
+    public DataFunctionalPosition() {
50
+    }
51
+
52
+    protected DataFunctionalPosition(Parcel in) {
53
+        this.id = (Integer) in.readValue(Integer.class.getClassLoader());
54
+        this.name = in.readString();
55
+        this.description = in.readString();
56
+    }
57
+
58
+    public static final Parcelable.Creator<DataFunctionalPosition> CREATOR = new Parcelable.Creator<DataFunctionalPosition>() {
59
+        @Override
60
+        public DataFunctionalPosition createFromParcel(Parcel source) {
61
+            return new DataFunctionalPosition(source);
62
+        }
63
+
64
+        @Override
65
+        public DataFunctionalPosition[] newArray(int size) {
66
+            return new DataFunctionalPosition[size];
67
+        }
68
+    };
32 69
 }

+ 38 - 1
app/src/main/java/com/fusi24/entryPermitScanner/data/entity/DataStructuralPosition.java

@@ -1,6 +1,9 @@
1 1
 package com.fusi24.entryPermitScanner.data.entity;
2 2
 
3
-public class DataStructuralPosition {
3
+import android.os.Parcel;
4
+import android.os.Parcelable;
5
+
6
+public class DataStructuralPosition implements Parcelable {
4 7
 
5 8
     private Integer id;
6 9
     private String name;
@@ -29,4 +32,38 @@ public class DataStructuralPosition {
29 32
     public void setDescription(String description) {
30 33
         this.description = description;
31 34
     }
35
+
36
+
37
+    @Override
38
+    public int describeContents() {
39
+        return 0;
40
+    }
41
+
42
+    @Override
43
+    public void writeToParcel(Parcel dest, int flags) {
44
+        dest.writeValue(this.id);
45
+        dest.writeString(this.name);
46
+        dest.writeString(this.description);
47
+    }
48
+
49
+    public DataStructuralPosition() {
50
+    }
51
+
52
+    protected DataStructuralPosition(Parcel in) {
53
+        this.id = (Integer) in.readValue(Integer.class.getClassLoader());
54
+        this.name = in.readString();
55
+        this.description = in.readString();
56
+    }
57
+
58
+    public static final Parcelable.Creator<DataStructuralPosition> CREATOR = new Parcelable.Creator<DataStructuralPosition>() {
59
+        @Override
60
+        public DataStructuralPosition createFromParcel(Parcel source) {
61
+            return new DataStructuralPosition(source);
62
+        }
63
+
64
+        @Override
65
+        public DataStructuralPosition[] newArray(int size) {
66
+            return new DataStructuralPosition[size];
67
+        }
68
+    };
32 69
 }

+ 97 - 0
app/src/main/java/com/fusi24/entryPermitScanner/data/entity/workingpermit/DataResultPermit.java

@@ -0,0 +1,97 @@
1
+package com.fusi24.entryPermitScanner.data.entity.workingpermit;
2
+
3
+import android.os.Parcel;
4
+import android.os.Parcelable;
5
+
6
+import com.fusi24.entryPermitScanner.data.entity.DataProblems;
7
+
8
+import java.util.ArrayList;
9
+import java.util.List;
10
+
11
+public class DataResultPermit implements Parcelable {
12
+
13
+    private Boolean passed;
14
+    private String alertType;
15
+    private String message;
16
+    private DataWorkingType workingType;
17
+    private List<DataProblems> problems;
18
+
19
+    public Boolean getPassed() {
20
+        return passed;
21
+    }
22
+
23
+    public void setPassed(Boolean passed) {
24
+        this.passed = passed;
25
+    }
26
+
27
+    public String getAlertType() {
28
+        return alertType;
29
+    }
30
+
31
+    public void setAlertType(String alertType) {
32
+        this.alertType = alertType;
33
+    }
34
+
35
+    public String getMessage() {
36
+        return message;
37
+    }
38
+
39
+    public void setMessage(String message) {
40
+        this.message = message;
41
+    }
42
+
43
+    public DataWorkingType getWorkingType() {
44
+        return workingType;
45
+    }
46
+
47
+    public void setWorkingType(DataWorkingType workingType) {
48
+        this.workingType = workingType;
49
+    }
50
+
51
+    public List<DataProblems> getProblems() {
52
+        return problems;
53
+    }
54
+
55
+    public void setProblems(List<DataProblems> problems) {
56
+        this.problems = problems;
57
+    }
58
+
59
+    public DataResultPermit() {
60
+    }
61
+
62
+
63
+    @Override
64
+    public int describeContents() {
65
+        return 0;
66
+    }
67
+
68
+    @Override
69
+    public void writeToParcel(Parcel dest, int flags) {
70
+        dest.writeValue(this.passed);
71
+        dest.writeString(this.alertType);
72
+        dest.writeString(this.message);
73
+        dest.writeParcelable(this.workingType, flags);
74
+        dest.writeList(this.problems);
75
+    }
76
+
77
+    protected DataResultPermit(Parcel in) {
78
+        this.passed = (Boolean) in.readValue(Boolean.class.getClassLoader());
79
+        this.alertType = in.readString();
80
+        this.message = in.readString();
81
+        this.workingType = in.readParcelable(DataWorkingType.class.getClassLoader());
82
+        this.problems = new ArrayList<DataProblems>();
83
+        in.readList(this.problems, DataProblems.class.getClassLoader());
84
+    }
85
+
86
+    public static final Creator<DataResultPermit> CREATOR = new Creator<DataResultPermit>() {
87
+        @Override
88
+        public DataResultPermit createFromParcel(Parcel source) {
89
+            return new DataResultPermit(source);
90
+        }
91
+
92
+        @Override
93
+        public DataResultPermit[] newArray(int size) {
94
+            return new DataResultPermit[size];
95
+        }
96
+    };
97
+}

+ 95 - 0
app/src/main/java/com/fusi24/entryPermitScanner/data/entity/workingpermit/DataWorkingPermit.java

@@ -0,0 +1,95 @@
1
+package com.fusi24.entryPermitScanner.data.entity.workingpermit;
2
+
3
+import android.os.Parcel;
4
+import android.os.Parcelable;
5
+
6
+import com.fusi24.entryPermitScanner.data.entity.DataEmployee;
7
+
8
+import java.util.List;
9
+
10
+public class DataWorkingPermit implements Parcelable {
11
+
12
+    private Boolean passed;
13
+    private String alertType;
14
+    private String message;
15
+    private DataEmployee employee;
16
+    private List<DataResultPermit> results;
17
+
18
+    public Boolean getPassed() {
19
+        return passed;
20
+    }
21
+
22
+    public void setPassed(Boolean passed) {
23
+        this.passed = passed;
24
+    }
25
+
26
+    public String getAlertType() {
27
+        return alertType;
28
+    }
29
+
30
+    public void setAlertType(String alertType) {
31
+        this.alertType = alertType;
32
+    }
33
+
34
+    public String getMessage() {
35
+        return message;
36
+    }
37
+
38
+    public void setMessage(String message) {
39
+        this.message = message;
40
+    }
41
+
42
+    public DataEmployee getEmployee() {
43
+        return employee;
44
+    }
45
+
46
+    public void setEmployee(DataEmployee employee) {
47
+        this.employee = employee;
48
+    }
49
+
50
+    public List<DataResultPermit> getResults() {
51
+        return results;
52
+    }
53
+
54
+    public void setResults(List<DataResultPermit> results) {
55
+        this.results = results;
56
+    }
57
+
58
+    public DataWorkingPermit() {
59
+    }
60
+
61
+
62
+    @Override
63
+    public int describeContents() {
64
+        return 0;
65
+    }
66
+
67
+    @Override
68
+    public void writeToParcel(Parcel dest, int flags) {
69
+        dest.writeValue(this.passed);
70
+        dest.writeString(this.alertType);
71
+        dest.writeString(this.message);
72
+        dest.writeParcelable(this.employee, flags);
73
+        dest.writeTypedList(this.results);
74
+    }
75
+
76
+    protected DataWorkingPermit(Parcel in) {
77
+        this.passed = (Boolean) in.readValue(Boolean.class.getClassLoader());
78
+        this.alertType = in.readString();
79
+        this.message = in.readString();
80
+        this.employee = in.readParcelable(DataEmployee.class.getClassLoader());
81
+        this.results = in.createTypedArrayList(DataResultPermit.CREATOR);
82
+    }
83
+
84
+    public static final Creator<DataWorkingPermit> CREATOR = new Creator<DataWorkingPermit>() {
85
+        @Override
86
+        public DataWorkingPermit createFromParcel(Parcel source) {
87
+            return new DataWorkingPermit(source);
88
+        }
89
+
90
+        @Override
91
+        public DataWorkingPermit[] newArray(int size) {
92
+            return new DataWorkingPermit[size];
93
+        }
94
+    };
95
+}

+ 79 - 0
app/src/main/java/com/fusi24/entryPermitScanner/data/entity/workingpermit/DataWorkingType.java

@@ -0,0 +1,79 @@
1
+package com.fusi24.entryPermitScanner.data.entity.workingpermit;
2
+
3
+import android.os.Parcel;
4
+import android.os.Parcelable;
5
+
6
+public class DataWorkingType implements Parcelable {
7
+
8
+    private Integer id;
9
+    private String name;
10
+    private String description;
11
+    private Boolean isActive;
12
+
13
+    public Integer getId() {
14
+        return id;
15
+    }
16
+
17
+    public void setId(Integer id) {
18
+        this.id = id;
19
+    }
20
+
21
+    public String getName() {
22
+        return name;
23
+    }
24
+
25
+    public void setName(String name) {
26
+        this.name = name;
27
+    }
28
+
29
+    public String getDescription() {
30
+        return description;
31
+    }
32
+
33
+    public void setDescription(String description) {
34
+        this.description = description;
35
+    }
36
+
37
+    public Boolean getActive() {
38
+        return isActive;
39
+    }
40
+
41
+    public void setActive(Boolean active) {
42
+        isActive = active;
43
+    }
44
+
45
+    @Override
46
+    public int describeContents() {
47
+        return 0;
48
+    }
49
+
50
+    @Override
51
+    public void writeToParcel(Parcel dest, int flags) {
52
+        dest.writeValue(this.id);
53
+        dest.writeString(this.name);
54
+        dest.writeString(this.description);
55
+        dest.writeValue(this.isActive);
56
+    }
57
+
58
+    public DataWorkingType() {
59
+    }
60
+
61
+    protected DataWorkingType(Parcel in) {
62
+        this.id = (Integer) in.readValue(Integer.class.getClassLoader());
63
+        this.name = in.readString();
64
+        this.description = in.readString();
65
+        this.isActive = (Boolean) in.readValue(Boolean.class.getClassLoader());
66
+    }
67
+
68
+    public static final Parcelable.Creator<DataWorkingType> CREATOR = new Parcelable.Creator<DataWorkingType>() {
69
+        @Override
70
+        public DataWorkingType createFromParcel(Parcel source) {
71
+            return new DataWorkingType(source);
72
+        }
73
+
74
+        @Override
75
+        public DataWorkingType[] newArray(int size) {
76
+            return new DataWorkingType[size];
77
+        }
78
+    };
79
+}

+ 71 - 12
app/src/main/java/com/fusi24/entryPermitScanner/ui/scanresult/ScanResultActivity.java

@@ -11,16 +11,14 @@ import androidx.appcompat.widget.Toolbar;
11 11
 import androidx.recyclerview.widget.DefaultItemAnimator;
12 12
 import androidx.recyclerview.widget.LinearLayoutManager;
13 13
 
14
-import com.annimon.stream.Collectors;
15
-import com.annimon.stream.Stream;
16 14
 import com.bumptech.glide.Glide;
17 15
 import com.fusi24.entryPermitScanner.R;
18
-import com.fusi24.entryPermitScanner.adapter.ProblemGroupAdapter;
16
+import com.fusi24.entryPermitScanner.adapter.ProblemWorkingAdapter;
19 17
 import com.fusi24.entryPermitScanner.base.BaseActivity;
20 18
 import com.fusi24.entryPermitScanner.config.Constant;
21
-import com.fusi24.entryPermitScanner.data.entity.DataGroup;
22
-import com.fusi24.entryPermitScanner.data.entity.DataProblems;
23 19
 import com.fusi24.entryPermitScanner.data.entity.DataResultRfid;
20
+import com.fusi24.entryPermitScanner.data.entity.workingpermit.DataResultPermit;
21
+import com.fusi24.entryPermitScanner.data.entity.workingpermit.DataWorkingPermit;
24 22
 import com.fusi24.entryPermitScanner.databinding.ActivityScanResultNewBinding;
25 23
 import com.fusi24.entryPermitScanner.ui.home.HomeActivity;
26 24
 import com.fusi24.entryPermitScanner.util.SoundUtil;
@@ -41,8 +39,8 @@ public class ScanResultActivity extends BaseActivity implements ScanResultView {
41 39
     public static final String LOCATION = "location";
42 40
 
43 41
     private ScanResultPresenter presenter;
44
-    private ProblemGroupAdapter adapter;
45
-    private List<DataProblems> problemsList;
42
+    private ProblemWorkingAdapter adapter;
43
+    private List<DataResultPermit> resultPermitList;
46 44
     private String dataUrl, numberRfid, numberRfidTemp, idPermit, idDevice, idCheckType, checkTypeName, longLat;
47 45
     private ActivityScanResultNewBinding binding;
48 46
 
@@ -102,8 +100,8 @@ public class ScanResultActivity extends BaseActivity implements ScanResultView {
102 100
     private void initView() {
103 101
         binding.tvRfidNumber.setText(numberRfid);
104 102
 
105
-        problemsList = new ArrayList<>();
106
-        adapter = new ProblemGroupAdapter(this);
103
+        resultPermitList = new ArrayList<>();
104
+        adapter = new ProblemWorkingAdapter(this);
107 105
 
108 106
         LinearLayoutManager layoutManager = new LinearLayoutManager(this);
109 107
         binding.rvGroupProblem.setLayoutManager(layoutManager);
@@ -112,13 +110,14 @@ public class ScanResultActivity extends BaseActivity implements ScanResultView {
112 110
     }
113 111
 
114 112
     private void loadingdata() {
115
-        problemsList.clear();
113
+        resultPermitList.clear();
116 114
         String[] expand = {"employee.company, employee.structuralPosition, employee.functionalPosition, problems.documentType.category,problems.documentType.group"};
117 115
 
118 116
         String bebas = "Location = " + longLat;
119 117
         Timber.i(bebas);
120 118
 
121
-        presenter.checkRfidCard(numberRfid, Integer.valueOf(idPermit), idDevice, Integer.valueOf(idCheckType), longLat, getSessionManager().getUserId(), expand);
119
+        //presenter.checkRfidCard(numberRfid, Integer.valueOf(idPermit), idDevice, Integer.valueOf(idCheckType), longLat, getSessionManager().getUserId(), expand);
120
+        presenter.checkPermitCard(numberRfid, Integer.valueOf(idPermit), idDevice, Integer.valueOf(idCheckType), longLat, getSessionManager().getUserId(), expand);
122 121
     }
123 122
 
124 123
     private void initEvent() {
@@ -147,7 +146,7 @@ public class ScanResultActivity extends BaseActivity implements ScanResultView {
147 146
     @Override
148 147
     public void showDataRfid(DataResultRfid dataResultRfid) {
149 148
 
150
-        if (dataResultRfid.getEmployee() != null) {
149
+        /*if (dataResultRfid.getEmployee() != null) {
151 150
             if (getSessionManager().isDevelopment()){
152 151
                 dataUrl = Constant.BASE_URL_DEV + Constant.URL_PHOTO + dataResultRfid.getEmployee().getUrlPhoto().substring(14);
153 152
             } else {
@@ -222,6 +221,66 @@ public class ScanResultActivity extends BaseActivity implements ScanResultView {
222 221
 
223 222
         adapter.updateGroupList(groupList);
224 223
         adapter.updateProblemList(problemsList);
224
+        adapter.notifyDataSetChanged();*/
225
+    }
226
+
227
+    @Override
228
+    public void showDataPermit(DataWorkingPermit dataWorkingPermit) {
229
+        if (dataWorkingPermit.getEmployee() != null) {
230
+            if (getSessionManager().isDevelopment()){
231
+                dataUrl = Constant.BASE_URL_DEV + Constant.URL_PHOTO + dataWorkingPermit.getEmployee().getUrlPhoto().substring(14);
232
+            } else {
233
+                dataUrl = Constant.BASE_URL_PROD + Constant.URL_PHOTO + dataWorkingPermit.getEmployee().getUrlPhoto().substring(14);
234
+            }
235
+
236
+            binding.tvProfileName.setText(dataWorkingPermit.getEmployee().getName());
237
+            binding.tvStructuralPosition.setText(dataWorkingPermit.getEmployee().getStructuralPosition().getName());
238
+            binding.tvFunctionalPosition.setText(dataWorkingPermit.getEmployee().getFunctionalPosition().getName());
239
+            binding.tvCompanyName.setText(dataWorkingPermit.getEmployee().getCompany().getName());
240
+        } else {
241
+            binding.tvProfileName.setText("-");
242
+            binding.tvStructuralPosition.setText("-");
243
+            binding.tvFunctionalPosition.setText("-");
244
+            binding.tvCompanyName.setText("-");
245
+        }
246
+
247
+        Glide.with(this)
248
+                .load(dataUrl)
249
+                .placeholder(R.drawable.ic_profile_default)
250
+                .error(R.drawable.ic_profile_default)
251
+                .into(binding.ivProfileImage);
252
+
253
+        if (dataWorkingPermit.getPassed()) {
254
+            binding.tvProfileStatus.setText(R.string.label_status_passed);
255
+            binding.llProfileStatus.setBackgroundColor(getResources().getColor(R.color.greenPassed));
256
+        } else {
257
+            SoundUtil.playSound();
258
+            if (dataWorkingPermit.getAlertType() != null) {
259
+                if (dataWorkingPermit.getAlertType().equalsIgnoreCase("ERROR")) {
260
+                    binding.tvProfileStatus.setText(R.string.label_status_not_passed);
261
+                    binding.llProfileStatus.setBackgroundColor(getResources().getColor(R.color.redNotPassed));
262
+                }
263
+
264
+                if (dataWorkingPermit.getAlertType().equalsIgnoreCase("WARNING")) {
265
+                    binding.tvProfileStatus.setText(R.string.label_status_not_valid);
266
+                    binding.llProfileStatus.setBackgroundColor(getResources().getColor(R.color.redNotPassed));
267
+                }
268
+
269
+            } else {
270
+                binding.tvProfileStatus.setText(R.string.label_status_not_passed);
271
+                binding.llProfileStatus.setBackgroundColor(getResources().getColor(R.color.redNotPassed));
272
+            }
273
+        }
274
+
275
+        if (dataWorkingPermit.getMessage() != null) {
276
+            binding.tvMessage.setVisibility(View.VISIBLE);
277
+            binding.tvMessage.setText(dataWorkingPermit.getMessage());
278
+        } else {
279
+            binding.tvMessage.setVisibility(View.GONE);
280
+        }
281
+
282
+        resultPermitList = dataWorkingPermit.getResults();
283
+        adapter.updateResultPermits(resultPermitList);
225 284
         adapter.notifyDataSetChanged();
226 285
     }
227 286
 

+ 15 - 0
app/src/main/java/com/fusi24/entryPermitScanner/ui/scanresult/ScanResultPresenter.java

@@ -33,4 +33,19 @@ class ScanResultPresenter extends BasePresenter<ScanResultView> {
33 33
                 }));
34 34
     }
35 35
 
36
+    void checkPermitCard(String numberRfid, Integer permitId, String rfidDeviceId, Integer checkTypeId, String longLat, Integer userId, String[] expand) {
37
+        disposable.add(manager.checkPermitCard(numberRfid, permitId, rfidDeviceId, checkTypeId, longLat, userId, expand)
38
+                .observeOn(androidScheduler)
39
+                .subscribeOn(processScheduler)
40
+                .subscribe(dataRfid -> {
41
+                    if (isViewAttached()) {
42
+                        getView().showDataPermit(dataRfid);
43
+                    }
44
+                }, throwable -> {
45
+                    if (isViewAttached()) {
46
+                        getView().showError(throwable);
47
+                    }
48
+                }));
49
+    }
50
+
36 51
 }

+ 2 - 0
app/src/main/java/com/fusi24/entryPermitScanner/ui/scanresult/ScanResultView.java

@@ -2,9 +2,11 @@ package com.fusi24.entryPermitScanner.ui.scanresult;
2 2
 
3 3
 import com.fusi24.entryPermitScanner.base.BaseView;
4 4
 import com.fusi24.entryPermitScanner.data.entity.DataResultRfid;
5
+import com.fusi24.entryPermitScanner.data.entity.workingpermit.DataWorkingPermit;
5 6
 
6 7
 public interface ScanResultView extends BaseView {
7 8
 
8 9
     void showDataRfid(DataResultRfid dataResultRfid);
10
+    void showDataPermit(DataWorkingPermit dataWorkingPermit);
9 11
 
10 12
 }

+ 6 - 0
app/src/main/res/drawable/ic_person_hand_right_up.xml

@@ -0,0 +1,6 @@
1
+<vector android:height="24dp" android:tint="#27AE5D"
2
+    android:viewportHeight="24" android:viewportWidth="24"
3
+    android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4
+    <path android:fillColor="@android:color/white" android:pathData="M12,4m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0"/>
5
+    <path android:fillColor="@android:color/white" android:pathData="M15.89,8.11C15.5,7.72 14.83,7 13.53,7c-0.21,0 -1.42,0 -2.54,0C8.24,6.99 6,4.75 6,2H4c0,3.16 2.11,5.84 5,6.71V22h2v-6h2v6h2V10.05L18.95,14l1.41,-1.41L15.89,8.11z"/>
6
+</vector>

+ 9 - 0
app/src/main/res/layout/row_group.xml

@@ -29,6 +29,7 @@
29 29
                 android:layout_alignParentStart="true">
30 30
 
31 31
                 <ImageView
32
+                    android:id="@+id/iv_icon_group"
32 33
                     android:layout_width="20dp"
33 34
                     android:layout_height="20dp"
34 35
                     android:layout_marginStart="4dp"
@@ -68,6 +69,14 @@
68 69
                 tools:listitem="@layout/row_document"
69 70
                 tools:itemCount="2"/>
70 71
 
72
+            <TextView
73
+                android:id="@+id/tv_message"
74
+                android:layout_width="wrap_content"
75
+                android:layout_height="wrap_content"
76
+                android:layout_below="@id/rv_sub_group"
77
+                android:visibility="gone"
78
+                tools:text="There is a problem: Working Permit Mapping is Empty"/>
79
+
71 80
         </RelativeLayout>
72 81
 
73 82
     </androidx.cardview.widget.CardView>