Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
beyond-clouds-android
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
云深项目组
beyond-clouds-android
Commits
21d72c4f
Commit
21d72c4f
authored
Mar 25, 2020
by
段启岩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
图片浏览器基本功能完成
parent
21821cc0
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
133 additions
and
2 deletions
+133
-2
app/build.gradle
+2
-2
app/src/main/AndroidManifest.xml
+2
-0
app/src/main/java/cn/yunliyunwai/beyondclouds/ui/common/PhotoViewerActivity.java
+85
-0
app/src/main/java/cn/yunliyunwai/beyondclouds/ui/handler/NavHandlers.java
+7
-0
app/src/main/java/cn/yunliyunwai/beyondclouds/view/DynamicGridLayout.java
+8
-0
app/src/main/res/layout/activity_photoviewer.xml
+13
-0
app/src/main/res/layout/fragment_photo.xml
+16
-0
No files found.
app/build.gradle
View file @
21d72c4f
...
...
@@ -8,8 +8,8 @@ android {
applicationId
"cn.yunliyunwai.beyondclouds"
minSdkVersion
19
targetSdkVersion
29
versionCode
1
versionName
"
1
.0"
versionCode
2
versionName
"
2
.0"
testInstrumentationRunner
"androidx.test.runner.AndroidJUnitRunner"
...
...
app/src/main/AndroidManifest.xml
View file @
21d72c4f
...
...
@@ -43,6 +43,7 @@
<activity
android:name=
".ui.question.QuestionDetailActivity"
/>
<activity
android:name=
".ui.settings.SettingsActivity"
/>
<activity
android:name=
".ui.user.UserHomeActivity"
/>
<activity
android:name=
".ui.common.PhotoViewerActivity"
android:theme=
"@style/AppTheme.FullScreen"
/>
</application>
</manifest>
\ No newline at end of file
app/src/main/java/cn/yunliyunwai/beyondclouds/ui/common/PhotoViewerActivity.java
0 → 100644
View file @
21d72c4f
package
cn
.
yunliyunwai
.
beyondclouds
.
ui
.
common
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.fragment.app.Fragment
;
import
androidx.fragment.app.FragmentManager
;
import
androidx.fragment.app.FragmentPagerAdapter
;
import
com.bumptech.glide.Glide
;
import
cn.yunliyunwai.beyondclouds.databinding.ActivityPhotoviewerBinding
;
import
cn.yunliyunwai.beyondclouds.databinding.FragmentPhotoBinding
;
public
class
PhotoViewerActivity
extends
AppCompatActivity
{
public
static
final
String
ARGS_PHOTO_LINKS
=
"PHOTO_LINKS"
;
ActivityPhotoviewerBinding
binding
;
private
String
[]
mPhotos
;
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
binding
=
ActivityPhotoviewerBinding
.
inflate
(
getLayoutInflater
());
setContentView
(
binding
.
getRoot
());
Intent
intent
=
getIntent
();
mPhotos
=
intent
.
getStringArrayExtra
(
ARGS_PHOTO_LINKS
);
PhotosPagerAdapter
adapter
=
new
PhotosPagerAdapter
(
getSupportFragmentManager
(),
mPhotos
);
binding
.
viewPager
.
setAdapter
(
adapter
);
}
public
static
class
PhotosPagerAdapter
extends
FragmentPagerAdapter
{
private
String
[]
mPhotos
;
public
PhotosPagerAdapter
(
FragmentManager
fm
,
String
[]
mPhotos
)
{
super
(
fm
,
BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT
);
this
.
mPhotos
=
mPhotos
;
}
@NonNull
@Override
public
Fragment
getItem
(
int
position
)
{
return
new
PhotoFragment
(
mPhotos
[
position
]);
}
@Override
public
int
getCount
()
{
return
mPhotos
.
length
;
}
}
public
static
class
PhotoFragment
extends
Fragment
{
FragmentPhotoBinding
binding
;
private
String
mPhoto
;
public
PhotoFragment
(
String
photo
)
{
this
.
mPhoto
=
photo
;
}
@Nullable
@Override
public
View
onCreateView
(
@NonNull
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
binding
=
FragmentPhotoBinding
.
inflate
(
inflater
,
container
,
false
);
return
binding
.
getRoot
();
}
@Override
public
void
onViewCreated
(
@NonNull
View
view
,
@Nullable
Bundle
savedInstanceState
)
{
super
.
onViewCreated
(
view
,
savedInstanceState
);
Glide
.
with
(
view
).
load
(
mPhoto
).
centerInside
().
into
(
binding
.
imgView
);
}
}
}
app/src/main/java/cn/yunliyunwai/beyondclouds/ui/handler/NavHandlers.java
View file @
21d72c4f
...
...
@@ -6,6 +6,7 @@ import android.view.View;
import
android.widget.Toast
;
import
cn.yunliyunwai.beyondclouds.ui.ToastUtils
;
import
cn.yunliyunwai.beyondclouds.ui.common.PhotoViewerActivity
;
import
cn.yunliyunwai.beyondclouds.ui.login.LoginActivity
;
import
cn.yunliyunwai.beyondclouds.ui.settings.SettingsActivity
;
import
cn.yunliyunwai.beyondclouds.ui.user.UserHomeActivity
;
...
...
@@ -205,4 +206,10 @@ public class NavHandlers {
intent
.
putExtra
(
UserHomeActivity
.
ARG_USER_ID
,
userId
);
view
.
getContext
().
startActivity
(
intent
);
}
public
static
void
toPhotoViewer
(
View
view
,
String
[]
photoLinks
)
{
Intent
intent
=
new
Intent
(
view
.
getContext
(),
PhotoViewerActivity
.
class
);
intent
.
putExtra
(
PhotoViewerActivity
.
ARGS_PHOTO_LINKS
,
photoLinks
);
view
.
getContext
().
startActivity
(
intent
);
}
}
app/src/main/java/cn/yunliyunwai/beyondclouds/view/DynamicGridLayout.java
View file @
21d72c4f
...
...
@@ -4,6 +4,7 @@ import android.content.Context;
import
android.graphics.drawable.BitmapDrawable
;
import
android.os.Build
;
import
android.util.AttributeSet
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.ImageView
;
...
...
@@ -24,6 +25,7 @@ import com.bumptech.glide.request.target.Target;
import
java.util.List
;
import
cn.yunliyunwai.beyondclouds.R
;
import
cn.yunliyunwai.beyondclouds.ui.handler.NavHandlers
;
/**
* 动态九宫格布局
...
...
@@ -126,6 +128,12 @@ public class DynamicGridLayout extends ViewGroup {
int
left
=
computePosition
(
currentCol
,
imageSize
)
+
getPaddingLeft
();
int
top
=
computePosition
(
currentRow
,
imageSize
)
+
getPaddingTop
();
imageView
.
layout
(
left
,
top
,
left
+
imageSize
,
top
+
imageSize
);
imageView
.
setOnClickListener
(
new
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
NavHandlers
.
toPhotoViewer
(
v
,
mImgUrls
.
toArray
(
new
String
[
0
]));
}
});
}
isImageInit
=
true
;
}
...
...
app/src/main/res/layout/activity_photoviewer.xml
0 → 100644
View file @
21d72c4f
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
android:background=
"#000000"
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<androidx.viewpager.widget.ViewPager
android:id=
"@+id/view_pager"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/fragment_photo.xml
0 → 100644
View file @
21d72c4f
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ImageView
android:id=
"@+id/img_view"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ 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