Skip to content

Commit

Permalink
下拉中的判断
Browse files Browse the repository at this point in the history
下拉中的判断
  • Loading branch information
gdpancheng committed Aug 6, 2014
1 parent 50f7313 commit d145299
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 16 deletions.
1 change: 1 addition & 0 deletions res/layout/fragment_main1.xml
Expand Up @@ -157,6 +157,7 @@
android:id="@+id/touch"
android:background="@android:color/holo_blue_dark"
android:layout_width="fill_parent"
android:longClickable="true"
android:layout_height="80dp"
android:text="触摸此区域"/>

Expand Down
1 change: 1 addition & 0 deletions src/com/android/pc/ioc/a/demo/FirstFragment.java
Expand Up @@ -129,6 +129,7 @@ private void onTextChanged(CharSequence s, int start, int before, int count) {

@InjectMethod(@InjectListener(ids = { R.id.touch }, listeners = { OnTouch.class }))
public boolean onTouch(View v, MotionEvent event) {
System.out.println(event.getAction());
MakeToast("触摸");
return true;
}
Expand Down
60 changes: 44 additions & 16 deletions src/com/android/pc/ioc/view/PullToRefreshView.java
Expand Up @@ -353,56 +353,84 @@ public boolean onPreDraw() {
}
isGet = true;
if (mAdapterView != null) {
if (LinearLayout.LayoutParams.class.isAssignableFrom(PullToRefreshView.this.getLayoutParams().getClass())) {
//重置listview的高度

int heigth = 0;

if (LinearLayout.LayoutParams.class.isAssignableFrom(mAdapterView.getLayoutParams().getClass())) {
// 重置listview的高度
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) mAdapterView.getLayoutParams();
layoutParams.height = mAdapterView.getHeight();
if (layoutParams.height <= 2) {
layoutParams.height = PullToRefreshView.this.getHeight();
}
mAdapterView.setLayoutParams(layoutParams);
//重置下拉组件的高度
heigth = layoutParams.height;
}

if (LinearLayout.LayoutParams.class.isAssignableFrom(PullToRefreshView.this.getLayoutParams().getClass())) {
// 重置下拉组件的高度
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) PullToRefreshView.this.getLayoutParams();
params.height = layoutParams.height;
if (heigth!=0) {
params.height = heigth;
}
PullToRefreshView.this.setLayoutParams(params);
}
if (AbsoluteLayout.LayoutParams.class.isAssignableFrom(PullToRefreshView.this.getLayoutParams().getClass())) {
//重置listview的高度

if (AbsoluteLayout.LayoutParams.class.isAssignableFrom(mAdapterView.getLayoutParams().getClass())) {
// 重置listview的高度
AbsoluteLayout.LayoutParams layoutParams = (AbsoluteLayout.LayoutParams) mAdapterView.getLayoutParams();
layoutParams.height = mAdapterView.getHeight();
if (layoutParams.height <= 2) {
layoutParams.height = PullToRefreshView.this.getHeight();
}
mAdapterView.setLayoutParams(layoutParams);
//重置下拉组件的高度
heigth = layoutParams.height;
}

if (AbsoluteLayout.LayoutParams.class.isAssignableFrom(PullToRefreshView.this.getLayoutParams().getClass())) {
// 重置下拉组件的高度
AbsoluteLayout.LayoutParams params = (AbsoluteLayout.LayoutParams) PullToRefreshView.this.getLayoutParams();
params.height = layoutParams.height;
if (heigth!=0) {
params.height = heigth;
}
PullToRefreshView.this.setLayoutParams(params);
}
if (RelativeLayout.LayoutParams.class.isAssignableFrom(PullToRefreshView.this.getLayoutParams().getClass())) {
//重置listview的高度

if (RelativeLayout.LayoutParams.class.isAssignableFrom(mAdapterView.getLayoutParams().getClass())) {
// 重置listview的高度
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mAdapterView.getLayoutParams();
layoutParams.height = mAdapterView.getHeight();
if (layoutParams.height <= 2) {
layoutParams.height = PullToRefreshView.this.getHeight();
}
mAdapterView.setLayoutParams(layoutParams);
//重置下拉组件的高度
heigth = layoutParams.height;
}

if (RelativeLayout.LayoutParams.class.isAssignableFrom(PullToRefreshView.this.getLayoutParams().getClass())) {
// 重置下拉组件的高度
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) PullToRefreshView.this.getLayoutParams();
params.height = layoutParams.height;
if (heigth!=0) {
params.height = heigth;
}
PullToRefreshView.this.setLayoutParams(params);
}
if (FrameLayout.LayoutParams.class.isAssignableFrom(PullToRefreshView.this.getLayoutParams().getClass())) {
//重置listview的高度
if (FrameLayout.LayoutParams.class.isAssignableFrom(mAdapterView.getLayoutParams().getClass())) {
// 重置listview的高度
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) mAdapterView.getLayoutParams();
layoutParams.height = mAdapterView.getHeight();
if (layoutParams.height <= 2) {
layoutParams.height = PullToRefreshView.this.getHeight();
}
mAdapterView.setLayoutParams(layoutParams);
//重置下拉组件的高度
heigth = layoutParams.height;
}
if (FrameLayout.LayoutParams.class.isAssignableFrom(PullToRefreshView.this.getLayoutParams().getClass())) {
// 重置下拉组件的高度
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) PullToRefreshView.this.getLayoutParams();
params.height = layoutParams.height;
if (heigth!=0) {
params.height = heigth;
}
PullToRefreshView.this.setLayoutParams(params);
}
}
Expand Down

0 comments on commit d145299

Please sign in to comment.