or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

caching-strategies.mderror-handling-debugging.mdindex.mdmodules-configuration.mdrequest-configuration.mdrequest-management.mdtargets-loading.mdtransformations.mdtransitions-animations.md

targets-loading.mddocs/

0

# Glide Targets and Loading System

1

2

This document provides comprehensive coverage of Glide's target system and loading methods, covering the complete API surface for handling image loading destinations and request execution.

3

4

## Core Target Interface

5

6

The base Target interface defines the contract for all image loading destinations in Glide.

7

8

```java { .api }

9

public interface Target<R> {

10

/**

11

* Called when the load has started

12

* @param placeholder The placeholder drawable to show during loading

13

*/

14

void onLoadStarted(@Nullable Drawable placeholder);

15

16

/**

17

* Called when the load has failed

18

* @param errorDrawable The error drawable to show on failure

19

*/

20

void onLoadFailed(@Nullable Drawable errorDrawable);

21

22

/**

23

* Called when the resource is ready

24

* @param resource The loaded resource

25

* @param transition The transition to apply

26

*/

27

void onResourceReady(@NonNull R resource, @Nullable Transition<? super R> transition);

28

29

/**

30

* Called when the load is cleared

31

* @param placeholder The placeholder drawable to show

32

*/

33

void onLoadCleared(@Nullable Drawable placeholder);

34

35

/**

36

* Get the target size for the request

37

* @param cb Callback to receive the size

38

*/

39

void getSize(@NonNull SizeReadyCallback cb);

40

41

/**

42

* Remove a size callback

43

* @param cb The callback to remove

44

*/

45

void removeCallback(@NonNull SizeReadyCallback cb);

46

47

/**

48

* Set the request for this target

49

* @param request The request to associate

50

*/

51

void setRequest(@Nullable Request request);

52

53

/**

54

* Get the current request

55

* @return The associated request or null

56

*/

57

@Nullable Request getRequest();

58

}

59

```

60

61

### Target Lifecycle

62

63

Targets follow a predictable lifecycle with well-defined callback methods:

64

65

```java

66

// Example of target lifecycle flow

67

Target<Drawable> target = new CustomTarget<Drawable>() {

68

@Override

69

public void onLoadStarted(Drawable placeholder) {

70

// 1. Load begins - show placeholder

71

imageView.setImageDrawable(placeholder);

72

}

73

74

@Override

75

public void onResourceReady(Drawable resource, Transition transition) {

76

// 2. Success - apply resource and transition

77

imageView.setImageDrawable(resource);

78

if (transition != null) {

79

transition.transition(resource, new DrawableViewAdapter(imageView));

80

}

81

}

82

83

@Override

84

public void onLoadFailed(Drawable errorDrawable) {

85

// 3. Failure - show error drawable

86

imageView.setImageDrawable(errorDrawable);

87

}

88

89

@Override

90

public void onLoadCleared(Drawable placeholder) {

91

// 4. Cleared - cleanup and show placeholder

92

imageView.setImageDrawable(placeholder);

93

}

94

};

95

```

96

97

## ImageView Targets

98

99

### ImageViewTarget Base Class

100

101

Abstract base class for all ImageView-based targets providing common functionality.

102

103

```java { .api }

104

public abstract class ImageViewTarget<Z> extends ViewTarget<ImageView, Z>

105

implements Transition.ViewAdapter {

106

107

/**

108

* Set the resource on the ImageView (implementation required)

109

* @param resource The resource to set

110

*/

111

protected abstract void setResource(@Nullable Z resource);

112

113

/**

114

* Get the current drawable from the ImageView

115

* @return The current drawable or null

116

*/

117

@Nullable

118

protected Drawable getCurrentDrawable() {

119

return view.getDrawable();

120

}

121

122

/**

123

* Set a drawable on the ImageView

124

* @param drawable The drawable to set

125

*/

126

protected void setDrawable(Drawable drawable) {

127

view.setImageDrawable(drawable);

128

}

129

130

@Override

131

public void onLoadStarted(@Nullable Drawable placeholder) {

132

super.onLoadStarted(placeholder);

133

setResourceInternal(null);

134

setDrawable(placeholder);

135

}

136

}

137

```

138

139

### DrawableImageViewTarget

140

141

Specialized target for loading Drawable resources into ImageViews.

142

143

```java { .api }

144

public class DrawableImageViewTarget extends ImageViewTarget<Drawable> {

145

146

/**

147

* Constructor

148

* @param view The ImageView to load into

149

*/

150

public DrawableImageViewTarget(@NonNull ImageView view) {

151

super(view);

152

}

153

154

@Override

155

protected void setResource(@Nullable Drawable resource) {

156

view.setImageDrawable(resource);

157

}

158

}

159

```

160

161

### BitmapImageViewTarget

162

163

Specialized target for loading Bitmap resources into ImageViews.

164

165

```java { .api }

166

public class BitmapImageViewTarget extends ImageViewTarget<Bitmap> {

167

168

/**

169

* Constructor

170

* @param view The ImageView to load into

171

*/

172

public BitmapImageViewTarget(@NonNull ImageView view) {

173

super(view);

174

}

175

176

@Override

177

protected void setResource(@Nullable Bitmap resource) {

178

view.setImageBitmap(resource);

179

}

180

}

181

```

182

183

### ImageView Target Usage

184

185

```java

186

// Automatic target creation (recommended)

187

Glide.with(context)

188

.load("https://example.com/image.jpg")

189

.into(imageView);

190

191

// Explicit drawable target

192

DrawableImageViewTarget target = new DrawableImageViewTarget(imageView);

193

Glide.with(context)

194

.load("https://example.com/image.jpg")

195

.into(target);

196

197

// Explicit bitmap target

198

BitmapImageViewTarget bitmapTarget = new BitmapImageViewTarget(imageView);

199

Glide.with(context)

200

.asBitmap()

201

.load("https://example.com/image.jpg")

202

.into(bitmapTarget);

203

```

204

205

## Custom Targets

206

207

### SimpleTarget (Deprecated)

208

209

Legacy target implementation - use CustomTarget instead.

210

211

```java { .api }

212

@Deprecated

213

public abstract class SimpleTarget<Z> extends BaseTarget<Z> {

214

/**

215

* Constructor with specific dimensions

216

* @param width Target width

217

* @param height Target height

218

*/

219

public SimpleTarget(int width, int height) {

220

super(width, height);

221

}

222

223

/**

224

* Constructor using SIZE_ORIGINAL

225

*/

226

public SimpleTarget() {

227

this(SIZE_ORIGINAL, SIZE_ORIGINAL);

228

}

229

}

230

```

231

232

### CustomTarget

233

234

Modern custom target implementation with proper lifecycle management.

235

236

```java { .api }

237

public abstract class CustomTarget<T> implements Target<T> {

238

239

/**

240

* Constructor with specific dimensions

241

* @param width Target width in pixels

242

* @param height Target height in pixels

243

*/

244

public CustomTarget(int width, int height) {

245

this.width = width;

246

this.height = height;

247

}

248

249

/**

250

* Constructor using SIZE_ORIGINAL

251

*/

252

public CustomTarget() {

253

this(SIZE_ORIGINAL, SIZE_ORIGINAL);

254

}

255

256

/**

257

* Handle successful resource loading (implementation required)

258

* @param resource The loaded resource

259

* @param transition The transition to apply

260

*/

261

public abstract void onResourceReady(@NonNull T resource,

262

@Nullable Transition<? super T> transition);

263

264

/**

265

* Handle load clearing (implementation required)

266

* @param placeholder The placeholder drawable

267

*/

268

public abstract void onLoadCleared(@Nullable Drawable placeholder);

269

270

@Override

271

public final void getSize(@NonNull SizeReadyCallback cb) {

272

if (Util.isValidDimensions(width, height)) {

273

cb.onSizeReady(width, height);

274

return;

275

}

276

throw new IllegalArgumentException("Width and height must both be > 0 or Target#SIZE_ORIGINAL");

277

}

278

}

279

```

280

281

### Custom Target Examples

282

283

```java

284

// Basic custom target for drawable processing

285

CustomTarget<Drawable> drawableTarget = new CustomTarget<Drawable>() {

286

@Override

287

public void onResourceReady(@NonNull Drawable resource,

288

@Nullable Transition<? super Drawable> transition) {

289

// Process the loaded drawable

290

processDrawable(resource);

291

}

292

293

@Override

294

public void onLoadCleared(@Nullable Drawable placeholder) {

295

// Cleanup when cleared

296

clearProcessedData();

297

}

298

};

299

300

// Custom target with specific dimensions

301

CustomTarget<Bitmap> bitmapTarget = new CustomTarget<Bitmap>(500, 300) {

302

@Override

303

public void onResourceReady(@NonNull Bitmap resource,

304

@Nullable Transition<? super Bitmap> transition) {

305

// Use the 500x300 bitmap

306

saveBitmapToFile(resource);

307

}

308

309

@Override

310

public void onLoadCleared(@Nullable Drawable placeholder) {

311

// Cleanup temporary files

312

cleanupTempFiles();

313

}

314

};

315

316

// Loading into custom targets

317

Glide.with(context)

318

.load("https://example.com/image.jpg")

319

.into(drawableTarget);

320

321

Glide.with(context)

322

.asBitmap()

323

.load("https://example.com/image.jpg")

324

.override(500, 300)

325

.into(bitmapTarget);

326

```

327

328

## Specialized Targets

329

330

### NotificationTarget

331

332

Target for loading images into notification RemoteViews.

333

334

```java { .api }

335

public class NotificationTarget extends CustomTarget<Bitmap> {

336

337

/**

338

* Constructor

339

* @param context Application context

340

* @param viewId The view ID in the RemoteViews

341

* @param remoteViews The RemoteViews to update

342

* @param notification The notification to update

343

* @param notificationId The notification ID

344

* @param notificationTag The notification tag (optional)

345

*/

346

public NotificationTarget(Context context,

347

int viewId,

348

RemoteViews remoteViews,

349

Notification notification,

350

int notificationId,

351

@Nullable String notificationTag) {

352

super(SIZE_ORIGINAL, SIZE_ORIGINAL);

353

// Implementation details

354

}

355

356

/**

357

* Constructor without notification tag

358

*/

359

public NotificationTarget(Context context,

360

int viewId,

361

RemoteViews remoteViews,

362

Notification notification,

363

int notificationId) {

364

this(context, viewId, remoteViews, notification, notificationId, null);

365

}

366

}

367

```

368

369

### AppWidgetTarget

370

371

Target for loading images into app widget RemoteViews.

372

373

```java { .api }

374

public class AppWidgetTarget extends CustomTarget<Bitmap> {

375

376

/**

377

* Constructor for single widget

378

* @param context Application context

379

* @param viewId The view ID in the RemoteViews

380

* @param remoteViews The RemoteViews to update

381

* @param appWidgetId The app widget ID

382

*/

383

public AppWidgetTarget(Context context,

384

int viewId,

385

RemoteViews remoteViews,

386

int appWidgetId) {

387

super(SIZE_ORIGINAL, SIZE_ORIGINAL);

388

// Implementation details

389

}

390

391

/**

392

* Constructor for multiple widgets

393

* @param context Application context

394

* @param viewId The view ID in the RemoteViews

395

* @param remoteViews The RemoteViews to update

396

* @param appWidgetIds Array of app widget IDs

397

*/

398

public AppWidgetTarget(Context context,

399

int viewId,

400

RemoteViews remoteViews,

401

int... appWidgetIds) {

402

super(SIZE_ORIGINAL, SIZE_ORIGINAL);

403

// Implementation details

404

}

405

}

406

```

407

408

### PreloadTarget

409

410

Target specifically designed for preloading resources into cache without displaying them.

411

412

```java { .api }

413

public final class PreloadTarget<Z> extends CustomTarget<Z> {

414

415

/**

416

* Get a preload target for the given dimensions

417

* @param width Target width

418

* @param height Target height

419

* @return PreloadTarget instance

420

*/

421

public static <Z> PreloadTarget<Z> obtain(RequestManager requestManager,

422

int width,

423

int height) {

424

return new PreloadTarget<>(requestManager, width, height);

425

}

426

427

@Override

428

public void onResourceReady(@NonNull Z resource,

429

@Nullable Transition<? super Z> transition) {

430

// Resource is now in cache - no display needed

431

}

432

433

@Override

434

public void onLoadCleared(@Nullable Drawable placeholder) {

435

// Cleanup if needed

436

}

437

}

438

```

439

440

### Specialized Target Usage

441

442

