Skip to content

Commit

Permalink
修复一直loading bug和样式问题
Browse files Browse the repository at this point in the history
  • Loading branch information
hxg committed Oct 28, 2021
1 parent 8a22e90 commit 8afc350
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 42 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:requestLegacyExternalStorage="true"
android:theme="@style/Theme.Demo">
<activity
android:name=".MainActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in

}

private ArrayList<String> docPaths = new ArrayList<>();

private void filePicker() {
String[] zips = {"zip", "rar"};
String[] doc = {"doc", "docx"};
Expand All @@ -77,8 +79,8 @@ private void filePicker() {
String[] music = {"m3u", "m4a", "m4b", "m4p", "ogg", "wma", "wmv", "ogg", "rmvb", "mp2", "mp3", "aac", "awb", "amr", "mka"};
FilePickerBuilder.getInstance()
.setMaxCount(9)
// .setSelectedFiles(docPaths)
// .setActivityTheme(R.style.DarkTheme2)
.setSelectedFiles(docPaths)
.setActivityTheme(R.style.LibAppTheme)
.enableCameraSupport(false)
.showPic(true)
.showVideo(true)
Expand All @@ -103,6 +105,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
if (requestCode == REQUEST_CODE_FILE) {//选择文件
ArrayList<String> filePaths = data.getStringArrayListExtra(FilePickerConst.KEY_SELECTED_DOCS);
docPaths.addAll(filePaths);
Toast.makeText(this, filePaths.toString(), Toast.LENGTH_SHORT).show();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import android.os.Bundle
import androidx.annotation.LayoutRes
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar

//import com.netease.nim.uikit.common.activity.UI
import com.google.android.material.appbar.MaterialToolbar

/**
* Created by droidNinja on 22/07/17.
Expand All @@ -15,12 +14,11 @@ abstract class BaseFilePickerActivity : AppCompatActivity() {

protected fun onCreate(savedInstanceState: Bundle?, @LayoutRes layout: Int) {
super.onCreate(savedInstanceState)
// setTheme(PickerManager.theme)
setTheme(PickerManager.theme)
setContentView(layout)

val toolbar = findViewById<Toolbar>(R.id.toolbar)
// fixme 这里有bug
// setSupportActionBar(toolbar)
val toolbar = findViewById<MaterialToolbar>(R.id.toolbar)
setSupportActionBar(toolbar)
supportActionBar?.setDisplayHomeAsUpEnabled(true)

//set orientation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import android.os.Bundle
import android.view.View
import androidx.viewpager.widget.ViewPager
import com.google.android.material.tabs.TabLayout

import com.xiaoguang.widget.filepicker.FilePickerConst
import com.xiaoguang.widget.filepicker.PickerManager
import com.xiaoguang.widget.filepicker.R
Expand Down Expand Up @@ -72,7 +71,7 @@ class DocPickerFragment : BaseFragment(), ViewPager.OnPageChangeListener {
val supportedTypes = PickerManager.getFileTypes()
//添加fragment
if (PickerManager.showPic) {
adapter!!.addFragment(MediaFolderPickerFragment.newInstance(FilePickerConst.MEDIA_TYPE_IMAGE), getString(R.string.images))
adapter!!.addFragment(MediaFolderPickerFragment.newInstance(FilePickerConst.MEDIA_TYPE_IMAGE), getString(R.string.image))
}
if (PickerManager.showVideo) {
adapter!!.addFragment(MediaFolderPickerFragment.newInstance(FilePickerConst.MEDIA_TYPE_VIDEO), getString(R.string.video))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.view.*
import android.widget.ProgressBar
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.widget.TextView
import android.widget.Toast
import androidx.recyclerview.widget.DefaultItemAnimator
Expand All @@ -15,9 +17,9 @@ import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.StaggeredGridLayoutManager
import com.bumptech.glide.Glide
import com.bumptech.glide.RequestManager

import com.xiaoguang.widget.filepicker.FilePickerConst
import com.xiaoguang.widget.filepicker.PickerManager
import com.xiaoguang.widget.filepicker.R
import com.xiaoguang.widget.filepicker.adapters.FileAdapterListener
import com.xiaoguang.widget.filepicker.adapters.PhotoGridAdapter
import com.xiaoguang.widget.filepicker.cursors.loadercallbacks.FileResultCallback
Expand All @@ -27,15 +29,14 @@ import com.xiaoguang.widget.filepicker.utils.AndroidLifecycleUtils
import com.xiaoguang.widget.filepicker.utils.ImageCaptureManager
import java.io.IOException
import java.util.*
import com.xiaoguang.widget.filepicker.R

/**
* 文件选择
*/
class MediaDetailPickerFragment : BaseFragment(), FileAdapterListener {
lateinit var recyclerView: RecyclerView

lateinit var emptyView: TextView
private var progressBar: ProgressBar? = null
private var mListener: PhotoPickerFragmentListener? = null
private var photoGridAdapter: PhotoGridAdapter? = null
private var imageCaptureManager: ImageCaptureManager? = null
Expand Down Expand Up @@ -81,7 +82,6 @@ class MediaDetailPickerFragment : BaseFragment(), FileAdapterListener {

override fun initView(view: View) {
recyclerView = view.findViewById(R.id.recyclerview)
progressBar = view.findViewById(R.id.progress_bar)
emptyView = view.findViewById(R.id.empty_view)
arguments?.let {
fileType = it.getInt(BaseFragment.FILE_TYPE)
Expand Down Expand Up @@ -125,7 +125,6 @@ class MediaDetailPickerFragment : BaseFragment(), FileAdapterListener {
MediaStoreHelper.getDirs(it.contentResolver, mediaStoreArgs,
object : FileResultCallback<PhotoDirectory> {
override fun onResultCallback(files: List<PhotoDirectory>) {
progressBar?.visibility = View.GONE
if (isAdded) {
updateList(files)
}
Expand Down
12 changes: 3 additions & 9 deletions filepicker/src/main/res/layout/activity_file_picker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,20 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:fitsSystemWindows="true"
android:orientation="vertical">

<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:elevation="0dp"
app:layout_scrollFlags="scroll|enterAlways">

<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:theme="@style/AppTheme.PopupOverlay"
app:titleTextAppearance="@style/MenuTextStyle" />
app:layout_scrollFlags="scroll|enterAlways" />

</com.google.android.material.appbar.AppBarLayout>

Expand Down
7 changes: 0 additions & 7 deletions filepicker/src/main/res/layout/fragment_doc_picker.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
Expand All @@ -19,10 +18,4 @@
android:layout_height="match_parent"
android:layout_below="@+id/tabs"/>

<ProgressBar
android:id="@+id/progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>

</RelativeLayout>
13 changes: 8 additions & 5 deletions filepicker/src/main/res/layout/fragment_photo_picker.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
android:layout_height="fill_parent" />

<TextView
android:id="@+id/empty_view"
Expand All @@ -18,6 +16,11 @@
android:text="@string/no_files_found"
android:textSize="25sp"
android:textStyle="bold"
android:visibility="gone"
/>
android:visibility="gone" />

<ProgressBar
android:id="@+id/progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
12 changes: 8 additions & 4 deletions filepicker/src/main/res/layout/item_doc_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@
android:maxLines="1"
android:textColor="@android:color/black"
android:textSize="@dimen/file_name_textSize"
tools:text="PPDF_112121.pdf"

/>
tools:text="PPDF_112121.pdf" />

<TextView
android:id="@+id/file_size_tv"
Expand All @@ -60,6 +58,7 @@
android:layout_below="@+id/file_name_tv"
android:layout_toEndOf="@+id/file_iv"
android:layout_toRightOf="@+id/file_iv"
android:textColor="@android:color/darker_gray"
tools:text="1.2MB" />


Expand All @@ -70,6 +69,11 @@
android:layout_height="@dimen/file_item_checkbox_size"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_margin="20dp" />
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="20dp" />

</RelativeLayout>
1 change: 1 addition & 0 deletions filepicker/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<string name="not_support_file_form">不支持該文件格式</string>
<string name="try_it">找不到?试试这里吧~</string>
<string name="video">视频</string>
<string name="image">图片</string>
<string name="camera_settings">没有相机权限,是否前往设置</string>
<string name="voice">音声</string>

Expand Down
1 change: 1 addition & 0 deletions filepicker/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<string name="not_support_file_form">The file format is not supported</string>
<string name="try_it">Can\'t find it? Try it here~</string>
<string name="video">Video</string>
<string name="image">Image</string>
<string name="camera_settings">There is no camera permission, do you want to go to setup</string>
<string name="voice">Voice</string>

Expand Down

0 comments on commit 8afc350

Please sign in to comment.