public class HeaderFragment
extends android.app.Fragment
implements android.view.View.OnClickListener, android.view.animation.Animation.AnimationListener
Modifier and Type | Class and Description |
---|---|
static class |
HeaderFragment.PlayerAction |
Modifier and Type | Field and Description |
---|---|
private android.os.Handler |
autoclose_handler_
Auto close
|
private java.lang.Runnable |
autoclose_runnable_ |
private android.widget.Button |
cheveron_button_
Header views
|
private int |
header_dim_
Header constant height (given by Resources)
|
private android.widget.TextView |
info_snippet_ |
private android.widget.TextView |
info_title_
Info views
|
private SlideAnimation.State |
next_state_
It may happen that an animation is requested before one is finished, in that case: we store
the future state to transit to, once the running animation has ended.
|
private PlaceEntity |
place_entity_ |
private android.widget.Button |
player_button_ |
private android.widget.ProgressBar |
player_progress_ |
private android.support.design.widget.TabLayout |
reading_dots_ |
private java.lang.String |
reading_id_ |
private PagerWrapper |
reading_pager_ |
private android.widget.LinearLayout |
reading_wrapper_
Reading views
|
private ResizeAnimation |
resize_animation_
View animations
|
private SlideAnimation |
slide_animation_ |
private android.widget.LinearLayout |
wrapper_ |
Constructor and Description |
---|
HeaderFragment() |
Modifier and Type | Method and Description |
---|---|
private void |
error_(java.lang.String snippet)
Displays an error.
|
void |
error(int snippet)
Displays a given
String xml resource as an error. |
void |
hide(boolean force)
Hides the fragment.
|
void |
onAnimationEnd(android.view.animation.Animation animation)
Tweaks some bits of ui when animations end, meaning:
when ending from
resize_animation_ : consumes an eventual reading_id_ into
a new adapter and hides the reading_pager_ if ending into ResizeAnimation.State#COLLAPSED state;
when ending from slide_animation_ into SlideAnimation.State#HIDDEN state:
ensures that the reading_pager_ is in ResizeAnimation.State#COLLAPSED state
and takes the wrapper_ off the screen.
|
void |
onAnimationRepeat(android.view.animation.Animation animation) |
void |
onAnimationStart(android.view.animation.Animation animation)
Makes the
wrapper_ visible if the slide_animation_ has been started. |
void |
onClick(android.view.View view)
Global click listeners that respond to both play/pause interactions expand/collapse interactions.
|
android.view.View |
onCreateView(android.view.LayoutInflater inflater,
android.view.ViewGroup container,
android.os.Bundle bundle) |
void |
onDestroyView() |
PlaceEntity |
place_entity() |
private void |
set_lecture_adapter(java.lang.String lecture_id)
Passes a new adapter to the
reading_pager_ by splitting an content of an input md
file into distinct paragraphs. |
private void |
show_(java.lang.String title,
java.lang.String snippet,
java.lang.String id)
Shows the header display.
|
void |
show_landscape() |
void |
show_reading(PlaceEntity place_entity)
Displays the fragment with content coming from a
PlaceEntity . |
void |
show(int title,
int snippet)
Sets header information.
|
void |
ui_busy(boolean value)
Switches
player_progress_ visibility. |
private void |
ui_collapse_()
Collapses the
reading_pager_ below header. |
private void |
ui_error_()
Sets
player_button_ ui state to error. |
private void |
ui_expand_()
Expands the header so it fits the biggest
reading_pager_ PagerFragment height. |
void |
ui_next()
Sets
player_button_ ui state to skip. |
void |
ui_pause()
Sets
player_button_ ui state to pause. |
void |
ui_play()
Sets
player_button_ ui state to play. |
void |
ui_replay()
Sets
player_button_ ui state to replay. |
boolean |
visible() |
dump, equals, getActivity, getAllowEnterTransitionOverlap, getAllowReturnTransitionOverlap, getArguments, getChildFragmentManager, getContext, getEnterTransition, getExitTransition, getFragmentManager, getHost, getId, getLayoutInflater, getLoaderManager, getParentFragment, getReenterTransition, getResources, getRetainInstance, getReturnTransition, getSharedElementEnterTransition, getSharedElementReturnTransition, getString, getString, getTag, getTargetFragment, getTargetRequestCode, getText, getUserVisibleHint, getView, hashCode, instantiate, instantiate, isAdded, isDetached, isHidden, isInLayout, isRemoving, isResumed, isStateSaved, isVisible, onActivityCreated, onActivityResult, onAttach, onAttach, onAttachFragment, onConfigurationChanged, onContextItemSelected, onCreate, onCreateAnimator, onCreateContextMenu, onCreateOptionsMenu, onDestroy, onDestroyOptionsMenu, onDetach, onGetLayoutInflater, onHiddenChanged, onInflate, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPause, onPictureInPictureModeChanged, onPictureInPictureModeChanged, onPrepareOptionsMenu, onRequestPermissionsResult, onResume, onSaveInstanceState, onStart, onStop, onTrimMemory, onViewCreated, onViewStateRestored, postponeEnterTransition, registerForContextMenu, requestPermissions, setAllowEnterTransitionOverlap, setAllowReturnTransitionOverlap, setArguments, setEnterSharedElementCallback, setEnterTransition, setExitSharedElementCallback, setExitTransition, setHasOptionsMenu, setInitialSavedState, setMenuVisibility, setReenterTransition, setRetainInstance, setReturnTransition, setSharedElementEnterTransition, setSharedElementReturnTransition, setTargetFragment, setUserVisibleHint, shouldShowRequestPermissionRationale, startActivity, startActivity, startActivityForResult, startActivityForResult, startIntentSenderForResult, startPostponedEnterTransition, toString, unregisterForContextMenu
private android.widget.LinearLayout wrapper_
private android.widget.Button cheveron_button_
private android.widget.Button player_button_
private android.widget.ProgressBar player_progress_
private android.widget.TextView info_title_
private android.widget.TextView info_snippet_
private java.lang.String reading_id_
private android.widget.LinearLayout reading_wrapper_
private PagerWrapper reading_pager_
private android.support.design.widget.TabLayout reading_dots_
@Nullable private PlaceEntity place_entity_
private ResizeAnimation resize_animation_
private SlideAnimation slide_animation_
private android.os.Handler autoclose_handler_
private java.lang.Runnable autoclose_runnable_
private int header_dim_
@Nullable private SlideAnimation.State next_state_
public android.view.View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle bundle)
onCreateView
in class android.app.Fragment
public void onDestroyView()
onDestroyView
in class android.app.Fragment
public void hide(boolean force)
force
- Is true, sets the next_state_
to be SlideAnimation.State#HIDDEN
after the currently running animation.onAnimationEnd(Animation)
public void onClick(android.view.View view)
onClick
in interface android.view.View.OnClickListener
view
- The clicked view.private void ui_collapse_()
reading_pager_
below header.private void ui_expand_()
reading_pager_
PagerFragment
height.
A this point, we don't know the size of the pager (its visibility is View.GONE
), so
we first take it out of the screen (to avoid a one-frame glitch that would sadly resize the
entire header) and sets its visibility to View.VISIBLE
. In a `once` manner, we catch a
layout measurement where we finally replace the pager at the right position before shooting
the ResizeAnimation.expand()
animation with proper value.
public void ui_play()
player_button_
ui state to play.public void ui_pause()
player_button_
ui state to pause.public void onAnimationStart(android.view.animation.Animation animation)
wrapper_
visible if the slide_animation_
has been started.onAnimationStart
in interface android.view.animation.Animation.AnimationListener
public void onAnimationEnd(android.view.animation.Animation animation)
resize_animation_
: consumes an eventual reading_id_
into
a new adapter and hides the reading_pager_
if ending into ResizeAnimation.State#COLLAPSED
state;slide_animation_
into SlideAnimation.State#HIDDEN
state:
ensures that the reading_pager_
is in ResizeAnimation.State#COLLAPSED
state
and takes the wrapper_
off the screen.onAnimationEnd
in interface android.view.animation.Animation.AnimationListener
private void set_lecture_adapter(@NonNull java.lang.String lecture_id)
reading_pager_
by splitting an content of an input md
file into distinct paragraphs.lecture_id
- The id / name of the lecture.ResourceUtils.text_to_paragraphs(Resources, int)
public void onAnimationRepeat(android.view.animation.Animation animation)
onAnimationRepeat
in interface android.view.animation.Animation.AnimationListener
public void error(@StringRes int snippet)
String
xml resource as an error.snippet
- A StringRes
integer.error_(String)
private void ui_error_()
player_button_
ui state to error.private void error_(@NonNull java.lang.String snippet)
snippet
- A mandatory error's descriptionprivate void show_(@NonNull java.lang.String title, @NonNull java.lang.String snippet, @Nullable java.lang.String id)
title
- One line text of titlesnippet
- One line text of infoid
- An eventual id to be associated with raw markdown filespublic void ui_next()
player_button_
ui state to skip.public void ui_busy(boolean value)
player_progress_
visibility.value
- Whether to display the progress icon or not.public void show(int title, @StringRes int snippet)
title
- Text of the titlesnippet
- Text of the snippetpublic void show_reading(@Nullable PlaceEntity place_entity)
PlaceEntity
.place_entity
- Entity to read values frompublic void show_landscape()
public void ui_replay()
player_button_
ui state to replay.@Nullable public PlaceEntity place_entity()
public boolean visible()