Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_vediosocial
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
android
android_vediosocial
Commits
cf052242
Commit
cf052242
authored
Jan 15, 2025
by
jyx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加上传照片功能
parent
331223d6
Changes
23
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
564 additions
and
195 deletions
+564
-195
AndroidManifest.xml
video/app/src/main/AndroidManifest.xml
+8
-0
OssType.kt
...app/src/main/java/com/duben/roseplaylet/common/OssType.kt
+1
-0
IMHelper.kt
...p/src/main/java/com/duben/roseplaylet/manager/IMHelper.kt
+4
-1
ImageMultiItemEntity.kt
...a/com/duben/roseplaylet/mvp/model/ImageMultiItemEntity.kt
+11
-0
AlbumPresenter.kt
...va/com/duben/roseplaylet/mvp/presenters/AlbumPresenter.kt
+86
-0
AlbumView.kt
...rc/main/java/com/duben/roseplaylet/mvp/views/AlbumView.kt
+11
-0
LoanService.java
.../src/main/java/com/duben/roseplaylet/net/LoanService.java
+1
-1
AlbumActivity.kt
.../java/com/duben/roseplaylet/ui/activitys/AlbumActivity.kt
+130
-130
IMActivity.kt
...ain/java/com/duben/roseplaylet/ui/activitys/IMActivity.kt
+1
-1
BaseActivity.java
...com/duben/roseplaylet/ui/activitys/base/BaseActivity.java
+1
-0
AlbumAdapter.kt
...ain/java/com/duben/roseplaylet/ui/adapter/AlbumAdapter.kt
+55
-0
SquarePageAdapter.kt
...ava/com/duben/roseplaylet/ui/adapter/SquarePageAdapter.kt
+0
-1
MainFragment.kt
...in/java/com/duben/roseplaylet/ui/fragment/MainFragment.kt
+7
-7
MyFragment.kt
...main/java/com/duben/roseplaylet/ui/fragment/MyFragment.kt
+6
-3
DeletePhotoConfirmDialog.kt
.../duben/roseplaylet/ui/widgets/DeletePhotoConfirmDialog.kt
+44
-0
AddImagesAdapter.kt
...uben/roseplaylet/ui/widgets/nineImage/AddImagesAdapter.kt
+59
-32
AddImagesInfo.kt
...m/duben/roseplaylet/ui/widgets/nineImage/AddImagesInfo.kt
+1
-1
AddImagesView.kt
...m/duben/roseplaylet/ui/widgets/nineImage/AddImagesView.kt
+24
-15
activity_album.xml
video/app/src/main/res/layout/activity_album.xml
+27
-0
dialog_delete_photo_confirm.xml
...o/app/src/main/res/layout/dialog_delete_photo_confirm.xml
+54
-0
item_add_images.xml
video/app/src/main/res/layout/item_add_images.xml
+3
-3
item_album_add.xml
video/app/src/main/res/layout/item_album_add.xml
+16
-0
item_album_normal.xml
video/app/src/main/res/layout/item_album_normal.xml
+14
-0
No files found.
video/app/src/main/AndroidManifest.xml
View file @
cf052242
...
@@ -256,6 +256,14 @@
...
@@ -256,6 +256,14 @@
android:name=
".ui.activitys.BasicUserProfileActivity"
android:name=
".ui.activitys.BasicUserProfileActivity"
android:exported=
"false"
android:exported=
"false"
android:screenOrientation=
"portrait"
/>
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".ui.activitys.AlbumActivity"
android:exported=
"false"
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".ui.preview.ImagePreviewActivity"
android:exported=
"false"
android:screenOrientation=
"portrait"
/>
<activity
<activity
android:name=
".ui.activitys.IMActivity"
android:name=
".ui.activitys.IMActivity"
...
...
video/app/src/main/java/com/duben/roseplaylet/common/OssType.kt
View file @
cf052242
...
@@ -2,6 +2,7 @@ package com.duben.roseplaylet.common
...
@@ -2,6 +2,7 @@ package com.duben.roseplaylet.common
enum
class
OssType
(
var
type
:
String
)
{
enum
class
OssType
(
var
type
:
String
)
{
ALBUM
(
"album"
),
PHOTO
(
"photo"
),
PHOTO
(
"photo"
),
VIDEO
(
"video"
)
VIDEO
(
"video"
)
...
...
video/app/src/main/java/com/duben/roseplaylet/manager/IMHelper.kt
View file @
cf052242
...
@@ -53,7 +53,10 @@ class IMHelper private constructor() {
...
@@ -53,7 +53,10 @@ class IMHelper private constructor() {
override
fun
onCompleted
()
{}
override
fun
onCompleted
()
{}
override
fun
onError
(
e
:
Throwable
)
{}
override
fun
onError
(
e
:
Throwable
)
{}
override
fun
onNext
(
baseResponse
:
BaseResponse
<
JsonObject
>)
{
override
fun
onNext
(
baseResponse
:
BaseResponse
<
JsonObject
>)
{
if
(
baseResponse
.
status
==
200
)
{
val
psw
=
baseResponse
.
data
[
"pass"
].
asString
SECRET_KEY
=
psw
}
}
}
})
})
}
}
...
...
video/app/src/main/java/com/duben/roseplaylet/mvp/model/ImageMultiItemEntity.kt
0 → 100644
View file @
cf052242
package
com.duben.roseplaylet.mvp.model
import
com.chad.library.adapter.base.entity.MultiItemEntity
const
val
IMAGE_MULTI_ITEM_ADD
=
1
const
val
IMAGE_MULTI_ITEM_NORMAL
=
2
data class
ImageMultiItemEntity
(
override
val
itemType
:
Int
,
var
img
:
String
,
)
:
MultiItemEntity
,
java
.
io
.
Serializable
video/app/src/main/java/com/duben/roseplaylet/mvp/presenters/AlbumPresenter.kt
0 → 100644
View file @
cf052242
package
com.duben.roseplaylet.mvp.presenters
import
com.duben.library.net.neterror.BaseSubscriber
import
com.duben.library.net.neterror.Throwable
import
com.duben.roseplaylet.manager.AppHttpManager
import
com.duben.roseplaylet.mvp.model.BaseResponse
import
com.duben.roseplaylet.mvp.views.AlbumView
import
com.google.gson.JsonObject
class
AlbumPresenter
:
BasePresenter
<
AlbumView
>()
{
fun
getImages
()
{
AppHttpManager
.
getInstance
(
loanApplication
)
.
call
(
loanService
.
getImages
({}),
object
:
BaseSubscriber
<
BaseResponse
<
JsonObject
>>()
{
override
fun
onCompleted
()
{
if
(
isLinkView
)
return
}
override
fun
onError
(
e
:
Throwable
)
{
if
(
isLinkView
)
return
view
.
getImagesFail
()
}
override
fun
onNext
(
baseResponse
:
BaseResponse
<
JsonObject
>)
{
if
(
isLinkView
)
return
view
.
hideLoading
()
val
code
=
baseResponse
.
status
val
message
=
baseResponse
.
message
when
(
code
)
{
200
->
{
val
ja
=
baseResponse
.
data
[
"images"
].
asJsonArray
val
imagesList
=
arrayListOf
<
String
>()
ja
.
forEach
{
imagesList
.
add
(
it
.
asString
)
}
view
.
getImagesSuc
(
imagesList
)
}
else
->
{
view
.
showToast
(
message
)
view
.
getImagesFail
()
}
}
}
})
}
fun
setImages
(
images
:
ArrayList
<
String
>
=
arrayListOf
(),
image
:
String
=
""
,
type
:
Int
=
0
)
{
val
vo
=
HashMap
<
String
,
Any
>()
if
(
images
.
isEmpty
()
&&
image
.
isEmpty
())
return
if
(
images
.
isNotEmpty
())
{
vo
[
"images"
]
=
images
}
else
{
vo
[
"image"
]
=
image
vo
[
"type"
]
=
type
}
AppHttpManager
.
getInstance
(
loanApplication
)
.
call
(
loanService
.
setImages
(
vo
),
object
:
BaseSubscriber
<
BaseResponse
<
JsonObject
>>()
{
override
fun
onCompleted
()
{
if
(
isLinkView
)
return
}
override
fun
onError
(
e
:
Throwable
)
{
if
(
isLinkView
)
return
view
.
setImagesFail
()
}
override
fun
onNext
(
baseResponse
:
BaseResponse
<
JsonObject
>)
{
if
(
isLinkView
)
return
view
.
hideLoading
()
val
code
=
baseResponse
.
status
val
message
=
baseResponse
.
message
when
(
code
)
{
200
->
{
view
.
setImagesSuc
()
}
else
->
{
view
.
showToast
(
message
)
view
.
setImagesFail
()
}
}
}
})
}
}
\ No newline at end of file
video/app/src/main/java/com/duben/roseplaylet/mvp/views/AlbumView.kt
0 → 100644
View file @
cf052242
package
com.duben.roseplaylet.mvp.views
interface
AlbumView
:
BaseView
{
fun
getImagesSuc
(
data
:
List
<
String
>)
fun
getImagesFail
()
fun
setImagesSuc
()
fun
setImagesFail
()
}
video/app/src/main/java/com/duben/roseplaylet/net/LoanService.java
View file @
cf052242
...
@@ -488,7 +488,7 @@ public interface LoanService {
...
@@ -488,7 +488,7 @@ public interface LoanService {
* 查看图片
* 查看图片
*/
*/
@POST
(
"roseApi/user/getImages"
)
@POST
(
"roseApi/user/getImages"
)
Observable
<
BaseResponse
<
JsonObject
>>
getImages
();
Observable
<
BaseResponse
<
JsonObject
>>
getImages
(
@Body
Object
obj
);
/**
/**
* 设置图片
* 设置图片
...
...
video/app/src/main/java/com/duben/roseplaylet/ui/activitys/
Template
Activity.kt
→
video/app/src/main/java/com/duben/roseplaylet/ui/activitys/
Album
Activity.kt
View file @
cf052242
This diff is collapsed.
Click to expand it.
video/app/src/main/java/com/duben/roseplaylet/ui/activitys/IMActivity.kt
View file @
cf052242
...
@@ -62,7 +62,7 @@ class IMActivity : TUIBaseChatActivity() {
...
@@ -62,7 +62,7 @@ class IMActivity : TUIBaseChatActivity() {
val
chatView
=
chatFragment
.
chatView
val
chatView
=
chatFragment
.
chatView
chatView
.
viewline
.
visibility
=
View
.
GONE
chatView
.
viewline
.
visibility
=
View
.
GONE
chatView
.
inputView
.
setInterceptTouchEvent
(
true
)
//
chatView.inputView.setInterceptTouchEvent(true)
chatView
.
inputView
.
setBgColor
(
resources
.
getColor
(
R
.
color
.
color_171619
))
chatView
.
inputView
.
setBgColor
(
resources
.
getColor
(
R
.
color
.
color_171619
))
chatView
.
inputView
.
setOnClickListener
{
chatView
.
inputView
.
setOnClickListener
{
...
...
video/app/src/main/java/com/duben/roseplaylet/ui/activitys/base/BaseActivity.java
View file @
cf052242
...
@@ -57,6 +57,7 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Base
...
@@ -57,6 +57,7 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Base
||
TextUtils
.
equals
(
getClass
().
getSimpleName
(),
"EditProfileActivity"
)
||
TextUtils
.
equals
(
getClass
().
getSimpleName
(),
"EditProfileActivity"
)
||
TextUtils
.
equals
(
getClass
().
getSimpleName
(),
"UserProfileActivity"
)
||
TextUtils
.
equals
(
getClass
().
getSimpleName
(),
"UserProfileActivity"
)
||
TextUtils
.
equals
(
getClass
().
getSimpleName
(),
"MainActivity"
)
||
TextUtils
.
equals
(
getClass
().
getSimpleName
(),
"MainActivity"
)
||
TextUtils
.
equals
(
getClass
().
getSimpleName
(),
"AlbumActivity"
)
)
{
)
{
setDarkStatusBar
();
setDarkStatusBar
();
}
else
{
}
else
{
...
...
video/app/src/main/java/com/duben/roseplaylet/ui/adapter/AlbumAdapter.kt
0 → 100644
View file @
cf052242
package
com.duben.roseplaylet.ui.adapter
import
android.view.View
import
android.widget.ImageView
import
com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import
com.chad.library.adapter.base.viewholder.BaseViewHolder
import
com.duben.library.utils.GlideUtils
import
com.duben.roseplaylet.R
import
com.duben.roseplaylet.mvp.model.*
/**
* @author Assen
* @date 2024/1/9
* @desc
*/
class
AlbumAdapter
:
BaseMultiItemQuickAdapter
<
ImageMultiItemEntity
,
BaseViewHolder
>()
{
init
{
addItemType
(
IMAGE_MULTI_ITEM_ADD
,
R
.
layout
.
item_album_add
)
addItemType
(
IMAGE_MULTI_ITEM_NORMAL
,
R
.
layout
.
item_album_normal
)
}
override
fun
convert
(
holder
:
BaseViewHolder
,
item
:
ImageMultiItemEntity
)
{
when
(
holder
.
itemViewType
)
{
IMAGE_MULTI_ITEM_ADD
->
{
holder
.
getView
<
View
>(
R
.
id
.
iv_add
).
setOnClickListener
{
mOnAlbumClickListener
?.
onAddClick
()
}
}
IMAGE_MULTI_ITEM_NORMAL
->
{
val
iv
=
holder
.
getView
<
ImageView
>(
R
.
id
.
iv_normal
)
iv
.
setOnClickListener
{
mOnAlbumClickListener
?.
onImageClick
(
holder
.
adapterPosition
)
}
iv
.
setOnLongClickListener
{
mOnAlbumClickListener
?.
onDeleteClick
(
holder
.
adapterPosition
)
return
@setOnLongClickListener
true
}
GlideUtils
.
loadImageViewNoAnim2
(
context
,
item
.
img
,
iv
)
}
}
}
private
var
mOnAlbumClickListener
:
OnAlbumClickListener
?
=
null
fun
setOnAlbumClickListener
(
onAlbumClickListener
:
OnAlbumClickListener
)
{
mOnAlbumClickListener
=
onAlbumClickListener
}
interface
OnAlbumClickListener
{
fun
onDeleteClick
(
position
:
Int
)
fun
onAddClick
()
fun
onImageClick
(
position
:
Int
)
}
}
\ No newline at end of file
video/app/src/main/java/com/duben/roseplaylet/ui/adapter/SquarePageAdapter.kt
View file @
cf052242
...
@@ -19,7 +19,6 @@ class SquarePageAdapter(
...
@@ -19,7 +19,6 @@ class SquarePageAdapter(
override
fun
getItemCount
()
=
data
.
size
override
fun
getItemCount
()
=
data
.
size
override
fun
createFragment
(
position
:
Int
):
Fragment
{
override
fun
createFragment
(
position
:
Int
):
Fragment
{
LogUtil
.
d
(
"AAAAAAAAAA$position"
)
val
newFragment
=
SquareListFragment
.
newInstance
(
position
+
1
)
val
newFragment
=
SquareListFragment
.
newInstance
(
position
+
1
)
fragments
[
position
]
=
newFragment
fragments
[
position
]
=
newFragment
return
newFragment
return
newFragment
...
...
video/app/src/main/java/com/duben/roseplaylet/ui/fragment/MainFragment.kt
View file @
cf052242
...
@@ -110,13 +110,13 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
...
@@ -110,13 +110,13 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
//获取游客登录数据
//获取游客登录数据
homePresenter
.
userLogin
()
homePresenter
.
userLogin
()
}
else
{
}
else
{
homePresenter
.
topTabs
()
//
homePresenter.topTabs()
homePresenter
.
orders
()
//
homePresenter.orders()
if
(
userManager
.
vipFlag
)
{
//
if (userManager.vipFlag) {
homePresenter
.
signAfterSeconds
()
//
homePresenter.signAfterSeconds()
}
//
}
IMHelper
.
instance
.
getImMsg
()
//
IMHelper.instance.getImMsg()
TrackManager
.
getInstance
().
getMyInfo
()
//
TrackManager.getInstance().getMyInfo()
}
}
AppConfig
.
showVipAdDialog
=
false
AppConfig
.
showVipAdDialog
=
false
...
...
video/app/src/main/java/com/duben/roseplaylet/ui/fragment/MyFragment.kt
View file @
cf052242
...
@@ -99,6 +99,7 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener {
...
@@ -99,6 +99,7 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener {
tuiLoginConfig
.
isInitLocalStorageOnly
=
true
tuiLoginConfig
.
isInitLocalStorageOnly
=
true
val
userID
=
instance
.
userID
val
userID
=
instance
.
userID
val
userSig
=
IMHelper
.
instance
.
getUserSig
()
val
userSig
=
IMHelper
.
instance
.
getUserSig
()
LogUtil
.
i
(
"LoginWrapper "
,
"userSig $userSig"
)
LoginWrapper
.
getInstance
().
loginIMSDK
(
MintsApplication
.
getContext
(),
LoginWrapper
.
getInstance
().
loginIMSDK
(
MintsApplication
.
getContext
(),
IMHelper
.
IM_SDK_APPID
,
userID
,
userSig
,
tuiLoginConfig
,
object
:
TUICallback
()
{
IMHelper
.
IM_SDK_APPID
,
userID
,
userSig
,
tuiLoginConfig
,
object
:
TUICallback
()
{
override
fun
onSuccess
()
{
override
fun
onSuccess
()
{
...
@@ -129,8 +130,8 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener {
...
@@ -129,8 +130,8 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener {
R
.
id
.
ll_my_setting
->
{
R
.
id
.
ll_my_setting
->
{
// readyGo(SettingsActivity::class.java)
// readyGo(SettingsActivity::class.java)
// readyGo(RealAuthActivity::class.java)
// readyGo(RealAuthActivity::class.java)
// readyGo(BasicUserProfileActivity::class.java)
readyGo
(
BasicUserProfile
Activity
::
class
.
java
)
readyGo
(
Album
Activity
::
class
.
java
)
}
}
R
.
id
.
tv_my_account
,
R
.
id
.
ll_my_login
->
{
R
.
id
.
tv_my_account
,
R
.
id
.
ll_my_login
->
{
if
(!
userManager
.
userIsLogin
())
{
if
(!
userManager
.
userIsLogin
())
{
...
@@ -139,7 +140,9 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener {
...
@@ -139,7 +140,9 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener {
}
}
R
.
id
.
ll_my_record
->
{
R
.
id
.
ll_my_record
->
{
// readyGo(WatchRecordActivity::class.java)
// readyGo(WatchRecordActivity::class.java)
readyGo
(
UserProfileActivity
::
class
.
java
)
IMHelper
.
instance
.
getImMsg
()
// readyGo(UserProfileActivity::class.java)
}
}
R
.
id
.
ll_my_feed
->
{
R
.
id
.
ll_my_feed
->
{
// readyGo(FeedbackActivity::class.java)
// readyGo(FeedbackActivity::class.java)
...
...
video/app/src/main/java/com/duben/roseplaylet/ui/widgets/DeletePhotoConfirmDialog.kt
0 → 100644
View file @
cf052242
package
com.duben.roseplaylet.ui.widgets
import
android.app.Dialog
import
android.content.Context
import
android.view.Gravity
import
android.view.KeyEvent
import
android.view.View
import
android.view.WindowManager
import
android.widget.ImageView
import
android.widget.TextView
import
com.duben.roseplaylet.R
class
DeletePhotoConfirmDialog
(
private
val
context
:
Context
,
private
val
listener
:
DialogListener
?
)
:
Dialog
(
context
,
R
.
style
.
dialog
)
{
private
val
lp
:
WindowManager
.
LayoutParams
private
val
tv_confirm
:
TextView
private
val
iv_close
:
ImageView
init
{
setContentView
(
R
.
layout
.
dialog_delete_photo_confirm
)
// 设置window属性
lp
=
window
!!
.
attributes
lp
.
gravity
=
Gravity
.
CENTER
lp
.
width
=
WindowManager
.
LayoutParams
.
MATCH_PARENT
lp
.
windowAnimations
=
R
.
style
.
DialogAnimFade
window
!!
.
attributes
=
lp
// 设置外部不可关闭
setCancelable
(
false
)
setCanceledOnTouchOutside
(
false
)
setOnKeyListener
{
_
,
i
,
_
->
i
==
KeyEvent
.
KEYCODE_BACK
}
tv_confirm
=
findViewById
<
View
>(
R
.
id
.
tv_confirm
)
as
TextView
iv_close
=
findViewById
<
View
>(
R
.
id
.
iv_close
)
as
ImageView
iv_close
.
setOnClickListener
(
listener
)
tv_confirm
.
setOnClickListener
(
listener
)
listener
?.
setDialog
(
this
)
}
}
\ No newline at end of file
video/app/src/main/java/com/duben/roseplaylet/ui/widgets/nineImage/AddImagesAdapter.kt
View file @
cf052242
...
@@ -2,6 +2,7 @@ package com.duben.roseplaylet.ui.widgets.nineImage
...
@@ -2,6 +2,7 @@ package com.duben.roseplaylet.ui.widgets.nineImage
import
android.content.Context
import
android.content.Context
import
android.util.DisplayMetrics
import
android.util.DisplayMetrics
import
android.util.TypedValue
import
android.view.LayoutInflater
import
android.view.LayoutInflater
import
android.view.View
import
android.view.View
import
android.view.ViewGroup
import
android.view.ViewGroup
...
@@ -9,8 +10,7 @@ import android.view.WindowManager
...
@@ -9,8 +10,7 @@ import android.view.WindowManager
import
android.widget.ImageView
import
android.widget.ImageView
import
android.widget.RelativeLayout
import
android.widget.RelativeLayout
import
androidx.recyclerview.widget.RecyclerView
import
androidx.recyclerview.widget.RecyclerView
import
com.bumptech.glide.Glide
import
com.duben.library.utils.GlideUtils
import
com.bumptech.glide.request.RequestOptions
import
com.duben.roseplaylet.R
import
com.duben.roseplaylet.R
class
AddImagesAdapter
(
class
AddImagesAdapter
(
...
@@ -20,8 +20,7 @@ class AddImagesAdapter(
...
@@ -20,8 +20,7 @@ class AddImagesAdapter(
addCloseImgs
:
Int
,
addCloseImgs
:
Int
,
addErrImgs
:
Int
,
addErrImgs
:
Int
,
addLimitNums
:
Int
addLimitNums
:
Int
)
:
)
:
RecyclerView
.
Adapter
<
RecyclerView
.
ViewHolder
>()
{
RecyclerView
.
Adapter
<
RecyclerView
.
ViewHolder
>()
{
var
mContext
:
Context
var
mContext
:
Context
var
limtNum
=
5
var
limtNum
=
5
var
addImgs
=
-
1
var
addImgs
=
-
1
...
@@ -29,6 +28,7 @@ class AddImagesAdapter(
...
@@ -29,6 +28,7 @@ class AddImagesAdapter(
var
addErrImgs
=
-
1
var
addErrImgs
=
-
1
var
addLimitNums
=
9
var
addLimitNums
=
9
var
addImages
=
ArrayList
<
AddImagesInfo
>()
var
addImages
=
ArrayList
<
AddImagesInfo
>()
var
enableClose
=
false
init
{
init
{
this
.
mContext
=
mContext
this
.
mContext
=
mContext
...
@@ -46,12 +46,7 @@ class AddImagesAdapter(
...
@@ -46,12 +46,7 @@ class AddImagesAdapter(
}
}
fun
getHeight
():
Int
{
fun
getHeight
():
Int
{
return
(
getScreenWidth
(
mContext
))
/
5
return
(
getScreenWidth
(
mContext
))
/
2
}
private
fun
dip2px
(
context
:
Context
,
dp
:
Int
):
Int
{
val
density
=
context
.
resources
.
displayMetrics
.
density
return
(
dp
*
density
+
0.5
).
toInt
()
}
}
private
fun
getScreenWidth
(
context
:
Context
):
Int
{
private
fun
getScreenWidth
(
context
:
Context
):
Int
{
...
@@ -62,7 +57,6 @@ class AddImagesAdapter(
...
@@ -62,7 +57,6 @@ class AddImagesAdapter(
return
outMetrics
.
widthPixels
return
outMetrics
.
widthPixels
}
}
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
RecyclerView
.
ViewHolder
{
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
RecyclerView
.
ViewHolder
{
val
view
=
LayoutInflater
.
from
(
parent
.
context
)
val
view
=
LayoutInflater
.
from
(
parent
.
context
)
.
inflate
(
R
.
layout
.
item_add_images
,
parent
,
false
)
.
inflate
(
R
.
layout
.
item_add_images
,
parent
,
false
)
...
@@ -71,45 +65,71 @@ class AddImagesAdapter(
...
@@ -71,45 +65,71 @@ class AddImagesAdapter(
override
fun
onBindViewHolder
(
holder
:
RecyclerView
.
ViewHolder
,
position
:
Int
)
{
override
fun
onBindViewHolder
(
holder
:
RecyclerView
.
ViewHolder
,
position
:
Int
)
{
val
ktHolder
=
holder
as
AddImagesViewHolder
val
ktHolder
=
holder
as
AddImagesViewHolder
if
(
addImgs
!=
-
1
)
{
if
(
addImgs
!=
-
1
)
{
ktHolder
.
ivAdd
.
setBackgroundResource
(
addImgs
)
ktHolder
.
ivAdd
.
setBackgroundResource
(
addImgs
)
}
else
{
}
else
{
ktHolder
.
ivAdd
.
setBackgroundResource
(
R
.
drawable
.
iv_add_images_add
)
ktHolder
.
ivAdd
.
setBackgroundResource
(
R
.
drawable
.
iv_add_images_add
)
}
}
if
(
addCloseImgs
!=
-
1
)
{
ktHolder
.
ivClose
.
setBackgroundResource
(
addCloseImgs
)
}
else
{
ktHolder
.
ivClose
.
setBackgroundResource
(
R
.
drawable
.
iv_add_img_close
)
}
ktHolder
.
rlClose
.
setOnClickListener
{
ktHolder
.
rlClose
.
setOnClickListener
{
processDelete
(
getItem
(
position
))
processDelete
(
getItem
(
position
))
if
(
listener
!=
null
)
listener
!!
.
onDeleteClick
(
position
)
listener
?
.
onDeleteClick
(
position
)
}
}
ktHolder
.
rlAdd
.
setOnClickListener
{
ktHolder
.
rlAdd
.
setOnClickListener
{
if
(
listener
!=
null
)
listener
!!
.
onAddClick
(
ktHolder
.
rlAdd
,
getItem
(
position
)
)
listener
?.
onAddClick
(
ktHolder
.
rlAdd
,
position
)
}
}
ktHolder
.
ivContent
.
setOnClickListener
{
ktHolder
.
ivContent
.
setOnClickListener
{
if
(
listener
!=
null
)
listener
!!
.
onAddClick
(
ktHolder
.
ivContent
,
getItem
(
position
)
)
listener
?.
onAddClick
(
ktHolder
.
ivContent
,
position
)
}
}
ktHolder
.
ivContent
.
setOnLongClickListener
()
{
listener
?.
onLongClick
(
getItem
(
position
))
return
@setOnLongClickListener
false
}
val
width
=
(
getScreenWidth
(
mContext
)
-
dp2px
(
40f
))
/
limtNum
if
(
getItem
(
position
)
!!
.
type
==
"2"
)
{
if
(
getItem
(
position
)
!!
.
type
==
"2"
)
{
ktHolder
.
ivContent
.
visibility
=
View
.
VISIBLE
ktHolder
.
ivContent
.
visibility
=
View
.
VISIBLE
ktHolder
.
rlClose
.
visibility
=
View
.
VISIBLE
ktHolder
.
rlClose
.
visibility
=
View
.
VISIBLE
ktHolder
.
rlAdd
.
visibility
=
View
.
GONE
ktHolder
.
rlAdd
.
visibility
=
View
.
GONE
if
(
addErrImgs
!=
-
1
)
{
val
requestOptions
=
RequestOptions
().
error
(
addErrImgs
)
if
(
enableClose
)
{
Glide
.
with
(
mContext
).
load
(
getItem
(
position
)
!!
.
imgUrl
).
apply
(
requestOptions
)
if
(
addCloseImgs
!=
-
1
)
{
.
into
(
ktHolder
.
ivContent
)
ktHolder
.
ivClose
.
setBackgroundResource
(
addCloseImgs
)
}
else
{
ktHolder
.
ivClose
.
setBackgroundResource
(
R
.
drawable
.
iv_add_img_close
)
}
}
else
{
}
else
{
val
requestOptions
=
RequestOptions
().
error
(
R
.
drawable
.
iv_add_err
)
ktHolder
.
ivClose
.
visibility
=
View
.
GONE
Glide
.
with
(
mContext
).
load
(
getItem
(
position
)
!!
.
imgUrl
).
apply
(
requestOptions
)
.
into
(
ktHolder
.
ivContent
)
}
}
if
(
addErrImgs
!=
-
1
)
{
GlideUtils
.
loadImageViewNoAnim2
(
mContext
,
getItem
(
position
)
?.
imgUrl
,
ktHolder
.
ivContent
)
}
else
{
GlideUtils
.
loadImageViewNoAnim2
(
mContext
,
getItem
(
position
)
?.
imgUrl
,
ktHolder
.
ivContent
)
}
// 设置宽高一致
val
layoutParams
=
ktHolder
.
ivContent
.
layoutParams
layoutParams
.
height
=
width
ktHolder
.
ivContent
.
layoutParams
=
layoutParams
}
else
{
}
else
{
// 设置宽高一致
val
layoutParams2
=
ktHolder
.
ivAdd
.
layoutParams
layoutParams2
.
height
=
width
ktHolder
.
ivAdd
.
layoutParams
=
layoutParams2
ktHolder
.
ivContent
.
visibility
=
View
.
GONE
ktHolder
.
ivContent
.
visibility
=
View
.
GONE
ktHolder
.
rlAdd
.
visibility
=
View
.
VISIBLE
ktHolder
.
rlAdd
.
visibility
=
View
.
VISIBLE
ktHolder
.
rlClose
.
visibility
=
View
.
GONE
ktHolder
.
rlClose
.
visibility
=
View
.
GONE
...
@@ -117,14 +137,13 @@ class AddImagesAdapter(
...
@@ -117,14 +137,13 @@ class AddImagesAdapter(
}
}
private
fun
processDelete
(
item
:
AddImagesInfo
?)
{
fun
processDelete
(
item
:
AddImagesInfo
?)
{
addImages
.
remove
(
item
)
addImages
.
remove
(
item
)
if
(!
hasAdd
())
{
if
(!
hasAdd
())
{
addItem
(
AddImagesInfo
(
R
.
drawable
.
iv_add_images_add
,
"1"
))
addItem
(
AddImagesInfo
(
R
.
drawable
.
iv_add_images_add
,
"1"
))
}
else
{
}
else
{
notifyDataSetChanged
()
notifyDataSetChanged
()
}
}
}
}
fun
addItems
(
lists
:
List
<
AddImagesInfo
>)
{
fun
addItems
(
lists
:
List
<
AddImagesInfo
>)
{
...
@@ -153,7 +172,6 @@ class AddImagesAdapter(
...
@@ -153,7 +172,6 @@ class AddImagesAdapter(
private
fun
processData
(
addDatas
:
List
<
AddImagesInfo
>)
{
private
fun
processData
(
addDatas
:
List
<
AddImagesInfo
>)
{
val
newList
=
processEnd
(
getItems
())
val
newList
=
processEnd
(
getItems
())
// if (newList.size >= limtNum) return
if
(
newList
.
size
+
addDatas
.
size
<
addLimitNums
)
{
if
(
newList
.
size
+
addDatas
.
size
<
addLimitNums
)
{
newList
.
addAll
(
addDatas
)
newList
.
addAll
(
addDatas
)
newList
.
add
(
AddImagesInfo
(
""
,
"1"
))
newList
.
add
(
AddImagesInfo
(
""
,
"1"
))
...
@@ -161,7 +179,6 @@ class AddImagesAdapter(
...
@@ -161,7 +179,6 @@ class AddImagesAdapter(
newList
.
addAll
(
addDatas
.
subList
(
0
,
addLimitNums
-
newList
.
size
))
newList
.
addAll
(
addDatas
.
subList
(
0
,
addLimitNums
-
newList
.
size
))
}
}
notifyDataSetChanged
()
notifyDataSetChanged
()
}
}
private
fun
processEnd
(
addDatas
:
ArrayList
<
AddImagesInfo
>):
ArrayList
<
AddImagesInfo
>
{
private
fun
processEnd
(
addDatas
:
ArrayList
<
AddImagesInfo
>):
ArrayList
<
AddImagesInfo
>
{
...
@@ -174,7 +191,7 @@ class AddImagesAdapter(
...
@@ -174,7 +191,7 @@ class AddImagesAdapter(
}
}
private
fun
hasAdd
():
Boolean
{
private
fun
hasAdd
():
Boolean
{
getItems
()
!!
.
forEach
{
getItems
().
forEach
{
if
(
it
.
type
==
"1"
)
{
if
(
it
.
type
==
"1"
)
{
return
true
return
true
}
}
...
@@ -194,8 +211,18 @@ class AddImagesAdapter(
...
@@ -194,8 +211,18 @@ class AddImagesAdapter(
return
null
return
null
}
}
fun
enableClose
(
enable
:
Boolean
)
{
this
.
enableClose
=
enable
}
private
fun
dp2px
(
dp
:
Float
):
Int
{
val
displayMetrics
:
DisplayMetrics
=
mContext
.
resources
.
displayMetrics
return
TypedValue
.
applyDimension
(
TypedValue
.
COMPLEX_UNIT_DIP
,
dp
,
displayMetrics
).
toInt
()
}
interface
OnAddClickListener
{
interface
OnAddClickListener
{
fun
onAddClick
(
view
:
View
?,
item
:
AddImagesInfo
?)
fun
onAddClick
(
view
:
View
?,
position
:
Int
)
fun
onLongClick
(
item
:
AddImagesInfo
?)
fun
onDeleteClick
(
position
:
Int
)
fun
onDeleteClick
(
position
:
Int
)
}
}
...
...
video/app/src/main/java/com/duben/roseplaylet/ui/widgets/nineImage/AddImagesInfo.kt
View file @
cf052242
package
com.duben.roseplaylet.ui.widgets.nineImage
package
com.duben.roseplaylet.ui.widgets.nineImage
class
AddImagesInfo
(
var
imgUrl
:
Any
,
var
type
:
String
)
class
AddImagesInfo
(
var
imgUrl
:
Any
,
var
type
:
String
)
\ No newline at end of file
\ No newline at end of file
video/app/src/main/java/com/duben/roseplaylet/ui/widgets/nineImage/AddImagesView.kt
View file @
cf052242
...
@@ -31,7 +31,7 @@ class AddImagesView @JvmOverloads constructor(
...
@@ -31,7 +31,7 @@ class AddImagesView @JvmOverloads constructor(
//最大图片数
//最大图片数
private
var
add_limit_nums
=
9
private
var
add_limit_nums
=
9
private
var
mAdapter
:
AddImagesAdapter
?
=
null
private
lateinit
var
mAdapter
:
AddImagesAdapter
init
{
init
{
this
.
mContext
=
mContext
this
.
mContext
=
mContext
...
@@ -68,42 +68,51 @@ class AddImagesView @JvmOverloads constructor(
...
@@ -68,42 +68,51 @@ class AddImagesView @JvmOverloads constructor(
add_limit_nums
add_limit_nums
)
)
rvContent
.
adapter
=
mAdapter
rvContent
.
adapter
=
mAdapter
mAdapter
!!
.
addItem
(
AddImagesInfo
(
""
,
"1"
))
mAdapter
.
addItem
(
AddImagesInfo
(
""
,
"1"
))
mAdapter
!!
.
setOnAddListener
(
object
:
AddImagesAdapter
.
OnAddClickListener
{
mAdapter
.
setOnAddListener
(
object
:
AddImagesAdapter
.
OnAddClickListener
{
override
fun
onAddClick
(
view
:
View
?,
item
:
AddImagesInfo
?
)
{
override
fun
onAddClick
(
view
:
View
?,
position
:
Int
)
{
when
(
view
!!
.
id
)
{
when
(
view
?
.
id
)
{
R
.
id
.
rl_add
->
{
R
.
id
.
rl_add
->
{
if
(
listener
!=
null
)
listener
?.
onAdd
()
listener
!!
.
onAdd
()
}
}
R
.
id
.
iv_content
->
{
R
.
id
.
iv_content
->
{
if
(
listener
!=
null
)
listener
?.
onPreview
(
position
,
mAdapter
.
getItems
())
listener
!!
.
onPreview
(
item
,
mAdapter
!!
.
getItems
())
}
}
}
}
}
}
override
fun
onDeleteClick
(
position
:
Int
)
{
override
fun
onLongClick
(
item
:
AddImagesInfo
?)
{
if
(
listener
!=
null
)
listener
?.
onLongClick
(
item
)
listener
!!
.
onDelete
(
position
)
}
}
override
fun
onDeleteClick
(
position
:
Int
)
{
listener
?.
onDelete
(
position
)
}
})
})
}
}
//添加数据
//添加数据
fun
addAddImages
(
lists
:
List
<
AddImagesInfo
>)
{
fun
addAddImages
(
lists
:
List
<
AddImagesInfo
>)
{
mAdapter
!!
.
addItems
(
lists
)
mAdapter
.
addItems
(
lists
)
}
}
fun
getAddImages
():
List
<
AddImagesInfo
>
{
fun
getAddImages
():
List
<
AddImagesInfo
>
{
return
mAdapter
!!
.
getItems
()
return
mAdapter
.
getItems
()
}
fun
enableCloseView
(
enable
:
Boolean
)
{
mAdapter
.
enableClose
(
enable
)
}
fun
deleteImage
(
item
:
AddImagesInfo
?)
{
mAdapter
.
processDelete
(
item
)
}
}
interface
AddImagesViewListener
{
interface
AddImagesViewListener
{
fun
onAdd
()
fun
onAdd
()
fun
onDelete
(
position
:
Int
)
fun
onDelete
(
position
:
Int
)
fun
onPreview
(
item
:
AddImagesInfo
?,
lists
:
List
<
AddImagesInfo
>?)
fun
onLongClick
(
item
:
AddImagesInfo
?)
fun
onPreview
(
position
:
Int
,
lists
:
List
<
AddImagesInfo
>?)
}
}
}
}
\ No newline at end of file
video/app/src/main/res/layout/activity_album.xml
0 → 100644
View file @
cf052242
<?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=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/color_232122"
android:orientation=
"vertical"
>
<include
layout=
"@layout/header_layout"
/>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"30dp"
android:background=
"@color/gray"
android:gravity=
"center"
android:text=
"最多上传6张图片,长按可删除照片"
android:textColor=
"@color/white"
/>
<com.duben.roseplaylet.ui.widgets.nineImage.AddImagesView
android:id=
"@+id/aiv"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_margin=
"10dp"
app:add_limit_nums=
"6"
app:column_nums=
"3"
/>
</LinearLayout>
video/app/src/main/res/layout/dialog_delete_photo_confirm.xml
0 → 100644
View file @
cf052242
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:layout_marginStart=
"30dp"
android:layout_marginEnd=
"30dp"
android:gravity=
"center"
android:orientation=
"vertical"
>
<LinearLayout
android:id=
"@+id/ll_content"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"@drawable/shape_bg_hall"
android:gravity=
"center_horizontal"
android:orientation=
"vertical"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"20dp"
android:layout_marginTop=
"30dp"
android:layout_marginEnd=
"20dp"
android:gravity=
"center"
android:text=
"删除后无法找回,确定要删除吗?"
android:textColor=
"@color/white"
android:textSize=
"16sp"
android:textStyle=
"bold"
/>
<TextView
android:id=
"@+id/tv_confirm"
android:layout_width=
"260dp"
android:layout_height=
"40dp"
android:layout_marginTop=
"30dp"
android:layout_marginBottom=
"30dp"
android:background=
"@drawable/shape_square_tab"
android:gravity=
"center"
android:text=
"确定"
android:textColor=
"@color/black"
android:textSize=
"14sp"
/>
</LinearLayout>
<ImageView
android:id=
"@+id/iv_close"
android:layout_width=
"30dp"
android:layout_height=
"30dp"
android:layout_below=
"@id/ll_content"
android:layout_centerHorizontal=
"true"
android:layout_marginTop=
"30dp"
android:src=
"@mipmap/ic_close"
/>
</RelativeLayout>
video/app/src/main/res/layout/item_add_images.xml
View file @
cf052242
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"80dp"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"10dp"
android:orientation=
"vertical"
>
android:orientation=
"vertical"
>
<RelativeLayout
<RelativeLayout
...
@@ -16,13 +15,14 @@
...
@@ -16,13 +15,14 @@
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:layout_centerInParent=
"true"
android:layout_centerInParent=
"true"
android:layout_margin=
"5dp"
android:scaleType=
"center"
/>
android:scaleType=
"center"
/>
</RelativeLayout>
</RelativeLayout>
<ImageView
<ImageView
android:id=
"@+id/iv_content"
android:id=
"@+id/iv_content"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"
wrap_cont
ent"
android:layout_height=
"
match_par
ent"
android:padding=
"5dp"
android:padding=
"5dp"
android:scaleType=
"center"
android:scaleType=
"center"
android:visibility=
"gone"
/>
android:visibility=
"gone"
/>
...
...
video/app/src/main/res/layout/item_album_add.xml
0 → 100644
View file @
cf052242
<?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=
"120dp"
android:layout_marginTop=
"4dp"
android:layout_marginBottom=
"6dp"
android:background=
"@drawable/shape_green"
android:orientation=
"horizontal"
>
<ImageView
android:id=
"@+id/iv_add"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:src=
"@drawable/ksad_reward_follow_add"
/>
</LinearLayout>
\ No newline at end of file
video/app/src/main/res/layout/item_album_normal.xml
0 → 100644
View file @
cf052242
<?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=
"120dp"
android:layout_marginTop=
"4dp"
android:layout_marginBottom=
"6dp"
android:orientation=
"horizontal"
>
<ImageView
android:id=
"@+id/iv_normal"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
</LinearLayout>
\ 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