use of net.osmand.plus.dashboard.tools.DashFragmentData in project Osmand by osmandapp.
the class OsmandPlugin method enablePlugin.
public static boolean enablePlugin(@Nullable Activity activity, @NonNull OsmandApplication app, @NonNull OsmandPlugin plugin, boolean enable) {
if (enable) {
if (!plugin.init(app, activity)) {
plugin.setEnabled(false);
return false;
} else {
plugin.setEnabled(true);
}
} else {
plugin.disable(app);
plugin.setEnabled(false);
}
app.getSettings().enablePlugin(plugin.getId(), enable);
app.getQuickActionRegistry().updateActionTypes();
if (activity != null) {
if (activity instanceof MapActivity) {
final MapActivity mapActivity = (MapActivity) activity;
plugin.updateLayers(mapActivity, mapActivity);
mapActivity.getDashboard().refreshDashboardFragments();
DashFragmentData fragmentData = plugin.getCardFragment();
if (!enable && fragmentData != null) {
FragmentManager fm = mapActivity.getSupportFragmentManager();
Fragment fragment = fm.findFragmentByTag(fragmentData.tag);
if (fragment != null) {
fm.beginTransaction().remove(fragment).commitAllowingStateLoss();
}
}
}
if (plugin.isMarketPlugin() || plugin.isPaid()) {
if (plugin.isActive()) {
plugin.showInstallDialog(activity);
} else if (OsmandPlugin.checkPluginPackage(app, plugin)) {
plugin.showDisableDialog(activity);
}
}
}
return true;
}
Aggregations