Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
StatInfo_1
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenyuling
StatInfo_1
Commits
777ea36c
Commit
777ea36c
authored
Oct 16, 2023
by
chenyuling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
"修改为8个组"
parent
ddc2d232
Pipeline
#1716
failed with stages
Changes
5
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
206 additions
and
0 deletions
+206
-0
GroupSelectAdapter.java
...va/com/srthinker/statinfo/adapter/GroupSelectAdapter.java
+76
-0
GroupShowAdapter.java
...java/com/srthinker/statinfo/adapter/GroupShowAdapter.java
+66
-0
Group2Bean.java
...src/main/java/com/srthinker/statinfo/bean/Group2Bean.java
+45
-0
item_dlg_select.xml
app/src/main/res/layout/item_dlg_select.xml
+12
-0
attrs.xml
app/src/main/res/values/attrs.xml
+7
-0
No files found.
app/src/main/java/com/srthinker/statinfo/adapter/GroupSelectAdapter.java
0 → 100644
View file @
777ea36c
package
com
.
srthinker
.
statinfo
.
adapter
;
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.ItemDlgSelectBinding
;
import
java.util.ArrayList
;
public
class
GroupSelectAdapter
extends
RecyclerView
.
Adapter
<
RecyclerView
.
ViewHolder
>
{
private
final
Context
context
;
private
final
ArrayList
<
Group2Bean
>
group2BeanList
;
private
int
selectPos
=
-
1
;
//当前选择的位置
private
int
tempPos
=
-
1
;
//临时记录上次选择的位置
private
OnItemClickListener
onItemClickListener
;
public
GroupSelectAdapter
(
Context
context
,
ArrayList
<
Group2Bean
>
group2BeanList
){
this
.
context
=
context
;
this
.
group2BeanList
=
group2BeanList
;
}
@NonNull
@Override
public
RecyclerView
.
ViewHolder
onCreateViewHolder
(
@NonNull
ViewGroup
parent
,
int
viewType
)
{
ItemDlgSelectBinding
binding
=
ItemDlgSelectBinding
.
inflate
(
LayoutInflater
.
from
(
context
),
parent
,
false
);
return
new
ItemHolder
(
binding
);
}
@Override
public
void
onBindViewHolder
(
@NonNull
RecyclerView
.
ViewHolder
holder
,
int
position
)
{
ItemHolder
itemHolder
=
(
ItemHolder
)
holder
;
Group2Bean
group2Bean
=
group2BeanList
.
get
(
position
);
itemHolder
.
binding
.
tvGroupName
.
setSelected
(
holder
.
getLayoutPosition
()==
selectPos
);
if
(
group2Bean
!=
null
){
itemHolder
.
binding
.
tvGroupName
.
setText
(
group2Bean
.
getGroup_name
());
itemHolder
.
binding
.
tvGroupName
.
setOnClickListener
(
v
->{
itemHolder
.
binding
.
tvGroupName
.
setSelected
(
true
);
//将就得位置保存下来,用于后面把旧的位置取消选择
tempPos
=
selectPos
;
selectPos
=
holder
.
getLayoutPosition
();
notifyItemChanged
(
tempPos
);
if
(
onItemClickListener
!=
null
){
onItemClickListener
.
onItemClick
(
group2Bean
.
getGroup_id
());
}
});
}
}
@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
.
ItemDlgSelectBinding
binding
;
public
ItemHolder
(
ItemDlgSelectBinding
binding
)
{
super
(
binding
.
getRoot
());
this
.
binding
=
binding
;
}
}
public
void
setOnItemClickListener
(
OnItemClickListener
onItemClickListener
){
this
.
onItemClickListener
=
onItemClickListener
;
}
public
interface
OnItemClickListener
{
void
onItemClick
(
int
groupId
);
}
}
app/src/main/java/com/srthinker/statinfo/adapter/GroupShowAdapter.java
0 → 100644
View file @
777ea36c
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.ItemGroupNewBinding
;
import
com.srthinker.statinfo.util.common.Utils
;
import
java.util.List
;
public
class
GroupShowAdapter
extends
RecyclerView
.
Adapter
<
RecyclerView
.
ViewHolder
>
{
private
final
Context
context
;
private
List
<
Group2Bean
>
group2BeanList
;
public
GroupShowAdapter
(
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
)
{
ItemGroupNewBinding
binding
=
ItemGroupNewBinding
.
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
);
if
(
position
<
4
){
//就第一列设置宽度
// 设置item的宽度
itemHolder
.
mBiding
.
llItem
.
getLayoutParams
().
width
=
Utils
.
getScreenWidth
(
context
)/
2
;
}
if
(
group2Bean
!=
null
){
String
text
=
group2Bean
.
getGroup_name
()+
":"
+
group2Bean
.
getNumber
();
itemHolder
.
mBiding
.
tvGroupName
.
setText
(
text
);
}
}
@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
.
ItemGroupNewBinding
mBiding
;
public
ItemHolder
(
ItemGroupNewBinding
binding
)
{
super
(
binding
.
getRoot
());
mBiding
=
binding
;
}
}
}
app/src/main/java/com/srthinker/statinfo/bean/Group2Bean.java
0 → 100644
View file @
777ea36c
package
com
.
srthinker
.
statinfo
.
bean
;
public
class
Group2Bean
{
private
int
group_id
;
private
String
group_name
;
private
int
number
;
public
Group2Bean
()
{
}
public
Group2Bean
(
int
group_id
,
String
group_name
)
{
this
.
group_id
=
group_id
;
this
.
group_name
=
group_name
;
}
public
Group2Bean
(
int
group_id
,
String
group_name
,
int
number
)
{
this
.
group_id
=
group_id
;
this
.
group_name
=
group_name
;
this
.
number
=
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
;
}
}
app/src/main/res/layout/item_dlg_select.xml
0 → 100644
View file @
777ea36c
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"20dp"
>
<TextView
android:id=
"@+id/tv_group_name"
style=
"@style/select"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
""
/>
</LinearLayout>
\ No newline at end of file
app/src/main/res/values/attrs.xml
0 → 100644
View file @
777ea36c
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr
name=
"autoScaleTextViewStyle"
/>
<declare-styleable
name=
"AutoScaleTextView"
>
<attr
name=
"minTextSize"
format=
"dimension"
/>
</declare-styleable>
</resources>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment