public void buildActionBarNav() { if ((((MainTimeLineActivity) getActivity()).getMenuFragment()).getCurrentIndex() != LeftMenuFragment.HOME_INDEX) { return; } ((MainTimeLineActivity) getActivity()).setCurrentFragment(this); getActivity().getActionBar().setDisplayShowTitleEnabled(false); getActivity().getActionBar().setDisplayHomeAsUpEnabled(Utility.isDevicePort()); getActivity().getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); List<GroupBean> list = new ArrayList<GroupBean>(); if (GlobalContext.getInstance().getGroup() != null) { list = GlobalContext.getInstance().getGroup().getLists(); } else { list = new ArrayList<GroupBean>(); } navAdapter = new FriendsTimeLineListNavAdapter(getActivity(), buildListNavData(list)); final List<GroupBean> finalList = list; getActivity() .getActionBar() .setListNavigationCallbacks( navAdapter, new ActionBar.OnNavigationListener() { @Override public boolean onNavigationItemSelected(int which, long itemId) { if (!Utility.isTaskStopped(dbTask)) { return true; } String groupId = getGroupIdFromIndex(which, finalList); if (!groupId.equals(currentGroupId)) { switchFriendsGroup(groupId); } return true; } }); currentGroupId = FriendsTimeLineDBTask.getRecentGroupId(GlobalContext.getInstance().getCurrentAccountId()); if (Utility.isDevicePort()) { ((MainTimeLineActivity) getActivity()).setTitle(""); getActivity().getActionBar().setIcon(R.drawable.ic_menu_home); } else { ((MainTimeLineActivity) getActivity()).setTitle(""); getActivity().getActionBar().setIcon(R.drawable.ic_launcher); } if (getActivity().getActionBar().getNavigationMode() == ActionBar.NAVIGATION_MODE_LIST && isVisible()) { getActivity().getActionBar().setSelectedNavigationItem(getRecentNavIndex()); } }
private void animateClose(ObjectAnimator backgroundAnimator) { AnimationRect rect = getArguments().getParcelable("rect"); if (rect == null) { photoView.animate().alpha(0); backgroundAnimator.start(); return; } final Rect startBounds = rect.scaledBitmapRect; final Rect finalBounds = AnimationUtility.getBitmapRectFromImageView(photoView); if (finalBounds == null) { photoView.animate().alpha(0); backgroundAnimator.start(); return; } if (Utility.isDevicePort() != rect.isScreenPortrait) { photoView.animate().alpha(0); backgroundAnimator.start(); return; } float startScale; if ((float) finalBounds.width() / finalBounds.height() > (float) startBounds.width() / startBounds.height()) { startScale = (float) startBounds.height() / finalBounds.height(); } else { startScale = (float) startBounds.width() / finalBounds.width(); } final float startScaleFinal = startScale; int deltaTop = startBounds.top - finalBounds.top; int deltaLeft = startBounds.left - finalBounds.left; photoView.setPivotY((photoView.getHeight() - finalBounds.height()) / 2); photoView.setPivotX((photoView.getWidth() - finalBounds.width()) / 2); photoView .animate() .translationX(deltaLeft) .translationY(deltaTop) .scaleY(startScaleFinal) .scaleX(startScaleFinal) .setDuration(ANIMATION_DURATION) .setInterpolator(new AccelerateDecelerateInterpolator()) .withEndAction( new Runnable() { @Override public void run() { photoView .animate() .alpha(0.0f) .setDuration(200) .withEndAction( new Runnable() { @Override public void run() {} }); } }); AnimatorSet animationSet = new AnimatorSet(); animationSet.setDuration(ANIMATION_DURATION); animationSet.setInterpolator(new AccelerateDecelerateInterpolator()); animationSet.playTogether(backgroundAnimator); animationSet.playTogether( ObjectAnimator.ofFloat( photoView, "clipBottom", 0, AnimationRect.getClipBottom(rect, finalBounds))); animationSet.playTogether( ObjectAnimator.ofFloat( photoView, "clipRight", 0, AnimationRect.getClipRight(rect, finalBounds))); animationSet.playTogether( ObjectAnimator.ofFloat( photoView, "clipTop", 0, AnimationRect.getClipTop(rect, finalBounds))); animationSet.playTogether( ObjectAnimator.ofFloat( photoView, "clipLeft", 0, AnimationRect.getClipLeft(rect, finalBounds))); animationSet.start(); }