Commit dadc78b6 authored by chenyuling's avatar chenyuling

"另外开分支,使用设计稿的UI显示,定制组名信息"

parent a4f49f09
Pipeline #2224 canceled with stages
package com.srthinker.statinfo.adapter;
import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.srthinker.statinfo.bean.Group2Bean;
import com.srthinker.statinfo.databinding.ItemGroupSmallBinding;
import java.util.List;
public class GroupSmallAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private final Context context;
private List<Group2Bean> group2BeanList;
public GroupSmallAdapter(Context context, List<Group2Bean> group2BeanList){
this.context = context;
this.group2BeanList = group2BeanList;
}
public void setDataList(List<Group2Bean> group2BeanList){
this.group2BeanList = group2BeanList;
notifyDataSetChanged();
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
ItemGroupSmallBinding binding = ItemGroupSmallBinding.inflate(LayoutInflater.from(context), parent, false);
return new ItemHolder(binding);
}
@SuppressLint("SetTextI18n")
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
ItemHolder itemHolder = (ItemHolder) holder;
Group2Bean group2Bean = group2BeanList.get(position);
itemHolder.mBinding.tvDesc.setText(group2Bean.getGroup_name());
itemHolder.mBinding.tvNumber.setText(group2Bean.getNumber()+"");
}
@Override
public int getItemCount() {
return group2BeanList!=null&&group2BeanList.size()>0?group2BeanList.size():0;
}
private class ItemHolder extends RecyclerView.ViewHolder {
private final com.srthinker.statinfo.databinding.ItemGroupSmallBinding mBinding;
public ItemHolder(ItemGroupSmallBinding binding) {
super(binding.getRoot());
mBinding = binding;
}
}
}
package com.srthinker.statinfo.database.entity;
import com.raizlabs.android.dbflow.annotation.Column;
import com.raizlabs.android.dbflow.annotation.PrimaryKey;
import com.raizlabs.android.dbflow.annotation.Table;
import com.raizlabs.android.dbflow.structure.BaseModel;
import com.srthinker.statinfo.database.AppDB;
@Table(database = AppDB.class)
public class GroupEntity extends BaseModel {
@PrimaryKey(autoincrement = true)
@Column
private int group_id;
@Column
private String group_name;
@Column
private int number;
public int getGroup_id() {
return group_id;
}
public void setGroup_id(int group_id) {
this.group_id = group_id;
}
public String getGroup_name() {
return group_name;
}
public void setGroup_name(String group_name) {
this.group_name = group_name;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
}
package com.srthinker.statinfo.database.helper;
import com.raizlabs.android.dbflow.config.DatabaseDefinition;
import com.raizlabs.android.dbflow.config.FlowManager;
import com.raizlabs.android.dbflow.sql.language.SQLite;
import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper;
import com.raizlabs.android.dbflow.structure.database.transaction.ITransaction;
import com.srthinker.statinfo.database.AppDB;
import com.srthinker.statinfo.database.entity.GroupEntity;
import com.srthinker.statinfo.util.common.Mutex;
import java.util.List;
public class GroupHelper {
private static GroupHelper groupHelper;
private Mutex locker = new Mutex();
public static GroupHelper getInstance(){
if (groupHelper == null) {
synchronized (GroupHelper.class){
groupHelper = new GroupHelper();
}
}
return groupHelper;
}
public boolean save(GroupEntity entity){
boolean result = false;
locker.lock(0);
result = entity.save();
locker.unlock();
return result;
}
public long add(GroupEntity entity) {
long result = -1;
locker.lock(0);
result = entity.insert();
locker.unlock();
return result;
}
public void add(List<GroupEntity> entities){
locker.lock(0);
DatabaseDefinition database = FlowManager.getDatabase(AppDB.class);
database.beginTransactionAsync(new ITransaction() {
@Override
public void execute(DatabaseWrapper databaseWrapper) {
for (GroupEntity entity : entities) {
entity.insert(databaseWrapper);
}
}
}).build().execute();
locker.unlock();
}
public void save(List<GroupEntity> entities){
locker.lock(0);
DatabaseDefinition database = FlowManager.getDatabase(AppDB.class);
database.beginTransactionAsync(new ITransaction() {
@Override
public void execute(DatabaseWrapper databaseWrapper) {
for (GroupEntity entity : entities) {
entity.save(databaseWrapper);
}
}
}).build().execute();
locker.unlock();
}
public boolean delete(GroupEntity entity) {
boolean result = false;
locker.lock(0);
result = entity.delete();
locker.unlock();
return result;
}
public void delete(List<GroupEntity> entities){
locker.lock(0);
DatabaseDefinition database = FlowManager.getDatabase(AppDB.class);
database.beginTransactionAsync(new ITransaction() {
@Override
public void execute(DatabaseWrapper databaseWrapper) {
for (GroupEntity entity : entities) {
entity.delete(databaseWrapper);
}
}
}).build().execute();
locker.unlock();
}
public void update(List<GroupEntity> entities){
locker.lock(0);
DatabaseDefinition database = FlowManager.getDatabase(AppDB.class);
database.beginTransactionAsync(new ITransaction() {
@Override
public void execute(DatabaseWrapper databaseWrapper) {
for (GroupEntity entity : entities) {
entity.update(databaseWrapper);
}
}
}).build().execute();
locker.unlock();
}
public boolean update(GroupEntity entity) {
boolean result = false;
locker.lock(0);
result = entity.update();
locker.unlock();
return result;
}
public void clear() {
locker.lock(0);
SQLite.delete(GroupEntity.class).execute();
locker.unlock();
}
public List<GroupEntity> queryAll(){
List<GroupEntity> groupEntityList = null;
locker.lock(0);
groupEntityList = SQLite.select().from(GroupEntity.class).queryList();
locker.unlock();
return groupEntityList;
}
}
package com.srthinker.statinfo.uis.fragment;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
import com.srthinker.statinfo.database.entity.GroupEntity;
import com.srthinker.statinfo.databinding.DialogGroupUpdateBinding;
import com.srthinker.statinfo.util.common.KeyBoardUtil;
import com.srthinker.statinfo.util.common.Utils;
import java.util.List;
public class GroupUpDlgFragment extends DialogFragment {
private static final String TAG = "GroupUpDlgFragment";
private Context context;
private com.srthinker.statinfo.databinding.DialogGroupUpdateBinding mBinding;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
context = getContext();
mBinding = DialogGroupUpdateBinding.inflate(inflater, container, false);
initData();
initView();
return mBinding.getRoot();
}
private void initView() {
}
private void initData() {
}
@Override
public void onResume() {
super.onResume();
initWindow();
}
private void initWindow() {
Window window = getDialog().getWindow();
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
//window.setLayout(Utils.dip2px(context,280),ViewGroup.LayoutParams.WRAP_CONTENT);
window.setLayout(Utils.dip2px(context,320), (int) (Utils.getScreenHeight(context)*0.6));
window.setGravity(Gravity.CENTER);
KeyBoardUtil.initSoftInputListener(getDialog());
}
@Override
public void onDestroyView() {
super.onDestroyView();
mBinding = null;
}
public interface GroupUpdateCallback{
void onUpdateGroup(List<GroupEntity>groupEntityList);
}
}
<?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:background="@color/white"
android:focusableInTouchMode="true"
android:focusable="true"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="42dp"
android:background="@color/color_2D52E3">
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center|left"
android:text="分组信息"
android:textColor="@color/white"
android:textSize="@dimen/text_13"
android:layout_centerVertical="true"
android:paddingLeft="15dp"/>
<ImageView
android:id="@+id/iv_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_close"
android:layout_alignParentRight="true"
android:padding="15dp"
android:layout_centerVertical="true"/>
</RelativeLayout>
<TextView
android:id="@+id/tv_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/text_11"
android:text="+添加分组"
android:textColor="@color/color_2D52E3"
android:layout_gravity="right|center"
android:layout_marginRight="15dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:fillViewport="true">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_group_update"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"/>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="10dp"
android:layout_marginBottom="20dp"
android:orientation="horizontal">
<Button
android:id="@+id/btn_cancel"
android:layout_width="84dp"
android:layout_height="32dp"
android:background="@drawable/button_bg_cancel"
android:text="取消"
android:textColor="@color/color_2D52E3"
android:textSize="@dimen/text_12_5"/>
<Button
android:id="@+id/btn_confirm"
android:layout_width="84dp"
android:layout_height="32dp"
android:background="@drawable/button_bg_confirm"
android:text="确定"
android:layout_marginLeft="30dp"
android:textColor="@color/white"
android:textSize="@dimen/text_12_5"/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ll_item"
android:layout_width="112dp"
android:layout_height="75dp"
android:layout_marginRight="14.5dp"
android:layout_marginBottom="2dp"
android:orientation="vertical">
<TextView
android:id="@+id/tv_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/text_11"
android:textColor="@color/white"
android:text="中交"
android:layout_centerHorizontal="true"
/>
<TextView
android:id="@+id/tv_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_centerHorizontal="true"
android:textColor="@color/white"
android:textSize="@dimen/text_30"
android:background="@null"
android:outlineProvider="none"
android:text="1000"
android:textStyle="bold"/>
</RelativeLayout>
\ No newline at end of file
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