Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2018-04-11 10:43:50 +02:00
commit c4d386d7f5
4 changed files with 33 additions and 12 deletions

View file

@ -3777,4 +3777,6 @@
<string name="poi_service_vehicle_motor_yes">Двигатель</string>
<string name="poi_service_vehicle_insurance_yes">Страхование</string>
<string name="poi_aerialway_zip_line">Зиплайн</string>
</resources>

View file

@ -3795,4 +3795,8 @@
<string name="poi_service_vehicle_insurance_yes">Insurance</string>
<string name="poi_service_vehicle_tyres_yes">Tyres</string>
<string name="poi_aerialway_zip_line">Zip line</string>
<string name="poi_climbing_adventure">Climbing adventure</string>
</resources>

View file

@ -22,6 +22,7 @@ import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.IndexConstants;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.wikivoyage.WikivoyageBaseDialogFragment;
import net.osmand.plus.wikivoyage.data.WikivoyageArticle;
@ -260,11 +261,24 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
return normal;
}
public static boolean showInstance(FragmentManager fm, long cityId, ArrayList<String> langs) {
public static boolean showInstance(@NonNull OsmandApplication app,
@NonNull FragmentManager fm,
long cityId,
@Nullable String selectedLang) {
ArrayList<String> langs = app.getWikivoyageDbHelper().getArticleLangs(cityId);
return showInstance(fm, cityId, langs, selectedLang);
}
public static boolean showInstance(@NonNull FragmentManager fm,
long cityId,
@NonNull ArrayList<String> langs) {
return showInstance(fm, cityId, langs, null);
}
public static boolean showInstance(FragmentManager fm, long cityId, ArrayList<String> langs, @Nullable String selectedLang) {
public static boolean showInstance(@NonNull FragmentManager fm,
long cityId,
@NonNull ArrayList<String> langs,
@Nullable String selectedLang) {
try {
Bundle args = new Bundle();
args.putLong(CITY_ID_KEY, cityId);

View file

@ -18,9 +18,10 @@ import android.widget.ImageButton;
import android.widget.ProgressBar;
import net.osmand.ResultMatcher;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment;
import net.osmand.plus.wikivoyage.WikivoyageBaseDialogFragment;
import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment;
import net.osmand.plus.wikivoyage.data.WikivoyageLocalDataHelper;
import net.osmand.plus.wikivoyage.data.WikivoyageSearchHistoryItem;
import net.osmand.plus.wikivoyage.data.WikivoyageSearchResult;
@ -47,7 +48,8 @@ public class WikivoyageSearchDialogFragment extends WikivoyageBaseDialogFragment
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
searchHelper = new WikivoyageSearchHelper(getMyApplication());
final OsmandApplication app = getMyApplication();
searchHelper = new WikivoyageSearchHelper(app);
final View mainView = inflate(R.layout.fragment_wikivoyage_search_dialog, container);
@ -93,7 +95,7 @@ public class WikivoyageSearchDialogFragment extends WikivoyageBaseDialogFragment
}
});
adapter = new SearchRecyclerViewAdapter(getMyApplication());
adapter = new SearchRecyclerViewAdapter(app);
final RecyclerView rv = (RecyclerView) mainView.findViewById(R.id.recycler_view);
rv.setLayoutManager(new LinearLayoutManager(getContext()));
rv.setAdapter(adapter);
@ -101,18 +103,17 @@ public class WikivoyageSearchDialogFragment extends WikivoyageBaseDialogFragment
@Override
public void onClick(View v) {
int pos = rv.getChildAdapterPosition(v);
if (pos != RecyclerView.NO_POSITION) {
FragmentManager fm = getFragmentManager();
if (pos != RecyclerView.NO_POSITION && fm != null) {
Object item = adapter.getItem(pos);
if (item instanceof WikivoyageSearchResult) {
WikivoyageSearchResult res = (WikivoyageSearchResult) item;
WikivoyageArticleDialogFragment.showInstance(getFragmentManager(),
res.getCityId(), new ArrayList<>(res.getLangs()));
WikivoyageArticleDialogFragment
.showInstance(fm, res.getCityId(), new ArrayList<>(res.getLangs()));
} else if (item instanceof WikivoyageSearchHistoryItem) {
WikivoyageSearchHistoryItem historyItem = (WikivoyageSearchHistoryItem) item;
ArrayList<String> langs = getMyApplication().getWikivoyageDbHelper()
.getArticleLangs(historyItem.getCityId());
WikivoyageArticleDialogFragment.showInstance(getFragmentManager(),
historyItem.getCityId(), langs, historyItem.getLang());
WikivoyageArticleDialogFragment
.showInstance(app, fm, historyItem.getCityId(), historyItem.getLang());
}
}
}