mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Check ShareActionprovider is not null
This commit is contained in:
parent
8ba07b0c9c
commit
ab3ef33c10
2 changed files with 9 additions and 5 deletions
|
|
@ -222,10 +222,14 @@ public class MediaDetailPagerFragment extends Fragment implements ViewPager.OnPa
|
||||||
|
|
||||||
// Set ShareActionProvider Intent
|
// Set ShareActionProvider Intent
|
||||||
ShareActionProvider mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menu.findItem(R.id.menu_share_current_image));
|
ShareActionProvider mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menu.findItem(R.id.menu_share_current_image));
|
||||||
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
// On some phones null is returned for some reason:
|
||||||
shareIntent.setType("text/plain");
|
// https://github.com/commons-app/apps-android-commons/issues/413
|
||||||
shareIntent.putExtra(Intent.EXTRA_TEXT, m.getDisplayTitle() + " \n" + m.getDescriptionUrl());
|
if(mShareActionProvider != null) {
|
||||||
mShareActionProvider.setShareIntent(shareIntent);
|
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) {
|
if(m instanceof Contribution) {
|
||||||
Contribution c = (Contribution)m;
|
Contribution c = (Contribution)m;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
android:id="@+id/menu_share_current_image"
|
android:id="@+id/menu_share_current_image"
|
||||||
app:actionProviderClass="android.support.v7.widget.ShareActionProvider"
|
app:actionProviderClass="android.support.v7.widget.ShareActionProvider"
|
||||||
android:title="@string/menu_share"
|
android:title="@string/menu_share"
|
||||||
app:showAsAction="ifRoom|withText" />
|
app:showAsAction="ifRoom" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_browser_current_image"
|
android:id="@+id/menu_browser_current_image"
|
||||||
android:title="@string/menu_open_in_browser"
|
android:title="@string/menu_open_in_browser"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue