protected View createContentView( int id ) {
View view = inflate( id );
return createContentView( view );
}
public View createContentView( View view ) {
FrameLayout root = new FrameLayout( this );
root.setLayoutParams(new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT ) );
LinearLayout pframe = new LinearLayout( this );
pframe.setId( R.id.INTERNAL_PROGRESS_CONTAINER_ID );
pframe.setOrientation( LinearLayout.VERTICAL );
pframe.setGravity( Gravity.CENTER );
ProgressBar progress = new ProgressBar( this, null, android.R.attr.progressBarStyleLarge );
pframe.addView( progress, new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT ) );
root.addView( pframe, new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT ) );
FrameLayout lframe = new FrameLayout( this );
lframe.setId( R.id.INTERNAL_FRAGMENT_CONTAINER_ID );
lframe.setVisibility( View.GONE );
lframe.addView( view, new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT ) );
root.addView( lframe, new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT ) );
return root;
}
public void setContentShown( View view, boolean shown ) {
View progress = view.findViewById( R.id.INTERNAL_PROGRESS_CONTAINER_ID );
View content = view.findViewById( R.id.INTERNAL_FRAGMENT_CONTAINER_ID );
if ( shown ) {
progress.startAnimation( AnimationUtils.loadAnimation( this, R.anim.fade_out ) );
content.startAnimation( AnimationUtils.loadAnimation( this, R.anim.fade_in ) );
progress.setVisibility( View.GONE );
content.setVisibility( View.VISIBLE );
} else {
progress.startAnimation( AnimationUtils.loadAnimation( this, R.anim.fade_in ) );
content.startAnimation( AnimationUtils.loadAnimation( this, R.anim.fade_out ) );
progress.setVisibility( View.VISIBLE );
content.setVisibility( View.GONE );
}
}
protected void setContentShown( boolean shown ) {
View root = findViewById( android.R.id.content );
setContentShown( root, shown );
}