Last updated
Last updated
The following directories lie inside the android studio project:
Describing Code :
Line 3 to 12 import packages required to create view for displaying files
Line 14 defines a class FilesAdapter that aims to converts the list of files data into a RecyclerView.
In the class following variables are defined
files: To hold list of Files uploaded to Allocation(Line 15)
A private variable that holds value for list of files converted to recyclable view on a mouse click.(Line 16 )
Line 19 to 25 defines A ViewHolder class that describes how a file view and metadata about its place within the RecyclerView.
Line 28 to 32 overrides the method onCreateViewHolder
which creates a new ViewHolder object and initializes some private fields to be used by RecyclerView.
Line 34 to 46 overrides onBindViewHolder method which is called by RecyclerView to display the files data at the specified position.
Also , If the download button is clicked for a document or image then also hold the view for download progress bar in a recyclable view.
Line 48 to 51 overrides the function getItemCount() to get the number of files in the list.
Line 53 to 55 defines an interface FileClickListener
that executes functions on file click.
Describing Code :
Line 3 to 36 import libraries required to create Vult UI .See of app for reference
At line 41,Class VultFragment
defines the following properties and fields for creating the Storage UI .
A late initialized private writable binding variable that can bind UI components in layouts to data sources in your app.(Line 42)
Line 43 and 44 defines variables to hold vultVIew and main app view.
Line 43 defines method for creating the Vult UI view
a) override fun
. This is just us overriding the function called onCreateView that is inherited from the Fragment class.
b) onCreateView()
method is called and assuming that we have provided our own VultFragment(Storage UI) with a non-null view(via view binding) the view returned from here will be visible to user.
Line 59 to 86 defines a file picker when user clicks on Upload File in the app. By default it takes file from our system home path. Checko see Upload File Picker
Line 88 to 111 defines a photo picker when user clicks on Upload Photo.Checkto see Upload Photo
Picker.
Line 114 to 192 make use of FilesAdapter and defines following
On mouse click listeners for Upload Image and Upload File and binds it to view(Line 127 to 137)
Line 148 to 152 makes use of functions defined by to retrieve allocation Data. If allocation data is not there create allocation.
Line 189 and 191 calls functions defined in VultVIew Model class to get allocation details and listed files
Line 197 defines function for making copies of file uploaded to Allocation.
Line 250 to 254 defines function onDownloadFileCliick
for downloading the file on mouse click after uploading
Line 295 defines function onFIleClick
for managing file click functionality in files uploaded to Allocation. In case file clicked does not exist prompts to download the file first and if file is not available for download then displays error no file found.
Describiing Code:
Line 23 VultViewModel
class utilizes the libraries/functions and provide the following functionalities for
(Line 102 to 131) createAllocation
: Create Allocation/ Storage Space on storage network.
(Line 173 to 190) getAllocation
: Get Allocation Information
(Line 211 to 239 )uploadFile
: Upload File to an Allocation/Storage Space.
(Line 241 to 258) downloadFile
:Download files from Allocation
(Line 260 to 273) listFiles
: List files stored in an allocation.
Line 275 to 283)getBlobberUrlsAndId
:
Get storage provider URL and ID to host allocation for storing files
(Line 296 to 305) getBlobbers
: Get list of available storage providers on the network