```java

443

// Notification target example

444

NotificationTarget notificationTarget = new NotificationTarget(

445

context,

446

R.id.notification_image,

447

remoteViews,

448

notification,

449

NOTIFICATION_ID

450

);

451

452

Glide.with(context)

453

.asBitmap()

454

.load("https://example.com/avatar.jpg")

455

.into(notificationTarget);

456

457

// App widget target example

458

AppWidgetTarget widgetTarget = new AppWidgetTarget(

459

context,

460

R.id.widget_image,

461

remoteViews,

462

appWidgetId

463

);

464

465

Glide.with(context)

466

.asBitmap()

467

.load("https://example.com/widget_image.jpg")

468

.into(widgetTarget);

469

470

// Preload target example

471

PreloadTarget<Drawable> preloadTarget = PreloadTarget.obtain(

472

Glide.with(context),

473

200, 200

474

);

475

476

Glide.with(context)

477

.load("https://example.com/image.jpg")

478

.into(preloadTarget);

479

```

480

481

## Loading Methods

482

483

### into() Method

484

485

The primary method for loading resources into targets.

486

487

```java { .api }

488

public class RequestBuilder<TranscodeType> {

489

490

/**

491

* Load into an ImageView (creates appropriate target automatically)

492

* @param view The ImageView to load into

493

* @return ViewTarget for the ImageView

494

*/

495

@NonNull

496

public ViewTarget<ImageView, TranscodeType> into(@NonNull ImageView view) {

497

return into(glideContext.buildImageViewTarget(view, transcodeClass));

498

}

499

500

/**

501

* Load into a custom target

502

* @param target The target to load into

503

* @return The target (for chaining)

504

*/

505

@NonNull

506

public <Y extends Target<TranscodeType>> Y into(@NonNull Y target) {

507

return into(target, /*targetListener=*/ null, Executors.mainThreadExecutor());

508

}

509

510

/**

511

* Load into target with listener

512

* @param target The target to load into

513

* @param targetListener Listener for target events

514

* @return The target (for chaining)

515

*/

516

@NonNull

517

public <Y extends Target<TranscodeType>> Y into(@NonNull Y target,

518

@Nullable RequestListener<TranscodeType> targetListener) {

519

return into(target, targetListener, Executors.mainThreadExecutor());

520

}

521

}

522

```

523

524

### submit() Method

525

526

For background loading without immediate display.

527

528

```java { .api }

529

public class RequestBuilder<TranscodeType> {

530

531

/**

532

* Submit for background loading with original dimensions

533

* @return Future target for the request

534

*/

535

@NonNull

536

public FutureTarget<TranscodeType> submit() {

537

return submit(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL);

538

}

539

540

/**

541

* Submit for background loading with specific dimensions

542

* @param width Target width

543

* @param height Target height

544

* @return Future target for the request

545

*/

546

@NonNull

547

public FutureTarget<TranscodeType> submit(int width, int height) {

548

final RequestFutureTarget<TranscodeType> target =

549

new RequestFutureTarget<>(width, height);

550

551

return into(target, target, MoreExecutors.directExecutor());

552

}

553

}

554

```

555

556

### preload() Method

557

558

For preloading resources into cache.

559

560

```java { .api }

561

public class RequestBuilder<TranscodeType> {

562

563

/**

564

* Preload with original dimensions

565

* @return PreloadTarget for the request

566

*/

567

@NonNull

568

public Target<TranscodeType> preload() {

569

return preload(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL);

570

}

571

572

/**

573

* Preload with specific dimensions

574

* @param width Target width for caching

575

* @param height Target height for caching

576

* @return PreloadTarget for the request

577

*/

578

@NonNull

579

public Target<TranscodeType> preload(int width, int height) {

580

final PreloadTarget<TranscodeType> target = PreloadTarget.obtain(requestManager, width, height);

581

return into(target);

582

}

583

}

584

```

585

586

### Loading Method Examples

587

588

```java

589

// Basic into() usage

590

Glide.with(context)

591

.load("https://example.com/image.jpg")

592

.into(imageView);

593

594

// Custom target with into()

595

CustomTarget<Bitmap> target = new CustomTarget<Bitmap>() {

596

@Override

597

public void onResourceReady(@NonNull Bitmap resource,

598

@Nullable Transition<? super Bitmap> transition) {

599

processImage(resource);

600

}

601

602

@Override

603

public void onLoadCleared(@Nullable Drawable placeholder) {

604

cleanup();

605

}

606

};

607

608

Glide.with(context)

609

.asBitmap()

610

.load("https://example.com/image.jpg")

611

.into(target);

612

613

// Background loading with submit()

614

FutureTarget<File> future = Glide.with(context)

615

.asFile()

616

.load("https://example.com/image.jpg")

617

.submit();

618

619

try {

620

File file = future.get(10, TimeUnit.SECONDS);

621

// Process downloaded file

622

} catch (Exception e) {

623

// Handle timeout or error

624

} finally {

625

Glide.with(context).clear(future);

626

}

627

628

// Preloading for cache

629

Glide.with(context)

630

.load("https://example.com/image.jpg")

631

.preload(200, 200);

632

633

// Later, load from cache

634

Glide.with(context)

635

.load("https://example.com/image.jpg")

636

.override(200, 200)

637

.into(imageView); // Will load from cache if available

638

```

