Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
TangKuPos
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
王海
TangKuPos
Commits
0c7c2aee
Commit
0c7c2aee
authored
Dec 22, 2017
by
陈前
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
编写了RecyclerView的分割线
parent
81643405
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
87 additions
and
82 deletions
+87
-82
app/src/main/java/com/xingdata/zzdpos/ui/main/fragment/CasherFragment.java
.../com/xingdata/zzdpos/ui/main/fragment/CasherFragment.java
+9
-11
app/src/main/java/com/xingdata/zzdpos/ui/settle/adapter/PayAdapter.java
...ava/com/xingdata/zzdpos/ui/settle/adapter/PayAdapter.java
+36
-36
app/src/main/java/com/xingdata/zzdpos/util/MyMenuItemDecoration.java
...n/java/com/xingdata/zzdpos/util/MyMenuItemDecoration.java
+17
-14
app/src/main/res/layout/fragment_casher.xml
app/src/main/res/layout/fragment_casher.xml
+1
-1
app/src/main/res/layout/item_menu_detail.xml
app/src/main/res/layout/item_menu_detail.xml
+21
-20
app/src/main/res/values/colors.xml
app/src/main/res/values/colors.xml
+3
-0
No files found.
app/src/main/java/com/xingdata/zzdpos/ui/main/fragment/CasherFragment.java
View file @
0c7c2aee
package
com
.
xingdata
.
zzdpos
.
ui
.
main
.
fragment
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.support.annotation.Nullable
;
import
android.support.v4.app.Fragment
;
import
android.support.v7.widget.GridLayoutManager
;
import
android.support.v7.widget.RecyclerView
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
com.chad.library.adapter.base.BaseQuickAdapter
;
import
com.xingdata.zzdpos.C
;
...
...
@@ -17,14 +13,16 @@ import com.xingdata.zzdpos.base.BaseFragment;
import
com.xingdata.zzdpos.databinding.FragmentCasherBinding
;
import
com.xingdata.zzdpos.ui.main.MainPresenter
;
import
com.xingdata.zzdpos.ui.main.adapter.MenuRecyclerAdapter
;
import
com.xingdata.zzdpos.util.MyMenuItemDecoration
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
CasherFragment
extends
BaseFragment
<
MainPresenter
,
FragmentCasherBinding
>
{
public
class
CasherFragment
extends
BaseFragment
<
MainPresenter
,
FragmentCasherBinding
>
{
private
MenuRecyclerAdapter
mMenuRecyclerAdapter
;
private
List
<
Integer
>
integers
;
@Override
public
int
getLayoutId
()
{
return
R
.
layout
.
fragment_casher
;
...
...
@@ -43,11 +41,11 @@ public class CasherFragment extends BaseFragment<MainPresenter,FragmentCasherBin
integers
.
add
(
106
);
mMenuRecyclerAdapter
=
new
MenuRecyclerAdapter
(
getActivity
(),
integers
);
mMenuRecyclerAdapter
.
bindToRecyclerView
(
mViewBinding
.
fragmentCasherRecycler
);
// mViewBinding.fragmentCasherRecycler.addItemDecoration(new MyItemDecoration(getActivity(), 2, R.color.black_zhangfei
));
mViewBinding
.
fragmentCasherRecycler
.
addItemDecoration
(
new
MyMenuItemDecoration
(
getActivity
(),
5
,
getResources
().
getColor
(
R
.
color
.
gray_kongming
)
));
mMenuRecyclerAdapter
.
setOnItemClickListener
(
new
BaseQuickAdapter
.
OnItemClickListener
()
{
@Override
public
void
onItemClick
(
BaseQuickAdapter
adapter
,
View
view
,
int
position
)
{
switch
((
int
)
adapter
.
getData
().
get
(
position
))
{
switch
((
int
)
adapter
.
getData
().
get
(
position
))
{
case
C
.
MENU
.
MENU_VIP
:
//会员
break
;
...
...
app/src/main/java/com/xingdata/zzdpos/ui/settle/adapter/PayAdapter.java
View file @
0c7c2aee
...
...
@@ -18,41 +18,41 @@ public class PayAdapter extends BaseAdapter<Pay, ItemPayBinding> {
@Override
protected
void
convert
(
ItemPayBinding
mViewBinding
,
Pay
item
)
{
int
resLogo
,
resBackground
;
switch
(
item
.
getPayType
())
{
case
C
.
PAY_CHANNEL
.
CASH
:
resLogo
=
R
.
mipmap
.
pay_cash
;
resBackground
=
R
.
color
.
red_diaochan
;
break
;
case
C
.
PAY_CHANNEL
.
WECHAT
:
resLogo
=
R
.
mipmap
.
pay_wechat
;
resBackground
=
R
.
color
.
green_kongrun
;
break
;
case
C
.
PAY_CHANNEL
.
ALI
:
resLogo
=
R
.
mipmap
.
pay_alipay
;
resBackground
=
R
.
color
.
blue_yuefei
;
break
;
case
C
.
PAY_CHANNEL
.
BANK
:
resLogo
=
R
.
mipmap
.
pay_card
;
resBackground
=
R
.
color
.
cyan_liubei
;
break
;
case
C
.
PAY_CHANNEL
.
CARD
:
resLogo
=
R
.
mipmap
.
pay_membershipcard
;
resBackground
=
R
.
color
.
yellow_huangxin
;
break
;
case
C
.
PAY_CHANNEL
.
TALLY
:
resLogo
=
R
.
mipmap
.
pay_credit
;
resBackground
=
R
.
color
.
purple_yanqing
;
break
;
default
:
resLogo
=
R
.
mipmap
.
pay_cash
;
resBackground
=
R
.
color
.
red_diaochan
;
break
;
}
mViewBinding
.
ivLogo
.
setImageResource
(
resLogo
);
GenericDraweeHierarchy
hierarchy
=
mViewBinding
.
ivBackground
.
getHierarchy
();
hierarchy
.
setBackgroundImage
(
mContext
.
getResources
().
getDrawable
(
resBackground
));
mViewBinding
.
ivBackground
.
setHierarchy
(
hierarchy
);
//
int resLogo, resBackground;
//
switch (item.getPayType()) {
//
case C.PAY_CHANNEL.CASH:
//
resLogo = R.mipmap.pay_cash;
//
resBackground = R.color.red_diaochan;
//
break;
//
case C.PAY_CHANNEL.WECHAT:
//
resLogo = R.mipmap.pay_wechat;
//
resBackground = R.color.green_kongrun;
//
break;
//
case C.PAY_CHANNEL.ALI:
//
resLogo = R.mipmap.pay_alipay;
//
resBackground = R.color.blue_yuefei;
//
break;
//
case C.PAY_CHANNEL.BANK:
//
resLogo = R.mipmap.pay_card;
//
resBackground = R.color.cyan_liubei;
//
break;
//
case C.PAY_CHANNEL.CARD:
//
resLogo = R.mipmap.pay_membershipcard;
//
resBackground = R.color.yellow_huangxin;
//
break;
//
case C.PAY_CHANNEL.TALLY:
//
resLogo = R.mipmap.pay_credit;
//
resBackground = R.color.purple_yanqing;
//
break;
//
default:
//
resLogo = R.mipmap.pay_cash;
//
resBackground = R.color.red_diaochan;
//
break;
//
}
//
mViewBinding.ivLogo.setImageResource(resLogo);
//
//
GenericDraweeHierarchy hierarchy = mViewBinding.ivBackground.getHierarchy();
//
hierarchy.setBackgroundImage(mContext.getResources().getDrawable(resBackground));
//
mViewBinding.ivBackground.setHierarchy(hierarchy);
}
}
app/src/main/java/com/xingdata/zzdpos/util/MyItemDecoration.java
→
app/src/main/java/com/xingdata/zzdpos/util/My
Menu
ItemDecoration.java
View file @
0c7c2aee
...
...
@@ -12,16 +12,16 @@ import android.view.View;
* Created by Administrator on 2017/12/21.
*/
class
My
ItemDecoration
extends
RecyclerView
.
ItemDecoration
{
public
class
MyMenu
ItemDecoration
extends
RecyclerView
.
ItemDecoration
{
private
Drawable
mDividerDarwable
;
private
int
mDividerHight
=
1
;
private
Paint
mColorPaint
;
private
int
size
=
2
;
private
int
size
=
2
;
public
final
int
[]
ATRRS
=
new
int
[]{
android
.
R
.
attr
.
listDivider
};
public
MyItemDecoration
(
Context
context
)
{
public
My
Menu
ItemDecoration
(
Context
context
)
{
final
TypedArray
ta
=
context
.
obtainStyledAttributes
(
ATRRS
);
this
.
mDividerDarwable
=
ta
.
getDrawable
(
0
);
ta
.
recycle
();
...
...
@@ -31,7 +31,7 @@ class MyItemDecoration extends RecyclerView.ItemDecoration {
int dividerHight 分割线的线宽
int dividerColor 分割线的颜色
*/
public
MyItemDecoration
(
Context
context
,
int
dividerHight
,
int
dividerColor
)
{
public
My
Menu
ItemDecoration
(
Context
context
,
int
dividerHight
,
int
dividerColor
)
{
this
(
context
);
mDividerHight
=
dividerHight
;
mColorPaint
=
new
Paint
();
...
...
@@ -42,18 +42,19 @@ class MyItemDecoration extends RecyclerView.ItemDecoration {
int dividerHight 分割线的线宽
int dividerColor 分割线的颜色
*/
public
MyItemDecoration
(
Context
context
,
int
dividerHight
,
int
dividerColor
,
int
size
)
{
public
My
Menu
ItemDecoration
(
Context
context
,
int
dividerHight
,
int
dividerColor
,
int
size
)
{
this
(
context
);
mDividerHight
=
dividerHight
;
mColorPaint
=
new
Paint
();
mColorPaint
.
setColor
(
dividerColor
);
this
.
size
=
size
;
this
.
size
=
size
;
}
/*
int dividerHight 分割线的线宽
Drawable dividerDrawable 图片分割线
*/
public
MyItemDecoration
(
Context
context
,
int
dividerHight
,
Drawable
dividerDrawable
)
{
public
My
Menu
ItemDecoration
(
Context
context
,
int
dividerHight
,
Drawable
dividerDrawable
)
{
this
(
context
);
mDividerHight
=
dividerHight
;
mDividerDarwable
=
dividerDrawable
;
...
...
@@ -73,8 +74,8 @@ class MyItemDecoration extends RecyclerView.ItemDecoration {
final
View
child
=
parent
.
getChildAt
(
i
);
final
RecyclerView
.
LayoutParams
params
=
(
RecyclerView
.
LayoutParams
)
child
.
getLayoutParams
();
final
int
top
=
child
.
getTop
()
-
params
.
topMargin
+
30
;
final
int
bottom
=
child
.
getBottom
()
+
params
.
bottomMargin
-
30
;
final
int
top
=
child
.
getTop
()
-
params
.
topMargin
+
30
;
final
int
bottom
=
child
.
getBottom
()
+
params
.
bottomMargin
-
30
;
int
left
=
0
;
int
right
=
0
;
...
...
@@ -108,8 +109,8 @@ class MyItemDecoration extends RecyclerView.ItemDecoration {
final
View
child
=
parent
.
getChildAt
(
i
);
RecyclerView
.
LayoutParams
params
=
(
RecyclerView
.
LayoutParams
)
child
.
getLayoutParams
();
final
int
left
=
child
.
getLeft
()
-
params
.
leftMargin
-
mDividerHight
;
final
int
right
=
child
.
getRight
()
+
params
.
rightMargin
;
final
int
left
=
child
.
getLeft
()
-
params
.
leftMargin
-
mDividerHight
+
30
;
final
int
right
=
child
.
getRight
()
+
params
.
rightMargin
-
30
;
int
top
=
0
;
int
bottom
=
0
;
...
...
@@ -127,9 +128,11 @@ class MyItemDecoration extends RecyclerView.ItemDecoration {
// top = child.getBottom() + params.bottomMargin;
// bottom = top + mDividerHight;
// } else {
// if (i!=)
if
(
i
/
size
!=(
parent
.
getAdapter
().
getItemCount
()/
size
-
1
)){
top
=
child
.
getBottom
()
+
params
.
bottomMargin
;
bottom
=
top
+
mDividerHight
;
}
// }
//画分割线
mDividerDarwable
.
setBounds
(
left
,
top
,
right
,
bottom
);
...
...
app/src/main/res/layout/fragment_casher.xml
View file @
0c7c2aee
...
...
@@ -55,7 +55,7 @@
android:layout_marginBottom=
"@dimen/all_padding"
android:layout_width=
"0dp"
android:layout_height=
"0dp"
android:background=
"@color/
gray_zhouyu
"
android:background=
"@color/
white_caocao
"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
...
...
app/src/main/res/layout/item_menu_detail.xml
View file @
0c7c2aee
<?xml version="1.0" encoding="utf-8"?>
<layout>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/ll"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:paddingTop=
"25dp"
android:paddingBottom=
"25dp"
android:gravity=
"center"
android:elevation=
"0.5dp"
android:background=
"@color/white_caocao"
android:layout_margin=
"0.8dp"
android:orientation=
"vertical"
>
android:background=
"@color/white_caocao"
android:gravity=
"center"
android:orientation=
"vertical"
android:paddingBottom=
"25dp"
android:paddingTop=
"25dp"
>
<ImageView
android:id=
"@+id/img"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_margin=
"4dp"
/>
android:layout_margin=
"4dp"
/>
<TextView
android:id=
"@+id/text"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
android:layout_height=
"wrap_content"
android:textColor=
"@color/black_baozheng"
/>
</LinearLayout>
</LinearLayout>
</layout>
app/src/main/res/values/colors.xml
View file @
0c7c2aee
...
...
@@ -124,6 +124,7 @@
<color
name=
"gray_zhouyu"
>
#f1f3f7
</color>
<color
name=
"gray_huanggai"
>
#afb9c3
</color>
<color
name=
"gray_kongming"
>
#e6e6e6
</color>
<color
name=
"white_caocao"
>
#ffffff
</color>
...
...
@@ -144,6 +145,8 @@
<color
name=
"yellow_huangxin"
>
#ffc960
</color>
<color
name=
"golden_yuji"
>
#f2e7d3
</color>
<color
name=
"purple_yanqing"
>
#6590e6
</color>
...
...
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