mirror of
https://github.com/moparisthebest/Yaaic
synced 2024-11-25 18:32:15 -05:00
Miscellaneous ConversationLayout cleanups
* Simplify control flow in onMeasure() by moving height adjusting to a separate method * Various whitespace changes and comment updates
This commit is contained in:
parent
e0f90768b2
commit
ec17d34e4d
@ -49,7 +49,7 @@ public class ConversationLayout extends LinearLayout
|
|||||||
boolean redoLayout = false;
|
boolean redoLayout = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new conversation view switcher
|
* Create a new conversation linear layout
|
||||||
*
|
*
|
||||||
* @param context
|
* @param context
|
||||||
*/
|
*/
|
||||||
@ -60,7 +60,7 @@ public class ConversationLayout extends LinearLayout
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new conversation view switcher
|
* Create a new conversation linear layout
|
||||||
*
|
*
|
||||||
* @param context
|
* @param context
|
||||||
* @param attrs
|
* @param attrs
|
||||||
@ -94,14 +94,13 @@ public class ConversationLayout extends LinearLayout
|
|||||||
/**
|
/**
|
||||||
* Check if starving the gui is necessary, and starves
|
* Check if starving the gui is necessary, and starves
|
||||||
* Starves when less then a vertical inch is available to us
|
* Starves when less then a vertical inch is available to us
|
||||||
|
*
|
||||||
* @return true if we are able to check, false if not.
|
* @return true if we are able to check, false if not.
|
||||||
* @author Reynaldo Cortorreal <reyncor@gmail.com>
|
* @author Reynaldo Cortorreal <reyncor@gmail.com>
|
||||||
*/
|
*/
|
||||||
private boolean setStarvationMode(int height)
|
private boolean setStarvationMode(int height)
|
||||||
{
|
{
|
||||||
if (height == 0) {
|
if (height == 0 || height == curHeight) {
|
||||||
return false;
|
|
||||||
} else if (height == curHeight){
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,32 +121,26 @@ public class ConversationLayout extends LinearLayout
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* onMeasure (ask the view how much space it wants)
|
* Adjust the height of the view to avoid scrolling and hide UI components
|
||||||
* This is called when the window size changes, so we can hook into it to
|
* if necessary to save space
|
||||||
* resize ourselves when the IME comes up
|
*
|
||||||
* @author Steven Luo <stevenandroid@steven676.net>
|
* @author Steven Luo <steven+android@steven676.net>
|
||||||
|
* @author Reynaldo Cortorreal <reyncor@gmail.com>
|
||||||
*/
|
*/
|
||||||
@Override
|
private void adjustHeight()
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
int height = getWindowHeight();
|
int height = getWindowHeight();
|
||||||
|
|
||||||
if(!fullscreen) {
|
if (!fullscreen) {
|
||||||
if (setStarvationMode(height)){
|
if (setStarvationMode(height)) {
|
||||||
curHeight = height;
|
curHeight = height;
|
||||||
redoLayout = true;
|
redoLayout = true;
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//here to forth the code applies only to full screen
|
//here to forth the code applies only to full screen
|
||||||
if (isLandscape && !setStarvationMode(height)) {
|
if (isLandscape && !setStarvationMode(height)) {
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
||||||
return;
|
return;
|
||||||
} else if (curHeight != height && height != 0) {
|
} else if (curHeight != height && height != 0) {
|
||||||
curHeight = height;
|
curHeight = height;
|
||||||
@ -160,9 +153,18 @@ public class ConversationLayout extends LinearLayout
|
|||||||
params.gravity = Gravity.BOTTOM | Gravity.CLIP_VERTICAL;
|
params.gravity = Gravity.BOTTOM | Gravity.CLIP_VERTICAL;
|
||||||
setLayoutParams(params);
|
setLayoutParams(params);
|
||||||
redoLayout = true;
|
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);
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user