639

640

## RequestFutureTarget

641

642

Synchronous loading target that implements Future interface.

643

644

```java { .api }

645

public class RequestFutureTarget<R> extends CustomTarget<R>

646

implements FutureTarget<R>, RequestListener<R> {

647

648

/**

649

* Get the result (blocking)

650

* @return The loaded resource

651

* @throws ExecutionException If loading failed

652

* @throws InterruptedException If interrupted

653

*/

654

@Override

655

public R get() throws InterruptedException, ExecutionException {

656

try {

657

return doGet(null);

658

} catch (TimeoutException e) {

659

throw new AssertionError(e);

660

}

661

}

662

663

/**

664

* Get the result with timeout

665

* @param time Maximum time to wait

666

* @param unit Time unit

667

* @return The loaded resource

668

* @throws ExecutionException If loading failed

669

* @throws InterruptedException If interrupted

670

* @throws TimeoutException If timeout exceeded

671

*/

672

@Override

673

public R get(long time, @NonNull TimeUnit unit)

674

throws InterruptedException, ExecutionException, TimeoutException {

675

return doGet(unit.toMillis(time));

676

}

677

678

/**

679

* Cancel the request

680

* @param mayInterruptIfRunning Whether to interrupt if running

681

* @return true if successfully cancelled

682

*/

683

@Override

684

public boolean cancel(boolean mayInterruptIfRunning) {

685

synchronized (this) {

686

if (isDone()) {

687

return false;

688

}

689

cancelled = true;

690

waiter.notifyAll();

691

if (mayInterruptIfRunning) {

692

clear();

693

}

694

return true;

695

}

696

}

697

698

/**

699

* Check if the request is cancelled

700

* @return true if cancelled

701

*/

702

@Override

703

public boolean isCancelled() {

704

synchronized (this) {

705

return cancelled;

706

}

707

}

708

709

/**

710

* Check if the request is done

711

* @return true if completed or cancelled

712

*/

713

@Override

714

public boolean isDone() {

715

synchronized (this) {

716

return cancelled || resultReceived || loadFailed;

717

}

718

}

719

}

720

```

721

722

## Target Size Handling

723

724

### SIZE_ORIGINAL Constant

725

726

```java { .api }

727

public interface Target<R> {

728

/**

729

* Indicates that the target wants the original image dimensions

730

*/

731

int SIZE_ORIGINAL = Integer.MIN_VALUE;

732

}

733

```

734

735

### SizeReadyCallback Interface

736

737

```java { .api }

738

public interface SizeReadyCallback {

739

/**

740

* Called when the target size is ready

741

* @param width The target width

742

* @param height The target height

743

*/

744

void onSizeReady(int width, int height);

745

}

746

```

747

748

### Custom Size Handling

749

750

```java

751

// Custom target with dynamic size calculation

752

CustomTarget<Drawable> dynamicTarget = new CustomTarget<Drawable>() {

753

@Override

754

public void getSize(@NonNull SizeReadyCallback cb) {

755

// Calculate size based on screen dimensions

756

DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();

757

int width = metrics.widthPixels / 2;

758

int height = metrics.heightPixels / 3;

759

cb.onSizeReady(width, height);

760

}

761

762

@Override

763

public void onResourceReady(@NonNull Drawable resource,

764

@Nullable Transition<? super Drawable> transition) {

765

// Handle dynamically sized resource

766

}

767

768

@Override

769

public void onLoadCleared(@Nullable Drawable placeholder) {

770

// Cleanup

771

}

772

};

773

774

// Using SIZE_ORIGINAL

775

CustomTarget<Bitmap> originalSizeTarget = new CustomTarget<Bitmap>(

776

Target.SIZE_ORIGINAL,

777

Target.SIZE_ORIGINAL

778

) {

779

// Implementation

780

};

781

```

782

783

## Target Lifecycle Management

784

785

### Clearing Targets

786

787

