-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a2b28cb
commit b67559b
Showing
15 changed files
with
291 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
app/src/main/java/com/yenaly/duanzile/ui/activity/PicViewActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.yenaly.duanzile.ui.activity | ||
|
||
import android.os.Bundle | ||
import android.widget.LinearLayout | ||
import androidx.viewpager2.widget.ViewPager2 | ||
import com.yenaly.duanzile.R | ||
import com.yenaly.duanzile.TO_PIC_VIEW_URLS | ||
import com.yenaly.duanzile.databinding.ActivityPicViewBinding | ||
import com.yenaly.duanzile.ui.adapter.PicViewVpAdapter | ||
import com.yenaly.duanzile.ui.viewmodel.PicViewViewModel | ||
import com.yenaly.yenaly_libs.base.YenalyActivity | ||
import com.yenaly.yenaly_libs.utils.SystemStatusUtil | ||
import com.yenaly.yenaly_libs.utils.intentExtra | ||
import com.yenaly.yenaly_libs.utils.statusBarHeight | ||
|
||
/** | ||
* @ProjectName : BlViewer | ||
* @Author : Yenaly Liew | ||
* @Time : 2022/06/01 001 22:59 | ||
* @Description : Description... | ||
*/ | ||
class PicViewActivity : YenalyActivity<ActivityPicViewBinding, PicViewViewModel>() { | ||
|
||
private lateinit var picViewAdapter: PicViewVpAdapter | ||
private val position = 0 | ||
private val urlsList by intentExtra(TO_PIC_VIEW_URLS, emptyList<String>()) | ||
|
||
override fun setUiStyle() { | ||
SystemStatusUtil.fullScreen(window, true) | ||
} | ||
|
||
override fun initData(savedInstanceState: Bundle?) { | ||
|
||
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out) | ||
|
||
picViewAdapter = PicViewVpAdapter(urlsList) | ||
|
||
binding.pvaViewPager.adapter = picViewAdapter | ||
binding.pvaViewPager.setCurrentItem(position, false) | ||
val emptyLayoutParams = | ||
LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, statusBarHeight) | ||
binding.emptyView.layoutParams = emptyLayoutParams | ||
|
||
val totalPage = urlsList.size | ||
binding.picPosition.text = getString(R.string.pic_view_position, position + 1, totalPage) | ||
binding.pvaViewPager.registerOnPageChangeCallback( | ||
object : ViewPager2.OnPageChangeCallback() { | ||
override fun onPageSelected(position: Int) { | ||
super.onPageSelected(position) | ||
binding.picPosition.text = | ||
getString(R.string.pic_view_position, position + 1, totalPage) | ||
} | ||
} | ||
) | ||
|
||
binding.btnBack.setOnClickListener { | ||
finish() | ||
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out) | ||
} | ||
} | ||
|
||
override fun onBackPressed() { | ||
super.onBackPressed() | ||
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out) | ||
} | ||
|
||
override fun onNavigateUp(): Boolean { | ||
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out) | ||
return super.onNavigateUp() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
app/src/main/java/com/yenaly/duanzile/ui/adapter/PicViewVpAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.yenaly.duanzile.ui.adapter | ||
|
||
import android.content.Context | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.core.view.isInvisible | ||
import androidx.core.view.isVisible | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.bumptech.glide.Glide | ||
import com.yenaly.duanzile.R | ||
import com.yenaly.duanzile.databinding.ItemPicViewBinding | ||
import com.yenaly.yenaly_libs.utils.SystemStatusUtil | ||
import com.yenaly.yenaly_libs.utils.activity | ||
import com.yenaly.yenaly_libs.utils.setSystemBarIconLightMode | ||
|
||
/** | ||
* @project Duanzile | ||
* @author Yenaly Liew | ||
* @time 2022/07/25 025 18:32 | ||
*/ | ||
class PicViewVpAdapter(private val data: List<String>) : | ||
RecyclerView.Adapter<PicViewVpAdapter.ViewHolder>() { | ||
|
||
private var recyclerView: RecyclerView? = null | ||
|
||
private val context: Context | ||
get() { | ||
checkNotNull(recyclerView) { | ||
"You have not attached adapter to RecyclerView!" | ||
} | ||
return recyclerView!!.context | ||
} | ||
|
||
override fun onAttachedToRecyclerView(recyclerView: RecyclerView) { | ||
super.onAttachedToRecyclerView(recyclerView) | ||
this.recyclerView = recyclerView | ||
} | ||
|
||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { | ||
val binding = ItemPicViewBinding.bind(view) | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | ||
val view = | ||
LayoutInflater.from(parent.context).inflate(R.layout.item_pic_view, parent, false) | ||
val viewHolder = ViewHolder(view) | ||
val activity = context.activity ?: throw NullPointerException("???") | ||
val fullToolbar: View = activity.findViewById(R.id.pva_full_toolbar) | ||
viewHolder.binding.photoView.setOnPhotoTapListener { _, _, _ -> | ||
fullToolbar.isInvisible = fullToolbar.isVisible | ||
SystemStatusUtil.fullScreen(activity.window, true, true) | ||
activity.window.setSystemBarIconLightMode(fullToolbar.isInvisible) | ||
} | ||
return viewHolder | ||
} | ||
|
||
override fun onBindViewHolder(holder: ViewHolder, position: Int) { | ||
Glide.with(context).load(data[position]).into(holder.binding.photoView) | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return data.size | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
app/src/main/java/com/yenaly/duanzile/ui/viewmodel/PicViewViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.yenaly.duanzile.ui.viewmodel | ||
|
||
import android.app.Application | ||
import com.yenaly.yenaly_libs.base.YenalyViewModel | ||
|
||
/** | ||
* @ProjectName : BlViewer | ||
* @Author : Yenaly Liew | ||
* @Time : 2022/06/01 001 23:03 | ||
* @Description : Description... | ||
*/ | ||
class PicViewViewModel(application: Application) : YenalyViewModel(application) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<vector android:autoMirrored="true" android:height="24dp" | ||
android:tint="?attr/colorControlNormal" android:viewportHeight="24" | ||
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<data> | ||
|
||
</data> | ||
|
||
<androidx.coordinatorlayout.widget.CoordinatorLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:animateLayoutChanges="true" | ||
android:background="@color/black"> | ||
|
||
<androidx.viewpager2.widget.ViewPager2 | ||
android:id="@+id/pva_view_pager" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" /> | ||
|
||
<LinearLayout | ||
android:id="@+id/pva_full_toolbar" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:animateLayoutChanges="true" | ||
android:background="@color/pic_view_action_bar_color" | ||
android:orientation="vertical"> | ||
|
||
<View | ||
android:id="@+id/empty_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="0dp" | ||
android:background="@color/pic_view_action_bar_color" /> | ||
|
||
<androidx.appcompat.widget.Toolbar | ||
android:id="@+id/pva_toolbar" | ||
android:layout_width="match_parent" | ||
android:layout_height="?attr/actionBarSize" | ||
android:animateLayoutChanges="true" | ||
android:background="@color/pic_view_action_bar_color"> | ||
|
||
<ImageButton | ||
android:id="@+id/btn_back" | ||
android:layout_width="24dp" | ||
android:layout_height="24dp" | ||
android:layout_marginEnd="16dp" | ||
android:background="@drawable/ic_baseline_arrow_back_24" | ||
android:contentDescription="@null" | ||
android:theme="@style/Theme.Material3.Dark" /> | ||
|
||
<TextView | ||
android:id="@+id/pic_position" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginEnd="16dp" | ||
android:ellipsize="end" | ||
android:singleLine="true" | ||
android:textAppearance="?attr/textAppearanceTitleLarge" | ||
android:textColor="@color/white" | ||
tools:text="1 of 2" /> | ||
|
||
</androidx.appcompat.widget.Toolbar> | ||
|
||
</LinearLayout> | ||
|
||
|
||
</androidx.coordinatorlayout.widget.CoordinatorLayout> | ||
|
||
</layout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<data> | ||
|
||
</data> | ||
|
||
<androidx.coordinatorlayout.widget.CoordinatorLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<com.github.chrisbanes.photoview.PhotoView | ||
android:id="@+id/photo_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:fitsSystemWindows="true" /> | ||
|
||
</androidx.coordinatorlayout.widget.CoordinatorLayout> | ||
|
||
</layout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters