Check ShareActionprovider is not null

This commit is contained in:
Adam Jones 2017-03-09 00:11:01 +00:00
parent 8ba07b0c9c
commit ab3ef33c10
2 changed files with 9 additions and 5 deletions

View file

@ -222,10 +222,14 @@ public class MediaDetailPagerFragment extends Fragment implements ViewPager.OnPa
// Set ShareActionProvider Intent
ShareActionProvider mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menu.findItem(R.id.menu_share_current_image));
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, m.getDisplayTitle() + " \n" + m.getDescriptionUrl());
mShareActionProvider.setShareIntent(shareIntent);
// On some phones null is returned for some reason:
// https://github.com/commons-app/apps-android-commons/issues/413
if(mShareActionProvider != null) {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, m.getDisplayTitle() + " \n" + m.getDescriptionUrl());
mShareActionProvider.setShareIntent(shareIntent);
}
if(m instanceof Contribution) {
Contribution c = (Contribution)m;