Skip to content

Commit

Permalink
Use requireContext()
Browse files Browse the repository at this point in the history
  • Loading branch information
h6ah4i committed Dec 9, 2018
1 parent b85627d commit c9b9cdd
Show file tree
Hide file tree
Showing 17 changed files with 57 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat

//noinspection ConstantConditions
mRecyclerView = getView().findViewById(R.id.recycler_view);
mLayoutManager = new LinearLayoutManager(getContext(), RecyclerView.VERTICAL, false);
mLayoutManager = new LinearLayoutManager(requireContext(), RecyclerView.VERTICAL, false);

// drag & drop manager
mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
mRecyclerViewDragDropManager.setDraggingItemShadowDrawable(
(NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
(NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z3));

//adapter
final DraggableExampleItemAdapter myItemAdapter = new DraggableExampleItemAdapter(getDataProvider());
Expand All @@ -85,9 +85,9 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z1)));
}
mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(requireContext(), R.drawable.list_divider_h), true));

mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat

//noinspection ConstantConditions
mRecyclerView = getView().findViewById(R.id.recycler_view);
mLayoutManager = new LinearLayoutManager(getContext(), RecyclerView.VERTICAL, false);
mLayoutManager = new LinearLayoutManager(requireContext(), RecyclerView.VERTICAL, false);

// drag & drop manager
mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
mRecyclerViewDragDropManager.setDraggingItemShadowDrawable(
(NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
(NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z3));
mRecyclerViewDragDropManager.setCheckCanDropEnabled(true); // !!! this method is required to use onCheckCanDrop()

//adapter
Expand All @@ -86,9 +86,9 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z1)));
}
mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(requireContext(), R.drawable.list_divider_h), true));

mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat

//noinspection ConstantConditions
mRecyclerView = getView().findViewById(R.id.recycler_view);
mLayoutManager = new GridLayoutManager(getContext(), 3, RecyclerView.VERTICAL, false);
mLayoutManager = new GridLayoutManager(requireContext(), 3, RecyclerView.VERTICAL, false);

// drag & drop manager
mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
mRecyclerViewDragDropManager.setDraggingItemShadowDrawable(
(NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
(NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z3));
// Start dragging after long press
mRecyclerViewDragDropManager.setInitiateOnLongPress(true);
mRecyclerViewDragDropManager.setInitiateOnMove(false);
Expand Down Expand Up @@ -105,7 +105,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z1)));
}

mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat

//noinspection ConstantConditions
mRecyclerView = getView().findViewById(R.id.recycler_view);
mLayoutManager = new LinearLayoutManager(getContext());
mLayoutManager = new LinearLayoutManager(requireContext());

// drag & drop manager
mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
mRecyclerViewDragDropManager.setDraggingItemShadowDrawable(
(NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
(NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z3));
// Start dragging after long press
mRecyclerViewDragDropManager.setInitiateOnLongPress(true);
mRecyclerViewDragDropManager.setInitiateOnMove(false);
Expand All @@ -88,9 +88,9 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z1)));
}
mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(requireContext(), R.drawable.list_divider_h), true));

mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
// drag & drop manager
mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
mRecyclerViewDragDropManager.setDraggingItemShadowDrawable(
(NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
(NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z3));
// Start dragging after long press
mRecyclerViewDragDropManager.setInitiateOnLongPress(true);
mRecyclerViewDragDropManager.setInitiateOnMove(false);
Expand All @@ -89,7 +89,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z1)));
}

mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat

//noinspection ConstantConditions
mRecyclerView = getView().findViewById(R.id.recycler_view);
mLayoutManager = new LinearLayoutManager(getContext());
mLayoutManager = new LinearLayoutManager(requireContext());

// drag & drop manager
mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
mRecyclerViewDragDropManager.setDraggingItemShadowDrawable(
(NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
(NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z3));

//adapter
final DraggableWithSectionExampleAdapter myItemAdapter = new DraggableWithSectionExampleAdapter(getDataProvider());
Expand All @@ -85,9 +85,9 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z1)));
}
mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(requireContext(), R.drawable.list_divider_h), true));

mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat

//noinspection ConstantConditions
mRecyclerView = getView().findViewById(R.id.recycler_view);
mLayoutManager = new LinearLayoutManager(getContext());
mLayoutManager = new LinearLayoutManager(requireContext());

// touch guard manager (this class is required to suppress scrolling while swipe-dismiss animation is running)
mRecyclerViewTouchActionGuardManager = new RecyclerViewTouchActionGuardManager();
Expand All @@ -75,7 +75,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
// drag & drop manager
mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
mRecyclerViewDragDropManager.setDraggingItemShadowDrawable(
(NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
(NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z3));

// swipe manager
mRecyclerViewSwipeManager = new RecyclerViewSwipeManager();
Expand Down Expand Up @@ -119,9 +119,9 @@ public void onItemViewClicked(View v, boolean pinned) {
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z1)));
}
mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(requireContext(), R.drawable.list_divider_h), true));

// NOTE:
// The initialization order is very important! This order determines the priority of touch event handling.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat

//noinspection ConstantConditions
mRecyclerView = getView().findViewById(R.id.recycler_view);
mLayoutManager = new LinearLayoutManager(getContext());
mLayoutManager = new LinearLayoutManager(requireContext());

final Parcelable eimSavedState = (savedInstanceState != null) ? savedInstanceState.getParcelable(SAVED_STATE_EXPANDABLE_ITEM_MANAGER) : null;
mRecyclerViewExpandableItemManager = new RecyclerViewExpandableItemManager(eimSavedState);
Expand Down Expand Up @@ -101,9 +101,9 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z1)));
}
mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(requireContext(), R.drawable.list_divider_h), true));

mRecyclerViewExpandableItemManager.attachRecyclerView(mRecyclerView);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat

//noinspection ConstantConditions
mRecyclerView = getView().findViewById(R.id.recycler_view);
mLayoutManager = new LinearLayoutManager(getContext());
mLayoutManager = new LinearLayoutManager(requireContext());

final Parcelable eimSavedState = (savedInstanceState != null) ? savedInstanceState.getParcelable(SAVED_STATE_EXPANDABLE_ITEM_MANAGER) : null;
mRecyclerViewExpandableItemManager = new RecyclerViewExpandableItemManager(eimSavedState);
Expand Down Expand Up @@ -101,9 +101,9 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z1)));
}
mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(requireContext(), R.drawable.list_divider_h), true));

mRecyclerViewExpandableItemManager.attachRecyclerView(mRecyclerView);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat

//noinspection ConstantConditions
mRecyclerView = getView().findViewById(R.id.recycler_view);
mLayoutManager = new LinearLayoutManager(getContext());
mLayoutManager = new LinearLayoutManager(requireContext());

final Parcelable eimSavedState = (savedInstanceState != null) ? savedInstanceState.getParcelable(SAVED_STATE_EXPANDABLE_ITEM_MANAGER) : null;
mRecyclerViewExpandableItemManager = new RecyclerViewExpandableItemManager(eimSavedState);
Expand Down Expand Up @@ -94,9 +94,9 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z1)));
}
mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(requireContext(), R.drawable.list_divider_h), true));

mRecyclerViewExpandableItemManager.attachRecyclerView(mRecyclerView);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat

//noinspection ConstantConditions
mRecyclerView = getView().findViewById(R.id.recycler_view);
mLayoutManager = new LinearLayoutManager(getContext());
mLayoutManager = new LinearLayoutManager(requireContext());

final Parcelable eimSavedState = (savedInstanceState != null) ? savedInstanceState.getParcelable(SAVED_STATE_EXPANDABLE_ITEM_MANAGER) : null;
mRecyclerViewExpandableItemManager = new RecyclerViewExpandableItemManager(eimSavedState);
Expand All @@ -79,7 +79,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
// drag & drop manager
mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
mRecyclerViewDragDropManager.setDraggingItemShadowDrawable(
(NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
(NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z3));

//adapter
final ExpandableDraggableWithSectionExampleAdapter myItemAdapter = new ExpandableDraggableWithSectionExampleAdapter(getDataProvider());
Expand Down Expand Up @@ -108,9 +108,9 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z1)));
}
mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(requireContext(), R.drawable.list_divider_h), true));


// NOTE:
Expand Down
Loading

0 comments on commit c9b9cdd

Please sign in to comment.