AlbumPage.java revision 7260f6f74d465520e4497b23fe56f98abb0c15a2
1/* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.android.gallery3d.app; 18 19import android.app.Activity; 20import android.content.Context; 21import android.content.Intent; 22import android.graphics.Rect; 23import android.net.Uri; 24import android.os.Bundle; 25import android.os.Vibrator; 26import android.provider.MediaStore; 27import android.view.ActionMode; 28import android.view.Menu; 29import android.view.MenuInflater; 30import android.view.MenuItem; 31import android.widget.Toast; 32 33import com.android.gallery3d.R; 34import com.android.gallery3d.common.Utils; 35import com.android.gallery3d.data.DataManager; 36import com.android.gallery3d.data.MediaDetails; 37import com.android.gallery3d.data.MediaItem; 38import com.android.gallery3d.data.MediaObject; 39import com.android.gallery3d.data.MediaSet; 40import com.android.gallery3d.data.MtpDevice; 41import com.android.gallery3d.data.Path; 42import com.android.gallery3d.ui.ActionModeHandler; 43import com.android.gallery3d.ui.ActionModeHandler.ActionModeListener; 44import com.android.gallery3d.ui.AlbumView; 45import com.android.gallery3d.ui.DetailsHelper; 46import com.android.gallery3d.ui.DetailsHelper.CloseListener; 47import com.android.gallery3d.ui.GLCanvas; 48import com.android.gallery3d.ui.GLView; 49import com.android.gallery3d.ui.GridDrawer; 50import com.android.gallery3d.ui.HighlightDrawer; 51import com.android.gallery3d.ui.PositionProvider; 52import com.android.gallery3d.ui.PositionRepository; 53import com.android.gallery3d.ui.PositionRepository.Position; 54import com.android.gallery3d.ui.SelectionManager; 55import com.android.gallery3d.ui.SlotView; 56import com.android.gallery3d.util.Future; 57import com.android.gallery3d.util.GalleryUtils; 58 59import java.util.Random; 60 61public class AlbumPage extends ActivityState implements GalleryActionBar.ClusterRunner, 62 SelectionManager.SelectionListener, MediaSet.SyncListener { 63 @SuppressWarnings("unused") 64 private static final String TAG = "AlbumPage"; 65 66 public static final String KEY_MEDIA_PATH = "media-path"; 67 public static final String KEY_PARENT_MEDIA_PATH = "parent-media-path"; 68 public static final String KEY_SET_CENTER = "set-center"; 69 public static final String KEY_AUTO_SELECT_ALL = "auto-select-all"; 70 public static final String KEY_SHOW_CLUSTER_MENU = "cluster-menu"; 71 72 private static final int REQUEST_SLIDESHOW = 1; 73 private static final int REQUEST_PHOTO = 2; 74 private static final int REQUEST_DO_ANIMATION = 3; 75 76 private static final int BIT_LOADING_RELOAD = 1; 77 private static final int BIT_LOADING_SYNC = 2; 78 79 private static final float USER_DISTANCE_METER = 0.3f; 80 81 private boolean mIsActive = false; 82 private AlbumView mAlbumView; 83 private Path mMediaSetPath; 84 private String mParentMediaSetString; 85 private SlotView mSlotView; 86 87 private AlbumDataAdapter mAlbumDataAdapter; 88 89 protected SelectionManager mSelectionManager; 90 private Vibrator mVibrator; 91 private GridDrawer mGridDrawer; 92 private HighlightDrawer mHighlightDrawer; 93 94 private boolean mGetContent; 95 private boolean mShowClusterMenu; 96 97 private ActionMode mActionMode; 98 private ActionModeHandler mActionModeHandler; 99 private int mFocusIndex = 0; 100 private DetailsHelper mDetailsHelper; 101 private MyDetailsSource mDetailsSource; 102 private MediaSet mMediaSet; 103 private boolean mShowDetails; 104 private float mUserDistance; // in pixel 105 106 private Future<Integer> mSyncTask = null; 107 108 private int mLoadingBits = 0; 109 private boolean mInitialSynced = false; 110 111 private final GLView mRootPane = new GLView() { 112 private final float mMatrix[] = new float[16]; 113 114 @Override 115 protected void renderBackground(GLCanvas view) { 116 view.clearBuffer(); 117 } 118 119 @Override 120 protected void onLayout( 121 boolean changed, int left, int top, int right, int bottom) { 122 123 int slotViewTop = mActivity.getGalleryActionBar().getHeight(); 124 int slotViewBottom = bottom - top; 125 int slotViewRight = right - left; 126 127 if (mShowDetails) { 128 mDetailsHelper.layout(left, slotViewTop, right, bottom); 129 } else { 130 mAlbumView.setSelectionDrawer(mGridDrawer); 131 } 132 133 mSlotView.layout(0, slotViewTop, slotViewRight, slotViewBottom); 134 GalleryUtils.setViewPointMatrix(mMatrix, 135 (right - left) / 2, (bottom - top) / 2, -mUserDistance); 136 // Reset position offset after the layout is changed. 137 PositionRepository.getInstance(mActivity).setOffset( 138 0, slotViewTop); 139 } 140 141 @Override 142 protected void render(GLCanvas canvas) { 143 canvas.save(GLCanvas.SAVE_FLAG_MATRIX); 144 canvas.multiplyMatrix(mMatrix, 0); 145 super.render(canvas); 146 canvas.restore(); 147 } 148 }; 149 150 @Override 151 protected void onBackPressed() { 152 if (mShowDetails) { 153 hideDetails(); 154 } else if (mSelectionManager.inSelectionMode()) { 155 mSelectionManager.leaveSelectionMode(); 156 } else { 157 // TODO: fix this regression 158 // mAlbumView.savePositions(PositionRepository.getInstance(mActivity)); 159 super.onBackPressed(); 160 } 161 } 162 163 private void onDown(int index) { 164 MediaItem item = mAlbumDataAdapter.get(index); 165 Path path = (item == null) ? null : item.getPath(); 166 mSelectionManager.setPressedPath(path); 167 mSlotView.invalidate(); 168 } 169 170 private void onUp() { 171 mSelectionManager.setPressedPath(null); 172 mSlotView.invalidate(); 173 } 174 175 private void onSingleTapUp(int slotIndex) { 176 MediaItem item = mAlbumDataAdapter.get(slotIndex); 177 if (item == null) { 178 Log.w(TAG, "item not ready yet, ignore the click"); 179 return; 180 } 181 if (mShowDetails) { 182 mHighlightDrawer.setHighlightItem(item.getPath()); 183 mDetailsHelper.reloadDetails(slotIndex); 184 } else if (!mSelectionManager.inSelectionMode()) { 185 if (mGetContent) { 186 onGetContent(item); 187 } else { 188 // Get into the PhotoPage. 189 Bundle data = new Bundle(); 190 191 // mAlbumView.savePositions(PositionRepository.getInstance(mActivity)); 192 data.putInt(PhotoPage.KEY_INDEX_HINT, slotIndex); 193 data.putParcelable(PhotoPage.KEY_OPEN_ANIMATION_RECT, 194 getSlotRect(slotIndex)); 195 data.putString(PhotoPage.KEY_MEDIA_SET_PATH, 196 mMediaSetPath.toString()); 197 data.putString(PhotoPage.KEY_MEDIA_ITEM_PATH, 198 item.getPath().toString()); 199 mActivity.getStateManager().startStateForResult( 200 PhotoPage.class, REQUEST_PHOTO, data); 201 } 202 } else { 203 mSelectionManager.toggle(item.getPath()); 204 mDetailsSource.findIndex(slotIndex); 205 mSlotView.invalidate(); 206 } 207 } 208 209 private Rect getSlotRect(int slotIndex) { 210 // Get slot rectangle relative to this root pane. 211 Rect offset = new Rect(); 212 mRootPane.getBoundsOf(mSlotView, offset); 213 Rect r = mSlotView.getSlotRect(slotIndex); 214 r.offset(offset.left - mSlotView.getScrollX(), 215 offset.top - mSlotView.getScrollY()); 216 return r; 217 } 218 219 private void onGetContent(final MediaItem item) { 220 DataManager dm = mActivity.getDataManager(); 221 Activity activity = (Activity) mActivity; 222 if (mData.getString(Gallery.EXTRA_CROP) != null) { 223 // TODO: Handle MtpImagew 224 Uri uri = dm.getContentUri(item.getPath()); 225 Intent intent = new Intent(CropImage.ACTION_CROP, uri) 226 .addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT) 227 .putExtras(getData()); 228 if (mData.getParcelable(MediaStore.EXTRA_OUTPUT) == null) { 229 intent.putExtra(CropImage.KEY_RETURN_DATA, true); 230 } 231 activity.startActivity(intent); 232 activity.finish(); 233 } else { 234 activity.setResult(Activity.RESULT_OK, 235 new Intent(null, item.getContentUri())); 236 activity.finish(); 237 } 238 } 239 240 public void onLongTap(int slotIndex) { 241 if (mGetContent) return; 242 if (mShowDetails) { 243 onSingleTapUp(slotIndex); 244 } else { 245 MediaItem item = mAlbumDataAdapter.get(slotIndex); 246 if (item == null) return; 247 mSelectionManager.setAutoLeaveSelectionMode(true); 248 mSelectionManager.toggle(item.getPath()); 249 mDetailsSource.findIndex(slotIndex); 250 mSlotView.invalidate(); 251 } 252 } 253 254 public void doCluster(int clusterType) { 255 String basePath = mMediaSet.getPath().toString(); 256 String newPath = FilterUtils.newClusterPath(basePath, clusterType); 257 Bundle data = new Bundle(getData()); 258 data.putString(AlbumSetPage.KEY_MEDIA_PATH, newPath); 259 if (mShowClusterMenu) { 260 Context context = mActivity.getAndroidContext(); 261 data.putString(AlbumSetPage.KEY_SET_TITLE, mMediaSet.getName()); 262 data.putString(AlbumSetPage.KEY_SET_SUBTITLE, 263 GalleryActionBar.getClusterByTypeString(context, clusterType)); 264 } 265 266 // mAlbumView.savePositions(PositionRepository.getInstance(mActivity)); 267 mActivity.getStateManager().startStateForResult( 268 AlbumSetPage.class, REQUEST_DO_ANIMATION, data); 269 } 270 271 @Override 272 protected void onCreate(Bundle data, Bundle restoreState) { 273 mUserDistance = GalleryUtils.meterToPixel(USER_DISTANCE_METER); 274 initializeViews(); 275 initializeData(data); 276 mGetContent = data.getBoolean(Gallery.KEY_GET_CONTENT, false); 277 mShowClusterMenu = data.getBoolean(KEY_SHOW_CLUSTER_MENU, false); 278 mDetailsSource = new MyDetailsSource(); 279 Context context = mActivity.getAndroidContext(); 280 mVibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); 281 282 startTransition(data); 283 284 // Enable auto-select-all for mtp album 285 if (data.getBoolean(KEY_AUTO_SELECT_ALL)) { 286 mSelectionManager.selectAll(); 287 } 288 } 289 290 private void startTransition() { 291 final PositionRepository repository = 292 PositionRepository.getInstance(mActivity); 293 mSlotView.startTransition(new PositionProvider() { 294 private final Position mTempPosition = new Position(); 295 public Position getPosition(int identity, Position target) { 296 Position p = repository.get(identity); 297 if (p != null) return p; 298 mTempPosition.set(target); 299 mTempPosition.z = 128; 300 return mTempPosition; 301 } 302 }); 303 } 304 305 private void startTransition(Bundle data) { 306 final PositionRepository repository = 307 PositionRepository.getInstance(mActivity); 308 final int[] center = data == null 309 ? null 310 : data.getIntArray(KEY_SET_CENTER); 311 final Random random = new Random(); 312 mSlotView.startTransition(new PositionProvider() { 313 private final Position mTempPosition = new Position(); 314 public Position getPosition(int identity, Position target) { 315 Position p = repository.get(identity); 316 if (p != null) return p; 317 if (center != null) { 318 random.setSeed(identity); 319 mTempPosition.set(center[0], center[1], 320 0, random.nextInt(60) - 30, 0); 321 } else { 322 mTempPosition.set(target); 323 mTempPosition.z = 128; 324 } 325 return mTempPosition; 326 } 327 }); 328 } 329 330 @Override 331 protected void onResume() { 332 super.onResume(); 333 mIsActive = true; 334 setContentPane(mRootPane); 335 // Reset position offset for resuming. 336 PositionRepository.getInstance(mActivity).setOffset( 337 mSlotView.bounds().left, mSlotView.bounds().top); 338 339 Path path = mMediaSet.getPath(); 340 boolean enableHomeButton = (mActivity.getStateManager().getStateCount() > 1) | 341 mParentMediaSetString != null; 342 mActivity.getGalleryActionBar().setDisplayOptions(enableHomeButton, true); 343 344 // Set the reload bit here to prevent it exit this page in clearLoadingBit(). 345 setLoadingBit(BIT_LOADING_RELOAD); 346 mAlbumDataAdapter.resume(); 347 348 mAlbumView.resume(); 349 mActionModeHandler.resume(); 350 if (!mInitialSynced) { 351 setLoadingBit(BIT_LOADING_SYNC); 352 mSyncTask = mMediaSet.requestSync(this); 353 } 354 } 355 356 @Override 357 protected void onPause() { 358 super.onPause(); 359 mIsActive = false; 360 mAlbumDataAdapter.pause(); 361 mAlbumView.pause(); 362 DetailsHelper.pause(); 363 364 if (mSyncTask != null) { 365 mSyncTask.cancel(); 366 mSyncTask = null; 367 clearLoadingBit(BIT_LOADING_SYNC); 368 } 369 mActionModeHandler.pause(); 370 GalleryUtils.setSpinnerVisibility((Activity) mActivity, false); 371 } 372 373 @Override 374 protected void onDestroy() { 375 super.onDestroy(); 376 if (mAlbumDataAdapter != null) { 377 mAlbumDataAdapter.setLoadingListener(null); 378 } 379 } 380 381 private void initializeViews() { 382 mSelectionManager = new SelectionManager(mActivity, false); 383 mSelectionManager.setSelectionListener(this); 384 mGridDrawer = new GridDrawer((Context) mActivity, mSelectionManager); 385 Config.AlbumPage config = Config.AlbumPage.get((Context) mActivity); 386 mSlotView = new SlotView((Context) mActivity, config.slotViewSpec); 387 mAlbumView = new AlbumView( 388 mActivity, mSlotView, 0/* don't cache thumbnail */); 389 mSlotView.setSlotRenderer(mAlbumView); 390 mAlbumView.setSelectionDrawer(mGridDrawer); 391 mRootPane.addComponent(mSlotView); 392 mSlotView.setListener(new SlotView.SimpleListener() { 393 @Override 394 public void onDown(int index) { 395 AlbumPage.this.onDown(index); 396 } 397 398 @Override 399 public void onUp() { 400 AlbumPage.this.onUp(); 401 } 402 403 @Override 404 public void onSingleTapUp(int slotIndex) { 405 AlbumPage.this.onSingleTapUp(slotIndex); 406 } 407 408 @Override 409 public void onLongTap(int slotIndex) { 410 AlbumPage.this.onLongTap(slotIndex); 411 } 412 }); 413 mActionModeHandler = new ActionModeHandler(mActivity, mSelectionManager); 414 mActionModeHandler.setActionModeListener(new ActionModeListener() { 415 public boolean onActionItemClicked(MenuItem item) { 416 return onItemSelected(item); 417 } 418 }); 419 } 420 421 private void initializeData(Bundle data) { 422 mMediaSetPath = Path.fromString(data.getString(KEY_MEDIA_PATH)); 423 mParentMediaSetString = data.getString(KEY_PARENT_MEDIA_PATH); 424 mMediaSet = mActivity.getDataManager().getMediaSet(mMediaSetPath); 425 if (mMediaSet == null) { 426 Utils.fail("MediaSet is null. Path = %s", mMediaSetPath); 427 } 428 mSelectionManager.setSourceMediaSet(mMediaSet); 429 mAlbumDataAdapter = new AlbumDataAdapter(mActivity, mMediaSet); 430 mAlbumDataAdapter.setLoadingListener(new MyLoadingListener()); 431 mAlbumView.setModel(mAlbumDataAdapter); 432 } 433 434 private void showDetails() { 435 mShowDetails = true; 436 if (mDetailsHelper == null) { 437 mHighlightDrawer = new HighlightDrawer(mActivity.getAndroidContext(), 438 mSelectionManager); 439 mDetailsHelper = new DetailsHelper(mActivity, mRootPane, mDetailsSource); 440 mDetailsHelper.setCloseListener(new CloseListener() { 441 public void onClose() { 442 hideDetails(); 443 } 444 }); 445 } 446 mAlbumView.setSelectionDrawer(mHighlightDrawer); 447 mDetailsHelper.show(); 448 } 449 450 private void hideDetails() { 451 mShowDetails = false; 452 mDetailsHelper.hide(); 453 mAlbumView.setSelectionDrawer(mGridDrawer); 454 mSlotView.invalidate(); 455 } 456 457 @Override 458 protected boolean onCreateActionBar(Menu menu) { 459 Activity activity = (Activity) mActivity; 460 GalleryActionBar actionBar = mActivity.getGalleryActionBar(); 461 MenuInflater inflater = activity.getMenuInflater(); 462 463 if (mGetContent) { 464 inflater.inflate(R.menu.pickup, menu); 465 int typeBits = mData.getInt(Gallery.KEY_TYPE_BITS, 466 DataManager.INCLUDE_IMAGE); 467 468 actionBar.setTitle(GalleryUtils.getSelectionModePrompt(typeBits)); 469 } else { 470 inflater.inflate(R.menu.album, menu); 471 actionBar.setTitle(mMediaSet.getName()); 472 if (mMediaSet instanceof MtpDevice) { 473 menu.findItem(R.id.action_slideshow).setVisible(false); 474 } else { 475 menu.findItem(R.id.action_slideshow).setVisible(true); 476 } 477 478 MenuItem groupBy = menu.findItem(R.id.action_group_by); 479 FilterUtils.setupMenuItems(actionBar, mMediaSetPath, true); 480 481 if (groupBy != null) { 482 groupBy.setVisible(mShowClusterMenu); 483 } 484 485 actionBar.setTitle(mMediaSet.getName()); 486 } 487 actionBar.setSubtitle(null); 488 489 return true; 490 } 491 492 @Override 493 protected boolean onItemSelected(MenuItem item) { 494 switch (item.getItemId()) { 495 case android.R.id.home: { 496 if (mActivity.getStateManager().getStateCount() > 1) { 497 onBackPressed(); 498 } else if (mParentMediaSetString != null) { 499 Activity a = (Activity) mActivity; 500 int flags = Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK; 501 Intent intent = new Intent() 502 .setClass(a, Gallery.class) 503 .setFlags(flags); 504 a.startActivity(intent); 505 } 506 return true; 507 } 508 case R.id.action_cancel: 509 mActivity.getStateManager().finishState(this); 510 return true; 511 case R.id.action_select: 512 mSelectionManager.setAutoLeaveSelectionMode(false); 513 mSelectionManager.enterSelectionMode(); 514 return true; 515 case R.id.action_group_by: { 516 mActivity.getGalleryActionBar().showClusterDialog(this); 517 return true; 518 } 519 case R.id.action_slideshow: { 520 Bundle data = new Bundle(); 521 data.putString(SlideshowPage.KEY_SET_PATH, 522 mMediaSetPath.toString()); 523 data.putBoolean(SlideshowPage.KEY_REPEAT, true); 524 mActivity.getStateManager().startStateForResult( 525 SlideshowPage.class, REQUEST_SLIDESHOW, data); 526 return true; 527 } 528 case R.id.action_details: { 529 if (mShowDetails) { 530 hideDetails(); 531 } else { 532 showDetails(); 533 } 534 return true; 535 } 536 default: 537 return false; 538 } 539 } 540 541 @Override 542 protected void onStateResult(int request, int result, Intent data) { 543 switch (request) { 544 case REQUEST_SLIDESHOW: { 545 // data could be null, if there is no images in the album 546 if (data == null) return; 547 mFocusIndex = data.getIntExtra(SlideshowPage.KEY_PHOTO_INDEX, 0); 548 mSlotView.setCenterIndex(mFocusIndex); 549 break; 550 } 551 case REQUEST_PHOTO: { 552 if (data == null) return; 553 mFocusIndex = data.getIntExtra(PhotoPage.KEY_INDEX_HINT, 0); 554 mSlotView.setCenterIndex(mFocusIndex); 555 startTransition(); 556 break; 557 } 558 case REQUEST_DO_ANIMATION: { 559 startTransition(null); 560 break; 561 } 562 } 563 } 564 565 public void onSelectionModeChange(int mode) { 566 switch (mode) { 567 case SelectionManager.ENTER_SELECTION_MODE: { 568 mActionMode = mActionModeHandler.startActionMode(); 569 mVibrator.vibrate(100); 570 break; 571 } 572 case SelectionManager.LEAVE_SELECTION_MODE: { 573 mActionMode.finish(); 574 mRootPane.invalidate(); 575 break; 576 } 577 case SelectionManager.SELECT_ALL_MODE: { 578 mActionModeHandler.updateSupportedOperation(); 579 mRootPane.invalidate(); 580 break; 581 } 582 } 583 } 584 585 public void onSelectionChange(Path path, boolean selected) { 586 Utils.assertTrue(mActionMode != null); 587 int count = mSelectionManager.getSelectedCount(); 588 String format = mActivity.getResources().getQuantityString( 589 R.plurals.number_of_items_selected, count); 590 mActionModeHandler.setTitle(String.format(format, count)); 591 mActionModeHandler.updateSupportedOperation(path, selected); 592 } 593 594 @Override 595 public void onSyncDone(final MediaSet mediaSet, final int resultCode) { 596 Log.d(TAG, "onSyncDone: " + Utils.maskDebugInfo(mediaSet.getName()) + " result=" 597 + resultCode); 598 ((Activity) mActivity).runOnUiThread(new Runnable() { 599 @Override 600 public void run() { 601 if (resultCode == MediaSet.SYNC_RESULT_SUCCESS) { 602 mInitialSynced = true; 603 } 604 clearLoadingBit(BIT_LOADING_SYNC); 605 if (resultCode == MediaSet.SYNC_RESULT_ERROR && mIsActive) { 606 Toast.makeText((Context) mActivity, R.string.sync_album_error, 607 Toast.LENGTH_LONG).show(); 608 } 609 } 610 }); 611 } 612 613 private void setLoadingBit(int loadTaskBit) { 614 if (mLoadingBits == 0 && mIsActive) { 615 GalleryUtils.setSpinnerVisibility((Activity) mActivity, true); 616 } 617 mLoadingBits |= loadTaskBit; 618 } 619 620 private void clearLoadingBit(int loadTaskBit) { 621 mLoadingBits &= ~loadTaskBit; 622 if (mLoadingBits == 0 && mIsActive) { 623 GalleryUtils.setSpinnerVisibility((Activity) mActivity, false); 624 625 if (mAlbumDataAdapter.size() == 0) { 626 Toast.makeText((Context) mActivity, 627 R.string.empty_album, Toast.LENGTH_LONG).show(); 628 mActivity.getStateManager().finishState(AlbumPage.this); 629 } 630 } 631 } 632 633 private class MyLoadingListener implements LoadingListener { 634 @Override 635 public void onLoadingStarted() { 636 setLoadingBit(BIT_LOADING_RELOAD); 637 } 638 639 @Override 640 public void onLoadingFinished() { 641 clearLoadingBit(BIT_LOADING_RELOAD); 642 } 643 } 644 645 private class MyDetailsSource implements DetailsHelper.DetailsSource { 646 private int mIndex; 647 648 public int size() { 649 return mAlbumDataAdapter.size(); 650 } 651 652 public int getIndex() { 653 return mIndex; 654 } 655 656 // If requested index is out of active window, suggest a valid index. 657 // If there is no valid index available, return -1. 658 public int findIndex(int indexHint) { 659 if (mAlbumDataAdapter.isActive(indexHint)) { 660 mIndex = indexHint; 661 } else { 662 mIndex = mAlbumDataAdapter.getActiveStart(); 663 if (!mAlbumDataAdapter.isActive(mIndex)) { 664 return -1; 665 } 666 } 667 return mIndex; 668 } 669 670 public MediaDetails getDetails() { 671 MediaObject item = mAlbumDataAdapter.get(mIndex); 672 if (item != null) { 673 mHighlightDrawer.setHighlightItem(item.getPath()); 674 return item.getDetails(); 675 } else { 676 return null; 677 } 678 } 679 } 680} 681