Fix screen rotation
This commit is contained in:
parent
7fb1bee03a
commit
fd4f89cd6f
3 changed files with 14 additions and 15 deletions
|
@ -45,7 +45,7 @@ public abstract class DashBaseFragment extends Fragment {
|
|||
public final void onResume() {
|
||||
// use on open update
|
||||
super.onResume();
|
||||
if(dashboard != null && dashboard.isVisible()) {
|
||||
if(dashboard != null && dashboard.isVisible() && getView() != null) {
|
||||
onOpenDash();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,6 @@ public class DashPluginsFragment extends DashBaseFragment {
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
OsmandPlugin plugin = (OsmandPlugin) view.getTag();
|
||||
|
||||
Intent intent = new Intent(getActivity(), PluginActivity.class);
|
||||
intent.putExtra(PluginActivity.EXTRA_PLUGIN_ID, plugin.getId());
|
||||
startActivity(intent);
|
||||
|
@ -60,8 +59,12 @@ public class DashPluginsFragment extends DashBaseFragment {
|
|||
startActivity(new Intent(getActivity(), getMyApplication().getAppCustomization().getPluginsActivity()));
|
||||
}
|
||||
});
|
||||
initPlugins();
|
||||
return contentView;
|
||||
}
|
||||
|
||||
LinearLayout pluginsContainer = (LinearLayout) contentView.findViewById(R.id.plugins);
|
||||
|
||||
private void initPlugins() {
|
||||
List<OsmandPlugin> notActivePlugins = OsmandPlugin.getNotEnabledPlugins();
|
||||
Collections.shuffle(notActivePlugins);
|
||||
plugins = new ArrayList<OsmandPlugin>();
|
||||
|
@ -81,23 +84,17 @@ public class DashPluginsFragment extends DashBaseFragment {
|
|||
}
|
||||
plugins.add(plugin);
|
||||
}
|
||||
for (OsmandPlugin p : plugins) {
|
||||
inflatePluginView(inflater, pluginsContainer, p);
|
||||
}
|
||||
return contentView;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onOpenDash() {
|
||||
View contentView = getView();
|
||||
if (contentView == null) {
|
||||
return;
|
||||
}
|
||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||
LinearLayout pluginsContainer = (LinearLayout) contentView.findViewById(R.id.plugins);
|
||||
for (int pluginIndex = 0; pluginIndex < plugins.size(); pluginIndex++) {
|
||||
View pluginView = pluginsContainer.getChildAt(pluginIndex);
|
||||
updatePluginState(pluginView, plugins.get(pluginIndex));
|
||||
pluginsContainer.removeAllViews();
|
||||
for (OsmandPlugin p : plugins) {
|
||||
inflatePluginView(inflater, pluginsContainer, p);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -231,7 +231,9 @@ public class DashboardOnMap {
|
|||
while(it.hasNext()) {
|
||||
WeakReference<DashBaseFragment> df = it.next();
|
||||
if(df.get() != null) {
|
||||
if(df.get().getView() != null) {
|
||||
df.get().onOpenDash();
|
||||
}
|
||||
} else {
|
||||
it.remove();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue