Try to fix storage dialog crash

This commit is contained in:
Alexey Kulish 2016-03-17 17:01:59 +03:00
parent eda43d414c
commit 4f6c8bfd75

View file

@ -3,7 +3,6 @@ package net.osmand.plus.download.ui;
import android.app.Activity; import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.os.StatFs; import android.os.StatFs;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -57,8 +56,8 @@ public class DataStoragePlaceDialogFragment extends BottomSheetDialogFragment {
hasExternalStoragePermission = DownloadActivity.hasPermissionToWriteExternalStorage(getActivity()); hasExternalStoragePermission = DownloadActivity.hasPermissionToWriteExternalStorage(getActivity());
internalStorage = getInternalStorageDirectory(getActivity()); internalStorage = getInternalStorageDirectory(getActivity());
sharedStorage = getSharedStorageDirectory(getActivity());
if (hasExternalStoragePermission) { if (hasExternalStoragePermission) {
sharedStorage = getSharedStorageDirectory(getActivity());
externalStorage = getMyApplication().getSettings().getSecondaryStorage(); externalStorage = getMyApplication().getSettings().getSecondaryStorage();
} }
@ -98,7 +97,7 @@ public class DataStoragePlaceDialogFragment extends BottomSheetDialogFragment {
sharedMemoryDescription.setText(getFreeSpace(sharedStorage)); sharedMemoryDescription.setText(getFreeSpace(sharedStorage));
View memoryStickRow = view.findViewById(R.id.memoryStickRow); View memoryStickRow = view.findViewById(R.id.memoryStickRow);
if (hasExternalStoragePermission) { if (hasExternalStoragePermission && externalStorage != null) {
memoryStickRow.setOnClickListener(externalMemoryOnClickListener); memoryStickRow.setOnClickListener(externalMemoryOnClickListener);
ImageView memoryStickImageView = (ImageView) view.findViewById(R.id.memoryStickImageView); ImageView memoryStickImageView = (ImageView) view.findViewById(R.id.memoryStickImageView);
memoryStickImageView.setImageDrawable(getContentIcon(R.drawable.ic_sdcard)); memoryStickImageView.setImageDrawable(getContentIcon(R.drawable.ic_sdcard));