/** * Sets the share content on the button. * @param shareContent The share content. */ public void setShareContent(final ShareContent shareContent) { this.shareContent = shareContent; if (!enabledExplicitlySet) { internalSetEnabled(canShare()); } }
private DeviceShareButton( final Context context, final AttributeSet attrs, final int defStyleAttr) { super( context, attrs, defStyleAttr, 0, AnalyticsEvents.EVENT_DEVICE_SHARE_BUTTON_CREATE, AnalyticsEvents.EVENT_DEVICE_SHARE_BUTTON_DID_TAP); requestCode = isInEditMode() ? 0 : getDefaultRequestCode(); internalSetEnabled(false); }
@Override protected void configureButton( final Context context, final AttributeSet attrs, final int defStyleAttr, final int defStyleRes) { super.configureButton(context, attrs, defStyleAttr, defStyleRes); setInternalOnClickListener(this.getShareOnClickListener()); }
private DeviceShareDialog getDialog() { if (dialog != null) { return dialog; } if (DeviceShareButton.this.getFragment() != null) { dialog = new DeviceShareDialog(DeviceShareButton.this.getFragment()); } else if (DeviceShareButton.this.getNativeFragment() != null) { dialog = new DeviceShareDialog(DeviceShareButton.this.getNativeFragment()); } else { dialog = new DeviceShareDialog(getActivity()); } return dialog; } }
/** * Allows registration of a callback for when the share completes. This should be called * in the {@link android.app.Activity#onCreate(android.os.Bundle)} or * {@link android.support.v4.app.Fragment#onCreate(android.os.Bundle)} methods. * * @param callbackManager The {@link com.facebook.CallbackManager} instance that will be * handling results that are received via * {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)} * @param callback The callback that should be called to handle dialog completion. * @param requestCode The request code to use, this should be outside of the range of those * reserved for the Facebook SDK * {@link com.facebook.FacebookSdk#isFacebookRequestCode(int)}. */ public void registerCallback( final CallbackManager callbackManager, final FacebookCallback<DeviceShareDialog.Result> callback, final int requestCode) { setRequestCode(requestCode); getDialog().registerCallback(callbackManager, callback, requestCode); }
private boolean canShare() { return new DeviceShareDialog(getActivity()).canShow(getShareContent()); }
@Override public void onClick(View v) { callExternalOnClickListener(v); getDialog().show(getShareContent()); } };
/** * Allows registration of a callback for when the share completes. This should be called * in the {@link android.app.Activity#onCreate(android.os.Bundle)} or * {@link android.support.v4.app.Fragment#onCreate(android.os.Bundle)} methods. * * @param callbackManager The {@link com.facebook.CallbackManager} instance that will be * handling results that are received via * {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)} * @param callback The callback that should be called to handle dialog completion. */ public void registerCallback( final CallbackManager callbackManager, final FacebookCallback<DeviceShareDialog.Result> callback) { getDialog().registerCallback(callbackManager, callback); }