Fix activity not found

This commit is contained in:
PavelRatushny 2017-11-08 18:36:21 +02:00
parent aaf4d7ad8c
commit e462afc10e
3 changed files with 10 additions and 4 deletions

View file

@ -8,6 +8,7 @@ import android.graphics.PorterDuff;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v4.content.FileProvider; import android.support.v4.content.FileProvider;
@ -535,8 +536,10 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
} }
private void importFavourites() { private void importFavourites() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
((FavoritesActivity) getActivity()).importFavourites(); ((FavoritesActivity) getActivity()).importFavourites();
} }
}
public void shareFavorites(final FavoriteGroup group) { public void shareFavorites(final FavoriteGroup group) {
final AsyncTask<Void, Void, Void> exportTask = new AsyncTask<Void, Void, Void>() { final AsyncTask<Void, Void, Void> exportTask = new AsyncTask<Void, Void, Void>() {

View file

@ -529,8 +529,10 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
} }
private void addTrack() { private void addTrack() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
((FavoritesActivity) getActivity()).addTrack(); ((FavoritesActivity) getActivity()).addTrack();
} }
}
public void showProgressBar() { public void showProgressBar() {
((FavoritesActivity) getActivity()).setSupportProgressBarIndeterminateVisibility(true); ((FavoritesActivity) getActivity()).setSupportProgressBarIndeterminateVisibility(true);

View file

@ -10,6 +10,7 @@ import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.RequiresApi;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.support.v7.widget.SearchView; import android.support.v7.widget.SearchView;
@ -83,14 +84,14 @@ public class FavoritesActivity extends TabActivity {
} }
} }
@TargetApi(Build.VERSION_CODES.KITKAT) @RequiresApi(Build.VERSION_CODES.KITKAT)
public void addTrack() { public void addTrack() {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.setType("*/*"); intent.setType("*/*");
startActivityForResult(intent, OPEN_GPX_DOCUMENT_REQUEST); startActivityForResult(intent, OPEN_GPX_DOCUMENT_REQUEST);
} }
@TargetApi(Build.VERSION_CODES.KITKAT) @RequiresApi(Build.VERSION_CODES.KITKAT)
public void importFavourites() { public void importFavourites() {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.setType("*/*"); intent.setType("*/*");