Skip to content

Commit

Permalink
* [android] fix onTouchEvent bug
Browse files Browse the repository at this point in the history
  • Loading branch information
miomin committed Jun 20, 2016
1 parent fb3202d commit 911e569
Show file tree
Hide file tree
Showing 14 changed files with 1,336 additions and 1,033 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,21 @@
/* 0 */
/***/ function(module, exports, __webpack_require__) {

;__weex_define__("@weex-component/1db44eabec6bad5890f917d5941a572e", [], function(__weex_require__, __weex_exports__, __weex_module__){
;__weex_define__("@weex-component/47db7c8a2e4e20dedaab66df04dd96ea", [], function(__weex_require__, __weex_exports__, __weex_module__){

;
__webpack_require__(1);
__weex_module__.exports = {
methods: {
onrefresh: function(e) {
var self = this;
self.refresh_display = 'show';
// self.$call('timer', 'setTimeout', function() {
// self.refresh_display = 'hide';
// },3000);
self.refresh_display = 'hide';
self.refresh_display = 'hide';
},
onloading: function(e) {
this.$call('modal', 'toast', {
'message': "onloading",
'duration': 2
});
},
onappear: function (e) {
var appearId = this.rows[e.target.attr.index].id;
Expand Down Expand Up @@ -209,6 +211,9 @@
"classList": [
"refresh-view"
],
"events": {
"loading": "onloading"
},
"children": [
{
"type": "text",
Expand Down Expand Up @@ -283,7 +288,7 @@
}
})
})
;__weex_bootstrap__("@weex-component/1db44eabec6bad5890f917d5941a572e", {
;__weex_bootstrap__("@weex-component/47db7c8a2e4e20dedaab66df04dd96ea", {
"transformerVersion": "0.3.1"
},undefined)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,13 @@
package com.taobao.weex.ui.component;

import android.text.TextUtils;
import android.util.Log;

import com.taobao.weex.WXSDKInstance;
import com.taobao.weex.dom.WXDomObject;
import com.taobao.weex.ui.component.list.WXListComponent;
import com.taobao.weex.ui.view.WXFrameLayout;
import com.taobao.weex.ui.view.refresh.wrapper.BaseBounceView;

/**
* div component
Expand Down Expand Up @@ -240,12 +243,12 @@ public WXFrameLayout getView() {

@WXComponentProp(name = "display")
public void setDisplay(String display) {
Log.i("miomin","finish");
if (!TextUtils.isEmpty(display)) {
if (display.equals("hide")) {
// if (getParent() instanceof WXListComponent && getParent().getView() instanceof BounceRecyclerView) {
// BounceRecyclerView brv = (BounceRecyclerView) getParent().getView();
// brv.refreshState();
// }
if (getParent() instanceof WXListComponent || getParent() instanceof WXScroller) {
((BaseBounceView)getParent().getView()).finishPullRefresh();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,15 @@
package com.taobao.weex.ui.component;

import com.taobao.weex.WXSDKInstance;
import com.taobao.weex.WXSDKManager;
import com.taobao.weex.dom.WXDomObject;
import com.taobao.weex.ui.view.WXBaseRefreshLayout;
import com.taobao.weex.ui.view.refresh.core.WXSwipeLayout;

/**
* div component
*/
public class WXLoading extends WXBaseRefresh {
public class WXLoading extends WXBaseRefresh implements WXSwipeLayout.WXOnLoadingListener {

public WXLoading(WXSDKInstance instance, WXDomObject node, WXVContainer parent, boolean lazy) {
super(instance, node, parent, lazy);
Expand All @@ -222,11 +224,10 @@ protected void initView() {
mHost = new WXBaseRefreshLayout(mContext);
}

// @Override
// public void onLoadMore() {
// if (mDomObj.event != null && mDomObj.event.contains(WXEventType.RECYCLERVIEW_ONLOADING)) {
// WXSDKManager.getInstance().fireEvent(mInstanceId, getRef(), WXEventType.RECYCLERVIEW_ONLOADING);
// }
// }

@Override
public void onLoading() {
if (mDomObj.event != null && mDomObj.event.contains(WXEventType.RECYCLERVIEW_ONLOADING)) {
WXSDKManager.getInstance().fireEvent(mInstanceId, getRef(), WXEventType.RECYCLERVIEW_ONLOADING);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,15 @@
package com.taobao.weex.ui.component;

import com.taobao.weex.WXSDKInstance;
import com.taobao.weex.WXSDKManager;
import com.taobao.weex.dom.WXDomObject;
import com.taobao.weex.ui.view.WXBaseRefreshLayout;
import com.taobao.weex.ui.view.refresh.core.WXSwipeLayout;

/**
* div component
*/
public class WXRefresh extends WXBaseRefresh {
public class WXRefresh extends WXBaseRefresh implements WXSwipeLayout.WXOnRefreshListener{

public WXRefresh(WXSDKInstance instance, WXDomObject node, WXVContainer parent, boolean lazy) {
super(instance, node, parent, lazy);
Expand All @@ -222,11 +224,10 @@ protected void initView() {
mHost = new WXBaseRefreshLayout(mContext);
}

// @Override
// public void onRefresh() {
// if (mDomObj.event != null && mDomObj.event.contains(WXEventType.RECYCLERVIEW_ONREFRESH)) {
// WXSDKManager.getInstance().fireEvent(mInstanceId, getRef(), WXEventType.RECYCLERVIEW_ONREFRESH);
// }
// }

@Override
public void onRefresh() {
if (mDomObj.event != null && mDomObj.event.contains(WXEventType.RECYCLERVIEW_ONREFRESH)) {
WXSDKManager.getInstance().fireEvent(mInstanceId, getRef(), WXEventType.RECYCLERVIEW_ONREFRESH);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,11 @@
import com.taobao.weex.ui.component.WXLoading;
import com.taobao.weex.ui.component.WXRefresh;
import com.taobao.weex.ui.component.WXVContainer;
import com.taobao.weex.ui.view.refresh.wrapper.BounceRecyclerView;
import com.taobao.weex.ui.view.listview.adapter.IRecyclerAdapterListener;
import com.taobao.weex.ui.view.listview.adapter.ListBaseViewHolder;
import com.taobao.weex.ui.view.listview.adapter.RecyclerViewBaseAdapter;
import com.taobao.weex.ui.view.listview.adapter.TransformItemDecoration;
import com.taobao.weex.ui.view.refresh.wrapper.BounceRecyclerView;
import com.taobao.weex.utils.WXLogUtils;
import com.taobao.weex.utils.WXViewUtils;

Expand Down Expand Up @@ -325,7 +326,7 @@ private RecyclerView.ItemDecoration parseTransforms(String raw){
WXLogUtils.e(TAG, "Invaild transform expression:" + match);
}
}
return new BounceRecyclerView.TransformItemDecoration(getOrientation() == VERTICAL,opacity,translateX,translateY,rotate,scaleX,scaleY);
return new TransformItemDecoration(getOrientation() == VERTICAL, opacity, translateX, translateY, rotate, scaleX, scaleY);
}

@Override
Expand Down Expand Up @@ -444,8 +445,8 @@ public void onBindViewHolder(ListBaseViewHolder holder, int position) {
holder.setComponentUsing(true);
WXComponent component = getChild(position);
if ( component == null
// || (component instanceof WXRefresh)
// || (component instanceof WXLoading)
|| (component instanceof WXRefresh)
|| (component instanceof WXLoading)
|| (component.mDomObj!=null && component.mDomObj.isFixed())
) {

Expand Down Expand Up @@ -478,6 +479,7 @@ public ListBaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (mChildren != null) {
for (int i = 0; i < childCount(); i++) {
WXComponent component = getChild(i);
checkRefreshOrLoading(component);
if (component == null
|| component.isUsing()
|| getItemViewType(i) != viewType)
Expand Down Expand Up @@ -509,6 +511,15 @@ public ListBaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
throw new WXRuntimeException("mChildren is null");
}

private void checkRefreshOrLoading(WXComponent child) {
if (child instanceof WXRefresh) {
bounceRecyclerView.setOnRefreshListener((WXRefresh)child);
}

if (child instanceof WXLoading) {
bounceRecyclerView.setOnLoadingListener((WXLoading)child);
}
}

/**
* Return the child component type. The type is defined by scopeValue in .we file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,11 @@
package com.taobao.weex.ui.view.listview;

import android.content.Context;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.OrientationHelper;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.View;
import android.view.ViewGroup;

public class WXRecyclerView extends RecyclerView {

Expand All @@ -229,9 +226,8 @@ public WXRecyclerView(Context context) {
* @param context
* @param type
* @param orientation should be {@link OrientationHelper#HORIZONTAL} or {@link OrientationHelper#VERTICAL}
*/
*/
public void initView(Context context, int type,int orientation) {

if (type == TYPE_GRID_LAYOUT) {
setLayoutManager(new GridLayoutManager(context, 2,orientation,false));
} else if (type == TYPE_STAGGERED_GRID_LAYOUT) {
Expand Down
Loading

0 comments on commit 911e569

Please sign in to comment.