Search in sources :

Example 1 with GroupBasicAdapter

use of com.tmall.wireless.tangram.core.adapter.GroupBasicAdapter in project Tangram-Android by alibaba.

the class BannerTestActivity method onCreate.

@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
protected void onCreate(Bundle savedInstanceState) {
    try {
        Picasso.setSingletonInstance(new Picasso.Builder(this).loggingEnabled(true).build());
    } catch (Exception e) {
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity);
    recyclerView = (RecyclerView) findViewById(R.id.main_view);
    // Step 1: init tangram
    TangramBuilder.init(this, new IInnerImageSetter() {

        @Override
        public <IMAGE extends ImageView> void doLoadImageUrl(@NonNull IMAGE view, @Nullable String url) {
            Picasso.with(BannerTestActivity.this).load(url).into(view);
        }
    }, ImageView.class);
    // Tangram.switchLog(true);
    mMainHandler = new Handler(getMainLooper());
    // Step 2: register build=in cells and cards
    builder = TangramBuilder.newInnerBuilder(this);
    // Step 3: register business cells and cards
    builder.registerCell(1, TestView.class);
    builder.registerCell(10, SimpleImgView.class);
    builder.registerCell(2, SimpleImgView.class);
    builder.registerCell(4, RatioTextView.class);
    builder.registerCell(110, TestViewHolderCell.class, new ViewHolderCreator<>(R.layout.item_holder, TestViewHolder.class, TextView.class));
    builder.registerCell(199, SingleImageView.class);
    builder.registerVirtualView("vvtest");
    // Step 4: new engine
    engine = builder.build();
    engine.setVirtualViewTemplate(VVTEST.BIN);
    engine.getService(VafContext.class).setImageLoaderAdapter(new IImageLoaderAdapter() {

        private List<ImageTarget> cache = new ArrayList<ImageTarget>();

        @Override
        public void bindImage(String uri, final ImageBase imageBase, int reqWidth, int reqHeight) {
            RequestCreator requestCreator = Picasso.with(BannerTestActivity.this).load(uri);
            Log.d("BannerTestActivity", "bindImage request width height " + reqHeight + " " + reqWidth);
            if (reqHeight > 0 || reqWidth > 0) {
                requestCreator.resize(reqWidth, reqHeight);
            }
            ImageTarget imageTarget = new ImageTarget(imageBase);
            cache.add(imageTarget);
            requestCreator.into(imageTarget);
        }

        @Override
        public void getBitmap(String uri, int reqWidth, int reqHeight, final Listener lis) {
            RequestCreator requestCreator = Picasso.with(BannerTestActivity.this).load(uri);
            Log.d("BannerTestActivity", "getBitmap request width height " + reqHeight + " " + reqWidth);
            if (reqHeight > 0 || reqWidth > 0) {
                requestCreator.resize(reqWidth, reqHeight);
            }
            ImageTarget imageTarget = new ImageTarget(lis);
            cache.add(imageTarget);
            requestCreator.into(imageTarget);
        }
    });
    Utils.setUedScreenWidth(720);
    // Step 5: add card load support if you have card that loading cells async
    engine.addCardLoadSupport(new CardLoadSupport(new AsyncLoader() {

        @Override
        public void loadData(Card card, @NonNull final LoadedCallback callback) {
            Log.w("Load Card", card.load);
            mMainHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    // do loading
                    JSONArray cells = new JSONArray();
                    for (int i = 0; i < 10; i++) {
                        try {
                            JSONObject obj = new JSONObject();
                            obj.put("type", 1);
                            obj.put("msg", "async loaded");
                            JSONObject style = new JSONObject();
                            style.put("bgColor", "#FF1111");
                            obj.put("style", style.toString());
                            cells.put(obj);
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                    // callback.fail(false);
                    callback.finish(engine.parseComponent(cells));
                }
            }, 200);
        }
    }, new AsyncPageLoader() {

        @Override
        public void loadData(final int page, @NonNull final Card card, @NonNull final LoadedCallback callback) {
            mMainHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    Log.w("Load page", card.load + " page " + page);
                    JSONArray cells = new JSONArray();
                    for (int i = 0; i < 9; i++) {
                        try {
                            JSONObject obj = new JSONObject();
                            obj.put("type", 1);
                            obj.put("msg", "async page loaded, params: " + card.getParams().toString());
                            cells.put(obj);
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                    List<BaseCell> cs = engine.parseComponent(cells);
                    if (card.page == 1) {
                        GroupBasicAdapter<Card, ?> adapter = engine.getGroupBasicAdapter();
                        card.setCells(cs);
                        adapter.refreshWithoutNotify();
                        Range<Integer> range = adapter.getCardRange(card);
                        adapter.notifyItemRemoved(range.getLower());
                        adapter.notifyItemRangeInserted(range.getLower(), cs.size());
                    } else
                        card.addCells(cs);
                    // mock load 6 pages
                    callback.finish(card.page != 6);
                    card.notifyDataChange();
                }
            }, 400);
        }
    }));
    engine.addSimpleClickSupport(new SampleClickSupport());
    // Step 6: enable auto load more if your page's data is lazy loaded
    engine.enableAutoLoadMore(true);
    // Step 7: bind recyclerView to engine
    engine.bindView(recyclerView);
    // Step 8: listener recyclerView onScroll event to trigger auto load more
    recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            engine.onScrolled();
        }
    });
    // Step 9: set an offset to fix card
    engine.getLayoutManager().setFixOffset(0, 40, 0, 0);
    // Step 10: get tangram data and pass it to engine
    String json = new String(getAssertsFile(this, "testdata.json"));
    JSONArray data = null;
    try {
        data = new JSONArray(json);
        engine.setData(data);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    findViewById(R.id.first).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            engine.refresh(true);
        }
    });
}
Also used : Listener(com.tmall.wireless.vaf.virtualview.Helper.ImageLoader.Listener) CardLoadSupport(com.tmall.wireless.tangram.support.async.CardLoadSupport) IInnerImageSetter(com.tmall.wireless.tangram.util.IInnerImageSetter) ArrayList(java.util.ArrayList) RequestCreator(com.squareup.picasso.RequestCreator) SampleClickSupport(com.tmall.wireless.tangram.example.support.SampleClickSupport) NonNull(android.support.annotation.NonNull) TextView(android.widget.TextView) RatioTextView(com.tmall.wireless.tangram.example.data.RatioTextView) List(java.util.List) ArrayList(java.util.ArrayList) GroupBasicAdapter(com.tmall.wireless.tangram.core.adapter.GroupBasicAdapter) AsyncLoader(com.tmall.wireless.tangram.support.async.AsyncLoader) TestViewHolder(com.tmall.wireless.tangram.example.data.TestViewHolder) JSONArray(org.json.JSONArray) Handler(android.os.Handler) JSONException(org.json.JSONException) AsyncPageLoader(com.tmall.wireless.tangram.support.async.AsyncPageLoader) Range(com.alibaba.android.vlayout.Range) ImageView(android.widget.ImageView) SimpleImgView(com.tmall.wireless.tangram.example.data.SimpleImgView) SingleImageView(com.tmall.wireless.tangram.example.data.SingleImageView) View(android.view.View) TestView(com.tmall.wireless.tangram.example.data.TestView) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) RatioTextView(com.tmall.wireless.tangram.example.data.RatioTextView) JSONException(org.json.JSONException) IOException(java.io.IOException) Card(com.tmall.wireless.tangram.dataparser.concrete.Card) JSONObject(org.json.JSONObject) VafContext(com.tmall.wireless.vaf.framework.VafContext) IImageLoaderAdapter(com.tmall.wireless.vaf.virtualview.Helper.ImageLoader.IImageLoaderAdapter) Picasso(com.squareup.picasso.Picasso) RecyclerView(android.support.v7.widget.RecyclerView) ImageBase(com.tmall.wireless.vaf.virtualview.view.image.ImageBase) TargetApi(android.annotation.TargetApi)

Example 2 with GroupBasicAdapter

use of com.tmall.wireless.tangram.core.adapter.GroupBasicAdapter in project Tangram-Android by alibaba.

the class LinearScrollView method getViewFromRecycler.

private View getViewFromRecycler(@NonNull BaseCell cell) {
    GroupBasicAdapter adapter = cell.serviceManager.getService(GroupBasicAdapter.class);
    RecyclerView.RecycledViewPool pool = cell.serviceManager.getService(RecyclerView.RecycledViewPool.class);
    int itemViewType = adapter.getItemType(cell);
    BinderViewHolder holder = (BinderViewHolder) pool.getRecycledView(itemViewType);
    if (holder == null) {
        holder = (BinderViewHolder) adapter.createViewHolder(this, itemViewType);
    }
    holder.bind(cell);
    mViewHolders.add(holder);
    return holder.itemView;
}
Also used : GroupBasicAdapter(com.tmall.wireless.tangram.core.adapter.GroupBasicAdapter) BinderViewHolder(com.tmall.wireless.tangram.core.adapter.BinderViewHolder) RecyclerView(android.support.v7.widget.RecyclerView)

Example 3 with GroupBasicAdapter

use of com.tmall.wireless.tangram.core.adapter.GroupBasicAdapter in project Tangram-Android by alibaba.

the class TangramActivity method onCreate.

@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity);
    recyclerView = (RecyclerView) findViewById(R.id.main_view);
    // Step 1: init tangram
    TangramBuilder.init(this.getApplicationContext(), new IInnerImageSetter() {

        @Override
        public <IMAGE extends ImageView> void doLoadImageUrl(@NonNull IMAGE view, @Nullable String url) {
            Picasso.with(TangramActivity.this.getApplicationContext()).load(url).into(view);
        }
    }, ImageView.class);
    // Tangram.switchLog(true);
    mMainHandler = new Handler(getMainLooper());
    // Step 2: register build=in cells and cards
    builder = TangramBuilder.newInnerBuilder(this);
    // Step 3: register business cells and cards
    builder.registerCell(1, TestView.class);
    builder.registerCell(10, SimpleImgView.class);
    builder.registerCell(2, SimpleImgView.class);
    builder.registerCell(4, RatioTextView.class);
    builder.registerCell(110, TestViewHolderCell.class, new ViewHolderCreator<>(R.layout.item_holder, TestViewHolder.class, TextView.class));
    builder.registerCell(199, SingleImageView.class);
    builder.registerVirtualView("vvtest");
    // Step 4: new engine
    engine = builder.build();
    engine.setVirtualViewTemplate(VVTEST.BIN);
    engine.setVirtualViewTemplate(DEBUG.BIN);
    engine.getService(VafContext.class).setImageLoaderAdapter(new IImageLoaderAdapter() {

        private List<ImageTarget> cache = new ArrayList<ImageTarget>();

        @Override
        public void bindImage(String uri, final ImageBase imageBase, int reqWidth, int reqHeight) {
            RequestCreator requestCreator = Picasso.with(TangramActivity.this).load(uri);
            Log.d("TangramActivity", "bindImage request width height " + reqHeight + " " + reqWidth);
            if (reqHeight > 0 || reqWidth > 0) {
                requestCreator.resize(reqWidth, reqHeight);
            }
            ImageTarget imageTarget = new ImageTarget(imageBase);
            cache.add(imageTarget);
            requestCreator.into(imageTarget);
        }

        @Override
        public void getBitmap(String uri, int reqWidth, int reqHeight, final Listener lis) {
            RequestCreator requestCreator = Picasso.with(TangramActivity.this).load(uri);
            Log.d("TangramActivity", "getBitmap request width height " + reqHeight + " " + reqWidth);
            if (reqHeight > 0 || reqWidth > 0) {
                requestCreator.resize(reqWidth, reqHeight);
            }
            ImageTarget imageTarget = new ImageTarget(lis);
            cache.add(imageTarget);
            requestCreator.into(imageTarget);
        }
    });
    Utils.setUedScreenWidth(720);
    // Step 5: add card load support if you have card that loading cells async
    engine.addCardLoadSupport(new CardLoadSupport(new AsyncLoader() {

        @Override
        public void loadData(Card card, @NonNull final LoadedCallback callback) {
            Log.w("Load Card", card.load);
            mMainHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    // do loading
                    JSONArray cells = new JSONArray();
                    for (int i = 0; i < 10; i++) {
                        try {
                            JSONObject obj = new JSONObject();
                            obj.put("type", 1);
                            obj.put("msg", "async loaded");
                            JSONObject style = new JSONObject();
                            style.put("bgColor", "#FF1111");
                            obj.put("style", style.toString());
                            cells.put(obj);
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                    // callback.fail(false);
                    callback.finish(engine.parseComponent(cells));
                }
            }, 200);
        }
    }, new AsyncPageLoader() {

        @Override
        public void loadData(final int page, @NonNull final Card card, @NonNull final LoadedCallback callback) {
            mMainHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    Log.w("Load page", card.load + " page " + page);
                    JSONArray cells = new JSONArray();
                    for (int i = 0; i < 9; i++) {
                        try {
                            JSONObject obj = new JSONObject();
                            obj.put("type", 1);
                            obj.put("msg", "async page loaded, params: " + card.getParams().toString());
                            cells.put(obj);
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                    List<BaseCell> cs = engine.parseComponent(cells);
                    if (card.page == 1) {
                        GroupBasicAdapter<Card, ?> adapter = engine.getGroupBasicAdapter();
                        card.setCells(cs);
                        adapter.refreshWithoutNotify();
                        Range<Integer> range = adapter.getCardRange(card);
                        adapter.notifyItemRemoved(range.getLower());
                        adapter.notifyItemRangeInserted(range.getLower(), cs.size());
                    } else
                        card.addCells(cs);
                    // mock load 6 pages
                    callback.finish(card.page != 6);
                    card.notifyDataChange();
                }
            }, 400);
        }
    }));
    engine.addSimpleClickSupport(new SampleClickSupport());
    // Step 6: enable auto load more if your page's data is lazy loaded
    engine.enableAutoLoadMore(true);
    engine.register(InternalErrorSupport.class, new SampleErrorSupport());
    // Step 7: bind recyclerView to engine
    engine.bindView(recyclerView);
    // Step 8: listener recyclerView onScroll event to trigger auto load more
    recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            engine.onScrolled();
        }
    });
    // Step 9: set an offset to fix card
    engine.getLayoutManager().setFixOffset(0, 40, 0, 0);
    // Step 10: get tangram data and pass it to engine
    String json = new String(getAssertsFile(this, "data.json"));
    JSONArray data = null;
    try {
        data = new JSONArray(json);
        engine.setData(data);
    } catch (JSONException e) {
        e.printStackTrace();
    }
}
Also used : SampleErrorSupport(com.tmall.wireless.tangram.example.support.SampleErrorSupport) Listener(com.tmall.wireless.vaf.virtualview.Helper.ImageLoader.Listener) CardLoadSupport(com.tmall.wireless.tangram.support.async.CardLoadSupport) IInnerImageSetter(com.tmall.wireless.tangram.util.IInnerImageSetter) ArrayList(java.util.ArrayList) RequestCreator(com.squareup.picasso.RequestCreator) SampleClickSupport(com.tmall.wireless.tangram.example.support.SampleClickSupport) NonNull(android.support.annotation.NonNull) TextView(android.widget.TextView) RatioTextView(com.tmall.wireless.tangram.example.data.RatioTextView) List(java.util.List) ArrayList(java.util.ArrayList) GroupBasicAdapter(com.tmall.wireless.tangram.core.adapter.GroupBasicAdapter) AsyncLoader(com.tmall.wireless.tangram.support.async.AsyncLoader) TestViewHolder(com.tmall.wireless.tangram.example.data.TestViewHolder) JSONArray(org.json.JSONArray) Handler(android.os.Handler) JSONException(org.json.JSONException) AsyncPageLoader(com.tmall.wireless.tangram.support.async.AsyncPageLoader) Range(com.alibaba.android.vlayout.Range) Card(com.tmall.wireless.tangram.dataparser.concrete.Card) JSONObject(org.json.JSONObject) VafContext(com.tmall.wireless.vaf.framework.VafContext) IImageLoaderAdapter(com.tmall.wireless.vaf.virtualview.Helper.ImageLoader.IImageLoaderAdapter) RecyclerView(android.support.v7.widget.RecyclerView) ImageBase(com.tmall.wireless.vaf.virtualview.view.image.ImageBase) TargetApi(android.annotation.TargetApi)

