toolbar NPE fix

This commit is contained in:
veliymolfar 2020-04-17 10:28:05 +03:00
parent d906e35cae
commit 1bb2e1621e

View file

@ -21,6 +21,8 @@ import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.appbar.AppBarLayout;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.plus.ApplicationMode; import net.osmand.plus.ApplicationMode;
@ -169,11 +171,10 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable Bundle savedInstanceState) {
View root = mInflater.inflate(R.layout.edit_arrangement_list_fragment, container, false); View root = mInflater.inflate(R.layout.edit_arrangement_list_fragment, container, false);
Toolbar toolbar = root.findViewById(R.id.toolbar); AppBarLayout appbar = root.findViewById(R.id.appbar);
TextView toolbarTitle = root.findViewById(R.id.toolbar_title); View toolbar = mInflater.inflate(R.layout.global_preference_toolbar, container, false);
ImageButton toolbarButton = root.findViewById(R.id.close_button); TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
RecyclerView recyclerView = root.findViewById(R.id.profiles_list); ImageButton toolbarButton = toolbar.findViewById(R.id.close_button);
recyclerView.setPadding(0, 0, 0, (int) app.getResources().getDimension(R.dimen.dialog_button_ex_min_width));
toolbar.setBackgroundColor(nightMode toolbar.setBackgroundColor(nightMode
? getResources().getColor(R.color.list_background_color_dark) ? getResources().getColor(R.color.list_background_color_dark)
: getResources().getColor(R.color.list_background_color_light)); : getResources().getColor(R.color.list_background_color_light));
@ -188,8 +189,9 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
exitFragment(); exitFragment();
} }
}); });
appbar.addView(toolbar);
RecyclerView recyclerView = root.findViewById(R.id.profiles_list);
recyclerView.setPadding(0, 0, 0, (int) app.getResources().getDimension(R.dimen.dialog_button_ex_min_width));
rearrangeAdapter = new RearrangeMenuItemsAdapter(app, getAdapterItems()); rearrangeAdapter = new RearrangeMenuItemsAdapter(app, getAdapterItems());
recyclerView.setLayoutManager(new LinearLayoutManager(app)); recyclerView.setLayoutManager(new LinearLayoutManager(app));
final ItemTouchHelper touchHelper = new ItemTouchHelper(new ReorderItemTouchHelperCallback(rearrangeAdapter)); final ItemTouchHelper touchHelper = new ItemTouchHelper(new ReorderItemTouchHelperCallback(rearrangeAdapter));