```java

788

// Clear specific target

789

Target<Drawable> target = // ... create target

790

Glide.with(context)

791

.load("https://example.com/image.jpg")

792

.into(target);

793

794

// Later, clear the target

795

Glide.with(context).clear(target);

796

797

// Clear ImageView (automatic target)

798

Glide.with(context).clear(imageView);

799

800

// Clear all requests for a RequestManager

801

RequestManager requestManager = Glide.with(activity);

802

requestManager.clear(target1);

803

requestManager.clear(target2);

804

// Or pause all requests

805

requestManager.pauseRequests();

806

```

807

808

### Memory Leak Prevention

809

810

```java

811

public class MyActivity extends Activity {

812

private CustomTarget<Drawable> target;

813

814

@Override

815

protected void onCreate(Bundle savedInstanceState) {

816

super.onCreate(savedInstanceState);

817

818

target = new CustomTarget<Drawable>() {

819

@Override

820

public void onResourceReady(@NonNull Drawable resource,

821

@Nullable Transition<? super Drawable> transition) {

822

// Use WeakReference for Activity context if needed

823

Activity activity = activityRef.get();

824

if (activity != null && !activity.isFinishing()) {

825

// Process resource

826

}

827

}

828

829

@Override

830

public void onLoadCleared(@Nullable Drawable placeholder) {

831

// Cleanup

832

}

833

};

834

835

Glide.with(this)

836

.load("https://example.com/image.jpg")

837

.into(target);

838

}

839

840

@Override

841

protected void onDestroy() {

842

// Clear target to prevent memory leaks

843

Glide.with(this).clear(target);

844

super.onDestroy();

845

}

846

}

847

```

848

849

## Advanced Target Patterns

850

851

### Target Pooling

852

853

```java

854

// Pool custom targets for performance

855

public class TargetPool {

856

private final Queue<CustomTarget<Bitmap>> pool = new ArrayDeque<>();

857

858

public CustomTarget<Bitmap> obtain() {

859

CustomTarget<Bitmap> target = pool.poll();

860

if (target == null) {

861

target = createNewTarget();

862

}

863

return target;

864

}

865

866

public void release(CustomTarget<Bitmap> target) {

867

// Reset target state

868

target.clear();

869

pool.offer(target);

870

}

871

872

private CustomTarget<Bitmap> createNewTarget() {

873

return new CustomTarget<Bitmap>() {

874

@Override

875

public void onResourceReady(@NonNull Bitmap resource,

876

@Nullable Transition<? super Bitmap> transition) {

877

// Process bitmap

878

processBitmap(resource);

879

// Return to pool when done

880

TargetPool.this.release(this);

881

}

882

883

@Override

884

public void onLoadCleared(@Nullable Drawable placeholder) {

885

// Cleanup

886

}

887

};

888

}

889

}

890

```

891

892

### Composite Target

893

894

```java

895

// Target that delegates to multiple other targets

896

public class CompositeTarget<T> extends CustomTarget<T> {

897

private final List<Target<T>> targets;

898

899

public CompositeTarget(Target<T>... targets) {

900

this.targets = Arrays.asList(targets);

901

}

902

903

@Override

904

public void onLoadStarted(@Nullable Drawable placeholder) {

905

for (Target<T> target : targets) {

906

target.onLoadStarted(placeholder);

907

}

908

}

909

910

@Override

911

public void onResourceReady(@NonNull T resource,

912

@Nullable Transition<? super T> transition) {

913

for (Target<T> target : targets) {

914

target.onResourceReady(resource, transition);

915

}

916

}

917

918

@Override

919

public void onLoadFailed(@Nullable Drawable errorDrawable) {

920

for (Target<T> target : targets) {

921

target.onLoadFailed(errorDrawable);

922

}

923

}

924

925

@Override

926

public void onLoadCleared(@Nullable Drawable placeholder) {

927

for (Target<T> target : targets) {

928

target.onLoadCleared(placeholder);

929

}

930

}

931

932

@Override

933

public void getSize(@NonNull SizeReadyCallback cb) {

934

// Use the first target's size or provide default

935

if (!targets.isEmpty()) {

936

targets.get(0).getSize(cb);

937

} else {

938

cb.onSizeReady(SIZE_ORIGINAL, SIZE_ORIGINAL);

939

}

940

}

941

}

942

```

943

944

This comprehensive documentation covers all aspects of Glide's target system and loading methods, providing developers with the complete API surface and practical usage patterns for implementing custom image loading destinations and managing the request lifecycle.