Closed GoogleCodeExporter closed 9 years ago
Purpose of code changes on this branch: Hide adWhirlLayout when no Ads to show When reviewing my code changes, please focus on: Define maximun hight and width. Using this and creating the layout using WRAP_CONTENT RelativeLayout.LayoutParams adWhirlLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); User can define maximun With and Height using adWhirlLayout.setMaxHeight(52); Then is no Ads, no space used. After the review, I'll merge this branch into: /trunk diff --git a/android/src/com/adwhirl/AdWhirlLayout.java b/android/src/com/adwhirl/AdWhirlLayout.java --- a/android/src/com/adwhirl/AdWhirlLayout.java +++ b/android/src/com/adwhirl/AdWhirlLayout.java @@ -35,6 +35,7 @@ import android.util.Log; import android.view.MotionEvent; import android.view.ViewGroup; +import android.view.View.MeasureSpec; import android.widget.RelativeLayout; import com.adwhirl.adapters.AdWhirlAdapter; @@ -88,6 +89,9 @@ setHorizontalScrollBarEnabled(false); setVerticalScrollBarEnabled(false); + + this.maxHeight = 0; + this.maxWidth = 0; } @Override @@ -327,4 +331,24 @@ } } } + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + int widthSize = MeasureSpec.getSize(widthMeasureSpec); + int heightSize = MeasureSpec.getSize(heightMeasureSpec); + if (maxHeight > 0 && heightSize > maxHeight){ + heightMeasureSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST); + } + if (maxWidth > 0 && widthSize > maxWidth){ + heightMeasureSpec = MeasureSpec.makeMeasureSpec(maxWidth, MeasureSpec.AT_MOST); + } + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + } + public void setMaxHeight(int height) { + maxHeight = height; + } + public void setMaxWidth(int width) { + maxWidth = width; + } + protected int maxWidth; + protected int maxHeight; }
Original issue reported on code.google.com by cjr...@gmail.com on 20 Aug 2010 at 10:41
cjr...@gmail.com
Original comment by nigelc...@google.com on 1 Sep 2010 at 12:48
nigelc...@google.com
Original issue reported on code.google.com by
cjr...@gmail.com
on 20 Aug 2010 at 10:41