Example 4 with GroupBasicAdapter

use of com.tmall.wireless.tangram.core.adapter.GroupBasicAdapter in project Tangram-Android by alibaba.

the class TangramDataParserActivity method onCreate.

@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity);
    recyclerView = (RecyclerView) findViewById(R.id.main_view);
    // Step 1: init tangram
    TangramBuilder.init(this, new IInnerImageSetter() {

        @Override
        public <IMAGE extends ImageView> void doLoadImageUrl(@NonNull IMAGE view, @Nullable String url) {
            Picasso.with(TangramDataParserActivity.this).load(url).into(view);
        }
    }, ImageView.class);
    // Tangram.switchLog(true);
    mMainHandler = new Handler(getMainLooper());
    // Step 2: register build=in cells and cards
    builder = TangramBuilder.newInnerBuilder(this);
    // add: custom dataParser
    builder.setDataParser(new SampleDataParser());
    // Step 3: register business cells and cards
    builder.registerCard(1000, BannerCard.class);
    builder.registerCard(2000, FourColumnCard.class);
    builder.registerCell(1, TestView.class);
    builder.registerCell(10, SimpleImgView.class);
    builder.registerCell(2, SimpleImgView.class);
    builder.registerCell(4, RatioTextView.class);
    builder.registerCell(110, TestViewHolderCell.class, new ViewHolderCreator<>(R.layout.item_holder, TestViewHolder.class, TextView.class));
    builder.registerCell(199, SingleImageView.class);
    builder.registerVirtualView("vvtest");
    // Step 4: new engine
    engine = builder.build();
    engine.setVirtualViewTemplate(VVTEST.BIN);
    Utils.setUedScreenWidth(720);
    // Step 5: add card load support if you have card that loading cells async
    engine.addCardLoadSupport(new CardLoadSupport(new AsyncLoader() {

        @Override
        public void loadData(Card card, @NonNull final LoadedCallback callback) {
            Log.w("Load Card", card.load);
            mMainHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    // do loading
                    JSONArray cells = new JSONArray();
                    for (int i = 0; i < 10; i++) {
                        try {
                            JSONObject obj = new JSONObject();
                            obj.put("type", 1);
                            obj.put("msg", "async loaded");
                            JSONObject style = new JSONObject();
                            style.put("bgColor", "#FF1111");
                            obj.put("style", style.toString());
                            cells.put(obj);
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                    // callback.fail(false);
                    callback.finish(engine.parseComponent(cells));
                }
            }, 200);
        }
    }, new AsyncPageLoader() {

        @Override
        public void loadData(final int page, @NonNull final Card card, @NonNull final LoadedCallback callback) {
            mMainHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    Log.w("Load page", card.load + " page " + page);
                    JSONArray cells = new JSONArray();
                    for (int i = 0; i < 9; i++) {
                        try {
                            JSONObject obj = new JSONObject();
                            obj.put("type", 1);
                            obj.put("msg", "async page loaded, params: " + card.getParams().toString());
                            cells.put(obj);
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                    List<BaseCell> cs = engine.parseComponent(cells);
                    if (card.page == 1) {
                        GroupBasicAdapter<Card, ?> adapter = engine.getGroupBasicAdapter();
                        card.setCells(cs);
                        adapter.refreshWithoutNotify();
                        Range<Integer> range = adapter.getCardRange(card);
                        adapter.notifyItemRemoved(range.getLower());
                        adapter.notifyItemRangeInserted(range.getLower(), cs.size());
                    } else
                        card.addCells(cs);
                    // mock load 6 pages
                    callback.finish(card.page != 6);
                    card.notifyDataChange();
                }
            }, 400);
        }
    }));
    engine.addSimpleClickSupport(new SampleClickSupport());
    // Step 6: enable auto load more if your page's data is lazy loaded
    engine.enableAutoLoadMore(true);
    // Step 7: bind recyclerView to engine
    engine.bindView(recyclerView);
    // Step 8: listener recyclerView onScroll event to trigger auto load more
    recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            engine.onScrolled();
        }
    });
    // Step 9: set an offset to fix card
    engine.getLayoutManager().setFixOffset(0, 40, 0, 0);
    // Step 10: get tangram data and pass it to engine
    String json = new String(getAssertsFile(this, "data_third.json"));
    JSONArray data = null;
    try {
        data = new JSONArray(json);
        engine.setData(data);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    findViewById(R.id.first).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            engine.refresh(true);
        }
    });
}
Also used : CardLoadSupport(com.tmall.wireless.tangram.support.async.CardLoadSupport) IInnerImageSetter(com.tmall.wireless.tangram.util.IInnerImageSetter) SampleClickSupport(com.tmall.wireless.tangram.example.support.SampleClickSupport) NonNull(android.support.annotation.NonNull) TextView(android.widget.TextView) RatioTextView(com.tmall.wireless.tangram.example.data.RatioTextView) List(java.util.List) GroupBasicAdapter(com.tmall.wireless.tangram.core.adapter.GroupBasicAdapter) AsyncLoader(com.tmall.wireless.tangram.support.async.AsyncLoader) TestViewHolder(com.tmall.wireless.tangram.example.data.TestViewHolder) JSONArray(org.json.JSONArray) Handler(android.os.Handler) JSONException(org.json.JSONException) AsyncPageLoader(com.tmall.wireless.tangram.support.async.AsyncPageLoader) Range(com.alibaba.android.vlayout.Range) ImageView(android.widget.ImageView) SimpleImgView(com.tmall.wireless.tangram.example.data.SimpleImgView) SingleImageView(com.tmall.wireless.tangram.example.data.SingleImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TestView(com.tmall.wireless.tangram.example.data.TestView) TextView(android.widget.TextView) RatioTextView(com.tmall.wireless.tangram.example.data.RatioTextView) BannerCard(com.tmall.wireless.tangram.structure.card.BannerCard) FourColumnCard(com.tmall.wireless.tangram.structure.card.FourColumnCard) Card(com.tmall.wireless.tangram.dataparser.concrete.Card) SampleDataParser(com.tmall.wireless.tangram.example.dataparser.SampleDataParser) JSONObject(org.json.JSONObject) RecyclerView(android.support.v7.widget.RecyclerView) TargetApi(android.annotation.TargetApi)

Example 5 with GroupBasicAdapter

use of com.tmall.wireless.tangram.core.adapter.GroupBasicAdapter in project Tangram-Android by alibaba.

the class BannerCell method initAdapter.

public void initAdapter() {
    if (mBannerAdapter == null) {
        if (serviceManager != null) {
            GroupBasicAdapter adapter = serviceManager.getService(GroupBasicAdapter.class);
            RecyclerView.RecycledViewPool pool = serviceManager.getService(RecyclerView.RecycledViewPool.class);
            mBannerAdapter = new BannerAdapter(adapter, pool);
        }
    }
    if (mBannerWrapper == null) {
        mBannerWrapper = new UltraViewPagerAdapter(mBannerAdapter);
    }
}
Also used : GroupBasicAdapter(com.tmall.wireless.tangram.core.adapter.GroupBasicAdapter) RecyclerView(android.support.v7.widget.RecyclerView) UltraViewPagerAdapter(com.tmall.ultraviewpager.UltraViewPagerAdapter)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)7 GroupBasicAdapter (com.tmall.wireless.tangram.core.adapter.GroupBasicAdapter)7 TargetApi (android.annotation.TargetApi)3 Handler (android.os.Handler)3 NonNull (android.support.annotation.NonNull)3 TextView (android.widget.TextView)3 Range (com.alibaba.android.vlayout.Range)3 BinderViewHolder (com.tmall.wireless.tangram.core.adapter.BinderViewHolder)3 Card (com.tmall.wireless.tangram.dataparser.concrete.Card)3 RatioTextView (com.tmall.wireless.tangram.example.data.RatioTextView)3 TestViewHolder (com.tmall.wireless.tangram.example.data.TestViewHolder)3 SampleClickSupport (com.tmall.wireless.tangram.example.support.SampleClickSupport)3 AsyncLoader (com.tmall.wireless.tangram.support.async.AsyncLoader)3 AsyncPageLoader (com.tmall.wireless.tangram.support.async.AsyncPageLoader)3 CardLoadSupport (com.tmall.wireless.tangram.support.async.CardLoadSupport)3 IInnerImageSetter (com.tmall.wireless.tangram.util.IInnerImageSetter)3 List (java.util.List)3 JSONArray (org.json.JSONArray)3 JSONException (org.json.JSONException)3 JSONObject (org.json.JSONObject)3