diff --git a/README.md b/README.md index b0f5b74..bbfbe9c 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ compile 'github.hellocsl:GalleryLayoutManager:1.0.3' > Be care :if you have used `RecyclerView` in your project , maybe your should use this library as below and your recyclerview-v7 requires API level 24.2.0 or higher ```java -compile ('github.hellocsl:GalleryLayoutManager:1.0.3'){ +compile ('github.hellocsl:GalleryLayoutManager:1.0.4'){ exclude group: 'com.android.support', module:'recyclerview-v7' } ``` diff --git a/README_CN.md b/README_CN.md index ac5cb30..99e5ac2 100644 --- a/README_CN.md +++ b/README_CN.md @@ -17,7 +17,7 @@ #### Gradle ```java -compile 'github.hellocsl:GalleryLayoutManager:1.0.3' +compile 'github.hellocsl:GalleryLayoutManager:1.0.4' ``` > 注意:如果你的项目已经引用了 `RecyclerView` ,那么应该这样引用,而且你的 `RecyclerView` 的引用版本必须大于 24.2.0 diff --git a/app/build.gradle b/app/build.gradle index 424ffc9..133b4c0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -31,10 +31,10 @@ dependencies { compile deps.butterKnife annotationProcessor deps.butterKnifeProcessor - compile ('github.hellocsl:GalleryLayoutManager:1.0.3'){ - exclude group: 'com.android.support', module:'recyclerview-v7' - } +// compile ('github.hellocsl:GalleryLayoutManager:1.0.3'){ +// exclude group: 'com.android.support', module:'recyclerview-v7' +// } -// compile project(path: ':library') + compile project(path: ':library') } diff --git a/app/src/main/java/github/hellocsl/gallerylayoutmanager/TestActivity.java b/app/src/main/java/github/hellocsl/gallerylayoutmanager/TestActivity.java deleted file mode 100644 index aaff674..0000000 --- a/app/src/main/java/github/hellocsl/gallerylayoutmanager/TestActivity.java +++ /dev/null @@ -1,106 +0,0 @@ -package github.hellocsl.gallerylayoutmanager; - -import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.RecyclerView; -import android.util.Log; -import android.view.View; -import android.view.ViewGroup; -import android.widget.Button; -import android.widget.TextView; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import butterknife.BindView; -import butterknife.ButterKnife; -import butterknife.OnClick; -import github.hellocsl.gallerylayoutmanager.adapter.DemoAdapter; -import github.hellocsl.gallerylayoutmanager.layout.impl.ScaleTransformer; -import github.hellocsl.layoutmanager.gallery.GalleryLayoutManager; - -/** - * Created by chensuilun on 2017/3/24. - */ - -public class TestActivity extends AppCompatActivity { - private static final String TAG = "TestActivity"; - @BindView(R.id.main_recycle1) - RecyclerView mMainRecycle1; - @BindView(R.id.main_tv_recycle_info_1) - TextView mMainTvRecycleInfo1; - @BindView(R.id.main_recycle2) - RecyclerView mMainRecycle2; - @BindView(R.id.main_tv_recycle_info_2) - TextView mMainTvRecycleInfo2; - @BindView(R.id.main_tv_recycle_info_3) - TextView mMainTvRecycleInfo3; - @BindView(R.id.main_btn_random) - Button mMainBtnRandom; - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.fragment_test); - ButterKnife.bind(this); - initView(); - } - - private void initView() { - final List title = new ArrayList(); - int size = 50; - for (int i = 0; i < size; i++) { - title.add("Hello" + i); - } - GalleryLayoutManager layoutManager1 = new GalleryLayoutManager(GalleryLayoutManager.HORIZONTAL); - layoutManager1.attach(mMainRecycle1, 30); - layoutManager1.setItemTransformer(new ScaleTransformer()); - DemoAdapter demoAdapter1 = new DemoAdapter(title) { - @Override - public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { - mMainTvRecycleInfo1.append("Create VH type:+" + viewType + "\n"); - return super.onCreateViewHolder(parent, viewType); - } - }; - demoAdapter1.setOnItemClickListener(new DemoAdapter.OnItemClickListener() { - @Override - public void onItemClick(View view, int position) { - mMainRecycle1.smoothScrollToPosition(position); - } - }); - mMainRecycle1.setAdapter(demoAdapter1); - - final GalleryLayoutManager layoutManager2 = new GalleryLayoutManager(GalleryLayoutManager.VERTICAL); - layoutManager2.attach(mMainRecycle2, 20); - layoutManager2.setCallbackInFling(true); - layoutManager2.setOnItemSelectedListener(new GalleryLayoutManager.OnItemSelectedListener() { - @Override - public void onItemSelected(RecyclerView recyclerView, View item, int position) { - if (BuildConfig.DEBUG) { - Log.d(TAG, "onItemSelected: " + item.isSelected()); - } - mMainTvRecycleInfo2.setText("selected:" + position + "\n"); - } - }); - DemoAdapter demoAdapter2 = new DemoAdapter(title, DemoAdapter.VIEW_TYPE_TEXT); - demoAdapter2.setOnItemClickListener(new DemoAdapter.OnItemClickListener() { - @Override - public void onItemClick(View view, int position) { - mMainRecycle2.smoothScrollToPosition(position); - } - }); - mMainRecycle2.setAdapter(demoAdapter2); - } - - private final Random mRandom = new Random(); - - @OnClick(R.id.main_btn_random) - public void onClick() { - int selectPosition = mRandom.nextInt(50); - mMainRecycle1.smoothScrollToPosition(selectPosition); - mMainRecycle2.smoothScrollToPosition(selectPosition); - } - -} diff --git a/library/build.gradle b/library/build.gradle index 8505121..ca5e5e8 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -34,7 +34,7 @@ publish { userOrg = 'bcsl' groupId = 'github.hellocsl' artifactId = 'GalleryLayoutManager' - publishVersion = '1.0.3' + publishVersion = '1.0.4' desc = 'A custom LayoutManager to build a Gallery or a ViewPager like widget with RecycleView in Android and ' + 'support both HORIZONTAL and VERTICAL scroll.' website = 'https://github.com/BCsl/GalleryLayoutManager' diff --git a/library/src/main/java/github/hellocsl/layoutmanager/gallery/GalleryLayoutManager.java b/library/src/main/java/github/hellocsl/layoutmanager/gallery/GalleryLayoutManager.java index 28a5200..1eb80a1 100644 --- a/library/src/main/java/github/hellocsl/layoutmanager/gallery/GalleryLayoutManager.java +++ b/library/src/main/java/github/hellocsl/layoutmanager/gallery/GalleryLayoutManager.java @@ -115,7 +115,12 @@ public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State if (state.isPreLayout()) { return; } - + if (state.getItemCount() != 0 && !state.didStructureChange()) { + if (BuildConfig.DEBUG) { + Log.d(TAG, "onLayoutChildren: ignore extra layout step"); + } + return; + } if (getChildCount() == 0 || state.didStructureChange()) { reset(); }