Skip to content

ADAssetBrowserDataSource

duzexu edited this page Sep 18, 2021 · 3 revisions

ADAssetBrowserDataSource

The data source of browser controller. It reload the associate reloadable view when selet or deselect asset, browser index change, select order change.

public class ADAssetBrowserDataSource: NSObject 

Inheritance

NSObject

Initializers

init(options:list:selects:index:)

Create data source with browser data, options and select info.

public init(options: ADAssetBrowserOptions,
                list: [ADAssetBrowsable],
                selects: [ADAssetBrowsable],
                index: Int?) 

Parameters

  • options: Options to control browser controller. It is ADAssetBrowserOptions.default by default.
  • list: Asset array to browser.
  • selects: Assets have been selected.
  • index: Default asset index in list. If nil, it will be set first select asset index in list or set 0 when select count is 0.

Properties

listView

Associate browser view.

public weak var listView: UICollectionView?

selectView

Associate select preview view.

public weak var selectView: UICollectionView?

options

Options to control the asset browser condition and ui.

public let options: ADAssetBrowserOptions

list

Assets to browser.

public var list: [ADAssetBrowsable]

selects

Select assets.

public var selects: [ADAssetBrowsable] = []

selectIndexs

Select asset's index.

public var selectIndexs: [Int?] = []

current

Current browser asset. Will be nil if select asset is not in list.

public var current: ADAssetBrowsable? 

index

Current browser asset index in list.

@objc
    public dynamic var index: Int = 0

isSelected

Current browser asset is select or not.

@objc
    public dynamic var isSelected: Bool = false

selectIndex

Current browser asset index in selects.

@objc
    public dynamic var selectIndex: Int = -1

selectAssetChanged

Called when selet or deselect asset.

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

selectAssetExistOrNot

Called whether selet asset is in list or not.

public var selectAssetExistOrNot: ((Bool) -> Void)?

Methods

didIndexChange(_:)

Change current browser index.

public func didIndexChange(_ idx: Int?) 

Parameters

  • idx: Asset index in list to browser.

didSelectIndexChange(_:)

Change select browser index.

public func didSelectIndexChange(_ idx: Int) 

Parameters

  • idx: Asset index in selects to browser.

appendSelect(_:)

Select the asset.

public func appendSelect(_ idx: Int) 

Parameters

  • idx: Index whitch asset is select.

deleteSelect(_:)

Deselect the asset.

public func deleteSelect(_ idx: Int) 

Parameters

  • index: Index whitch asset is deselect.

moveSelect(from:to:reload:)

Change select assets order.

public func moveSelect(from fIdx: Int, to tIdx: Int, reload: Bool = false) 

Parameters

  • fIdx: Index move from.
  • tIdx: Index move to.
  • reload: Indicator reload selectView or not.
Types
Protocols
Global Typealiases
Operators
Extensions

Clone this wiki locally