Commit ddc2d232 authored by chenyuling's avatar chenyuling

"修改为8个组"

parent 215bcfd8
package com.srthinker.statinfo.constant;
import com.srthinker.statinfo.bean.Group2Bean;
import java.util.ArrayList;
public class GroupConst {
public static final String WATERPROOF = "waterproof";
......@@ -14,4 +18,17 @@ public class GroupConst {
public static final int NO_GROUP = 100;
public static final int GROUPED = 200;
//钢筋班组,木工班组,泥工班组,水电班组,防水班组,外架班组,项目部,监理单位
public static ArrayList<Group2Bean> group2BeansConst = new ArrayList<>();
static {
group2BeansConst.add(new Group2Bean(5, "钢筋班组",0));
group2BeansConst.add(new Group2Bean(6, "木工班组",0));
group2BeansConst.add(new Group2Bean(7, "泥工班组",0));
group2BeansConst.add(new Group2Bean(8, "水电班组",0));
group2BeansConst.add(new Group2Bean(1, "防水班组",0));
group2BeansConst.add(new Group2Bean(2, "外架班组",0));
group2BeansConst.add(new Group2Bean(3, "项目部",0));
group2BeansConst.add(new Group2Bean(4, "监理单位",0));
}
}
......@@ -2,14 +2,6 @@ package com.srthinker.statinfo.uis;
import static com.srthinker.statinfo.constant.Const.DEVICE_SN;
import static com.srthinker.statinfo.constant.Const.DEVICE_TYPE;
import static com.srthinker.statinfo.constant.GroupConst.BUILD;
import static com.srthinker.statinfo.constant.GroupConst.BUILD_ID;
import static com.srthinker.statinfo.constant.GroupConst.OUTRIGGER;
import static com.srthinker.statinfo.constant.GroupConst.OUTRIGGER_ID;
import static com.srthinker.statinfo.constant.GroupConst.SUPERVISOR;
import static com.srthinker.statinfo.constant.GroupConst.SUPERVISOR_ID;
import static com.srthinker.statinfo.constant.GroupConst.WATERPROOF;
import static com.srthinker.statinfo.constant.GroupConst.WATERPROOF_ID;
import static com.srthinker.statinfo.constant.InOutType.ENTER_TYPE;
import static com.srthinker.statinfo.constant.InOutType.LEAVE_TYPE;
import static com.srthinker.statinfo.download.upper.DownStatus.DOWN_ERROR;
......@@ -25,7 +17,12 @@ import android.util.Log;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.srthinker.statinfo.adapter.GroupShowAdapter;
import com.srthinker.statinfo.bean.Group2Bean;
import com.srthinker.statinfo.constant.GroupConst;
import com.srthinker.statinfo.database.entity.ConfigEntity;
import com.srthinker.statinfo.database.entity.PersonEntity;
import com.srthinker.statinfo.database.helper.ConfigHelper;
......@@ -77,6 +74,8 @@ public class MainActivity extends BaseActivity implements NetworkIPMonitor.OnIPC
private HashMap<Integer, Integer> groupLeaveHashMap=null;
private HashMap<Integer,Integer> groupPresentHashMap=null;
public static boolean NEED_NO_REPET = true; //是否需要去重,false:不需要,true:需要
private int group;
private GroupShowAdapter showAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -107,19 +106,26 @@ public class MainActivity extends BaseActivity implements NetworkIPMonitor.OnIPC
});
}
private void initGroup() {
/*private void initGroup() {
int waterproof = SharedUtil.getInstance(this).readShared(WATERPROOF, 0);
int outrigger = SharedUtil.getInstance(this).readShared(OUTRIGGER, 0);
int build = SharedUtil.getInstance(this).readShared(BUILD, 0);
int supervisor = SharedUtil.getInstance(this).readShared(SUPERVISOR, 0);
/*mBinding.ngvBuild.initItem("工地班组",build,groupSize);
*//*mBinding.ngvBuild.initItem("工地班组",build,groupSize);
mBinding.ngvWaterproof.initItem("防水班组",waterproof,groupSize);
mBinding.ngvOutrigger.initItem("外架班组",outrigger,groupSize);
mBinding.ngvSupervisor.initItem("监理单位",supervisor,groupSize);*/
mBinding.ngvSupervisor.initItem("监理单位",supervisor,groupSize);*//*
mBinding.ngvBuild.initItem("工地班组",build);
mBinding.ngvWaterproof.initItem("防水班组",waterproof);
mBinding.ngvOutrigger.initItem("外架班组",outrigger);
mBinding.ngvSupervisor.initItem("监理单位",supervisor);
}*/
private void initGroup(){
GridLayoutManager gLM = new GridLayoutManager(this, 4, RecyclerView.HORIZONTAL, false);
mBinding.rvGroupTotal.setLayoutManager(gLM);
showAdapter = new GroupShowAdapter(this, GroupConst.group2BeansConst);
mBinding.rvGroupTotal.setAdapter(showAdapter);
}
private void checkAllPermission() {
......@@ -133,7 +139,7 @@ public class MainActivity extends BaseActivity implements NetworkIPMonitor.OnIPC
}
}
private void updateGroup() {
/*private void updateGroup() {
int waterproof = SharedUtil.getInstance(this).readShared(WATERPROOF, 0);
int outrigger = SharedUtil.getInstance(this).readShared(OUTRIGGER, 0);
int build = SharedUtil.getInstance(this).readShared(BUILD, 0);
......@@ -143,7 +149,7 @@ public class MainActivity extends BaseActivity implements NetworkIPMonitor.OnIPC
mBinding.ngvOutrigger.setNumber(outrigger);
mBinding.ngvSupervisor.setNumber(supervisor);
}
}*/
@Override
protected void onResume() {
......@@ -345,15 +351,25 @@ public class MainActivity extends BaseActivity implements NetworkIPMonitor.OnIPC
}
}
//如果只有一个人,从一个组换到另一个组,之前的数据没有清空,需要先进行清空,置空为0
SharedUtil.getInstance(this).writeShared(WATERPROOF,0);
/*SharedUtil.getInstance(this).writeShared(WATERPROOF,0);
SharedUtil.getInstance(this).writeShared(OUTRIGGER,0);
SharedUtil.getInstance(this).writeShared(BUILD,0);
SharedUtil.getInstance(this).writeShared(SUPERVISOR,0);
SharedUtil.getInstance(this).writeShared(SUPERVISOR,0);*/
//清空
for (Group2Bean group2Bean : GroupConst.group2BeansConst) {
group2Bean.setNumber(0);
}
for (Map.Entry<Integer, Integer> presentEntry : groupPresentHashMap.entrySet()) {
int group = presentEntry.getKey();
int presentSize = presentEntry.getValue();
Log.i(TAG, "updatePresentSize: group="+group+",presentSize="+presentSize);
switch (group){
for (Group2Bean group2Bean : GroupConst.group2BeansConst) {
if (group2Bean.getGroup_id()==group){
group2Bean.setNumber(presentSize);
break;
}
}
/* switch (group){
case WATERPROOF_ID:
SharedUtil.getInstance(this).writeShared(WATERPROOF,presentSize);
break;
......@@ -366,11 +382,11 @@ public class MainActivity extends BaseActivity implements NetworkIPMonitor.OnIPC
case SUPERVISOR_ID:
SharedUtil.getInstance(this).writeShared(SUPERVISOR,presentSize);
break;
}
}*/
}
//要更新演示页面的分组请求
updateGroup();
//updateGroup();
showAdapter.setDataList(GroupConst.group2BeansConst);
}
@Override
......
package com.srthinker.statinfo.uis.fragment.group;
import static com.srthinker.statinfo.constant.GroupConst.BUILD_ID;
import static com.srthinker.statinfo.constant.GroupConst.OUTRIGGER_ID;
import static com.srthinker.statinfo.constant.GroupConst.SUPERVISOR_ID;
import static com.srthinker.statinfo.constant.GroupConst.WATERPROOF_ID;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
......@@ -15,8 +10,9 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.srthinker.statinfo.R;
import com.srthinker.statinfo.adapter.GroupPagerAdapter;
import com.srthinker.statinfo.bean.Group2Bean;
import com.srthinker.statinfo.constant.GroupConst;
import com.srthinker.statinfo.database.entity.PersonEntity;
import com.srthinker.statinfo.databinding.FragmentGroupedBinding;
import com.srthinker.statinfo.uis.fragment.BaseFragment;
......@@ -44,10 +40,13 @@ public class GroupedFragment extends BaseFragment {
@Override
protected void initData() {
mGroupMap = new LinkedHashMap<>();
mGroupMap.put(getString(R.string.select_one), WATERPROOF_ID);
for (Group2Bean group2Bean : GroupConst.group2BeansConst) {
mGroupMap.put(group2Bean.getGroup_name(),group2Bean.getGroup_id());
}
/*mGroupMap.put(getString(R.string.select_one), WATERPROOF_ID);
mGroupMap.put(getString(R.string.select_two), OUTRIGGER_ID);
mGroupMap.put(getString(R.string.select_three),BUILD_ID);
mGroupMap.put(getString(R.string.select_four),SUPERVISOR_ID);
mGroupMap.put(getString(R.string.select_four),SUPERVISOR_ID);*/
}
@Override
......
package com.srthinker.statinfo.uis.fragment.group;
import static com.srthinker.statinfo.constant.GroupConst.BUILD_ID;
import static com.srthinker.statinfo.constant.GroupConst.OUTRIGGER_ID;
import static com.srthinker.statinfo.constant.GroupConst.SUPERVISOR_ID;
import static com.srthinker.statinfo.constant.GroupConst.WATERPROOF_ID;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
......@@ -18,18 +13,21 @@ import android.view.Window;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
import androidx.recyclerview.widget.GridLayoutManager;
import com.srthinker.statinfo.R;
import com.srthinker.statinfo.adapter.GroupSelectAdapter;
import com.srthinker.statinfo.constant.GroupConst;
import com.srthinker.statinfo.databinding.DialogSelectBinding;
import com.srthinker.statinfo.util.common.Utils;
public class SelectDlgFragment extends DialogFragment {
public class SelectDlgFragment extends DialogFragment implements GroupSelectAdapter.OnItemClickListener {
private static final String TAG = "SelectDlgFragment";
private com.srthinker.statinfo.databinding.DialogSelectBinding mBinding;
private Context context;
private int select = 0;
private OnSelectOneListener onSelectOneListener;
private GroupSelectAdapter gSelAda;
public static SelectDlgFragment getInstance(){
SelectDlgFragment selectDlgFragment = new SelectDlgFragment();
......@@ -52,6 +50,11 @@ public class SelectDlgFragment extends DialogFragment {
}
private void initView() {
GridLayoutManager gLM = new GridLayoutManager(context, 4);
mBinding.rvSelectGroup.setLayoutManager(gLM);
gSelAda = new GroupSelectAdapter(context, GroupConst.group2BeansConst);
mBinding.rvSelectGroup.setAdapter(gSelAda);
gSelAda.setOnItemClickListener(this);
mBinding.ivClose.setOnClickListener(v->{
dismiss();
});
......@@ -60,13 +63,14 @@ public class SelectDlgFragment extends DialogFragment {
});
mBinding.btnConfirm.setOnClickListener(v->{
//Log.i(TAG, "initView: select="+select);
//Utils.showTips(context,"select="+select);
if (onSelectOneListener != null) {
onSelectOneListener.onSelectOne(select);
}
//Utils.showTips(context,"已更新列表");
dismiss();
});
mBinding.rgSelect.setOnCheckedChangeListener((radioGroup, i) -> {
/*mBinding.rgSelect.setOnCheckedChangeListener((radioGroup, i) -> {
switch (i){
case R.id.rb_select_one:
select = WATERPROOF_ID;
......@@ -81,7 +85,7 @@ public class SelectDlgFragment extends DialogFragment {
select = SUPERVISOR_ID;
break;
}
});
});*/
}
......@@ -109,6 +113,11 @@ public class SelectDlgFragment extends DialogFragment {
this.onSelectOneListener = onSelectOneListener;
}
@Override
public void onItemClick(int groupId) {
select = groupId;
}
public interface OnSelectOneListener{
void onSelectOne(int select);
}
......
......@@ -12,7 +12,6 @@ import android.provider.Settings;
import android.text.InputType;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.Toast;
......@@ -92,18 +91,7 @@ public class Utils {
return dm.density; // 返回屏幕的像素密度数值
}
//根据高度和行数设置字体大小
public static float calculateTextSize(Context ctx,int line){
int screenHeight = getScreenHeight(ctx);
if (line>0) {
int lineHeight = screenHeight / line;
TypedValue typedValue = new TypedValue();
typedValue.density = (int) ctx.getResources().getDisplayMetrics().density;
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, lineHeight, ctx.getResources().getDisplayMetrics());
}else{
return 0;
}
}
......
......@@ -31,20 +31,20 @@ public class NewGroupView extends LinearLayout {
}
@SuppressLint("SetTextI18n")
public void initItem(String name, int number,float textSize){
mBinding.tvGroupName.setText(name+":");
mBinding.tvGroupNumber.setText(number+"");
mBinding.tvGroupName.setText(name+":"+number);
//mBinding.tvGroupNumber.setText(number+"");
mBinding.tvGroupName.setTextSize(TypedValue.COMPLEX_UNIT_SP,textSize);
mBinding.tvGroupNumber.setTextSize(TypedValue.COMPLEX_UNIT_SP,textSize);
//mBinding.tvGroupNumber.setTextSize(TypedValue.COMPLEX_UNIT_SP,textSize);
}
public void initItem(String name, int number){
mBinding.tvGroupName.setText(name+":");
mBinding.tvGroupNumber.setText(number+"");
mBinding.tvGroupName.setText(name+":"+number);
// mBinding.tvGroupNumber.setText(number+"");
}
public void setNumber(int number){
mBinding.tvGroupNumber.setText(number+"");
//mBinding.tvGroupNumber.setText(number+"");
}
}
......@@ -16,11 +16,10 @@
android:layout_alignParentRight="true"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_centerVertical="true">
<com.srthinker.statinfo.wedget.NewGroupView
<!-- <com.srthinker.statinfo.wedget.NewGroupView
android:id="@+id/ngv_build"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
......@@ -35,6 +34,11 @@
<com.srthinker.statinfo.wedget.NewGroupView
android:id="@+id/ngv_supervisor"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>-->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_group_total"
android:layout_width="match_parent"
android:layout_gravity="center"
android:layout_height="wrap_content"/>
</LinearLayout>
......
......@@ -29,7 +29,7 @@
android:padding="15dp"
android:layout_centerVertical="true"/>
</RelativeLayout>
<RadioGroup
<!--<RadioGroup
android:id="@+id/rg_select"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......@@ -60,7 +60,14 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/select_four"/>
</RadioGroup>
</RadioGroup>-->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_select_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center">
</androidx.recyclerview.widget.RecyclerView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
......
......@@ -47,7 +47,7 @@
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_toRightOf="@+id/iv_back"
android:visibility="visible"
android:visibility="gone"
android:layout_centerVertical="true"
android:layout_marginLeft="200dp">
<EditText
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ll_item"
android:paddingLeft="5dp"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_group_name"
......@@ -11,8 +14,10 @@
android:text=""
android:textColor="@color/red"
android:gravity="center|left"
android:textSize="@dimen/display_text"/>
<TextView
android:textSize="@dimen/display_text"
android:maxLines="1"
/>
<!--<TextView
android:id="@+id/tv_group_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......@@ -20,5 +25,7 @@
android:text=""
android:textColor="@color/red"
android:gravity="center|left"
android:textSize="@dimen/display_text"/>
android:textSize="@dimen/display_text"
/>-->
</LinearLayout>
\ No newline at end of file
......@@ -11,5 +11,5 @@
<dimen name="text_15">15sp</dimen>
<dimen name="text_11">11sp</dimen>
<dimen name="dlg_margin">10dp</dimen>
<dimen name="display_text">95sp</dimen>
<dimen name="display_text">73sp</dimen> //一列:95sp
</resources>
\ No newline at end of file
......@@ -8,7 +8,7 @@
<item name="android:textColor">@color/black</item>
<item name="android:background">@null</item>
<item name="android:button">@null</item>
<item name="android:drawableLeft">@drawable/check_one</item>
<item name="android:drawableLeft">@drawable/select_one</item>
<item name="android:drawablePadding">5dp</item>
<item name="android:layout_marginRight">25dp</item>
</style>
......
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.StatInfo" parent="Theme.MaterialComponents.DayNight.NoActionBar.Bridge">
<style name="Theme.StatInfo" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/white</item>
<item name="colorPrimaryVariant">@color/transparent</item>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment