-
Notifications
You must be signed in to change notification settings - Fork 2
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
826d0dc
commit da0c722
Showing
15 changed files
with
126 additions
and
244 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
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
34 changes: 34 additions & 0 deletions
34
...sample/src/main/java/com/omh/android/storage/sample/drive/adapter/grid/FileGridAdapter.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,34 @@ | ||
package com.omh.android.storage.sample.drive.adapter.grid | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.omh.android.storage.api.domain.model.OmhFile | ||
import com.omh.android.storage.sample.databinding.RvItemFilefolderGridBinding | ||
|
||
class FileGridAdapter : RecyclerView.Adapter<FileGridViewHolder>() { | ||
|
||
private val files = mutableListOf<OmhFile>() | ||
|
||
override fun getItemCount() = files.size | ||
|
||
override fun onCreateViewHolder( | ||
parent: ViewGroup, | ||
viewType: Int, | ||
): FileGridViewHolder = FileGridViewHolder( | ||
RvItemFilefolderGridBinding.inflate( | ||
LayoutInflater.from(parent.context), parent, false | ||
) | ||
) | ||
|
||
override fun onBindViewHolder(holder: FileGridViewHolder, position: Int) { | ||
holder.bind(files[position]) | ||
} | ||
|
||
fun addAll(items: List<OmhFile>) { | ||
files.clear() | ||
files.addAll(items) | ||
notifyDataSetChanged() | ||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
...ple/src/main/java/com/omh/android/storage/sample/drive/adapter/grid/FileGridViewHolder.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,52 @@ | ||
package com.omh.android.storage.sample.drive.adapter.grid | ||
|
||
import android.widget.ImageView | ||
import android.widget.TextView | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.bumptech.glide.Glide | ||
import com.omh.android.storage.api.domain.model.OmhFile | ||
import com.omh.android.storage.api.domain.model.OmhFileType | ||
import com.omh.android.storage.sample.R | ||
import com.omh.android.storage.sample.databinding.RvItemFilefolderGridBinding | ||
|
||
class FileGridViewHolder( | ||
binding: RvItemFilefolderGridBinding | ||
) : RecyclerView.ViewHolder(binding.root) { | ||
|
||
private val fileIcon: ImageView = binding.ivFileGridItem | ||
private val fileName: TextView = binding.tvFileFolderGridItemName | ||
|
||
private fun loadFileImage(url: String) { | ||
Glide.with(itemView) | ||
.asBitmap() | ||
.load(url) | ||
.centerCrop() | ||
.placeholder(R.mipmap.ic_launcher) | ||
.into(fileIcon) | ||
} | ||
|
||
fun bind(file: OmhFile) { | ||
fileName.text = file.name | ||
|
||
val iconLink = when (file.fileType) { | ||
OmhFileType.PDF -> "https://drive-thirdparty.googleusercontent.com/32/type/application/pdf" | ||
|
||
OmhFileType.DOCUMENT, | ||
OmhFileType.MICROSOFT_WORD, | ||
OmhFileType.OPEN_DOCUMENT_TEXT -> "https://drive-thirdparty.googleusercontent.com/32/type/application/vnd.google-apps.document" | ||
|
||
OmhFileType.SPREADSHEET, | ||
OmhFileType.MICROSOFT_EXCEL, | ||
OmhFileType.OPEN_DOCUMENT_SPREADSHEET -> "https://drive-thirdparty.googleusercontent.com/32/type/application/vnd.google-apps.spreadsheet" | ||
|
||
OmhFileType.PNG -> "https://drive-thirdparty.googleusercontent.com/32/type/image/png" | ||
|
||
OmhFileType.ZIP -> "https://drive-thirdparty.googleusercontent.com/32/type/application/zip" | ||
|
||
else -> "https://static.thenounproject.com/png/3482632-200.png" | ||
} | ||
|
||
loadFileImage(iconLink) | ||
} | ||
|
||
} |
38 changes: 0 additions & 38 deletions
38
...e/src/main/java/com/omh/android/storage/sample/drive/adapter/grid/FileInGridViewHolder.kt
This file was deleted.
Oops, something went wrong.
57 changes: 0 additions & 57 deletions
57
...rc/main/java/com/omh/android/storage/sample/drive/adapter/grid/FilesFoldersGridAdapter.kt
This file was deleted.
Oops, something went wrong.
39 changes: 0 additions & 39 deletions
39
...src/main/java/com/omh/android/storage/sample/drive/adapter/grid/FolderInGridViewHolder.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.