Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
Sobot_module_Dev
Project
Overview
Details
Activity
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
sobot_android
Sobot_module_Dev
Commits
080439e2
Commit
080439e2
authored
Jun 26, 2024
by
郭倩芳
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
album 预览功能
parent
173b3db7
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
551 additions
and
191 deletions
+551
-191
AndroidManifest.xml
sobot_album/src/main/AndroidManifest.xml
+6
-5
AlbumFile.java
sobot_album/src/main/java/com/sobot/album/AlbumFile.java
+8
-2
SobotAlbum.java
sobot_album/src/main/java/com/sobot/album/SobotAlbum.java
+0
-1
AlbumFilterActivity.java
...in/java/com/sobot/album/activity/AlbumFilterActivity.java
+0
-182
GalleryAlbumWrapper.java
...rc/main/java/com/sobot/album/api/GalleryAlbumWrapper.java
+17
-0
ImageFragment.java
...main/java/com/sobot/album/app/fragment/ImageFragment.java
+2
-0
VideoFragment.java
...main/java/com/sobot/album/app/fragment/VideoFragment.java
+31
-1
PreviewAlbumActivity.java
...ava/com/sobot/album/app/preview/PreviewAlbumActivity.java
+176
-0
PreviewView.java
...rc/main/java/com/sobot/album/app/preview/PreviewView.java
+165
-0
sobot_bg_download_color_3dp.xml
...bum/src/main/res/drawable/sobot_bg_download_color_3dp.xml
+9
-0
sobot_bg_download_color_9dp.xml
...bum/src/main/res/drawable/sobot_bg_download_color_9dp.xml
+9
-0
fragment_img_item.xml
sobot_album/src/main/res/layout/fragment_img_item.xml
+2
-0
sobot_activity_album_preview.xml
...lbum/src/main/res/layout/sobot_activity_album_preview.xml
+123
-0
colors.xml
sobot_album/src/main/res/values/colors.xml
+2
-0
dimens.xml
sobot_album/src/main/res/values/dimens.xml
+1
-0
No files found.
sobot_album/src/main/AndroidManifest.xml
View file @
080439e2
...
...
@@ -45,11 +45,6 @@
android:screenOrientation=
"portrait"
/>
<activity
android:name=
"com.sobot.album.activity.AlbumFilterActivity"
android:configChanges=
"orientation|keyboardHidden|screenSize|touchscreen|navigation|locale|fontScale|uiMode|screenLayout|smallestScreenSize"
android:screenOrientation=
"portrait"
android:theme=
"@style/sobot_activity_def_theme"
/>
<activity
android:name=
"com.sobot.album.app.album.AlbumActivity"
android:configChanges=
"orientation|keyboardHidden|screenSize|touchscreen|navigation|locale|fontScale|uiMode|screenLayout|smallestScreenSize"
android:screenOrientation=
"portrait"
...
...
@@ -69,6 +64,11 @@
android:configChanges=
"orientation|keyboardHidden|screenSize|touchscreen|navigation|locale|fontScale|uiMode|screenLayout|smallestScreenSize"
android:screenOrientation=
"portrait"
android:theme=
"@style/sobot_activity_def_theme"
/>
<activity
android:name=
"com.sobot.album.app.preview.PreviewAlbumActivity"
android:configChanges=
"orientation|keyboardHidden|screenSize|touchscreen|navigation|locale|fontScale|uiMode|screenLayout|smallestScreenSize"
android:screenOrientation=
"portrait"
android:theme=
"@style/sobot_activity_def_theme"
/>
</application>
</manifest>
\ No newline at end of file
sobot_album/src/main/java/com/sobot/album/AlbumFile.java
View file @
080439e2
...
...
@@ -258,6 +258,9 @@ public class AlbumFile implements Parcelable, Comparable<AlbumFile> {
protected
AlbumFile
(
Parcel
in
)
{
mPath
=
in
.
readString
();
fileName
=
in
.
readString
();
fileUrl
=
in
.
readString
();
mThumbPath
=
in
.
readString
();
mBucketName
=
in
.
readString
();
mMimeType
=
in
.
readString
();
mAddDate
=
in
.
readLong
();
...
...
@@ -265,15 +268,18 @@ public class AlbumFile implements Parcelable, Comparable<AlbumFile> {
mLongitude
=
in
.
readFloat
();
mSize
=
in
.
readLong
();
mDuration
=
in
.
readLong
();
mThumbPath
=
in
.
readString
();
mMediaType
=
in
.
readInt
();
isChecked
=
in
.
readByte
()
!=
0
;
isDisable
=
in
.
readByte
()
!=
0
;
fileNumKey
=
in
.
readString
();
}
@Override
public
void
writeToParcel
(
Parcel
dest
,
int
flags
)
{
dest
.
writeString
(
mPath
);
dest
.
writeString
(
fileName
);
dest
.
writeString
(
fileUrl
);
dest
.
writeString
(
mThumbPath
);
dest
.
writeString
(
mBucketName
);
dest
.
writeString
(
mMimeType
);
dest
.
writeLong
(
mAddDate
);
...
...
@@ -281,10 +287,10 @@ public class AlbumFile implements Parcelable, Comparable<AlbumFile> {
dest
.
writeFloat
(
mLongitude
);
dest
.
writeLong
(
mSize
);
dest
.
writeLong
(
mDuration
);
dest
.
writeString
(
mThumbPath
);
dest
.
writeInt
(
mMediaType
);
dest
.
writeByte
((
byte
)
(
isChecked
?
1
:
0
));
dest
.
writeByte
((
byte
)
(
isDisable
?
1
:
0
));
dest
.
writeString
(
fileNumKey
);
}
@Override
...
...
sobot_album/src/main/java/com/sobot/album/SobotAlbum.java
View file @
080439e2
...
...
@@ -18,7 +18,6 @@ package com.sobot.album;
import
android.app.Activity
;
import
android.app.Fragment
;
import
android.content.Context
;
import
android.util.Log
;
import
androidx.annotation.IntDef
;
...
...
sobot_album/src/main/java/com/sobot/album/activity/AlbumFilterActivity.java
deleted
100644 → 0
View file @
173b3db7
/*
* Copyright 2017 Yan Zhenjie.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
sobot
.
album
.
activity
;
import
android.graphics.Color
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.recyclerview.widget.GridLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.sobot.album.Action
;
import
com.sobot.album.AlbumFile
;
import
com.sobot.album.Filter
;
import
com.sobot.album.R
;
import
com.sobot.album.SobotAlbum
;
import
com.sobot.album.api.widget.Widget
;
import
com.sobot.album.impl.OnItemClickListener
;
import
com.sobot.album.widget.divider.Api21ItemDivider
;
import
com.sobot.album.widget.divider.Divider
;
import
java.util.ArrayList
;
public
class
AlbumFilterActivity
extends
AppCompatActivity
{
// private Toolbar mToolbar;
private
TextView
mTvMessage
;
private
Adapter
mAdapter
;
private
ArrayList
<
AlbumFile
>
mAlbumFiles
;
private
boolean
mAfterFilterVisibility
;
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_album_filter
);
// mToolbar = findViewById(R.id.toolbar);
// setSupportActionBar(mToolbar);
mTvMessage
=
findViewById
(
R
.
id
.
tv_message
);
RecyclerView
recyclerView
=
findViewById
(
R
.
id
.
recycler_view
);
recyclerView
.
setLayoutManager
(
new
GridLayoutManager
(
this
,
3
));
Divider
divider
=
new
Api21ItemDivider
(
Color
.
TRANSPARENT
,
10
,
10
);
recyclerView
.
addItemDecoration
(
divider
);
mAdapter
=
new
Adapter
(
this
,
new
OnItemClickListener
()
{
@Override
public
void
onItemClick
(
View
view
,
int
position
)
{
previewAlbum
(
position
);
}
});
recyclerView
.
setAdapter
(
mAdapter
);
}
/**
* Select picture, from album.
*/
private
void
selectAlbum
()
{
SobotAlbum
.
album
(
this
)
.
multipleChoice
()
.
filterMimeType
(
new
Filter
<
String
>()
{
// MimeType of File.
@Override
public
boolean
filter
(
String
attributes
)
{
// MimeType: image/jpeg, image/png, video/mp4, video/3gp...
return
attributes
.
contains
(
"jpeg"
);
}
})
// .filterSize() // File size.
// .filterDuration() // Video duration.
.
afterFilterVisibility
(
mAfterFilterVisibility
)
.
columnCount
(
2
)
.
selectCount
(
6
)
.
camera
(
true
)
.
checkedList
(
mAlbumFiles
)
.
widget
(
Widget
.
newDarkBuilder
(
this
)
.
title
(
"albun filter"
)
.
build
()
)
.
onResult
(
new
Action
<
ArrayList
<
AlbumFile
>>()
{
@Override
public
void
onAction
(
@NonNull
ArrayList
<
AlbumFile
>
result
)
{
mAlbumFiles
=
result
;
mAdapter
.
notifyDataSetChanged
(
mAlbumFiles
);
mTvMessage
.
setVisibility
(
result
.
size
()
>
0
?
View
.
VISIBLE
:
View
.
GONE
);
}
})
.
onCancel
(
new
Action
<
String
>()
{
@Override
public
void
onAction
(
@NonNull
String
result
)
{
Toast
.
makeText
(
AlbumFilterActivity
.
this
,
R
.
string
.
canceled
,
Toast
.
LENGTH_LONG
).
show
();
}
})
.
start
();
}
/**
* Preview image, to album.
*/
private
void
previewAlbum
(
int
position
)
{
if
(
mAlbumFiles
==
null
||
mAlbumFiles
.
size
()
==
0
)
{
Toast
.
makeText
(
this
,
R
.
string
.
no_selected
,
Toast
.
LENGTH_LONG
).
show
();
}
else
{
SobotAlbum
.
galleryAlbum
(
this
)
.
checkable
(
true
)
.
checkedList
(
mAlbumFiles
)
.
currentPosition
(
position
)
.
widget
(
Widget
.
newDarkBuilder
(
this
)
.
title
(
"Album filter"
)
.
build
()
)
.
onResult
(
new
Action
<
ArrayList
<
AlbumFile
>>()
{
@Override
public
void
onAction
(
@NonNull
ArrayList
<
AlbumFile
>
result
)
{
mAlbumFiles
=
result
;
mAdapter
.
notifyDataSetChanged
(
mAlbumFiles
);
mTvMessage
.
setVisibility
(
result
.
size
()
>
0
?
View
.
VISIBLE
:
View
.
GONE
);
}
})
.
start
();
}
}
/* @Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_album, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == android.R.id.home) {
finish();
} else if (id == R.id.menu_eye) {
previewAlbum(0);
} else if (id == R.id.menu_album) {
new AlertDialog.Builder(this)
.setCancelable(false)
.setTitle(R.string.app_name)
.setMessage(R.string.hint_filter_after_visibility)
.setNeutralButton(R.string.filter_after_visibility_gone, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mAfterFilterVisibility = false;
selectAlbum();
}
})
.setPositiveButton(R.string.filter_after_visibility_visible, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mAfterFilterVisibility = true;
selectAlbum();
}
})
.show();
}
return true;
}*/
}
\ No newline at end of file
sobot_album/src/main/java/com/sobot/album/api/GalleryAlbumWrapper.java
View file @
080439e2
...
...
@@ -17,10 +17,12 @@ package com.sobot.album.api;
import
android.content.Context
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
com.sobot.album.AlbumFile
;
import
com.sobot.album.SobotAlbum
;
import
com.sobot.album.app.gallery.GalleryAlbumActivity
;
import
com.sobot.album.app.preview.PreviewAlbumActivity
;
public
class
GalleryAlbumWrapper
extends
BasicGalleryWrapper
<
GalleryAlbumWrapper
,
AlbumFile
,
String
,
AlbumFile
>
{
...
...
@@ -42,4 +44,18 @@ public class GalleryAlbumWrapper extends BasicGalleryWrapper<GalleryAlbumWrapper
intent
.
putExtra
(
SobotAlbum
.
KEY_INPUT_GALLERY_CHECKABLE
,
mCheckable
);
mContext
.
startActivity
(
intent
);
}
public
void
preview
()
{
PreviewAlbumActivity
.
sResult
=
mResult
;
PreviewAlbumActivity
.
sCancel
=
mCancel
;
PreviewAlbumActivity
.
sClick
=
mItemClick
;
PreviewAlbumActivity
.
sLongClick
=
mItemLongClick
;
Intent
intent
=
new
Intent
(
mContext
,
PreviewAlbumActivity
.
class
);
Bundle
bundle
=
new
Bundle
();
bundle
.
putParcelable
(
SobotAlbum
.
KEY_INPUT_WIDGET
,
mWidget
);
bundle
.
putParcelableArrayList
(
SobotAlbum
.
KEY_INPUT_CHECKED_LIST
,
mChecked
);
bundle
.
putInt
(
SobotAlbum
.
KEY_INPUT_CURRENT_POSITION
,
mCurrentPosition
);
bundle
.
putBoolean
(
SobotAlbum
.
KEY_INPUT_GALLERY_CHECKABLE
,
mCheckable
);
intent
.
putExtras
(
bundle
);
mContext
.
startActivity
(
intent
);
}
}
\ No newline at end of file
sobot_album/src/main/java/com/sobot/album/app/fragment/ImageFragment.java
View file @
080439e2
...
...
@@ -5,6 +5,7 @@ import android.os.Bundle;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.ImageView
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
...
...
@@ -32,6 +33,7 @@ public class ImageFragment extends Fragment implements PhotoViewAttacher.OnViewT
attacher
.
setOnViewTapListener
(
this
);
attacher
.
setOnLongClickListener
(
this
);
imageView
.
setAttacher
(
attacher
);
imageView
.
setScaleType
(
ImageView
.
ScaleType
.
CENTER_CROP
);
initDate
();
return
mRootView
;
}
...
...
sobot_album/src/main/java/com/sobot/album/app/fragment/VideoFragment.java
View file @
080439e2
...
...
@@ -27,6 +27,9 @@ import androidx.fragment.app.Fragment;
import
com.sobot.album.AlbumFile
;
import
com.sobot.album.R
;
import
com.sobot.album.SobotAlbum
;
import
com.sobot.utils.SobotStringUtils
;
import
java.io.IOException
;
public
class
VideoFragment
extends
Fragment
{
private
View
mRootView
;
...
...
@@ -68,7 +71,34 @@ public class VideoFragment extends Fragment {
if
(
mAlbum
!=
null
)
{
//设置预览图
// setFirstFrameDrawable(getContext(),mAlbum.getUri());
SobotAlbum
.
getAlbumConfig
().
getAlbumLoader
().
load
(
mIvPreview
,
mAlbum
);
if
(
SobotStringUtils
.
isNoEmpty
(
mAlbum
.
getThumbPath
()))
{
SobotAlbum
.
getAlbumConfig
().
getAlbumLoader
().
load
(
mIvPreview
,
mAlbum
);
}
else
{
//获取封面图
Bitmap
bitmap
=
null
;
// 首先创建一个MediaMetadataRetriever
MediaMetadataRetriever
retriever
=
new
MediaMetadataRetriever
();
try
{
retriever
.
setDataSource
(
getContext
(),
mAlbum
.
getUri
());
// setDataSource
bitmap
=
retriever
.
getFrameAtTime
(-
1
);
// 获取封面
// 此处有两种方式获取封面,一种是getFrameAtTime, 一种是getImageAtIndex
// 这两个的区别是一个是通过时间戳解析封面,另一个是通过index解析封面
}
catch
(
IllegalArgumentException
ex
)
{
// Assume this is a corrupt video file
}
catch
(
RuntimeException
ex
)
{
// Assume this is a corrupt video file.
}
finally
{
try
{
retriever
.
release
();
}
catch
(
Exception
ex
)
{
// Ignore failures while cleaning up.
}
}
if
(
null
!=
bitmap
){
mIvPreview
.
setImageBitmap
(
bitmap
);
}
}
//设置视频
mVideoView
.
setVideoURI
(
mAlbum
.
getUri
());
mIvPlay
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
...
...
sobot_album/src/main/java/com/sobot/album/app/preview/PreviewAlbumActivity.java
0 → 100644
View file @
080439e2
/*
* Copyright 2017 Yan Zhenjie.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
sobot
.
album
.
app
.
preview
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.widget.FrameLayout
;
import
android.widget.TextView
;
import
androidx.fragment.app.FragmentManager
;
import
androidx.viewpager.widget.ViewPager
;
import
com.sobot.album.Action
;
import
com.sobot.album.AlbumFile
;
import
com.sobot.album.ItemAction
;
import
com.sobot.album.R
;
import
com.sobot.album.SobotAlbum
;
import
com.sobot.album.api.widget.Widget
;
import
com.sobot.album.app.Contract
;
import
com.sobot.album.mvp.SobotAlbumBaseActivity
;
import
java.util.ArrayList
;
/**
* 预览图片、视频
*/
public
class
PreviewAlbumActivity
extends
SobotAlbumBaseActivity
implements
Contract
.
GalleryPresenter
,
View
.
OnClickListener
{
public
static
Action
<
ArrayList
<
AlbumFile
>>
sResult
;
public
static
Action
<
String
>
sCancel
;
public
static
ItemAction
<
AlbumFile
>
sClick
;
public
static
ItemAction
<
AlbumFile
>
sLongClick
;
private
Widget
mWidget
;
private
Contract
.
GalleryView
<
AlbumFile
>
mView
;
private
ArrayList
<
AlbumFile
>
mAlbumFiles
;
//预览的图片和视频
private
int
mCurrentPosition
;
//当前页数
private
ViewPager
mViewPager
;
private
TextView
sobot_tv_title
;
//预览已选时显示预览进度
private
FrameLayout
mLayoutLayer
;
private
FragmentManager
fragmentManager
;
private
TextView
sobot_tv_page
;
//当前页数显示
private
TextView
sobot_tv_download
;
//下载按钮
@Override
protected
int
getContentViewResId
()
{
return
R
.
layout
.
sobot_activity_album_preview
;
}
@Override
protected
void
initView
()
{
mView
=
new
PreviewView
<>(
this
,
getSupportFragmentManager
(),
this
);
this
.
fragmentManager
=
getSupportFragmentManager
();
this
.
mViewPager
=
findViewById
(
R
.
id
.
view_pager
);
this
.
mLayoutLayer
=
findViewById
(
R
.
id
.
layout_layer
);
this
.
sobot_tv_title
=
findViewById
(
R
.
id
.
sobot_text_title_center
);
this
.
sobot_tv_download
=
findViewById
(
R
.
id
.
sobot_tv_download
);
this
.
sobot_tv_page
=
findViewById
(
R
.
id
.
sobot_tv_page
);
this
.
sobot_tv_download
.
setOnClickListener
(
this
);
this
.
mLayoutLayer
.
setOnClickListener
(
this
);
Bundle
argument
=
getIntent
().
getExtras
();
assert
argument
!=
null
;
mWidget
=
argument
.
getParcelable
(
SobotAlbum
.
KEY_INPUT_WIDGET
);
mAlbumFiles
=
argument
.
getParcelableArrayList
(
SobotAlbum
.
KEY_INPUT_CHECKED_LIST
);
mCurrentPosition
=
argument
.
getInt
(
SobotAlbum
.
KEY_INPUT_CURRENT_POSITION
,
0
);
mViewPager
.
addOnPageChangeListener
(
new
ViewPager
.
SimpleOnPageChangeListener
()
{
@Override
public
void
onPageSelected
(
int
position
)
{
onCurrentChanged
(
position
);
if
(
mAlbumFiles
!=
null
&&
position
<
mAlbumFiles
.
size
())
{
showTitle
(
position
);
}
}
});
mView
.
setupViews
(
mWidget
,
true
);
if
(
mCurrentPosition
==
0
)
{
onCurrentChanged
(
mCurrentPosition
);
}
else
{
mView
.
setCurrentItem
(
mCurrentPosition
);
}
mView
.
bindData
(
mAlbumFiles
);
setCheckedCount
();
}
private
void
showTitle
(
int
position
)
{
String
title
=
(
position
+
1
)
+
"/"
+
mAlbumFiles
.
size
();
AlbumFile
albumFile
=
mAlbumFiles
.
get
(
position
);
sobot_tv_page
.
setText
(
title
);
sobot_tv_page
.
setVisibility
(
View
.
VISIBLE
);
sobot_tv_title
.
setText
(
albumFile
.
getFileName
());
if
(
albumFile
.
getPath
().
startsWith
(
"http"
))
{
//显示下载
sobot_tv_download
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
//隐藏下载
sobot_tv_download
.
setVisibility
(
View
.
GONE
);
}
}
@Override
protected
void
initData
()
{
//设置标题
if
(
mAlbumFiles
!=
null
)
{
showTitle
(
mCurrentPosition
);
}
}
private
void
setCheckedCount
()
{
}
@Override
public
void
clickItem
(
int
position
)
{
}
@Override
public
void
longClickItem
(
int
position
)
{
}
@Override
public
void
onCurrentChanged
(
int
position
)
{
mCurrentPosition
=
position
;
}
@Override
public
void
onCheckedChanged
()
{
AlbumFile
albumFile
=
mAlbumFiles
.
get
(
mCurrentPosition
);
albumFile
.
setChecked
(!
albumFile
.
isChecked
());
setCheckedCount
();
}
@Override
public
void
complete
()
{
finish
();
}
@Override
public
void
onBackPressed
()
{
finish
();
}
@Override
public
void
finish
()
{
super
.
finish
();
}
@Override
public
void
onClick
(
View
view
)
{
if
(
view
==
sobot_tv_download
)
{
//下载
AlbumFile
albumFile
=
mAlbumFiles
.
get
(
mCurrentPosition
);
if
(
sClick
!=
null
)
{
sClick
.
onAction
(
this
,
albumFile
);
}
}
}
}
\ No newline at end of file
sobot_album/src/main/java/com/sobot/album/app/preview/PreviewView.java
0 → 100644
View file @
080439e2
/*
* Copyright 2018 Yan Zhenjie.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
sobot
.
album
.
app
.
preview
;
import
android.app.Activity
;
import
android.net.Uri
;
import
android.text.SpannableStringBuilder
;
import
android.text.Spanned
;
import
android.text.style.ForegroundColorSpan
;
import
android.view.Menu
;
import
android.view.MenuItem
;
import
android.view.View
;
import
android.widget.CheckBox
;
import
android.widget.FrameLayout
;
import
android.widget.HorizontalScrollView
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
androidx.fragment.app.Fragment
;
import
androidx.fragment.app.FragmentManager
;
import
androidx.viewpager.widget.ViewPager
;
import
com.sobot.album.AlbumFile
;
import
com.sobot.album.R
;
import
com.sobot.album.SobotAlbum
;
import
com.sobot.album.api.widget.Widget
;
import
com.sobot.album.app.Contract
;
import
com.sobot.album.app.fragment.ImageFragment
;
import
com.sobot.album.app.fragment.SobotViewPagerAdapter
;
import
com.sobot.album.app.fragment.VideoFragment
;
import
com.sobot.utils.SobotStringUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
PreviewView
<
Data
>
extends
Contract
.
GalleryView
<
Data
>
implements
View
.
OnClickListener
{
private
Activity
mActivity
;
// private MenuItem mCompleteMenu;
private
ViewPager
mViewPager
;
private
LinearLayout
mLayoutBottom
;
private
TextView
mTvDuration
;
private
FrameLayout
mLayoutLayer
;
private
SobotViewPagerAdapter
pagerAdapter
;
private
List
<
Fragment
>
fragments
;
private
FragmentManager
fragmentManager
;
public
PreviewView
(
Activity
activity
,
FragmentManager
fragmentManager
,
Contract
.
GalleryPresenter
presenter
)
{
super
(
activity
,
presenter
);
this
.
mActivity
=
activity
;
this
.
fragmentManager
=
fragmentManager
;
this
.
mViewPager
=
activity
.
findViewById
(
R
.
id
.
view_pager
);
this
.
mLayoutBottom
=
activity
.
findViewById
(
R
.
id
.
layout_bottom
);
this
.
mTvDuration
=
activity
.
findViewById
(
R
.
id
.
tv_duration
);
this
.
mLayoutLayer
=
activity
.
findViewById
(
R
.
id
.
layout_layer
);
this
.
mLayoutLayer
.
setOnClickListener
(
this
);
}
@Override
protected
void
onCreateOptionsMenu
(
Menu
menu
)
{
// getMenuInflater().inflate(R.menu.album_menu_gallery, menu);
// mCompleteMenu = menu.findItem(R.id.album_menu_finish);
}
@Override
protected
void
onOptionsItemSelected
(
MenuItem
item
)
{
// int id = item.getItemId();
// if (id == R.id.album_menu_finish) {
// getPresenter().complete();
// }
}
@Override
public
void
setupViews
(
Widget
widget
,
boolean
checkable
)
{
mViewPager
.
addOnPageChangeListener
(
new
ViewPager
.
SimpleOnPageChangeListener
()
{
@Override
public
void
onPageSelected
(
int
position
)
{
getPresenter
().
onCurrentChanged
(
position
);
}
});
}
@Override
public
void
bindData
(
List
<
Data
>
dataList
)
{
if
(
dataList
==
null
||
dataList
.
size
()==
0
){
return
;
}
fragments
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
dataList
.
size
();
i
++)
{
if
(
dataList
.
get
(
i
)
instanceof
AlbumFile
)
{
AlbumFile
albumFile
=
(
AlbumFile
)
dataList
.
get
(
i
);
if
(
albumFile
.
getMediaType
()
==
AlbumFile
.
TYPE_IMAGE
)
{
ImageFragment
fragment
=
ImageFragment
.
getInstance
(
albumFile
);
fragments
.
add
(
fragment
);
}
else
if
(
albumFile
.
getMediaType
()
==
AlbumFile
.
TYPE_VIDEO
)
{
if
(
null
==
albumFile
.
getUri
()
&&
SobotStringUtils
.
isNoEmpty
(
albumFile
.
getPath
())){
albumFile
.
setUri
(
Uri
.
parse
(
albumFile
.
getPath
()));
}
VideoFragment
fragment
=
VideoFragment
.
getInstance
(
albumFile
);
fragments
.
add
(
fragment
);
}
}
}
pagerAdapter
=
new
SobotViewPagerAdapter
(
mActivity
,
fragmentManager
,
fragments
);
mViewPager
.
setAdapter
(
pagerAdapter
);
}
@Override
public
void
setCurrentItem
(
int
position
)
{
mViewPager
.
setCurrentItem
(
position
);
}
@Override
public
void
setDurationDisplay
(
boolean
display
)
{
mTvDuration
.
setVisibility
(
display
?
View
.
VISIBLE
:
View
.
GONE
);
}
@Override
public
void
setDuration
(
String
duration
)
{
mTvDuration
.
setText
(
duration
);
}
@Override
public
void
setChecked
(
boolean
checked
)
{
}
@Override
public
void
setBottomDisplay
(
boolean
display
)
{
mLayoutBottom
.
setVisibility
(
display
?
View
.
VISIBLE
:
View
.
GONE
);
}
@Override
public
void
setLayerDisplay
(
boolean
display
)
{
// mLayoutLayer.setVisibility(display ? View.VISIBLE : View.GONE);
}
@Override
public
void
setCompleteText
(
String
sCheckedCount
)
{
}
@Override
public
void
onClick
(
View
v
)
{
if
(
v
==
mLayoutLayer
)
{
// Intercept click events.
}
}
}
\ No newline at end of file
sobot_album/src/main/res/drawable/sobot_bg_download_color_3dp.xml
0 → 100644
View file @
080439e2
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<solid
android:color=
"@color/albumdownBg"
/>
<corners
android:radius=
"6dp"
/>
</shape>
\ No newline at end of file
sobot_album/src/main/res/drawable/sobot_bg_download_color_9dp.xml
0 → 100644
View file @
080439e2
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<solid
android:color=
"@color/albumdownBg"
/>
<corners
android:radius=
"18dp"
/>
</shape>
\ No newline at end of file
sobot_album/src/main/res/layout/fragment_img_item.xml
View file @
080439e2
...
...
@@ -7,6 +7,7 @@
android:id=
"@+id/sobot_item_iv"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:scaleType=
"centerCrop"
/>
</LinearLayout>
\ No newline at end of file
sobot_album/src/main/res/layout/sobot_activity_album_preview.xml
0 → 100644
View file @
080439e2
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
style=
"@style/MatchParent"
android:background=
"@color/albumColorPrimaryBlack"
android:orientation=
"vertical"
>
<!--头部帖标题-->
<RelativeLayout
android:id=
"@+id/sobot_layout_titlebar"
android:layout_width=
"match_parent"
android:layout_height=
"@dimen/sobot_titlebar_height"
android:background=
"@color/albumSheetBottom"
>
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_centerVertical=
"true"
android:orientation=
"horizontal"
>
<TextView
android:id=
"@+id/sobot_tv_left"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:drawableLeft=
"@drawable/sobot_icon_back"
android:drawablePadding=
"5dp"
android:gravity=
"center_vertical"
android:paddingStart=
"10dp"
android:paddingLeft=
"10dp"
android:textColor=
"@color/sobot_color_title_bar_menu_text"
android:textSize=
"@dimen/sobot_titlebar_title_size"
/>
<LinearLayout
android:id=
"@+id/sobot_header_center_ll"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_centerInParent=
"true"
android:layout_marginStart=
"80dp"
android:layout_marginLeft=
"80dp"
android:layout_marginEnd=
"80dp"
android:layout_marginRight=
"80dp"
android:gravity=
"center"
android:orientation=
"horizontal"
>
<TextView
android:id=
"@+id/sobot_text_title_center"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:ellipsize=
"end"
android:singleLine=
"true"
android:textColor=
"@color/sobot_color_title_bar_title"
android:textSize=
"@dimen/sobot_titlebar_title_size"
android:textStyle=
"bold"
android:visibility=
"visible"
/>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
<!--中间图片、视频-->
<FrameLayout
style=
"@style/MatchParent"
android:layout_weight=
"1"
>
<com.sobot.album.widget.photoview.FixViewPager
android:id=
"@+id/view_pager"
style=
"@style/MatchParent"
android:layout_weight=
"1"
/>
<TextView
android:id=
"@+id/sobot_tv_page"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"top|center_horizontal"
android:layout_marginTop=
"28dp"
android:background=
"@drawable/sobot_bg_download_color_3dp"
android:paddingTop=
"5dp"
android:paddingBottom=
"5dp"
android:paddingLeft=
"12dp"
android:paddingRight=
"12dp"
android:paddingStart=
"12dp"
android:paddingEnd=
"12dp"
android:textColor=
"@color/sobot_white"
android:textSize=
"12sp"
/>
<TextView
android:id=
"@+id/sobot_tv_download"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"bottom|center_horizontal"
android:layout_marginBottom=
"20dp"
android:background=
"@drawable/sobot_bg_download_color_9dp"
android:gravity=
"center"
android:paddingTop=
"5dp"
android:paddingBottom=
"5dp"
android:paddingLeft=
"18dp"
android:paddingRight=
"18dp"
android:paddingStart=
"18dp"
android:paddingEnd=
"18dp"
android:text=
"@string/sobot_download"
android:textColor=
"@color/sobot_white"
android:textSize=
"12sp"
/>
</FrameLayout>
<FrameLayout
style=
"@style/Album.WrapContent.WidthMatchParent"
android:layout_alignParentBottom=
"true"
>
<FrameLayout
android:id=
"@+id/layout_layer"
style=
"@style/Album.MatchParent.SheetBottom"
android:background=
"@color/albumSheetLayer"
android:visibility=
"gone"
>
<TextView
style=
"@style/Album.WrapContent"
android:layout_gravity=
"center"
android:text=
"@string/album_item_unavailable"
android:textColor=
"@color/albumFontLight"
android:textSize=
"@dimen/album_sp_18"
/>
</FrameLayout>
</FrameLayout>
</LinearLayout>
\ No newline at end of file
sobot_album/src/main/res/values/colors.xml
View file @
080439e2
...
...
@@ -34,4 +34,5 @@
<color
name=
"albumSheetBottom"
>
#992B2B2B
</color>
<color
name=
"albumSheetLayer"
>
#EE2B2B2B
</color>
<color
name=
"albumdownBg"
>
#CC999999
</color>
</resources>
\ No newline at end of file
sobot_album/src/main/res/values/dimens.xml
View file @
080439e2
...
...
@@ -44,6 +44,7 @@
<dimen
name=
"sobot_dialog_list_min_h"
>
150dp
</dimen>
<dimen
name=
"album_sp_12"
>
12sp
</dimen>
<dimen
name=
"album_sp_14"
>
14sp
</dimen>
<dimen
name=
"album_sp_16"
>
16sp
</dimen>
<dimen
name=
"album_sp_18"
>
18sp
</dimen>
...
...
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