diff --git a/tangram/src/main/java/com/tmall/wireless/tangram3/BaseTangramEngine.java b/tangram/src/main/java/com/tmall/wireless/tangram3/BaseTangramEngine.java index b5a9bdf..fe18ef9 100644 --- a/tangram/src/main/java/com/tmall/wireless/tangram3/BaseTangramEngine.java +++ b/tangram/src/main/java/com/tmall/wireless/tangram3/BaseTangramEngine.java @@ -510,14 +510,6 @@ public class BaseTangramEngine implements ServiceManager { return type.cast(service); } - public void setSupportRx(boolean supportRx) { - isSupportRx = supportRx; - TimerSupport timerSupport = getService(TimerSupport.class); - if (timerSupport != null) { - timerSupport.setSupportRx(supportRx); - } - } - @Override public boolean supportRx() { return isSupportRx; diff --git a/tangram/src/main/java/com/tmall/wireless/tangram3/support/BannerScrollStateChangedObservable.java b/tangram/src/main/java/com/tmall/wireless/tangram3/support/BannerScrollStateChangedObservable.java deleted file mode 100644 index 61fc306..0000000 --- a/tangram/src/main/java/com/tmall/wireless/tangram3/support/BannerScrollStateChangedObservable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2018 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.tmall.wireless.tangram3.support; - -import io.reactivex.Observable; -import io.reactivex.Observer; - -/** - * Created by longerian on 2018/3/14. - * - * @author longerian - * @date 2018/03/14 - */ - -public class BannerScrollStateChangedObservable extends Observable { - - private final RxBannerListener mBannerListener; - - public BannerScrollStateChangedObservable(RxBannerScrollStateChangedListener bannerListener) { - mBannerListener = bannerListener; - } - - @Override - protected void subscribeActual(Observer observer) { - observer.onSubscribe(mBannerListener); - mBannerListener.addObserver(observer); - } -} diff --git a/tangram/src/main/java/com/tmall/wireless/tangram3/support/BannerScrolledObservable.java b/tangram/src/main/java/com/tmall/wireless/tangram3/support/BannerScrolledObservable.java deleted file mode 100644 index 9b2b7f0..0000000 --- a/tangram/src/main/java/com/tmall/wireless/tangram3/support/BannerScrolledObservable.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2018 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.tmall.wireless.tangram3.support; - -import com.tmall.wireless.tangram3.support.RxBannerScrolledListener.ScrollEvent; - -import io.reactivex.Observable; -import io.reactivex.Observer; - -/** - * Created by longerian on 2018/3/14. - * - * @author longerian - * @date 2018/03/14 - */ - -public class BannerScrolledObservable extends Observable { - - private final RxBannerListener mBannerListener; - - public BannerScrolledObservable(RxBannerScrolledListener bannerListener) { - mBannerListener = bannerListener; - } - - @Override - protected void subscribeActual(Observer observer) { - observer.onSubscribe(mBannerListener); - mBannerListener.addObserver(observer); - } - -} diff --git a/tangram/src/main/java/com/tmall/wireless/tangram3/support/BannerSelectedObservable.java b/tangram/src/main/java/com/tmall/wireless/tangram3/support/BannerSelectedObservable.java deleted file mode 100644 index 91dc3ad..0000000 --- a/tangram/src/main/java/com/tmall/wireless/tangram3/support/BannerSelectedObservable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2018 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.tmall.wireless.tangram3.support; - -import io.reactivex.Observable; -import io.reactivex.Observer; - -/** - * Created by longerian on 2018/3/9. - * - * @author longerian - * @date 2018/03/09 - */ - -public class BannerSelectedObservable extends Observable { - - private final RxBannerListener mBannerListener; - - public BannerSelectedObservable(RxBannerSelectedListener bannerListener) { - mBannerListener = bannerListener; - } - - @Override - protected void subscribeActual(Observer observer) { - observer.onSubscribe(mBannerListener); - mBannerListener.addObserver(observer); - } -} diff --git a/tangram/src/main/java/com/tmall/wireless/tangram3/support/BannerSupport.java b/tangram/src/main/java/com/tmall/wireless/tangram3/support/BannerSupport.java index 772d90d..8974fa5 100644 --- a/tangram/src/main/java/com/tmall/wireless/tangram3/support/BannerSupport.java +++ b/tangram/src/main/java/com/tmall/wireless/tangram3/support/BannerSupport.java @@ -26,14 +26,11 @@ package com.tmall.wireless.tangram3.support; import android.support.v4.util.ArrayMap; -import com.tmall.wireless.tangram3.support.RxBannerScrolledListener.ScrollEvent; import com.tmall.wireless.tangram3.ext.BannerListener; import java.util.ArrayList; import java.util.List; -import io.reactivex.Observable; - /** * You can get banner scroll info from this support * Created by mikeafc on 17/4/9. @@ -78,42 +75,6 @@ public class BannerSupport { return mScrollStateListenerArrayMap.get(id); } - public Observable observeSelected(String id) { - List list = mSelectedListenerArrayMap.get(id); - if (list == null) { - list = new ArrayList<>(); - mSelectedListenerArrayMap.put(id, list); - } - RxBannerSelectedListener rxBannerSelectedListener = new RxBannerSelectedListener(); - list.add(rxBannerSelectedListener); - BannerSelectedObservable bannerSupportObservable = new BannerSelectedObservable(rxBannerSelectedListener); - return bannerSupportObservable; - } - - public Observable observeScrolled(String id) { - List list = mScrolledListenerArrayMap.get(id); - if (list == null) { - list = new ArrayList<>(); - mScrolledListenerArrayMap.put(id, list); - } - RxBannerScrolledListener rxBannerSelectedListener = new RxBannerScrolledListener(); - list.add(rxBannerSelectedListener); - BannerScrolledObservable bannerSupportObservable = new BannerScrolledObservable(rxBannerSelectedListener); - return bannerSupportObservable; - } - - public Observable observeScrollStateChanged(String id) { - List list = mScrollStateListenerArrayMap.get(id); - if (list == null) { - list = new ArrayList<>(); - mScrollStateListenerArrayMap.put(id, list); - } - RxBannerScrollStateChangedListener rxBannerSelectedListener = new RxBannerScrollStateChangedListener(); - list.add(rxBannerSelectedListener); - BannerScrollStateChangedObservable bannerSupportObservable = new BannerScrollStateChangedObservable(rxBannerSelectedListener); - return bannerSupportObservable; - } - public void destroy() { destroyBannerSelected(); destroyBannerScrolled(); diff --git a/tangram/src/main/java/com/tmall/wireless/tangram3/support/CellClickObservable.java b/tangram/src/main/java/com/tmall/wireless/tangram3/support/CellClickObservable.java deleted file mode 100644 index d30d5e1..0000000 --- a/tangram/src/main/java/com/tmall/wireless/tangram3/support/CellClickObservable.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2018 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.tmall.wireless.tangram3.support; - -import com.tmall.wireless.tangram3.op.ClickExposureCellOp; -import com.tmall.wireless.tangram3.util.Preconditions; - -import io.reactivex.Observable; -import io.reactivex.Observer; - -/** - * Created by longerian on 2018/3/7. - * - * @author longerian - * @date 2018/03/07 - */ - -public class CellClickObservable extends Observable { - - private ClickExposureCellOp mRxClickExposureEvent; - - private RxClickListener mListener; - - public CellClickObservable(ClickExposureCellOp rxClickExposureEvent) { - Preconditions.checkNotNull(rxClickExposureEvent); - Preconditions.checkNotNull(rxClickExposureEvent.getArg1()); - this.mRxClickExposureEvent = rxClickExposureEvent; - } - - public void setRxClickExposureEvent(ClickExposureCellOp rxClickExposureEvent) { - mRxClickExposureEvent = rxClickExposureEvent; - } - - @Override - protected void subscribeActual(Observer observer) { - if (!Preconditions.checkMainThread(observer)) { - return; - } - if (mListener == null) { - mListener = new RxClickListener(mRxClickExposureEvent, observer); - } else { - mListener.setRxClickExposureEvent(mRxClickExposureEvent); - mListener.setObserver(observer); - } - observer.onSubscribe(mListener); - mRxClickExposureEvent.getArg1().setOnClickListener(mListener); - } - -} diff --git a/tangram/src/main/java/com/tmall/wireless/tangram3/support/CellExposureObservable.java b/tangram/src/main/java/com/tmall/wireless/tangram3/support/CellExposureObservable.java deleted file mode 100644 index 212acfa..0000000 --- a/tangram/src/main/java/com/tmall/wireless/tangram3/support/CellExposureObservable.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2018 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.tmall.wireless.tangram3.support; - -import com.tmall.wireless.tangram3.op.ClickExposureCellOp; -import com.tmall.wireless.tangram3.util.Preconditions; - -import java.util.concurrent.atomic.AtomicBoolean; - -import io.reactivex.Observable; -import io.reactivex.Observer; -import io.reactivex.disposables.Disposable; - -/** - * Created by longerian on 2018/3/7. - * - * @author longerian - * @date 2018/03/07 - */ - -public class CellExposureObservable extends Observable { - - private ClickExposureCellOp mRxClickExposureEvent; - - private ExposureDispose mExposureDispose; - - public CellExposureObservable(ClickExposureCellOp rxClickExposureEvent) { - Preconditions.checkNotNull(rxClickExposureEvent); - Preconditions.checkNotNull(rxClickExposureEvent.getArg1()); - this.mRxClickExposureEvent = rxClickExposureEvent; - } - - public void setRxClickExposureEvent(ClickExposureCellOp rxClickExposureEvent) { - mRxClickExposureEvent = rxClickExposureEvent; - } - - @Override - protected void subscribeActual(Observer observer) { - if (mExposureDispose == null) { - mExposureDispose = new ExposureDispose(); - } - observer.onSubscribe(mExposureDispose); - if (!mExposureDispose.isDisposed()) { - observer.onNext(mRxClickExposureEvent); - } - } - - private static class ExposureDispose implements Disposable { - - private final AtomicBoolean unsubscribed = new AtomicBoolean(); - - @Override - public void dispose() { - unsubscribed.compareAndSet(false, true); - } - - @Override - public boolean isDisposed() { - return unsubscribed.get(); - } - } - - -} diff --git a/tangram/src/main/java/com/tmall/wireless/tangram3/support/RxBannerListener.java b/tangram/src/main/java/com/tmall/wireless/tangram3/support/RxBannerListener.java deleted file mode 100644 index ae6dc25..0000000 --- a/tangram/src/main/java/com/tmall/wireless/tangram3/support/RxBannerListener.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2018 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.tmall.wireless.tangram3.support; - -import com.tmall.wireless.tangram3.ext.BannerListener; - -import io.reactivex.Observer; -import io.reactivex.android.MainThreadDisposable; - -/** - * Created by longerian on 2018/3/9. - * - * @author longerian - * @date 2018/03/09 - */ - -public abstract class RxBannerListener extends MainThreadDisposable implements BannerListener { - - protected Observer mObserver; - - public void addObserver(Observer observer) { - mObserver = observer; - } - - public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels, int direction) { - - } - - public void onPageSelected(int position) { - - } - - public void onPageScrollStateChanged(int state) { - - } - - public void onItemPositionInBanner(int position) { - - } - - @Override - protected void onDispose() { - mObserver = null; - } -} diff --git a/tangram/src/main/java/com/tmall/wireless/tangram3/support/RxBannerScrollStateChangedListener.java b/tangram/src/main/java/com/tmall/wireless/tangram3/support/RxBannerScrollStateChangedListener.java deleted file mode 100644 index bf36ff6..0000000 --- a/tangram/src/main/java/com/tmall/wireless/tangram3/support/RxBannerScrollStateChangedListener.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2018 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.tmall.wireless.tangram3.support; - -/** - * Created by longerian on 2018/3/9. - * - * @author longerian - * @date 2018/03/09 - */ - -public class RxBannerScrollStateChangedListener extends RxBannerListener { - - @Override - public void onPageScrollStateChanged(final int state) { - if (!isDisposed()) { - mObserver.onNext(state); - } - } - -} diff --git a/tangram/src/main/java/com/tmall/wireless/tangram3/support/RxBannerScrolledListener.java b/tangram/src/main/java/com/tmall/wireless/tangram3/support/RxBannerScrolledListener.java deleted file mode 100644 index 5e7e39a..0000000 --- a/tangram/src/main/java/com/tmall/wireless/tangram3/support/RxBannerScrolledListener.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2018 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.tmall.wireless.tangram3.support; - -import com.tmall.wireless.tangram3.support.RxBannerScrolledListener.ScrollEvent; - -/** - * Created by longerian on 2018/3/9. - * - * @author longerian - * @date 2018/03/09 - */ - -public class RxBannerScrolledListener extends RxBannerListener { - - @Override - public void onPageScrolled(final int position, final float positionOffset, final int positionOffsetPixels, int direction) { - if (!isDisposed()) { - mObserver.onNext(new ScrollEvent(position, positionOffset, positionOffsetPixels)); - } - } - - @Override - public void onPageSelected(int position) { - } - - @Override - public void onPageScrollStateChanged(int state) { - - } - - public static class ScrollEvent { - - public final int position; - public final float positionOffset; - public final int positionOffsetPixels; - - public ScrollEvent(int position, float positionOffset, int positionOffsetPixels) { - this.position = position; - this.positionOffset = positionOffset; - this.positionOffsetPixels = positionOffsetPixels; - } - - @Override - public String toString() { - return "ScrollEvent{" + - "position=" + position + - ", positionOffset=" + positionOffset + - ", positionOffsetPixels=" + positionOffsetPixels + - '}'; - } - } - -} diff --git a/tangram/src/main/java/com/tmall/wireless/tangram3/support/RxBannerSelectedListener.java b/tangram/src/main/java/com/tmall/wireless/tangram3/support/RxBannerSelectedListener.java deleted file mode 100644 index 9349e60..0000000 --- a/tangram/src/main/java/com/tmall/wireless/tangram3/support/RxBannerSelectedListener.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2018 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.tmall.wireless.tangram3.support; - -/** - * Created by longerian on 2018/3/9. - * - * @author longerian - * @date 2018/03/09 - */ - -public class RxBannerSelectedListener extends RxBannerListener { - - @Override - public void onPageSelected(final int position) { - if (!isDisposed()) { - mObserver.onNext(position); - } - } - -} diff --git a/tangram/src/main/java/com/tmall/wireless/tangram3/support/RxClickListener.java b/tangram/src/main/java/com/tmall/wireless/tangram3/support/RxClickListener.java deleted file mode 100644 index 2b7da86..0000000 --- a/tangram/src/main/java/com/tmall/wireless/tangram3/support/RxClickListener.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2018 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.tmall.wireless.tangram3.support; - -import android.view.View; - -import com.tmall.wireless.tangram3.op.ClickExposureCellOp; - -import io.reactivex.Observer; -import io.reactivex.android.MainThreadDisposable; - -/** - * Created by longerian on 2018/3/7. - * - * @author longerian - * @date 2018/03/07 - */ - -public class RxClickListener extends MainThreadDisposable implements View.OnClickListener { - - private ClickExposureCellOp mRxClickExposureEvent; - - private Observer mObserver; - - public RxClickListener(ClickExposureCellOp rxClickExposureEvent, Observer observer) { - this.mRxClickExposureEvent = rxClickExposureEvent; - this.mObserver = observer; - } - - public void setRxClickExposureEvent(ClickExposureCellOp rxClickExposureEvent) { - mRxClickExposureEvent = rxClickExposureEvent; - } - - public void setObserver(Observer observer) { - mObserver = observer; - } - - @Override - public void onClick(View v) { - if (!isDisposed()) { - mObserver.onNext(mRxClickExposureEvent); - } - } - - @Override - protected void onDispose() { - mRxClickExposureEvent.getArg1().setOnClickListener(null); - } - -} diff --git a/tangram/src/main/java/com/tmall/wireless/tangram3/support/RxTimer.java b/tangram/src/main/java/com/tmall/wireless/tangram3/support/RxTimer.java deleted file mode 100644 index 4e57c0e..0000000 --- a/tangram/src/main/java/com/tmall/wireless/tangram3/support/RxTimer.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2018 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.tmall.wireless.tangram3.support; - -import android.support.annotation.NonNull; -import android.support.v4.util.ArrayMap; -import android.util.Log; - -import com.tmall.wireless.tangram3.support.HandlerTimer.TimerStatus; -import com.tmall.wireless.tangram3.support.TimerSupport.OnTickListener; - -import java.util.concurrent.TimeUnit; - -import io.reactivex.Observable; -import io.reactivex.android.schedulers.AndroidSchedulers; -import io.reactivex.disposables.Disposable; -import io.reactivex.functions.Action; -import io.reactivex.functions.Consumer; -import io.reactivex.functions.Predicate; - -/** - * Created by longerian on 2018/3/8. - * - * @author longerian - * @date 2018/03/08 - */ - -public class RxTimer implements ITimer { - - private long mInterval; - - private TimerStatus mStatus; - - private boolean pause; - - private Observable mIntervalObservable; - - private ArrayMap tickCache = new ArrayMap<>(); - - public RxTimer(long interval) { - this.mInterval = interval; - this.mStatus = TimerStatus.Waiting; - this.mIntervalObservable = Observable - .interval(0, this.mInterval, TimeUnit.MILLISECONDS) - .doOnSubscribe(new Consumer() { - @Override - public void accept(Disposable disposable) throws Exception { - mStatus = TimerStatus.Running; - Log.d("RxTimerSupportTest", "accept " + disposable + " status " + mStatus); - } - }) - .doOnDispose(new Action() { - @Override - public void run() throws Exception { - mStatus = TimerStatus.Paused; - Log.d("RxTimerSupportTest", "on dispose " + " status " + mStatus); - } - }) - .doOnTerminate(new Action() { - @Override - public void run() throws Exception { - mStatus = TimerStatus.Stopped; - Log.d("RxTimerSupportTest", "on terminate " + " status " + mStatus); - } - }) - .share(); - } - - public void register(final int interval, @NonNull final OnTickListener onTickListener, boolean intermediate) { - Disposable disposable = this.mIntervalObservable.delaySubscription(intermediate ? 0 : interval * mInterval, TimeUnit.MILLISECONDS).skipWhile( - - new Predicate() { - @Override - public boolean test(Long aLong) throws Exception { - return pause; - } - }).observeOn( - AndroidSchedulers.mainThread()).subscribe(new Consumer() { - - @Override - public void accept(Long count) throws Exception { - Log.d("RxTimerSupportTest", "accept " + " value " + count); - if (count % interval == 0) { - if (onTickListener != null) { - onTickListener.onTick(); - } - } - } - }); - tickCache.put(onTickListener, disposable); - } - - public void unregister(OnTickListener onTickListener) { - Disposable disposable = tickCache.get(onTickListener); - if (disposable != null) { - disposable.dispose(); - tickCache.remove(onTickListener); - } - } - - public boolean isRegistered(@NonNull OnTickListener onTickListener) { - return tickCache.containsKey(onTickListener); - } - - @Override - public void start() { - //no need - } - - @Override - public void start(boolean bySecond) { - //no need - } - - @Override - public void pause() { - pause = true; - mStatus = TimerStatus.Paused; - } - - @Override - public void restart() { - pause = false; - if (mStatus == TimerStatus.Paused) { - mStatus = TimerStatus.Running; - } - } - - @Override - public void stop() { - for (int i = 0, size = tickCache.size(); i < size; i++) { - Disposable disposable = tickCache.valueAt(i); - disposable.dispose(); - } - tickCache.clear(); - } - - @Override - public void cancel() { - //no need - } - - @Override - public void clear() { - tickCache.clear(); - } - - @Override - public TimerStatus getStatus() { - return mStatus; - } -} diff --git a/tangram/src/main/java/com/tmall/wireless/tangram3/support/TimerSupport.java b/tangram/src/main/java/com/tmall/wireless/tangram3/support/TimerSupport.java index 4e18cbd..0701c94 100644 --- a/tangram/src/main/java/com/tmall/wireless/tangram3/support/TimerSupport.java +++ b/tangram/src/main/java/com/tmall/wireless/tangram3/support/TimerSupport.java @@ -42,18 +42,6 @@ public class TimerSupport { private ITimer mDefaultTimer = new HandlerTimer(MILLISECOND); - public void setSupportRx(boolean supportRx) { - if (supportRx) { - if (!(mDefaultTimer instanceof RxTimer)) { - mDefaultTimer = new RxTimer(MILLISECOND); - } - } else { - if (!(mDefaultTimer instanceof HandlerTimer)) { - mDefaultTimer = new HandlerTimer(MILLISECOND); - } - } - } - public void register(int interval, @NonNull OnTickListener onTickListener) { register(interval, onTickListener, false); } diff --git a/tangram/src/main/java/com/tmall/wireless/tangram3/support/async/CardLoadSupport.java b/tangram/src/main/java/com/tmall/wireless/tangram3/support/async/CardLoadSupport.java index 3ddda3e..a3e8172 100644 --- a/tangram/src/main/java/com/tmall/wireless/tangram3/support/async/CardLoadSupport.java +++ b/tangram/src/main/java/com/tmall/wireless/tangram3/support/async/CardLoadSupport.java @@ -26,8 +26,6 @@ package com.tmall.wireless.tangram3.support.async; import com.tmall.wireless.tangram3.TangramEngine; import com.tmall.wireless.tangram3.dataparser.concrete.Card; -import com.tmall.wireless.tangram3.op.LoadGroupOp; -import com.tmall.wireless.tangram3.op.LoadMoreOp; import com.tmall.wireless.tangram3.structure.BaseCell; import java.util.List; @@ -225,30 +223,6 @@ public class CardLoadSupport { mLoadCardObserver.onNext(card); } - /** - * Combine with {@link #observeCardLoading()}, use this method as success consumer to subscribe to the Observable.
- * If your request success, provide a {@link LoadGroupOp} with original card and non-empty List.
- * Otherwise, provide a {@link LoadGroupOp} with original card and empty List. - * @return A consumer to consume load event. - */ - public Consumer asDoLoadFinishConsumer() { - return new Consumer() { - @Override - public void accept(LoadGroupOp result) throws Exception { - Card card = result.getArg1(); - card.loading = false; - List cells = result.getArg2(); - if (cells != null && !cells.isEmpty()) { - card.loaded = true; - card.setCells(cells); - card.notifyDataChange(); - } else { - card.loaded = false; - } - } - }; - } - /** * * @return An observable start loading more for a card @@ -293,38 +267,4 @@ public class CardLoadSupport { } mLoadMoreObserver.onNext(card); } - - - /** - * Combine with {@link #observeCardLoadingMore()}, use this method as success consumer to subscribe to the Observable.
- * If your request success, provide a {@link LoadMoreOp} with original card, non-empty List and boolean value to indicate whether there is more.
- * Otherwise, provide a {@link LoadMoreOp} with original card, empty List and boolean value to indicate whether there is more. - * @return A consumer to consume load more event. - */ - public Consumer asDoLoadMoreFinishConsumer() { - return new Consumer() { - @Override - public void accept(LoadMoreOp result) throws Exception { - Card card = result.getArg1(); - card.loading = false; - card.loaded = true; - List cells = result.getArg2(); - boolean hasMore = result.getArg3(); - if (cells != null && !cells.isEmpty()) { - if (card.page == sInitialPage) { - card.setCells(cells); - } else { - card.addCells(cells); - } - card.page++; - card.hasMore = hasMore; - card.notifyDataChange(); - } else { - card.hasMore = hasMore; - } - } - }; - } - - }