Class PropertyInspector
-
- All Implemented Interfaces:
-
android.graphics.drawable.Drawable.Callback
,android.view.KeyEvent.Callback
,android.view.View.OnClickListener
,android.view.ViewManager
,android.view.ViewParent
,android.view.accessibility.AccessibilityEventSource
,com.pspdfkit.internal.views.inspector.bottomsheet.BottomSheetContentViewInterface
,com.pspdfkit.ui.inspector.PropertyInspectorController
,com.pspdfkit.ui.inspector.PropertyInspectorTitleButtonListener
public class PropertyInspector extends ViewGroup implements BottomSheetContentViewInterface, PropertyInspectorController, View.OnClickListener, PropertyInspectorTitleButtonListener
Top level layout of the generic properties inspector. Contains title and scrollable list of PropertyInspectorView.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public abstract class
PropertyInspector.ItemDecoration
An ItemDecoration allows the application to add custom drawing to specific inspector views. This can be useful for drawing dividers between items, highlights etc.
public interface
PropertyInspector.OnCancelListener
Listener for inspector cancellation.
public interface
PropertyInspector.OnInspectorTitleButtonClickListener
Listener for the buttons on the property inspector title
-
Field Summary
Fields Modifier and Type Field Description public int
suggestedHeight
public int
minimumHeight
public int
maximumHeight
-
Constructor Summary
Constructors Constructor Description PropertyInspector(Context context)
Construct inspector layout.
-
Method Summary
Modifier and Type Method Description int
getSuggestedHeight()
Returns best height for this view. int
getMinimumHeight()
int
getMaximumHeight()
Returns maximum height of the view in the bottom sheet. void
onClick(View view)
boolean
onBackButtonClicked()
Handles the back-button click on the inspector title. boolean
onCloseButtonClicked()
Handles the close-button click on the inspectore title. void
setInspectorViews(@NonNull() List<PropertyInspectorView> inspectorViews, boolean animate)
Sets list of inspector views to be displayed in property inspector. void
setInspectorViews(@NonNull() List<PropertyInspectorView> inspectorViews, boolean animate, @Nullable() PropertyInspectorTitleButtonListener titleButtonListener, @Nullable() PropertyInspectorViewTitleStyleProvider titleStyleProvider)
void
addInspectorView(@NonNull() PropertyInspectorView inspectorView)
Add new view to inspector layout. void
addInspectorView(@NonNull() PropertyInspectorView inspectorView, @IntRange(from = 0) int location)
Add new view to inspector layout. int
getInspectorViewCount()
Returns the number of PropertyInspectorViews inside inspector. PropertyInspectorView
getInspectorView(@IntRange(from = 0) int location)
Retrieve PropertyInspectorView at specified location. int
indexOfInspectorView(@NonNull() PropertyInspectorView inspectorView)
Find index of specified inspector view. void
removeInspectorView(@NonNull() PropertyInspectorView inspectorView)
Removes inspector view from inspector. void
removeAllInspectorViews()
Removes all inspector views from inspector. void
reset()
Resets inspector to its initial state. void
setTitle(@NonNull() String title)
Sets header title inside inspector view. void
setTitle(@StringRes() int titleRes)
Sets header title inside inspector view. void
setTitleBarVisible(boolean isTitleEnabled)
Controls inspector title bar visibility. boolean
isCancelOnTouchOutside()
Returns True when the inspector should be cancelled when touched outside of its bounds. void
addItemDecoration(@NonNull() PropertyInspector.ItemDecoration decoration, int index)
Adds an ItemDecoration to this inspector. void
addItemDecoration(@NonNull() PropertyInspector.ItemDecoration decoration)
Adds an ItemDecoration to this inspector. void
removeItemDecoration(@NonNull() PropertyInspector.ItemDecoration decoration)
Removes an ItemDecoration from this inspector. void
removeAllItemDecorations()
Removes all ItemDecorations from this inspector. void
showDetailView(@NonNull() View view, @Nullable() String title, boolean animate)
Replaces inspector contents with specific view
.void
hideDetailView(boolean animate)
Hide view shown in showDetailView. void
ensureFullyVisible(@NonNull() PropertyInspectorView inspectorView)
Scrolls to inspector view when its not fully visible in property inspector. View
getVisibleDetailView()
Retrieve detail view that is currently visible in the property inspector. void
cancel()
Request cancellation of the inspector. boolean
dispatchKeyEvent(@NonNull() KeyEvent event)
Custom back key handling to implement navigation from detail view. boolean
dispatchTouchEvent(MotionEvent event)
Handle touches outside edit text so focus is released. Parcelable
onSaveInstanceState()
void
onRestoreInstanceState(Parcelable state)
void
setCancelOnTouchOutside(boolean cancelOnTouchOutside)
Make inspector request PropertyInspectorCoordinatorLayout to be cancelled when touched outside its bounds. void
setCancelListener(@Nullable() PropertyInspector.OnCancelListener cancelListener)
Sets a listener to be notified of a cancellation. -
-
Constructor Detail
-
PropertyInspector
PropertyInspector(Context context)
Construct inspector layout.- Parameters:
context
- The context.
-
-
Method Detail
-
getSuggestedHeight
int getSuggestedHeight()
Returns best height for this view. This is guaranteed to be called after onMeasure.
- Returns:
Suggested height of the view.
-
getMinimumHeight
int getMinimumHeight()
-
getMaximumHeight
int getMaximumHeight()
Returns maximum height of the view in the bottom sheet. Bottom sheet can't be resized above this height.
- Returns:
Maximum height for the view.
-
onBackButtonClicked
boolean onBackButtonClicked()
Handles the back-button click on the inspector title. Checks if either an active detail view consumes it or we have a custom title button listener set. The default implementation just hides the detail view.
- Returns:
true
if the click has been consumed, otherwisefalse
-
onCloseButtonClicked
boolean onCloseButtonClicked()
Handles the close-button click on the inspectore title. Checks if either an active detail view consumes it or we have a custom title button listener set. The default implementation closes the inspector.
- Returns:
true
if the click has been consumed, otherwisefalse
-
setInspectorViews
void setInspectorViews(@NonNull() List<PropertyInspectorView> inspectorViews, boolean animate)
Sets list of inspector views to be displayed in property inspector. This replaces previously displayed views.
- Parameters:
inspectorViews
- The inspector views to display.animate
- Whether to animate the change.
-
setInspectorViews
void setInspectorViews(@NonNull() List<PropertyInspectorView> inspectorViews, boolean animate, @Nullable() PropertyInspectorTitleButtonListener titleButtonListener, @Nullable() PropertyInspectorViewTitleStyleProvider titleStyleProvider)
-
addInspectorView
@UiThread() void addInspectorView(@NonNull() PropertyInspectorView inspectorView)
Add new view to inspector layout.
- Parameters:
inspectorView
- The inspector view to add.
-
addInspectorView
@UiThread() void addInspectorView(@NonNull() PropertyInspectorView inspectorView, @IntRange(from = 0) int location)
Add new view to inspector layout.
- Parameters:
inspectorView
- The inspector view to add.location
- The position at which to add the child or -1 to add last.
-
getInspectorViewCount
@UiThread() int getInspectorViewCount()
Returns the number of PropertyInspectorViews inside inspector.
- Returns:
Positive number indicating number of child inspector views.
-
getInspectorView
@UiThread()@NonNull() PropertyInspectorView getInspectorView(@IntRange(from = 0) int location)
Retrieve PropertyInspectorView at specified location.
- Returns:
Inspector view at requested location.
-
indexOfInspectorView
@IntRange(from = "-1") int indexOfInspectorView(@NonNull() PropertyInspectorView inspectorView)
Find index of specified inspector view.
- Returns:
Index inside inspector views array or -1 when not found.
-
removeInspectorView
@UiThread() void removeInspectorView(@NonNull() PropertyInspectorView inspectorView)
Removes inspector view from inspector.
- Parameters:
inspectorView
- View to remove from inspector.
-
removeAllInspectorViews
@UiThread() void removeAllInspectorViews()
Removes all inspector views from inspector.
-
reset
void reset()
Resets inspector to its initial state.
-
setTitleBarVisible
void setTitleBarVisible(boolean isTitleEnabled)
Controls inspector title bar visibility.
- Parameters:
isTitleEnabled
-true
to enable title bar,false
to disable.
-
isCancelOnTouchOutside
boolean isCancelOnTouchOutside()
Returns True when the inspector should be cancelled when touched outside of its bounds.
-
addItemDecoration
void addItemDecoration(@NonNull() PropertyInspector.ItemDecoration decoration, int index)
Adds an ItemDecoration to this inspector.
Item decorations are ordered. Decorations placed earlier in the list will be run/queried/drawn first for their effects on item views.
- Parameters:
decoration
- Decoration to add.index
- Position to add decoration at.
-
addItemDecoration
@UiThread() void addItemDecoration(@NonNull() PropertyInspector.ItemDecoration decoration)
Adds an ItemDecoration to this inspector.
- Parameters:
decoration
- Decoration to add.
-
removeItemDecoration
@UiThread() void removeItemDecoration(@NonNull() PropertyInspector.ItemDecoration decoration)
Removes an ItemDecoration from this inspector.
- Parameters:
decoration
- Decoration to remove.
-
removeAllItemDecorations
@UiThread() void removeAllItemDecorations()
Removes all ItemDecorations from this inspector.
-
showDetailView
void showDetailView(@NonNull() View view, @Nullable() String title, boolean animate)
Replaces inspector contents with specific
view
. Only single detail view can be visible at a time.- Parameters:
view
- View to show.title
- Optional inspector title that will be displayed when detail view is visible.animate
- True to animate transition, false to change immediately.
-
hideDetailView
void hideDetailView(boolean animate)
Hide view shown in showDetailView. This will restore previous inspector contents.
- Parameters:
animate
- True to animate transition, false to change immediately.
-
ensureFullyVisible
void ensureFullyVisible(@NonNull() PropertyInspectorView inspectorView)
Scrolls to inspector view when its not fully visible in property inspector.
- Parameters:
inspectorView
- Property inspector view to scroll to.
-
getVisibleDetailView
@Nullable() View getVisibleDetailView()
Retrieve detail view that is currently visible in the property inspector.
- Returns:
Visible detail view or null if no detail view is visible right now.
-
cancel
void cancel()
Request cancellation of the inspector.
-
dispatchKeyEvent
boolean dispatchKeyEvent(@NonNull() KeyEvent event)
Custom back key handling to implement navigation from detail view.
-
dispatchTouchEvent
boolean dispatchTouchEvent(MotionEvent event)
Handle touches outside edit text so focus is released. Useful for small property inspector window with lots of edit text fields
-
onSaveInstanceState
Parcelable onSaveInstanceState()
-
onRestoreInstanceState
void onRestoreInstanceState(Parcelable state)
-
setCancelOnTouchOutside
void setCancelOnTouchOutside(boolean cancelOnTouchOutside)
Make inspector request PropertyInspectorCoordinatorLayout to be cancelled when touched outside its bounds.
- Parameters:
cancelOnTouchOutside
- True when inspector should be cancelled when touched outside its bounds.
-
setCancelListener
void setCancelListener(@Nullable() PropertyInspector.OnCancelListener cancelListener)
Sets a listener to be notified of a cancellation. Calling this method will replace any previously set listener. You may provide
null
to clear the listener.- Parameters:
cancelListener
- OnCancelListener that should be notified, ornull
to clear the listener.
-
-
-
-