protected void postPhoto() { RunnableWithParameter<Photo> runnable = new RunnableWithParameter<Photo>() { @Override public void run(Photo photo) { new PostPhotoTask(photo).execute(); } }; PhotoUtils.validateUrlForSizeExistAsyncAndRun(photo, thumbSize, runnable, null, loadingControl); }
void init(View view) { try { new ShowCurrentlyLoggedInUserTask(view).execute(); messageEt = (EditText) view.findViewById(R.id.message); messageEt.setText(null); Button logOutButton = (Button) view.findViewById(R.id.logoutBtn); logOutButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { TrackerUtils.trackButtonClickEvent("logoutBtn", FacebookFragment.this); performFacebookLogout(); } }); sendButton = (Button) view.findViewById(R.id.sendBtn); sendButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { TrackerUtils.trackButtonClickEvent("sendBtn", FacebookFragment.this); if (GuiUtils.checkLoggedInAndOnline()) { postPhoto(); } } }); { sendButton.setEnabled(false); PhotoUtils.validateShareTokenExistsAsyncAndRunAsync( photo, new RunnableWithParameter<Photo>() { @Override public void run(Photo parameter) { sendButton.setEnabled(true); } }, new Runnable() { @Override public void run() { sendButton.setEnabled(false); } }, new FBLoadingControl(view)); } } catch (Exception ex) { GuiUtils.error(TAG, R.string.errorCouldNotInitFacebookFragment, ex, getActivity()); dismissAllowingStateLoss(); } }
/** * @param message the sharing message * @param photo the photo to share * @param thumbSize the thumb image size * @param appendToken whether to append share token to the photo url * @throws FileNotFoundException * @throws MalformedURLException * @throws IOException */ public static void sharePhoto( String message, Photo photo, ReturnSizes thumbSize, boolean appendToken) throws FileNotFoundException, MalformedURLException, IOException { Facebook facebook = FacebookProvider.getFacebook(); Bundle bparams = new Bundle(); bparams.putString("message", message); bparams.putString("name", photo.getTitle()); bparams.putString("caption", photo.getTitle()); bparams.putString( "description", CommonUtils.getStringResource(R.string.share_facebook_default_description)); bparams.putString("picture", photo.getUrl(thumbSize.toString())); bparams.putString("link", PhotoUtils.getShareUrl(photo, appendToken)); TrackerUtils.trackSocial("facebook", "feed", message + " | " + photo.getUrl(Photo.URL)); facebook.request("feed", bparams, "POST"); }