Skip to content

Commit

Permalink
Miscellaneous ConversationLayout cleanups
Browse files Browse the repository at this point in the history
* Simplify control flow in onMeasure() by moving height adjusting to
  a separate method
* Various whitespace changes and comment updates
  • Loading branch information
steven676 authored and pocmo committed Jul 3, 2011
1 parent e0f9076 commit ec17d34
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions application/src/org/yaaic/view/ConversationLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class ConversationLayout extends LinearLayout
boolean redoLayout = false;

/**
* Create a new conversation view switcher
* Create a new conversation linear layout
*
* @param context
*/
Expand All @@ -60,7 +60,7 @@ public ConversationLayout(Context context)
}

/**
* Create a new conversation view switcher
* Create a new conversation linear layout
*
* @param context
* @param attrs
Expand Down Expand Up @@ -94,14 +94,13 @@ private int getWindowHeight()
/**
* Check if starving the gui is necessary, and starves
* Starves when less then a vertical inch is available to us
*
* @return true if we are able to check, false if not.
* @author Reynaldo Cortorreal <[email protected]>
*/
private boolean setStarvationMode(int height)
{
if (height == 0) {
return false;
} else if (height == curHeight){
if (height == 0 || height == curHeight) {
return false;
}

Expand All @@ -122,32 +121,26 @@ private boolean setStarvationMode(int height)
}

/**
* onMeasure (ask the view how much space it wants)
* This is called when the window size changes, so we can hook into it to
* resize ourselves when the IME comes up
* @author Steven Luo <[email protected]>
* Adjust the height of the view to avoid scrolling and hide UI components
* if necessary to save space
*
* @author Steven Luo <[email protected]>
* @author Reynaldo Cortorreal <[email protected]>
*/
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
private void adjustHeight()
{

int height = getWindowHeight();

if(!fullscreen) {
if (setStarvationMode(height)){
if (!fullscreen) {
if (setStarvationMode(height)) {
curHeight = height;
redoLayout = true;
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
return;
} else {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
return;
}
return;
}

//here to forth the code applies only to full screen
if (isLandscape && !setStarvationMode(height)) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
return;
} else if (curHeight != height && height != 0) {
curHeight = height;
Expand All @@ -160,9 +153,18 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
params.gravity = Gravity.BOTTOM | Gravity.CLIP_VERTICAL;
setLayoutParams(params);
redoLayout = true;
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
return;
}
}

/**
* onMeasure (ask the view how much space it wants)
* This is called when the window size changes, so we can hook into it to
* resize ourselves when the IME comes up
*/
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
adjustHeight();
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}

Expand Down

0 comments on commit ec17d34

Please sign in to comment.