Merge remote-tracking branch 'origin/main'
# Conflicts: # app/src/main/java/ru/myitschool/work/domain/UserRepository.java
This commit is contained in:
commit
6cf20482b5
82
.kotlin/errors/errors-1740048772972.log
Normal file
82
.kotlin/errors/errors-1740048772972.log
Normal file
@ -0,0 +1,82 @@
|
||||
kotlin version: 2.0.21
|
||||
error message: Daemon compilation failed: null
|
||||
java.lang.Exception
|
||||
at org.jetbrains.kotlin.daemon.common.CompileService$CallResult$Error.get(CompileService.kt:69)
|
||||
at org.jetbrains.kotlin.daemon.common.CompileService$CallResult$Error.get(CompileService.kt:65)
|
||||
at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.compileWithDaemon(GradleKotlinCompilerWork.kt:240)
|
||||
at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.compileWithDaemonOrFallbackImpl(GradleKotlinCompilerWork.kt:159)
|
||||
at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.run(GradleKotlinCompilerWork.kt:111)
|
||||
at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction.execute(GradleCompilerRunnerWithWorkers.kt:76)
|
||||
at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
|
||||
at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:66)
|
||||
at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:62)
|
||||
at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:100)
|
||||
at org.gradle.workers.internal.NoIsolationWorkerFactory$1.lambda$execute$0(NoIsolationWorkerFactory.java:62)
|
||||
at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
|
||||
at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)
|
||||
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:209)
|
||||
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
|
||||
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
|
||||
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
|
||||
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:166)
|
||||
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
|
||||
at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
|
||||
at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
|
||||
at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:59)
|
||||
at org.gradle.workers.internal.DefaultWorkerExecutor.lambda$submitWork$0(DefaultWorkerExecutor.java:174)
|
||||
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
|
||||
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:195)
|
||||
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.access$700(DefaultConditionalExecutionQueue.java:128)
|
||||
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner$1.run(DefaultConditionalExecutionQueue.java:170)
|
||||
at org.gradle.internal.Factories$1.create(Factories.java:31)
|
||||
at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:267)
|
||||
at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:131)
|
||||
at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:136)
|
||||
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:165)
|
||||
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:134)
|
||||
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
|
||||
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
|
||||
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
|
||||
at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:48)
|
||||
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
|
||||
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
|
||||
at java.base/java.lang.Thread.run(Unknown Source)
|
||||
Caused by: java.nio.file.DirectoryNotEmptyException: C:\Users\User\AppData\Local\Temp\kotlin-backups7383909767525510423
|
||||
at java.base/sun.nio.fs.WindowsFileSystemProvider.implDelete(Unknown Source)
|
||||
at java.base/sun.nio.fs.AbstractFileSystemProvider.delete(Unknown Source)
|
||||
at java.base/java.nio.file.Files.delete(Unknown Source)
|
||||
at org.jetbrains.kotlin.incremental.RecoverableCompilationTransaction$cleanupStash$2$1$1.invoke(CompilationTransaction.kt:244)
|
||||
at org.jetbrains.kotlin.incremental.RecoverableCompilationTransaction$cleanupStash$2$1$1.invoke(CompilationTransaction.kt:244)
|
||||
at org.jetbrains.kotlin.incremental.RecoverableCompilationTransaction.cleanupStash$lambda$11$lambda$10$lambda$9(CompilationTransaction.kt:244)
|
||||
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(Unknown Source)
|
||||
at java.base/java.util.ArrayList.forEach(Unknown Source)
|
||||
at java.base/java.util.stream.SortedOps$RefSortingSink.end(Unknown Source)
|
||||
at java.base/java.util.stream.Sink$ChainedReference.end(Unknown Source)
|
||||
at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
|
||||
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
|
||||
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source)
|
||||
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source)
|
||||
at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
|
||||
at java.base/java.util.stream.ReferencePipeline.forEach(Unknown Source)
|
||||
at org.jetbrains.kotlin.incremental.RecoverableCompilationTransaction.cleanupStash(CompilationTransaction.kt:244)
|
||||
at org.jetbrains.kotlin.incremental.RecoverableCompilationTransaction.close(CompilationTransaction.kt:254)
|
||||
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.tryCompileIncrementally(IncrementalCompilerRunner.kt:747)
|
||||
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:120)
|
||||
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:675)
|
||||
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:92)
|
||||
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1660)
|
||||
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
|
||||
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
|
||||
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
|
||||
at java.rmi/sun.rmi.transport.Transport$1.run(Unknown Source)
|
||||
at java.rmi/sun.rmi.transport.Transport$1.run(Unknown Source)
|
||||
at java.base/java.security.AccessController.doPrivileged(Unknown Source)
|
||||
at java.rmi/sun.rmi.transport.Transport.serviceCall(Unknown Source)
|
||||
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
|
||||
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
|
||||
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(Unknown Source)
|
||||
at java.base/java.security.AccessController.doPrivileged(Unknown Source)
|
||||
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
|
||||
... 3 more
|
||||
|
||||
|
@ -62,13 +62,13 @@ public class UserRepositoryImpl implements UserRepository, SignUserRepository {
|
||||
historiesDto -> {
|
||||
ArrayList<HistoryEntity> result1 = new ArrayList<>(historiesDto.size());
|
||||
for (HistoryDto history : historiesDto) {
|
||||
final Integer id1 = history.id;
|
||||
final Long id1 = history.id;
|
||||
final String username1 = history.username;
|
||||
final Long time = history.time;
|
||||
final String time = history.time;
|
||||
final String type = history.type;
|
||||
final Integer code = history.code;
|
||||
final Long code = history.code;
|
||||
if (username1 != null && id1 != null){
|
||||
result1.add(new HistoryEntity(id1, username1, time, type, code));
|
||||
result1.add(new HistoryEntity(id1, username1, type, time, code));
|
||||
}
|
||||
}
|
||||
return result1;
|
||||
@ -111,14 +111,14 @@ public class UserRepositoryImpl implements UserRepository, SignUserRepository {
|
||||
callback,
|
||||
user -> {
|
||||
if (user != null) {
|
||||
final Integer id1 = user.id;
|
||||
final String username1 = user.username;
|
||||
final String name = user.name;
|
||||
final String photo = user.photo;
|
||||
final Long lastVisit = user.lastVisit;
|
||||
final Integer idUser = user.idUser;
|
||||
final String position = user.position;
|
||||
final boolean action = user.action;
|
||||
if (idUser != null && username != null){
|
||||
return new UserEntity(username1, photo, lastVisit, idUser, position, action);
|
||||
final String authority = user.authority;
|
||||
if (id1 != null && username != null){
|
||||
return new UserEntity(id1, username1, name, photo, position, authority);
|
||||
}
|
||||
else{
|
||||
return null;
|
||||
|
@ -7,7 +7,7 @@ import com.google.gson.annotations.SerializedName;
|
||||
public class HistoryDto {
|
||||
@Nullable
|
||||
@SerializedName("id")
|
||||
public Integer id;
|
||||
public Long id;
|
||||
|
||||
@Nullable
|
||||
@SerializedName("username")
|
||||
@ -15,7 +15,7 @@ public class HistoryDto {
|
||||
|
||||
@Nullable
|
||||
@SerializedName("time")
|
||||
public Long time;
|
||||
public String time;
|
||||
|
||||
@Nullable
|
||||
@SerializedName("type")
|
||||
@ -23,6 +23,6 @@ public class HistoryDto {
|
||||
|
||||
@Nullable
|
||||
@SerializedName("code")
|
||||
public Integer code;
|
||||
public Long code;
|
||||
|
||||
}
|
||||
|
@ -1,51 +1,36 @@
|
||||
package ru.myitschool.work.data.dto;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class UserDto {
|
||||
|
||||
@Nullable
|
||||
@SerializedName("id")
|
||||
public Integer id;
|
||||
|
||||
@Nullable
|
||||
@SerializedName("username")
|
||||
public String username;
|
||||
|
||||
@Nullable
|
||||
@SerializedName("password")
|
||||
public String password;
|
||||
@SerializedName("name")
|
||||
public String name;
|
||||
|
||||
@Nullable
|
||||
@SerializedName("photo")
|
||||
public String photo;
|
||||
|
||||
@Nullable
|
||||
@SerializedName("lastVisit")
|
||||
public Long lastVisit;
|
||||
|
||||
@Nullable
|
||||
@SerializedName("idUser")
|
||||
public Integer idUser;
|
||||
|
||||
@Nullable
|
||||
@SerializedName("status")
|
||||
public int status;
|
||||
|
||||
@Nullable
|
||||
@SerializedName("position")
|
||||
public String position;
|
||||
|
||||
@Nullable
|
||||
@SerializedName("action")
|
||||
public boolean action;
|
||||
@SerializedName("authority")
|
||||
public String authority;
|
||||
|
||||
@Nullable
|
||||
public boolean getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public UserDto(@Nullable String username, @Nullable String password, @Nullable String photo,
|
||||
@Nullable Long lastVisit, @Nullable Integer idUser, int status,
|
||||
@Nullable String position, @NonNull boolean action) {
|
||||
/*public UserDto(@Nullable String username, @Nullable String password, @Nullable String photo, @Nullable Long lastVisit, @Nullable Integer idUser, int status, @Nullable String position) {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.photo = photo;
|
||||
@ -53,7 +38,6 @@ public class UserDto {
|
||||
this.idUser = idUser;
|
||||
this.status = status;
|
||||
this.position = position;
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -15,14 +15,14 @@ import ru.myitschool.work.ui.History;
|
||||
public interface UserApi {
|
||||
@GET("api/user")
|
||||
Call<List<UserDto>> getAllUsers();
|
||||
@GET("api/user/{id}")
|
||||
@GET("api/user/{id}")
|
||||
Call<UserDto> getUserByUsername(@Path("username") String Username);
|
||||
@GET("api/user/username/{username}")
|
||||
Call<UserDto> isExistUser(@Path("username") String username);
|
||||
@GET("api/user/login")
|
||||
@GET("api/{username}/auth")
|
||||
Call<Void> isExistUser(@Path("username") String username);
|
||||
@GET("api/login")
|
||||
Call<Void> login();
|
||||
@GET("api/history/user/{id}")
|
||||
Call<List<HistoryDto>> getAllUserHistory(@Path("id") String username);
|
||||
@GET("api/{username}/passing")
|
||||
Call<List<HistoryDto>> getAllUserHistory(@Path("username") String username);
|
||||
/* @GET("api/history/{id}")
|
||||
Call<HistoryDto> getHistoryById(@Path("id") Integer id);
|
||||
*/
|
||||
|
@ -19,5 +19,4 @@ public interface UserRepository {
|
||||
//void register(@NonNull String id, @NonNull Consumer<Status<FullUserEntity>> callback);
|
||||
|
||||
// void login(@NonNull String username, @NonNull String password, @NonNull Consumer<Status<Void>> callback);
|
||||
|
||||
}
|
@ -7,14 +7,14 @@ import com.google.gson.annotations.SerializedName;
|
||||
public class HistoryEntity {
|
||||
@Nullable
|
||||
@SerializedName("id")
|
||||
public Integer id;
|
||||
public Long id;
|
||||
|
||||
@Nullable
|
||||
public Integer getId() {
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable Integer id) {
|
||||
public void setId(@Nullable Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@ -28,11 +28,11 @@ public class HistoryEntity {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Long getTime() {
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(@Nullable Long time) {
|
||||
public void setTime(@Nullable String time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
@ -46,19 +46,19 @@ public class HistoryEntity {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Integer getCode() {
|
||||
public Long getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(@Nullable Integer code) {
|
||||
public void setCode(@Nullable Long code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public HistoryEntity(@Nullable Integer id, @Nullable String username, @Nullable Long time, @Nullable String type, @Nullable Integer code) {
|
||||
public HistoryEntity(@Nullable Long id, @Nullable String username, @Nullable String type, @Nullable String time, @Nullable Long code) {
|
||||
this.id = id;
|
||||
this.username = username;
|
||||
this.time = time;
|
||||
this.type = type;
|
||||
this.time = time;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ public class HistoryEntity {
|
||||
|
||||
@Nullable
|
||||
@SerializedName("time")
|
||||
public Long time;
|
||||
public String time;
|
||||
|
||||
@Nullable
|
||||
@SerializedName("type")
|
||||
@ -76,6 +76,6 @@ public class HistoryEntity {
|
||||
|
||||
@Nullable
|
||||
@SerializedName("code")
|
||||
public Integer code;
|
||||
public Long code;
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package ru.myitschool.work.domain.entities;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
@ -15,42 +14,38 @@ public class UserEntity {
|
||||
@SerializedName("username")
|
||||
public String username;
|
||||
|
||||
@Nullable
|
||||
@SerializedName("name")
|
||||
public String name;
|
||||
|
||||
@Nullable
|
||||
@SerializedName("photo")
|
||||
public String photo;
|
||||
|
||||
@Nullable
|
||||
@SerializedName("lastVisit")
|
||||
public Long lastVisit;
|
||||
|
||||
@Nullable
|
||||
@SerializedName("position")
|
||||
public String position;
|
||||
@Nullable
|
||||
@SerializedName("action")
|
||||
public boolean action;
|
||||
|
||||
@Nullable
|
||||
public boolean getAction() {
|
||||
return action;
|
||||
}
|
||||
@SerializedName("authority")
|
||||
public String authority;
|
||||
|
||||
public UserEntity(@Nullable String username, @Nullable String photo, @Nullable Long lastVisit, @Nullable Integer id, @Nullable String position, @NonNull boolean action) {
|
||||
this.username = username;
|
||||
this.photo = photo;
|
||||
this.lastVisit = lastVisit;
|
||||
public UserEntity(@Nullable Integer id, @Nullable String username, @Nullable String name, @Nullable String photo, @Nullable String position, @Nullable String authority) {
|
||||
this.id = id;
|
||||
this.username = username;
|
||||
this.name = name;
|
||||
this.photo = photo;
|
||||
this.position = position;
|
||||
this.action = action;
|
||||
this.authority = authority;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPosition() {
|
||||
return position;
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setPosition(@Nullable String position) {
|
||||
this.position = position;
|
||||
public void setId(@Nullable Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -62,6 +57,15 @@ public class UserEntity {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPhoto() {
|
||||
return photo;
|
||||
@ -72,21 +76,20 @@ public class UserEntity {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Long getLastVisit() {
|
||||
return lastVisit;
|
||||
public String getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public void setLastVisit(@Nullable Long lastVisit) {
|
||||
this.lastVisit = lastVisit;
|
||||
public void setPosition(@Nullable String position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Integer getId() {
|
||||
return id;
|
||||
public String getAuthority() {
|
||||
return authority;
|
||||
}
|
||||
|
||||
public void setId(@Nullable Integer id) {
|
||||
this.id = id;
|
||||
public void setAuthority(@Nullable String authority) {
|
||||
this.authority = authority;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import ru.myitschool.work.domain.entities.Status;
|
||||
public interface SignUserRepository {
|
||||
|
||||
void getUserByUsername(@NonNull String username, Consumer<Status<UserEntity>> callback);
|
||||
void isExistUser(@NonNull String login, Consumer<Status<Void>> callback);
|
||||
void isExistUser(@NonNull String username, Consumer<Status<Void>> callback);
|
||||
|
||||
void login(
|
||||
@NonNull String username,
|
||||
|
@ -56,9 +56,12 @@ public class HistoryAdapter extends RecyclerView.Adapter<HistoryAdapter.ViewHold
|
||||
}
|
||||
|
||||
public void bind(HistoryEntity item) {
|
||||
binding.time.setText(item.getTime().toString().substring(0, 10) + " "
|
||||
+ item.getTime().toString().substring(11, 16));
|
||||
binding.nameReader.setText(item.getType());
|
||||
//binding.time.setText(item.getTime().toString().substring(0, 10) + " "
|
||||
//+ item.getTime().toString().substring(11, 16));
|
||||
//binding.nameReader.setText(item.getType());
|
||||
binding.time.setText(item.getTime());
|
||||
binding.code.setText(item.getCode().toString());
|
||||
binding.type.setText(item.getType());
|
||||
/*if (item.getType() == 1){
|
||||
binding.type.setText("QR-code");
|
||||
}
|
||||
|
@ -59,12 +59,13 @@ public class InformationFragment extends Fragment {
|
||||
//sharedPreferences = getContext().getSharedPreferences(getString(R.string.app_name), Context.MODE_PRIVATE);
|
||||
preferenceManager = new PreferenceManager(this.getContext());
|
||||
username = preferenceManager.getString(Constants.KEY_USER_USERNAME);
|
||||
Toast.makeText(getContext(), username, Toast.LENGTH_SHORT).show();
|
||||
viewModel = new ViewModelProvider(this).get(InformationViewModel.class);
|
||||
//getInformation();
|
||||
|
||||
binding.scan.setOnClickListener(view1 -> {
|
||||
onClickScan(view);
|
||||
});
|
||||
// binding.scan.setOnClickListener(view1 -> {
|
||||
// onClickScan(view);
|
||||
// });
|
||||
|
||||
binding.logout.setOnClickListener(view2 -> {
|
||||
onClickLogout(view);
|
||||
@ -120,8 +121,9 @@ public class InformationFragment extends Fragment {
|
||||
|
||||
|
||||
|
||||
binding.loading.setVisibility(Utils.visibleOrGone(loadingHistory));
|
||||
//binding.loading.setVisibility(Utils.visibleOrGone(loadingHistory));
|
||||
if (state.isLoading() == false) {
|
||||
binding.refreshLayout.setRefreshing(false);
|
||||
if (state.getItemsHistory() != null) {
|
||||
history = state.getItemsHistory();
|
||||
|
||||
@ -138,12 +140,12 @@ public class InformationFragment extends Fragment {
|
||||
historyAdapter.updateData(history);
|
||||
historyAdapter.notifyDataSetChanged();
|
||||
binding.refreshLayout.setRefreshing(false);
|
||||
} else {
|
||||
Toast.makeText(this.getContext(), "Error", Toast.LENGTH_SHORT).show();
|
||||
takeError();
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(this.getContext(), "Error", Toast.LENGTH_SHORT).show();
|
||||
takeError();
|
||||
}
|
||||
binding.refreshLayout.setRefreshing(false);
|
||||
//binding.refreshLayout.setRefreshing(false);
|
||||
});
|
||||
/*
|
||||
viewModel.stateHistoryLiveData.observe(getViewLifecycleOwner(), state -> {
|
||||
@ -250,7 +252,7 @@ public class InformationFragment extends Fragment {
|
||||
binding.lastEntry.setVisibility(View.GONE);
|
||||
binding.position.setVisibility(View.GONE);
|
||||
//binding.logout.setVisibility(View.GONE);
|
||||
binding.scan.setVisibility(View.GONE);
|
||||
//binding.scan.setVisibility(View.GONE);
|
||||
|
||||
binding.error.setVisibility(View.VISIBLE);
|
||||
binding.refreshLayout.setRefreshing(false);
|
||||
|
@ -34,7 +34,7 @@ public class InformationViewModel extends ViewModel {
|
||||
private String username;
|
||||
|
||||
public void changeSelectedUsername(@NonNull String username) {
|
||||
this.username = this.username;
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public void load() {
|
||||
|
@ -23,10 +23,10 @@ import retrofit2.Response;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
import ru.myitschool.work.R;
|
||||
import ru.myitschool.work.core.Constants;
|
||||
import ru.myitschool.work.databinding.FragmentLoginBinding;
|
||||
import ru.myitschool.work.ui.StoreAPI;
|
||||
import ru.myitschool.work.ui.login.LoginViewModel;
|
||||
import ru.myitschool.work.utils.Constants;
|
||||
import ru.myitschool.work.utils.OnChangeText;
|
||||
import ru.myitschool.work.utils.PreferenceManager;
|
||||
|
||||
@ -135,7 +135,7 @@ public class LoginFragment extends Fragment {
|
||||
subscribe(viewModel);
|
||||
}
|
||||
|
||||
private void onClickLogin(View view) {
|
||||
/*private void onClickLogin(View view) {
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.baseUrl(Constants.SERVER_ADDRESS)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
@ -171,7 +171,7 @@ public class LoginFragment extends Fragment {
|
||||
binding.error.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
}*/
|
||||
|
||||
private void subscribe(LoginViewModel viewModel) {
|
||||
viewModel.errorLiveData.observe(getViewLifecycleOwner(), error -> {
|
||||
@ -184,8 +184,10 @@ public class LoginFragment extends Fragment {
|
||||
});*/
|
||||
viewModel.openListLiveData.observe(getViewLifecycleOwner(), username -> {
|
||||
final View view = getView();
|
||||
Toast.makeText(getContext(), "FFFFFFFFF", Toast.LENGTH_SHORT).show();
|
||||
if (view == null) return;
|
||||
preferenceManager.putString(ru.myitschool.work.utils.Constants.KEY_USER_USERNAME, username);
|
||||
preferenceManager.putString(Constants.KEY_USER_USERNAME, username);
|
||||
preferenceManager.putString(Constants.KEY_USER_ROLE, username);
|
||||
view.getRootView().findViewById(R.id.nav_view).setVisibility(View.VISIBLE);
|
||||
Navigation.findNavController(view).navigate(R.id.action_loginFragment_to_informationFragment);
|
||||
});
|
||||
|
@ -59,11 +59,12 @@ public class LoginViewModel extends ViewModel {
|
||||
}
|
||||
|
||||
public void confirm() {
|
||||
if (userCheckCompleted) {
|
||||
loginUser(username, password);
|
||||
/*if (userCheckCompleted) {
|
||||
checkAuth();
|
||||
} else {
|
||||
checkUserExist();
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
@ -72,14 +73,17 @@ public class LoginViewModel extends ViewModel {
|
||||
final String currentPassword = password;
|
||||
if (currentPassword == null || currentPassword.isEmpty()) {
|
||||
mutableErrorLiveData.postValue("Password cannot be null");
|
||||
userCheckCompleted = false;
|
||||
return;
|
||||
}
|
||||
if (currentUsername == null || currentUsername.isEmpty()) {
|
||||
mutableErrorLiveData.postValue("Login cannot be null");
|
||||
userCheckCompleted = false;
|
||||
return;
|
||||
}
|
||||
if (!isAccountExist) {
|
||||
mutableErrorLiveData.postValue("This user not exist");
|
||||
userCheckCompleted = false;
|
||||
return;
|
||||
/*createUserUseCase.execute(currentUsername, currentPassword, status -> {
|
||||
if (status.getStatusCode() == 201 && status.getErrors() == null) {
|
||||
@ -101,6 +105,7 @@ public class LoginViewModel extends ViewModel {
|
||||
mutableOpenListLiveData.postValue(currentUsername);
|
||||
} else {
|
||||
mutableErrorLiveData.postValue("Something wrong");
|
||||
userCheckCompleted = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -109,12 +114,14 @@ public class LoginViewModel extends ViewModel {
|
||||
final String currentUsername = username;
|
||||
if (currentUsername == null || currentUsername.isEmpty()) {
|
||||
mutableErrorLiveData.postValue("Login cannot be null");
|
||||
userCheckCompleted = false;
|
||||
return;
|
||||
}
|
||||
isUserExistUseCase.execute(currentUsername, status -> {
|
||||
if (status.getErrors() != null) {
|
||||
//Log.d("tagg", status.getErrors().toString());
|
||||
mutableErrorLiveData.postValue("Something wrong. Try later =(" + status.getErrors());
|
||||
userCheckCompleted = false;
|
||||
return;
|
||||
}
|
||||
userCheckCompleted = true;
|
||||
|
@ -40,7 +40,7 @@ public class ProfileFragment extends Fragment {
|
||||
|
||||
binding.username.setText(userEntity.getUsername());
|
||||
binding.position.setText(userEntity.getPosition());
|
||||
binding.lastTime.setText(userEntity.getLastVisit().toString());
|
||||
binding.lastTime.setText(userEntity.getName());
|
||||
|
||||
});
|
||||
|
||||
|
@ -24,9 +24,9 @@ public class ProfileViewModel extends ViewModel {
|
||||
UserRepositoryImpl.getInstance()
|
||||
);
|
||||
|
||||
public final GetAllUserHistoryUseCase getAllUserHistoryListUseCase = new GetAllUserHistoryUseCase(
|
||||
/*public final GetAllUserHistoryUseCase getAllUserHistoryListUseCase = new GetAllUserHistoryUseCase(
|
||||
UserRepositoryImpl.getInstance()
|
||||
);
|
||||
);*/
|
||||
private final IsUserExistUseCase isUserExistUseCase = new IsUserExistUseCase(
|
||||
UserRepositoryImpl.getInstance()
|
||||
);
|
||||
|
@ -3,6 +3,8 @@ package ru.myitschool.work.utils;
|
||||
public class Constants {
|
||||
public static final String KEY_PREFERENCE_NAME = "App";
|
||||
public static final String KEY_USER_USERNAME = "userUsername";
|
||||
public static final String KEY_USER_ROLE = "userRole";
|
||||
public static final String KEY_USER_BLOCKED = "userBlocked";
|
||||
public static String KEY_LOGIN = "login";
|
||||
public static String KEY_RESULT = "result";
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/refresh_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@ -51,50 +52,36 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/refresh"
|
||||
android:text="@string/refresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@id/logout"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/scan"
|
||||
android:text="@string/scan"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@id/refresh"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/error"
|
||||
android:visibility="gone"
|
||||
android:text="@string/error"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@id/scan"
|
||||
app:layout_constraintTop_toBottomOf="@id/logout"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/historylist"
|
||||
android:layout_gravity="center"
|
||||
/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/loading"
|
||||
android:visibility="gone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/error"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"/>
|
||||
app:layout_constraintBottom_toBottomOf="parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:id="@+id/historylist"
|
||||
tools:listitem="@layout/item_history"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
app:layout_constraintTop_toBottomOf="@id/error"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
@ -1,39 +1,79 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/time"
|
||||
android:layout_width="match_parent"
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
app:layout_constraintBottom_toTopOf="parent"
|
||||
app:layout_constraintStart_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:tag="iuroi"/>
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/nameReader"
|
||||
android:layout_width="match_parent"
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Title"
|
||||
android:textSize="16sp"
|
||||
android:text="@string/time"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/time"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:text="iuroxsssssi"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_code"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:text="kijt"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/time"
|
||||
app:layout_constraintStart_toEndOf="@id/time"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/layout_time">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/type"
|
||||
android:layout_width="match_parent"
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Title"
|
||||
android:textSize="16sp"
|
||||
android:text="@string/code"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/code"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:text="iuroxsssssi"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_type"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:text="hgfdfbjdhf"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/time"
|
||||
app:layout_constraintStart_toEndOf="@id/nameReader"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/layout_code">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Title"
|
||||
android:textSize="16sp"
|
||||
android:text="@string/type"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/type"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:text="iuroxsssssi"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -12,4 +12,8 @@
|
||||
<string name="cancelled">Operation was cancelled</string>
|
||||
<string name="success">Success</string>
|
||||
<string name="wrong">Something wrong</string>
|
||||
|
||||
<string name="time">Time:</string>
|
||||
<string name="type">Enter type:</string>
|
||||
<string name="code">Identificator:</string>
|
||||
</resources>
|
@ -12,4 +12,7 @@
|
||||
<string name="cancelled">Вход был отменён</string>
|
||||
<string name="success">Успешно</string>
|
||||
<string name="wrong">Что-то пошло не так</string>
|
||||
<string name="time">Время:</string>
|
||||
<string name="type">Тип прохода:</string>
|
||||
<string name="code">Идентификатор:</string>
|
||||
</resources>
|
@ -12,4 +12,8 @@
|
||||
<string name="cancelled">Вход был отменён</string>
|
||||
<string name="success">Успешно</string>
|
||||
<string name="wrong">Что-то пошло не так</string>
|
||||
|
||||
<string name="time">Время:</string>
|
||||
<string name="type">Тип прохода:</string>
|
||||
<string name="code">Идентификатор:</string>
|
||||
</resources>
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="close_button">Close</string>
|
||||
<string name="close_button" translatable="false">Close</string>
|
||||
</resources>
|
Loading…
x
Reference in New Issue
Block a user