Fix last view visibility
This commit is contained in:
parent
4117295fe8
commit
490d42f334
2 changed files with 21 additions and 7 deletions
|
@ -6,8 +6,10 @@ import android.os.Bundle;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.ExpandableListView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -18,6 +20,8 @@ import androidx.core.view.ViewCompat;
|
|||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.github.ksoichiro.android.observablescrollview.ScrollUtils;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -129,6 +133,7 @@ public abstract class BaseSettingsListFragment extends BaseOsmAndFragment implem
|
|||
adapter = new ExportSettingsAdapter(app, exportMode, this, nightMode);
|
||||
adapter.updateSettingsItems(dataList, selectedItemsMap);
|
||||
expandableList.setAdapter(adapter);
|
||||
setupListView(expandableList);
|
||||
updateAvailableSpace();
|
||||
|
||||
return root;
|
||||
|
@ -195,6 +200,22 @@ public abstract class BaseSettingsListFragment extends BaseOsmAndFragment implem
|
|||
});
|
||||
}
|
||||
|
||||
private void setupListView(@NonNull final ListView listView) {
|
||||
if (listView.getFooterViewsCount() == 0) {
|
||||
int padding = getResources().getDimensionPixelSize(R.dimen.toolbar_height_expanded);
|
||||
|
||||
View emptyView = new View(listView.getContext());
|
||||
emptyView.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, padding));
|
||||
listView.addFooterView(emptyView);
|
||||
ScrollUtils.addOnGlobalLayoutListener(listView, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
listView.requestLayout();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateAvailableSpace() {
|
||||
long calculatedSize = ExportSettingsAdapter.calculateItemsSize(adapter.getData());
|
||||
if (calculatedSize != 0) {
|
||||
|
|
|
@ -58,7 +58,6 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
|||
private final int secondaryColorRes;
|
||||
private final int groupViewHeight;
|
||||
private final int childViewHeight;
|
||||
private final int listBottomPadding;
|
||||
|
||||
ExportSettingsAdapter(OsmandApplication app, boolean exportMode, OnItemSelectedListener listener, boolean nightMode) {
|
||||
this.app = app;
|
||||
|
@ -71,7 +70,6 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
|||
secondaryColorRes = nightMode ? R.color.icon_color_secondary_dark : R.color.icon_color_secondary_light;
|
||||
groupViewHeight = app.getResources().getDimensionPixelSize(R.dimen.setting_list_item_group_height);
|
||||
childViewHeight = app.getResources().getDimensionPixelSize(R.dimen.setting_list_item_large_height);
|
||||
listBottomPadding = app.getResources().getDimensionPixelSize(R.dimen.fab_recycler_view_padding_bottom);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -118,9 +116,6 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
|||
}
|
||||
});
|
||||
|
||||
boolean addPadding = !isExpanded && groupPosition == getGroupCount() - 1;
|
||||
group.setPadding(0, 0, 0, addPadding ? listBottomPadding : 0);
|
||||
|
||||
adjustIndicator(app, groupPosition, isExpanded, group, nightMode);
|
||||
AndroidUiHelper.updateVisibility(group.findViewById(R.id.divider), isExpanded);
|
||||
AndroidUiHelper.updateVisibility(group.findViewById(R.id.card_top_divider), true);
|
||||
|
@ -188,8 +183,6 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
|||
notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
boolean addPadding = isLastChild && groupPosition == getGroupCount() - 1;
|
||||
child.setPadding(0, 0, 0, addPadding ? listBottomPadding : 0);
|
||||
AndroidUiHelper.updateVisibility(child.findViewById(R.id.card_bottom_divider), isLastChild);
|
||||
|
||||
return child;
|
||||
|
|
Loading…
Reference in a new issue