Skip to content

ADAssetListDataSource

duzexu edited this page Sep 18, 2021 · 4 revisions

ADAssetListDataSource

The data source of asset model controller. It get assets you request and reload the associate reloadable view when assets changed.

public class ADAssetListDataSource: NSObject 

Inheritance

NSObject, PHPhotoLibraryChangeObserver

Initializers

init(reloadable:album:selects:albumOpts:assetOpts:)

Create data source with associate reloadable view, album model, select assets and options.

public init(reloadable: ADDataSourceReloadable,
                album: ADAlbumModel,
                selects: [PHAsset],
                albumOpts: ADAlbumSelectOptions,
                assetOpts: ADAssetSelectOptions) 

Parameters

  • reloadable: Associate reloadable view.
  • album: Album to get assets.
  • selects: Selected assets.
  • albumOpts: Options to limit album type and order. It is ADAlbumSelectOptions.default by default.
  • assetOpts: Options to control the asset select condition and ui. It is ADAssetSelectOptions.default by default.

init(reloadable:album:selects:albumOpts:assetOpts:)

Create data source with associate reloadable view, album model, select assets and options.

public init(reloadable: ADDataSourceReloadable,
                album: ADAlbumModel,
                selects: [ADSelectAssetModel],
                albumOpts: ADAlbumSelectOptions,
                assetOpts: ADAssetSelectOptions) 

Parameters

  • reloadable: Associate reloadable view.
  • album: Album to get assets.
  • selects: Selected asset models.
  • albumOpts: Options to limit album type and order. It is ADAlbumSelectOptions.default by default.
  • assetOpts: Options to control the asset select condition and ui. It is ADAssetSelectOptions.default by default.

Properties

reloadable

The associate reloadable view conform to ADDataSourceReloadable.

public weak var reloadable: ADDataSourceReloadable?

albumOpts

Options to set the album type and order.

public let albumOpts: ADAlbumSelectOptions

assetOpts

Options to control the asset select condition and ui.

public let assetOpts: ADAssetSelectOptions

album

The album select to get assets.

public let album: ADAlbumModel

list

Assets array request from album.

public var list: [ADAssetModel] = []

selects

Assets you select.

public var selects: [ADSelectAssetModel] = []

appendCellCount

The cell count except assets.

public var appendCellCount: Int 

enableCameraCell

Indicate whether show camera cell in CameraRoll. if true, camera roll page will show camera cell.

public var enableCameraCell: Bool 

cameraCellIndex

The index for camera cell.

public var cameraCellIndex: Int 

enableAddAssetCell

Indicate whether show add asset in CameraRoll when user choose limited Photo mode. if true, camera roll page will show add asset cell.

@available(iOS 14, *)
    public var enableAddAssetCell: Bool 

addAssetCellIndex

The index for add seest cell.

public var addAssetCellIndex: Int 

selectAssetChanged

Called when select asset or deselect asset.

public var selectAssetChanged: ((Int)->Void)?

Methods

reloadData(completion:)

Reload the associate view with fetch assets.

public func reloadData(completion: (() -> Void)? = nil) 

Parameters

  • completion: Called when the reload finished.

modifyIndexPath(_:)

Return modify indexPath when camera cell or add asset cell is enable.

public func modifyIndexPath(_ indexPath: IndexPath) -> IndexPath 

Parameters

  • indexPath: Orginal indexPath.

Returns

Modify indexPath.

selectAssetAt(index:)

Select the asset.

public func selectAssetAt(index: Int) 

Parameters

  • index: Index whitch asset is select.

deselectAssetAt(index:)

Deselect the asset.

public func deselectAssetAt(index: Int) 

Parameters

  • index: Index whitch asset is deselect.

reloadSelectAssetIndexs(_:current:)

Reload asset selectStatus with select indexs. Use this method when return from browser controller.

public func reloadSelectAssetIndexs(_ indexs: [Int], current: Int) 

Parameters

  • indexs: Select asset indexs.
  • current: Current browser index.

photoLibraryDidChange(_:)

public func photoLibraryDidChange(_ changeInstance: PHChange) 
Types
Protocols
Global Typealiases
Operators
Extensions
Clone this wiki locally