private void shareOnFacebook() { facebookCallbackManager = CallbackManager.Factory.create(); ShareDialog shareDialog = new ShareDialog(this); if (ShareDialog.canShow(ShareLinkContent.class)) { ShareLinkContent linkContent = new ShareLinkContent.Builder() .setShareHashtag(new ShareHashtag.Builder() .setHashtag(getString(R.string.nomorehomelessanimals)).build()) .setQuote(getString(R.string.explore_adoption)) .setContentUrl(Uri.parse(getString(R.string.findmeahome_store_url))) .build(); shareDialog.show(linkContent); } }
@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; }
/** * Handle Facebook */ public static void shareImageOnFace(Activity activity, RelativeLayout photoContent, View v) { // Cria conteudo para ser publicado no face SharePhoto photo = new SharePhoto.Builder().setBitmap(ImageUtil.drawBitmap(photoContent)).build(); SharePhotoContent content = new SharePhotoContent.Builder() .addPhoto(photo) .setShareHashtag(new ShareHashtag.Builder().setHashtag(HASHTAG).build()) .build(); new ShareDialog(activity).show(content); }