open TrackMenuFragment
This commit is contained in:
parent
94b97e0318
commit
048f6035cb
3 changed files with 28 additions and 16 deletions
|
@ -11,6 +11,7 @@ import androidx.annotation.DrawableRes;
|
|||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
@ -25,6 +26,7 @@ import net.osmand.plus.OsmandApplication;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.track.TrackMenuFragment;
|
||||
import net.osmand.plus.widgets.tools.CropCircleTransformation;
|
||||
import net.osmand.plus.wikipedia.WikiArticleHelper;
|
||||
import net.osmand.plus.wikivoyage.WikivoyageUtils;
|
||||
|
@ -33,6 +35,7 @@ import net.osmand.plus.wikivoyage.data.TravelGpx;
|
|||
import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper;
|
||||
import net.osmand.plus.wikivoyage.explore.travelcards.TravelGpxCard;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -58,7 +61,7 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
|||
this.listener = listener;
|
||||
}
|
||||
|
||||
SavedArticlesRvAdapter(OsmandApplication app) {
|
||||
SavedArticlesRvAdapter(OsmandApplication app, FragmentActivity activity) {
|
||||
this.app = app;
|
||||
this.settings = app.getSettings();
|
||||
picasso = PicassoUtils.getPicasso(app);
|
||||
|
@ -147,7 +150,9 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
|||
View.OnClickListener readClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
app.getTravelHelper().createGpxFile(article);
|
||||
if (listener != null) {
|
||||
listener.openArticle(article);
|
||||
}
|
||||
}
|
||||
};
|
||||
holder.leftButton.setOnClickListener(readClickListener);
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.view.ViewGroup;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.recyclerview.widget.DiffUtil;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
@ -17,12 +18,15 @@ import net.osmand.PlatformUtil;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||
import net.osmand.plus.track.TrackMenuFragment;
|
||||
import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment;
|
||||
import net.osmand.plus.wikivoyage.data.TravelArticle;
|
||||
import net.osmand.plus.wikivoyage.data.TravelGpx;
|
||||
import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -44,13 +48,21 @@ public class SavedArticlesTabFragment extends BaseOsmAndFragment implements Trav
|
|||
|
||||
final View mainView = inflater.inflate(R.layout.fragment_saved_articles_tab, container, false);
|
||||
|
||||
adapter = new SavedArticlesRvAdapter(app);
|
||||
adapter = new SavedArticlesRvAdapter(app, getActivity());
|
||||
adapter.setListener(new SavedArticlesRvAdapter.Listener() {
|
||||
@Override
|
||||
public void openArticle(TravelArticle article) {
|
||||
FragmentManager fm = getFragmentManager();
|
||||
if (fm != null) {
|
||||
WikivoyageArticleDialogFragment.showInstance(app, fm, article.generateIdentifier(), article.getLang());
|
||||
if (article instanceof TravelGpx) {
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity != null) {
|
||||
File file = app.getTravelHelper().createGpxFile(article);
|
||||
TrackMenuFragment.openTrack(getActivity(), file, null);
|
||||
}
|
||||
} else {
|
||||
FragmentManager fm = getFragmentManager();
|
||||
if (fm != null) {
|
||||
WikivoyageArticleDialogFragment.showInstance(app, fm, article.generateIdentifier(), article.getLang());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -12,12 +12,13 @@ import net.osmand.AndroidUtils;
|
|||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.track.TrackMenuFragment;
|
||||
import net.osmand.plus.wikipedia.WikiArticleHelper;
|
||||
import net.osmand.plus.wikivoyage.data.TravelGpx;
|
||||
import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class TravelGpxCard extends BaseTravelCard {
|
||||
|
||||
public static final int TYPE = 3;
|
||||
|
@ -52,14 +53,8 @@ public class TravelGpxCard extends BaseTravelCard {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
if (activity != null) {
|
||||
app.getTravelHelper().createGpxFile(article);
|
||||
final OsmandSettings settings = app.getSettings();
|
||||
settings.setMapLocationToShow(article.getLat(), article.getLon(),
|
||||
settings.getLastKnownMapZoom(),
|
||||
null,
|
||||
false,
|
||||
article.getGpxFile());
|
||||
MapActivity.launchMapActivityMoveToTop(activity);
|
||||
File file = app.getTravelHelper().createGpxFile(article);
|
||||
TrackMenuFragment.openTrack(activity, file, null);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue