boolean sharePhoto(Photo photo) { try { sharePhoto(messageEt.getText().toString(), photo, thumbSize, true); return true; } catch (Exception ex) { GuiUtils.error(TAG, R.string.errorCouldNotSendFacebookPhoto, ex, getActivity()); } return false; }
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(); } }
@Override protected Boolean doInBackground(Void... params) { try { Facebook facebook = FacebookProvider.getFacebook(); Bundle bparams = new Bundle(); bparams.putString("fields", "name"); String response = facebook.request("me", bparams); JSONObject jsonObject = new JSONObject(response); name = jsonObject.getString("name"); return true; } catch (Exception ex) { GuiUtils.error(TAG, R.string.errorCouldNotRetrieveFacebookScreenName, ex, activity); } return false; }