-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from emreesen27/v1.0.0-beta6
V1.0.0 beta6
- Loading branch information
Showing
37 changed files
with
667 additions
and
319 deletions.
There are no files selected for viewing
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
59 changes: 59 additions & 0 deletions
59
app/src/main/java/com/sn/snfilemanager/core/base/BaseDialog.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,59 @@ | ||
package com.sn.snfilemanager.core.base | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.constraintlayout.widget.ConstraintLayout | ||
import androidx.fragment.app.DialogFragment | ||
import androidx.fragment.app.FragmentManager | ||
import androidx.viewbinding.ViewBinding | ||
import com.sn.snfilemanager.R | ||
|
||
abstract class BaseDialog<VBinding : ViewBinding> : DialogFragment() { | ||
protected lateinit var binding: VBinding | ||
|
||
protected abstract fun getViewBinding(): VBinding | ||
|
||
open var setCancelable: Boolean = true | ||
|
||
protected abstract val dialogTag: String | ||
|
||
open fun setupViews() {} | ||
|
||
fun showDialog(fragmentManager: FragmentManager) { | ||
show(fragmentManager, dialogTag) | ||
} | ||
|
||
override fun onStart() { | ||
super.onStart() | ||
dialog?.window?.setLayout( | ||
ConstraintLayout.LayoutParams.MATCH_PARENT, | ||
ConstraintLayout.LayoutParams.WRAP_CONTENT, | ||
) | ||
} | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = getViewBinding() | ||
isCancelable = setCancelable | ||
setStyle(STYLE_NO_TITLE, R.style.DialogTheme_transparent) | ||
dialog?.window?.setBackgroundDrawableResource(R.drawable.dialog_rounded) | ||
} | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle?, | ||
): View? { | ||
return binding.root | ||
} | ||
|
||
override fun onViewCreated( | ||
view: View, | ||
savedInstanceState: Bundle?, | ||
) { | ||
super.onViewCreated(view, savedInstanceState) | ||
setupViews() | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
app/src/main/java/com/sn/snfilemanager/core/util/FileUtils.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,23 @@ | ||
package com.sn.snfilemanager.core.util | ||
|
||
import com.sn.snfilemanager.feature.files.data.FileModel | ||
import com.sn.snfilemanager.feature.files.data.toFileModel | ||
import java.nio.file.Files | ||
import java.nio.file.Paths | ||
import java.util.stream.Collectors | ||
|
||
object FileUtils { | ||
fun getTotalSizeAndFileCount(itemList: List<FileModel>): Pair<Long, Long> = | ||
itemList.fold(Pair(0L, 0L)) { acc, item -> | ||
if (item.isDirectory && Files.isReadable(Paths.get(item.absolutePath))) { | ||
val childResult = | ||
getTotalSizeAndFileCount( | ||
Files.list(Paths.get(item.absolutePath)).collect(Collectors.toList()) | ||
.map { it.toFileModel() }, | ||
) | ||
Pair(acc.first + childResult.first, acc.second + childResult.second) | ||
} else { | ||
Pair(acc.first + item.size, acc.second + 1) | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.