Commit 61e24108 authored by wanglei's avatar wanglei

初始化项目...

parent 3f3e62e3
......@@ -49,4 +49,7 @@ dependencies {
androidTestImplementation libs.androidx.espresso.core
implementation("com.blankj:utilcodex:1.31.1")
//ui第三方
implementation("com.github.JavaNoober.BackgroundLibrary:libraryx:1.7.6")
}
\ No newline at end of file
package com.base.superpdfreader
import android.annotation.SuppressLint
import android.graphics.Color
import android.os.Bundle
import android.util.Log
import android.widget.LinearLayout
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.updatePadding
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.base.superpdfreader.databinding.ActivityMainBinding
import com.base.superpdfreader.databinding.ItemTabBinding
import com.base.superpdfreader.fragment.DocumentListFragment
import com.base.superpdfreader.fragment.DocumentListFragment.Companion.MODE_DPF
import com.base.superpdfreader.fragment.DocumentListFragment.Companion.MODE_PPT
import com.base.superpdfreader.fragment.DocumentListFragment.Companion.MODE_WORD
import com.base.superpdfreader.helps.BaseActivity
import com.blankj.utilcode.util.BarUtils
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator
class MainActivity : BaseActivity<ActivityMainBinding>() {
override val binding: ActivityMainBinding by lazy {
ActivityMainBinding.inflate(layoutInflater)
}
private val pages = arrayListOf<DocumentListFragment>()
private val pdfFragment by lazy {
DocumentListFragment().apply { UI_MODE = MODE_DPF }
}
private val wordFragment by lazy {
DocumentListFragment().apply { UI_MODE = MODE_WORD }
}
private val pptFragment by lazy {
DocumentListFragment().apply { UI_MODE = MODE_PPT }
}
private val excelFragment by lazy {
DocumentListFragment().apply { UI_MODE = MODE_PPT }
}
private lateinit var pagerAdapter: DocumentPagerAdapter
override fun initView() {
BarUtils.setStatusBarLightMode(this, true)
BarUtils.setStatusBarColor(this, Color.TRANSPARENT)
initPage()
intTab()
}
private fun initPage() {
pages.add(pdfFragment)
pages.add(wordFragment)
pages.add(pptFragment)
pages.add(excelFragment)
pagerAdapter = DocumentPagerAdapter(this)
binding.viewpager2.adapter = pagerAdapter
}
@SuppressLint("SetTextI18n")
private fun intTab() {
val pdfBinding = ItemTabBinding.inflate(layoutInflater)
pdfBinding.tvTab.text = "PDF"
val pdfTab = binding.tabLayout.newTab()
pdfTab.customView = pdfBinding.root
binding.tabLayout.addTab(pdfTab)
val wordBinding = ItemTabBinding.inflate(layoutInflater)
wordBinding.tvTab.text = "Word"
val wordTab = binding.tabLayout.newTab()
wordTab.customView = pdfBinding.root
binding.tabLayout.addTab(wordTab)
val pptBinding = ItemTabBinding.inflate(layoutInflater)
wordBinding.tvTab.text = "PPT"
val pptTab = binding.tabLayout.newTab()
pptTab.customView = pptBinding.root
binding.tabLayout.addTab(pptTab)
val excelBinding = ItemTabBinding.inflate(layoutInflater)
wordBinding.tvTab.text = "Excel"
val excelTab = binding.tabLayout.newTab()
excelTab.customView = excelBinding.root
binding.tabLayout.addTab(excelTab)
binding.tabLayout.setTabRippleColorResource(android.R.color.transparent)
TabLayoutMediator(binding.tabLayout, binding.viewpager2, false) { tab, position ->
repeat(4) { index ->
// val tab=binding.tabLayout.
}
}.attach()
binding.viewpager2.currentItem = 0
}
inner class DocumentPagerAdapter(fa: FragmentActivity) : FragmentStateAdapter(fa) {
override fun getItemCount(): Int = pages.size
override fun createFragment(position: Int): Fragment = pages[position]
}
}
\ No newline at end of file
package com.base.superpdfreader.adapter
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import com.base.superpdfreader.bean.DocumentBean
class DocumentAdapter : RecyclerView.Adapter<DocumentAdapter.DDD>() {
private val docList = arrayListOf<DocumentBean>()
class DDD(view: View) : ViewHolder(view)
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DDD {
TODO("Not yet implemented")
}
override fun getItemCount(): Int {
return docList.size
}
override fun onBindViewHolder(holder: DDD, position: Int) {
TODO("Not yet implemented")
}
}
\ No newline at end of file
package com.base.superpdfreader.bean
import android.graphics.drawable.Drawable
data class DocumentBean(
val drawable: Int = 0,
val name: String = "",
val time: Long = 0,
val size: Long = 0
)
\ No newline at end of file
package com.base.superpdfreader.fragment
import com.base.superpdfreader.databinding.FragmentDocumentListBinding
import com.base.superpdfreader.helps.BaseFragment
class DocumentListFragment() : BaseFragment<FragmentDocumentListBinding>() {
var UI_MODE: String = MODE_DPF
override val binding: FragmentDocumentListBinding by lazy {
FragmentDocumentListBinding.inflate(layoutInflater)
}
override fun setView() {
}
companion object {
const val MODE_DPF = "PDF"
const val MODE_WORD = "WORD"
const val MODE_PPT = "PPT"
const val MODE_EXCEL = "EXCEL"
}
}
\ No newline at end of file
package com.base.superpdfreader.helps
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.viewbinding.ViewBinding
abstract class BaseFragment<T : ViewBinding> : Fragment() {
protected abstract val binding: T
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setView()
setListener()
}
protected abstract fun setView()
protected open fun setListener() {}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/white" />
<corners
android:topLeftRadius="15dp"
android:topRightRadius="15dp" />
</shape>
\ No newline at end of file
......@@ -12,6 +12,7 @@
android:id="@+id/ll_top"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color_pdf"
android:orientation="vertical"
app:layout_constraintTop_toTopOf="parent">
......@@ -32,8 +33,34 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:layout_marginBottom="36dp" />
android:layout_marginBottom="36dp"
android:background="@android:color/transparent"
app:tabContentStart="0dp"
app:tabGravity="fill"
app:tabIndicator="@null"
app:tabMode="fixed" />
</LinearLayout>
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/viewpager2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="-15dp"
android:background="@drawable/bg_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/ll_top">
</androidx.viewpager2.widget.ViewPager2>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="76dp"
android:layout_height="76dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="99dp"
app:layout_constraintBottom_toBottomOf="@id/viewpager2"
app:layout_constraintEnd_toEndOf="@id/viewpager2"
tools:ignore="ContentDescription" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragment.DocumentListFragment">
<FrameLayout
android:id="@+id/fl_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<LinearLayout
android:id="@+id/ll_empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:visibility="gone"
tools:ignore="UseCompoundDrawables">
<ImageView
android:id="@+id/iv_empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
tools:ignore="ContentDescription"
tools:src="@mipmap/home_notu" />
<TextView
android:id="@+id/tv_empty_tip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="24dp"
android:text="You don't hava any PDF document"
android:textColor="#5A5A5A"
android:textSize="15sp"
tools:ignore="HardcodedText" />
</LinearLayout>
</FrameLayout>
<LinearLayout
android:id="@+id/ll_permission"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
tools:ignore="UseCompoundDrawables">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="@mipmap/homequnxiantu"
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/tv_permission_tip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="48dp"
android:layout_marginTop="24dp"
android:gravity="center"
android:text="To read and edit your files, please allowSuper PDF Reader to ac"
tools:ignore="HardcodedText" />
<com.noober.background.view.BLTextView
android:id="@+id/tv_allow"
android:layout_width="280dp"
android:layout_height="44dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="24dp"
android:gravity="center"
android:text="Allow"
android:textColor="@color/white"
android:textSize="17sp"
android:textStyle="bold"
app:bl_corners_radius="10dp"
app:bl_solid_color="#FF3835"
tools:ignore="HardcodedText" />
</LinearLayout>
</FrameLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView 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"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="8dp"
android:layout_marginVertical="4dp"
app:cardBackgroundColor="@color/white"
app:cardCornerRadius="10dp"
app:cardElevation="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingVertical="20dp">
<ImageView
android:id="@+id/iv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="8dp"
android:minWidth="37dp"
android:minHeight="37dp"
tools:ignore="ContentDescription" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:textColor="@color/black"
tools:text="All Document.xls" />
<TextView
android:id="@+id/tv_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:textColor="#999999"
tools:text="05-05-2024 01:20 11.52KB" />
</LinearLayout>
<FrameLayout
android:id="@+id/fl_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="16dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@mipmap/genduo"
tools:ignore="ContentDescription" />
</FrameLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
\ No newline at end of file
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/tv_tab"
android:layout_width="80dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:gravity="center"
android:textSize="15sp"
app:bl_corners_radius="15dp"
app:bl_selected_solid_color="@color/white"
app:bl_unSelected_solid_color="@android:color/transparent"
tools:text="PDF" />
</LinearLayout>
\ No newline at end of file
......@@ -2,4 +2,9 @@
<resources>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="color_pdf">#FF3835</color>
<color name="color_word">#0F91FF</color>
<color name="color_ppt">#FF7A19</color>
<color name="color_excel">#1DD059</color>
<color name="color_white">#FFFFFF</color>
</resources>
\ No newline at end of file
<resources>
<string name="app_name">Super PDF Reader</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources>
\ No newline at end of file
......@@ -16,6 +16,11 @@ dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url "https://android-sdk.is.com" }
maven { url "https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea" }
maven { url "https://artifact.bytedance.com/repository/pangle" }
maven { url "https://s01.oss.sonatype.org/content/groups/public" }
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment