|
@@ -1,25 +1,78 @@
|
|
|
package com.sunwin.visitorapp.fragment;
|
|
|
|
|
|
+import android.annotation.SuppressLint;
|
|
|
+import android.content.Context;
|
|
|
import android.os.Bundle;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
+import android.widget.EditText;
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
import androidx.annotation.Nullable;
|
|
|
+import androidx.appcompat.app.AlertDialog;
|
|
|
import androidx.fragment.app.Fragment;
|
|
|
+import androidx.recyclerview.widget.LinearLayoutManager;
|
|
|
+import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
|
|
+import com.litesuits.orm.db.assit.QueryBuilder;
|
|
|
import com.sunwin.visitorapp.R;
|
|
|
+import com.sunwin.visitorapp.adapter.BaseRecyclerAdapter;
|
|
|
+import com.sunwin.visitorapp.adapter.BaseViewHolder;
|
|
|
+import com.sunwin.visitorapp.db.DatabaseManager;
|
|
|
+import com.sunwin.visitorapp.db.LogModel;
|
|
|
+import com.sunwin.visitorapp.db.RoleModel;
|
|
|
+import com.sunwin.visitorapp.db.UserManagerModel;
|
|
|
+import com.sunwin.visitorapp.utils.TimeUtils;
|
|
|
|
|
|
public class LogManageFr extends Fragment {
|
|
|
|
|
|
private View root;
|
|
|
+ private Context context;
|
|
|
+ private BaseRecyclerAdapter<LogModel> adapter ;
|
|
|
@Nullable
|
|
|
@Override
|
|
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
|
|
|
|
if(root==null)root = inflater.inflate(R.layout.fr_log_manage,container,false);
|
|
|
+ context = root.getContext();
|
|
|
+ RecyclerView RecyclerBlackList = root.findViewById(R.id.RecyclerLogList);
|
|
|
+ adapter = new BaseRecyclerAdapter<LogModel>() {
|
|
|
+ @Override
|
|
|
+ protected View getLayoutView(ViewGroup parent, int viewType) {
|
|
|
+ return LayoutInflater.from(parent.getContext()).inflate(R.layout.item_loglist,parent,false);
|
|
|
+ }
|
|
|
|
|
|
+ @SuppressLint("UseCompatLoadingForDrawables")
|
|
|
+ @Override
|
|
|
+ public void bind(int position, LogModel data, BaseViewHolder holder, int viewType) {
|
|
|
+
|
|
|
+ holder.setText(R.id.TextName,data.name);
|
|
|
+ holder.setText(R.id.TextType, data.type.getName());
|
|
|
+ holder.setText(R.id.TextTime, TimeUtils.stampToTime(data.time));
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ };
|
|
|
+ RecyclerBlackList.setAdapter(adapter);
|
|
|
+ RecyclerBlackList.setLayoutManager(new LinearLayoutManager(context,LinearLayoutManager.VERTICAL,false));
|
|
|
+// RecyclerBlackList.addItemDecoration(new RVLinearItemDecoration.Builder(root.getContext()).color(R.color.ColorGray).dashWidth(2).create());
|
|
|
+ refreshData();
|
|
|
+
|
|
|
+ EditText EditSearchKey = root.findViewById(R.id.EditSearchKey);
|
|
|
+ root.findViewById(R.id.ButtonSearch).setOnClickListener(v->{
|
|
|
+ search(EditSearchKey.getText().toString().trim());
|
|
|
+ });
|
|
|
return root;
|
|
|
}
|
|
|
+
|
|
|
+ private void refreshData(){
|
|
|
+ adapter.setList(DatabaseManager.getInstance().getQueryAll(LogModel.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void search(String key){
|
|
|
+ QueryBuilder<LogModel> q =new QueryBuilder<>(LogModel.class);
|
|
|
+ q.whereEquals(LogModel.Column_Name,key);
|
|
|
+ adapter.setList(DatabaseManager.getInstance().query(q));
|
|
|
+ }
|
|
|
}
|