Java 类com.facebook.share.widget.ShareButton 实例源码

项目:aftercare-app-android    文件:DCRoutineCompletedFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_routine_completed, container);
    fbShare = (ShareButton) view.findViewById(R.id.fb_share);
    tvMessage = (DCTextView) view.findViewById(R.id.tv_message);
    tvCompleted = (DCTextView) view.findViewById(R.id.tv_completed);
    ivTooth = (ImageView) view.findViewById(R.id.iv_tooth);

    if (getArguments() != null) {
        final Routine.Type routineType = (Routine.Type)getArguments().getSerializable(KEY_ROUTINE_TYPE);

        if (routineType != null) {
            AudibleMessage audibleMessage;
            String shareLinkMessage;

            switch (routineType) {
                case MORNING:
                    shareLinkMessage = getString(R.string.fb_share_morning_routine_completed);
                    audibleMessage = AudibleMessage.MORNING_ROUTINE_END;
                    break;
                default:
                    shareLinkMessage = getString(R.string.fb_share_evening_routine_completed);
                    audibleMessage = AudibleMessage.EVENING_ROUTINE_END;
                    break;
            }

            tvMessage.setText(audibleMessage.getMessage(getActivity()));

            ShareLinkContent shareLinkContent = new ShareLinkContent.Builder()
                    .setContentUrl(Uri.parse(DCConstants.DENTACARE_GOOGLE_PLAY))
                    .setShareHashtag(new ShareHashtag.Builder()
                            .setHashtag("#dentacoin")
                            .build())
                    .setQuote(shareLinkMessage)
                    .build();

            fbShare.setShareContent(shareLinkContent);

            if (audibleMessage.getVoices() != null && audibleMessage.getVoices().length > 0) {
                DCSoundManager.getInstance().playVoice(getActivity(), audibleMessage.getVoices()[0]);
            }
        }
    }

    AlphaAnimation alphaAnimation = new AlphaAnimation(0f, 1f);
    alphaAnimation.setDuration(1000);
    ivTooth.startAnimation(alphaAnimation);

    AlphaAnimation dayAlphaAnimation = new AlphaAnimation(0f, 1f);
    dayAlphaAnimation.setDuration(2000);
    tvCompleted.startAnimation(dayAlphaAnimation);

    AlphaAnimation alphaAnimationMessage = new AlphaAnimation(0f, 1f);
    alphaAnimationMessage.setDuration(1000);
    tvMessage.startAnimation(alphaAnimationMessage);

    return view;
}
项目:androidadvanced    文件:RecipesAdapterTest.java   
@Test
public void testFBShareBind_shareContentSet() throws Exception {
    int positionToShow = 0;
    when(recipeList.get(positionToShow)).thenReturn(recipe);

    shadowAdapter.itemVisible(positionToShow);
    View view = shadowAdapter.getViewForHolderPosition(positionToShow);
    ShareButton fbShare = (ShareButton) view.findViewById(R.id.fbShare);

    ShareContent shareContent = fbShare.getShareContent();
    assertNotNull(shareContent);
    assertEquals(URL, shareContent.getContentUrl().toString());
}