From 592a9478c198c191c1402ca11ba19d174a008a5f Mon Sep 17 00:00:00 2001 From: Paulo Date: Tue, 19 Sep 2017 19:17:58 +0100 Subject: [PATCH 1/6] [New] Addtion of a new carousel item with options sample. --- .../simdea/gmlrva/sample/SampleActivity.java | 30 +++- .../CarouselCategoryItemWithOptionLayout.java | 80 ++++++++++ .../layouts/CarouselItemWithOptionLayout.java | 147 ++++++++++++++++++ .../gmlrva_layout_carousel_item_option.xml | 53 +++++++ ...va_layout_carousel_item_option_section.xml | 49 ++++++ gmlrva-sample/src/main/res/values/dimens.xml | 3 + gmlrva-sample/src/main/res/values/strings.xml | 1 + 7 files changed, 362 insertions(+), 1 deletion(-) create mode 100644 gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselCategoryItemWithOptionLayout.java create mode 100644 gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselItemWithOptionLayout.java create mode 100644 gmlrva-sample/src/main/res/layout/gmlrva_layout_carousel_item_option.xml create mode 100644 gmlrva-sample/src/main/res/layout/gmlrva_layout_carousel_item_option_section.xml diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/SampleActivity.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/SampleActivity.java index f79cdd4..5efb7c7 100644 --- a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/SampleActivity.java +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/SampleActivity.java @@ -19,7 +19,9 @@ import pt.simdea.gmlrva.lib.GenericMultipleLayoutAdapter; import pt.simdea.gmlrva.lib.GenericRecyclerViewLayout; import pt.simdea.gmlrva.sample.layouts.CarouselCategoryItemLayout; +import pt.simdea.gmlrva.sample.layouts.CarouselCategoryItemWithOptionLayout; import pt.simdea.gmlrva.sample.layouts.CarouselItemLayout; +import pt.simdea.gmlrva.sample.layouts.CarouselItemWithOptionLayout; import pt.simdea.gmlrva.sample.layouts.SingleImageItemLayout; import pt.simdea.gmlrva.sample.utilities.GenericUtils; @@ -86,11 +88,17 @@ private List buildGenericListExample() { = new CarouselCategoryItemLayout("Carousel Title", buildCarouselItemData(10), this); exampleHolders.add(carouselCategoryItemLayout); + /* Add a Carousel (Category + List with options) Item Example */ + final CarouselCategoryItemWithOptionLayout carouselCategoryItemWithOptionsLayout + = new CarouselCategoryItemWithOptionLayout("Carousel Title With Option", + buildCarouselItemWithOptionsData(10), this); + exampleHolders.add(carouselCategoryItemWithOptionsLayout); + return exampleHolders; } /** - * Auxiliary procedure meant to build the Carousel item lsit sample for the Carousel example present in this + * Auxiliary procedure meant to build the Carousel item list sample for the Carousel example present in this * activity's Sample List. * @param maxItemNumber the maximum number of carousel items. * @return the intended Carousel item list. @@ -109,6 +117,26 @@ private List buildCarouselItemData(final int maxItemNumber) return carouselItemData; } + /** + * Auxiliary procedure meant to build the Carousel item list with options sample for the Carousel example present + * in this activity's Sample List. + * @param maxItemNumber the maximum number of carousel items. + * @return the intended Carousel item list. + */ + private List buildCarouselItemWithOptionsData(final int maxItemNumber) { + final List carouselItemData = new ArrayList<>(); + + String title, description; + final int resource = R.mipmap.gmlrva_ic_launcher_round; + for (int i = 0; i < maxItemNumber; i++) { + title = "Title " + i; + description = "Description " + i; + carouselItemData.add(new CarouselItemWithOptionLayout(title, description, resource)); + } + + return carouselItemData; + } + /** Procedure meant to bind this activity's views. */ private void bindSampleActivityViews() { mGenericTest = (RecyclerView) findViewById(R.id.rvGeneric); diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselCategoryItemWithOptionLayout.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselCategoryItemWithOptionLayout.java new file mode 100644 index 0000000..1b3b304 --- /dev/null +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselCategoryItemWithOptionLayout.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2017. Simdea. + */ + +package pt.simdea.gmlrva.sample.layouts; + +import android.content.Context; +import android.support.annotation.NonNull; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import java.util.List; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import pt.simdea.gmlrva.lib.GenericMultipleLayoutAdapter; +import pt.simdea.gmlrva.lib.GenericRecyclerViewLayout; +import pt.simdea.gmlrva.sample.R; +import pt.simdea.gmlrva.sample.utilities.GenericUtils; + +/** + * Class representing a Carousel Category Layout meant to be used on a {@link GenericMultipleLayoutAdapter}. + * + * Created by Paulo Ribeiro on 7/16/2017. + * Simdea © All Rights Reserved. + * paulo.ribeiro@simdea.pt + */ +@AllArgsConstructor public class CarouselCategoryItemWithOptionLayout + implements GenericRecyclerViewLayout { + + private final String mCategoryTitle; + private final List mCategoryData; + private final Context mContext; + + @Override public CarouselCategoryViewHolder createViewHolder(@NonNull final ViewGroup parent) { + final View view = LayoutInflater.from(parent.getContext()) + .inflate(R.layout.gmlrva_layout_carousel_category_item, parent, false); + return new CarouselCategoryViewHolder(view); + } + + @Override public void setElements(@NonNull final CarouselCategoryViewHolder holder) { + holder.getTitle().setText(mCategoryTitle); + loadItems(holder.getItems()); + } + + /** + * Procedure meant to load the Carousel Item Layout items, bound by this Carousel Category Layout. + * @param items the {@link RecyclerView} which will hold the Carousel Item Layout items. + */ + private void loadItems(@NonNull final RecyclerView items) { + items.setAdapter(new GenericMultipleLayoutAdapter<>(mCategoryData)); + items.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false)); + GenericUtils.setOptimalConfigurationForRecyclerView(items); + } + + /** Class meant to define the {@link RecyclerView.ViewHolder} for a Carousel Category Layout instance. */ + class CarouselCategoryViewHolder extends RecyclerView.ViewHolder { + @Getter private TextView mTitle; + @Getter private RecyclerView mItems; + + /** + * Instantiates a new CarouselCategoryViewHolder. + * @param view this {@link RecyclerView.ViewHolder}'s root view. + */ + CarouselCategoryViewHolder(@NonNull final View view) { + super(view); + bindViews(view); + } + + /** Procedure meant to bind this {@link RecyclerView.ViewHolder}'s views. */ + private void bindViews(@NonNull final View view) { + mTitle = (TextView) view.findViewById(R.id.tvCarouselCategoryItemTitle); + mItems = (RecyclerView) view.findViewById(R.id.rvCarouselCategoryItemData); + } + } +} diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselItemWithOptionLayout.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselItemWithOptionLayout.java new file mode 100644 index 0000000..3d09a34 --- /dev/null +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselItemWithOptionLayout.java @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2017. Simdea. + */ + +package pt.simdea.gmlrva.sample.layouts; + +import android.support.annotation.NonNull; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.RelativeLayout; +import android.widget.TextView; +import android.widget.Toast; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import pt.simdea.gmlrva.lib.GenericMultipleLayoutAdapter; +import pt.simdea.gmlrva.lib.GenericRecyclerViewLayout; +import pt.simdea.gmlrva.sample.R; + +import static pt.simdea.gmlrva.sample.utilities.GMLRVAConstants.UNSUPPORTED_ERROR; + +/** + * Class representing a Carousel Item Layout meant to be used on a {@link GenericMultipleLayoutAdapter}. + * + * Created by Paulo Ribeiro on 9/14/2017. + * Simdea © All Rights Reserved. + * paulo.ribeiro@simdea.pt + */ +@AllArgsConstructor public class CarouselItemWithOptionLayout + implements GenericRecyclerViewLayout { + + private final String mTitle; + private final String mDescription; + private final int mCoverResource; + + @Override public CarouselItemViewHolder createViewHolder(@NonNull final ViewGroup parent) { + final View view = LayoutInflater.from(parent.getContext()) + .inflate(R.layout.gmlrva_layout_carousel_item_option, parent, false); + return new CarouselItemViewHolder(view); + } + + @Override public void setElements(@NonNull final CarouselItemViewHolder holder) { + holder.getTitle().setText(mTitle); + holder.getDescription().setText(mDescription); + holder.getCover().setImageResource(mCoverResource); + } + + /** Class meant to define the {@link RecyclerView.ViewHolder} for a Carousel Item Layout instance. */ + class CarouselItemViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { + @Getter private TextView mTitle; + @Getter private TextView mDescription; + @Getter private ImageView mCover; + @Getter private ImageView mOption; + @Getter private RelativeLayout mOptionSection; + @Getter private View mLeftOption; + @Getter private View mRightOption; + + /** + * Instantiates a new CarouselItemViewHolder. + * @param view this {@link RecyclerView.ViewHolder}'s root view. + */ + CarouselItemViewHolder(@NonNull final View view) { + super(view); + bindViews(view); + bindListeners(); + } + + @Override public void onClick(@NonNull final View v) { + final int viewId = v.getId(); + if (viewId == mTitle.getId()) { + handleTitleClick(); + } else if (viewId == mDescription.getId()) { + handleDescriptionClick(); + } else if (viewId == mCover.getId()) { + handleCoverClick(); + } else if (viewId == mOption.getId()) { + handleOptionClick(); + } else if (viewId == mLeftOption.getId()) { + handleLeftOptionClick(); + } else if (viewId == mRightOption.getId()) { + handleRightOptionClick(); + } else { + throw new UnsupportedOperationException(UNSUPPORTED_ERROR); + } + } + + /** Procedure meant to handle a Left Option view Carousel Item Layout click action. */ + private void handleLeftOptionClick() { + Toast.makeText(itemView.getContext(), "Left Option selected!", Toast.LENGTH_SHORT).show(); + handleOptionClick(); + } + + /** Procedure meant to handle a Right Option view Carousel Item Layout click action. */ + private void handleRightOptionClick() { + Toast.makeText(itemView.getContext(), "Right Option selected!", Toast.LENGTH_SHORT).show(); + handleOptionClick(); + } + + /** Procedure meant to handle an Option view Carousel Item Layout click action. */ + private void handleOptionClick() { + if (mOptionSection.getVisibility() == View.GONE) { + mOptionSection.setVisibility(View.VISIBLE); + } else { + mOptionSection.setVisibility(View.GONE); + } + } + + /** Procedure meant to handle a Cover view Carousel Item Layout click action. */ + private void handleCoverClick() { + Toast.makeText(itemView.getContext(), "Cover Click!", Toast.LENGTH_SHORT).show(); + } + + /** Procedure meant to handle a Description view Carousel Item Layout click action. */ + private void handleDescriptionClick() { + Toast.makeText(itemView.getContext(), "Description Click!", Toast.LENGTH_SHORT).show(); + } + + /** Procedure meant to handle a Title view Carousel Item Layout click action. */ + private void handleTitleClick() { + Toast.makeText(itemView.getContext(), "Title Click!", Toast.LENGTH_SHORT).show(); + } + + /** Procedure meant to bind this {@link RecyclerView.ViewHolder}'s listeners. */ + private void bindListeners() { + final View[] clickableViews = { mTitle, mCover, mDescription, mOption, mLeftOption, mRightOption }; + for (final View view : clickableViews) { + view.setOnClickListener(this); + } + } + + /** Procedure meant to bind this {@link RecyclerView.ViewHolder}'s views. */ + private void bindViews(@NonNull final View view) { + mTitle = (TextView) view.findViewById(R.id.tvCarouselItemTitle); + mDescription = (TextView) view.findViewById(R.id.tvCarouselItemDescription); + mCover = (ImageView) view.findViewById(R.id.ivCarouselItemCover); + mOption = (ImageView) view.findViewById(R.id.ivCarouselItemOption); + mOptionSection = (RelativeLayout) view.findViewById(R.id.rlOptionSection); + mLeftOption = view.findViewById(R.id.vOptionsSectionLeft); + mRightOption = view.findViewById(R.id.vOptionsSectionRight); + } + } + +} diff --git a/gmlrva-sample/src/main/res/layout/gmlrva_layout_carousel_item_option.xml b/gmlrva-sample/src/main/res/layout/gmlrva_layout_carousel_item_option.xml new file mode 100644 index 0000000..eacee6b --- /dev/null +++ b/gmlrva-sample/src/main/res/layout/gmlrva_layout_carousel_item_option.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/gmlrva-sample/src/main/res/layout/gmlrva_layout_carousel_item_option_section.xml b/gmlrva-sample/src/main/res/layout/gmlrva_layout_carousel_item_option_section.xml new file mode 100644 index 0000000..80ba184 --- /dev/null +++ b/gmlrva-sample/src/main/res/layout/gmlrva_layout_carousel_item_option_section.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/gmlrva-sample/src/main/res/values/dimens.xml b/gmlrva-sample/src/main/res/values/dimens.xml index 8264b7a..c2cfc0a 100644 --- a/gmlrva-sample/src/main/res/values/dimens.xml +++ b/gmlrva-sample/src/main/res/values/dimens.xml @@ -1,10 +1,13 @@ + 0dp 5dp 40dp + 80dp 150dp 200dp + 16sp \ No newline at end of file diff --git a/gmlrva-sample/src/main/res/values/strings.xml b/gmlrva-sample/src/main/res/values/strings.xml index 0bd2ba4..55f8afb 100644 --- a/gmlrva-sample/src/main/res/values/strings.xml +++ b/gmlrva-sample/src/main/res/values/strings.xml @@ -1,3 +1,4 @@ gmlrva + Hello\u003F From c47a460443409c11790a7d6a119f6f992762b57a Mon Sep 17 00:00:00 2001 From: Paulo Date: Tue, 26 Sep 2017 22:57:00 +0100 Subject: [PATCH 2/6] [New] Addition of DiffUtil logic. [Known Issue] Pending further testing. --- .../lib/GenericMultipleLayoutAdapter.java | 28 +++++++++ .../pt/simdea/gmlrva/lib/GenericPayload.java | 26 ++++++++ .../gmlrva/lib/GenericRecyclerViewLayout.java | 3 + .../simdea/gmlrva/lib/GmlrvaDiffCallback.java | 52 ++++++++++++++++ gmlrva-sample/build.gradle | 7 ++- .../simdea/gmlrva/sample/SampleActivity.java | 59 ++++++++++++++++--- .../gmlrva/sample/data/FakeDataObject.java | 20 +++++++ .../gmlrva/sample/data/FakeDataProvider.java | 38 ++++++++++++ .../layouts/CarouselCategoryItemLayout.java | 4 ++ .../CarouselCategoryItemWithOptionLayout.java | 4 ++ .../sample/layouts/CarouselItemLayout.java | 4 ++ .../layouts/CarouselItemWithOptionLayout.java | 4 ++ .../sample/layouts/SingleImageItemLayout.java | 9 +++ .../sample/utilities/ClickListener.java | 9 +++ tools/rules-proguard-debug.pro | 19 ++++++ tools/rules-proguard.pro | 19 ++++++ 16 files changed, 296 insertions(+), 9 deletions(-) create mode 100644 gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericPayload.java create mode 100644 gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GmlrvaDiffCallback.java create mode 100644 gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/data/FakeDataObject.java create mode 100644 gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/data/FakeDataProvider.java create mode 100644 gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/utilities/ClickListener.java diff --git a/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericMultipleLayoutAdapter.java b/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericMultipleLayoutAdapter.java index e523389..29bba0f 100644 --- a/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericMultipleLayoutAdapter.java +++ b/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericMultipleLayoutAdapter.java @@ -4,7 +4,9 @@ package pt.simdea.gmlrva.lib; +import android.os.Bundle; import android.support.annotation.NonNull; +import android.support.v7.util.DiffUtil; import android.support.v7.widget.RecyclerView; import android.view.ViewGroup; @@ -12,6 +14,8 @@ import lombok.AllArgsConstructor; +import static pt.simdea.gmlrva.lib.GenericPayload.UPDATE_ITEM; + /** * Generic {@link RecyclerView.Adapter} base class reponsible for binding "all intents and purposes" layout * implementations applied to {@link RecyclerView} instances. @@ -38,6 +42,21 @@ public class GenericMultipleLayoutAdapter mDataSet.get(position).setElements(holder); } + @SuppressWarnings("unchecked") @Override public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, + final int position, + @NonNull final List payloads) { + if (payloads.isEmpty()) { + onBindViewHolder(holder, position); + } else { + final Bundle o = (Bundle) payloads.get(0); + for (final String key : o.keySet()) { + if ("CENAS".equals(key)) { + mDataSet.get(position).setElements(holder); + } + } + } + } + @Override public int getItemCount() { return mDataSet.size(); } @@ -109,6 +128,15 @@ public void update(@NonNull final T item) { add(item); } + /** + * Procedure meant to update this adapter's entire data set. + * @param items the list of Generic Layout Implementation items to be added. + */ + public void updateList(@NonNull final List items) { + DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new GmlrvaDiffCallback<>(this.mDataSet, items)); + diffResult.dispatchUpdatesTo(this); + } + /** * Procedure meant to swap this adapter's entire data set. * @param items the list of Generic Layout Implementation items to be added. diff --git a/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericPayload.java b/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericPayload.java new file mode 100644 index 0000000..71bdfad --- /dev/null +++ b/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericPayload.java @@ -0,0 +1,26 @@ +package pt.simdea.gmlrva.lib; + +import android.support.annotation.IntDef; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +import lombok.AllArgsConstructor; + +/** + * TODO... + * Created by Paulo on 9/26/2017. + */ +@AllArgsConstructor public class GenericPayload { + + /* Constants */ + + /** UPDATE_ITEM representing an item that needs to be update. */ + public static final int UPDATE_ITEM = 0; + + // Declare the @IntDef for these constants + @IntDef({ UPDATE_ITEM }) + @Retention(RetentionPolicy.SOURCE) + public @interface GenericPayloadConstants { /* Do nothing here ... */ } + +} diff --git a/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericRecyclerViewLayout.java b/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericRecyclerViewLayout.java index 0cacd71..2a6f8d6 100644 --- a/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericRecyclerViewLayout.java +++ b/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericRecyclerViewLayout.java @@ -32,4 +32,7 @@ * @param holder the {@link RecyclerView.ViewHolder} instance. */ void setElements(@NonNull final T holder); + + Object getTag(); + } diff --git a/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GmlrvaDiffCallback.java b/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GmlrvaDiffCallback.java new file mode 100644 index 0000000..4f78741 --- /dev/null +++ b/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GmlrvaDiffCallback.java @@ -0,0 +1,52 @@ +package pt.simdea.gmlrva.lib; + +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.v7.util.DiffUtil; + +import java.util.List; + +import lombok.AllArgsConstructor; + +import static pt.simdea.gmlrva.lib.GenericPayload.UPDATE_ITEM; + +/** + * TODO... + * Created by Paulo on 9/26/2017. + */ +@AllArgsConstructor public class GmlrvaDiffCallback extends DiffUtil.Callback { + + private List mOldList; + private final List mNewList; + + @Override public int getOldListSize() { + return mOldList.size(); + } + + @Override public int getNewListSize() { + return mNewList.size(); + } + + @Override public boolean areItemsTheSame(final int oldItemPosition, final int newItemPosition) { + return !mOldList.get(oldItemPosition).getTag().equals(mNewList.get(newItemPosition).getTag()); + } + + @Override public boolean areContentsTheSame(final int oldItemPosition, final int newItemPosition) { + return mOldList.get(oldItemPosition).getTag().equals(mNewList.get(newItemPosition).getTag()); + } + + @Nullable @Override public Object getChangePayload(final int oldItemPosition, final int newItemPosition) { + final T oldItem = mOldList.get(oldItemPosition); + final T newItem = mNewList.get(oldItemPosition); + final Bundle diffBundle = new Bundle(); + if (!newItem.getTag().equals(oldItem.getTag())) { + diffBundle.putString("CENAS", (String) newItem.getTag()); + } + + if (diffBundle.size() == 0) { + return null; + } + return diffBundle; + } + +} diff --git a/gmlrva-sample/build.gradle b/gmlrva-sample/build.gradle index 29466f5..51ca915 100644 --- a/gmlrva-sample/build.gradle +++ b/gmlrva-sample/build.gradle @@ -61,6 +61,11 @@ dependencies { /* Lombok */ provided "org.projectlombok:lombok:$project.lombokVersion" + /* Retrofit & OkHttp */ + compile 'com.squareup.retrofit2:retrofit:2.3.0' + compile 'com.squareup.retrofit2:converter-gson:2.3.0' + /* GMLRVA Library */ - compile project(':gmlrva-lib') + devCompile project(path: ':gmlrva-lib', configuration: 'debug') + prodCompile project(path: ':gmlrva-lib', configuration: 'release') } diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/SampleActivity.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/SampleActivity.java index 5efb7c7..bcd7d8b 100644 --- a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/SampleActivity.java +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/SampleActivity.java @@ -12,17 +12,21 @@ import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; +import android.widget.Toast; import java.util.ArrayList; import java.util.List; import pt.simdea.gmlrva.lib.GenericMultipleLayoutAdapter; import pt.simdea.gmlrva.lib.GenericRecyclerViewLayout; +import pt.simdea.gmlrva.sample.data.FakeDataObject; +import pt.simdea.gmlrva.sample.data.FakeDataProvider; import pt.simdea.gmlrva.sample.layouts.CarouselCategoryItemLayout; import pt.simdea.gmlrva.sample.layouts.CarouselCategoryItemWithOptionLayout; import pt.simdea.gmlrva.sample.layouts.CarouselItemLayout; import pt.simdea.gmlrva.sample.layouts.CarouselItemWithOptionLayout; import pt.simdea.gmlrva.sample.layouts.SingleImageItemLayout; +import pt.simdea.gmlrva.sample.utilities.ClickListener; import pt.simdea.gmlrva.sample.utilities.GenericUtils; @@ -33,9 +37,13 @@ * Simdea © All Rights Reserved. * paulo.ribeiro@simdea.pt */ -public class SampleActivity extends AppCompatActivity { +public class SampleActivity extends AppCompatActivity implements ClickListener { private RecyclerView mGenericTest; + private FakeDataProvider dataProvider = new FakeDataProvider(); + + private List carouselItemData = new ArrayList<>(); + private List carouselItemDataWithOptions = new ArrayList<>(); /** * Starter procedure for SampleActivity. @@ -71,6 +79,34 @@ public class SampleActivity extends AppCompatActivity { } } + @Override public void onClick() { + if (mGenericTest != null) { + rebuildGenericListExample(); + } + } + + private void rebuildGenericListExample() { + final List exampleHolders = new ArrayList<>(); + + /* Add a Single Image Item Example */ + final SingleImageItemLayout singleItemLayout = new SingleImageItemLayout(R.mipmap.gmlrva_ic_launcher, this); + exampleHolders.add(singleItemLayout); + + /* Add a Carousel (Category + List) Item Example */ + final CarouselCategoryItemLayout carouselCategoryItemLayout + = new CarouselCategoryItemLayout("Carousel sadsadsadf", carouselItemData, this); + exampleHolders.add(carouselCategoryItemLayout); + + /* Add a Carousel (Category + List with options) Item Example */ + final CarouselCategoryItemWithOptionLayout carouselCategoryItemWithOptionsLayout + = new CarouselCategoryItemWithOptionLayout("Carousel Title With Option dasdasdasdas", + carouselItemDataWithOptions, this); + exampleHolders.add(carouselCategoryItemWithOptionsLayout); + + final GenericMultipleLayoutAdapter adapter = (GenericMultipleLayoutAdapter) mGenericTest.getAdapter(); + adapter.updateList(exampleHolders); + } + /** * Procedure meant to build the Sample List, showcasing multiple layout types manage by the same * {@link RecyclerView.Adapter} instance. @@ -80,18 +116,20 @@ private List buildGenericListExample() { final List exampleHolders = new ArrayList<>(); /* Add a Single Image Item Example */ - final SingleImageItemLayout singleItemLayout = new SingleImageItemLayout(R.mipmap.gmlrva_ic_launcher); + final SingleImageItemLayout singleItemLayout = new SingleImageItemLayout(R.mipmap.gmlrva_ic_launcher, this); exampleHolders.add(singleItemLayout); /* Add a Carousel (Category + List) Item Example */ + carouselItemData = buildCarouselItemData(10); final CarouselCategoryItemLayout carouselCategoryItemLayout - = new CarouselCategoryItemLayout("Carousel Title", buildCarouselItemData(10), this); + = new CarouselCategoryItemLayout("Carousel Title", carouselItemData, this); exampleHolders.add(carouselCategoryItemLayout); /* Add a Carousel (Category + List with options) Item Example */ + carouselItemDataWithOptions = buildCarouselItemWithOptionsData(10); final CarouselCategoryItemWithOptionLayout carouselCategoryItemWithOptionsLayout = new CarouselCategoryItemWithOptionLayout("Carousel Title With Option", - buildCarouselItemWithOptionsData(10), this); + carouselItemDataWithOptions, this); exampleHolders.add(carouselCategoryItemWithOptionsLayout); return exampleHolders; @@ -108,9 +146,11 @@ private List buildCarouselItemData(final int maxItemNumber) String title, description; final int resource = R.mipmap.gmlrva_ic_launcher_round; + FakeDataObject item; for (int i = 0; i < maxItemNumber; i++) { - title = "Title " + i; - description = "Description " + i; + item = dataProvider.provideFakeData(); + title = item.getTitle(); + description = item.getDescription(); carouselItemData.add(new CarouselItemLayout(title, description, resource)); } @@ -128,9 +168,11 @@ private List buildCarouselItemWithOptionsData(fina String title, description; final int resource = R.mipmap.gmlrva_ic_launcher_round; + FakeDataObject item; for (int i = 0; i < maxItemNumber; i++) { - title = "Title " + i; - description = "Description " + i; + item = dataProvider.provideFakeData(); + title = item.getTitle(); + description = item.getDescription(); carouselItemData.add(new CarouselItemWithOptionLayout(title, description, resource)); } @@ -141,4 +183,5 @@ private List buildCarouselItemWithOptionsData(fina private void bindSampleActivityViews() { mGenericTest = (RecyclerView) findViewById(R.id.rvGeneric); } + } diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/data/FakeDataObject.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/data/FakeDataObject.java new file mode 100644 index 0000000..7ceb6bd --- /dev/null +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/data/FakeDataObject.java @@ -0,0 +1,20 @@ +package pt.simdea.gmlrva.sample.data; + +import android.support.annotation.NonNull; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * TODO... + * Created by Paulo on 9/26/2017. + */ +@AllArgsConstructor @Getter public final class FakeDataObject implements Comparable { + + private String mTitle, mDescription; + + @Override public int compareTo(@NonNull final FakeDataObject o) { + return getTitle().compareToIgnoreCase(o.getTitle()); + } + +} diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/data/FakeDataProvider.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/data/FakeDataProvider.java new file mode 100644 index 0000000..6579938 --- /dev/null +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/data/FakeDataProvider.java @@ -0,0 +1,38 @@ +package pt.simdea.gmlrva.sample.data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import lombok.NoArgsConstructor; + +/** + * TODO... + * Created by Paulo on 9/26/2017. + */ +@NoArgsConstructor public class FakeDataProvider { + + private static final int MAX_LENGTH = 10; + private final RandomStringGenerator generator = new RandomStringGenerator(); + + public FakeDataObject provideFakeData() { + final Random random = new Random(); + return new FakeDataObject(generator.getRandomString(random.nextInt(MAX_LENGTH)), + generator.getRandomString(random.nextInt(MAX_LENGTH))); + } + + private final class RandomStringGenerator { + private static final String ALLOWED_CHARACTERS ="0123456789qwertyuiopasdfghjklzxcvbnm"; + + String getRandomString(final int sizeOfRandomString) { + final Random random = new Random(); + final StringBuilder sb = new StringBuilder(sizeOfRandomString); + for (int i = 0; i < sizeOfRandomString; i++) { + sb.append(ALLOWED_CHARACTERS.charAt(random.nextInt(ALLOWED_CHARACTERS.length()))); + } + return sb.toString(); + } + + } + +} diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselCategoryItemLayout.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselCategoryItemLayout.java index 383e3b9..f5f1bbb 100644 --- a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselCategoryItemLayout.java +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselCategoryItemLayout.java @@ -47,6 +47,10 @@ loadItems(holder.getItems()); } + @Override public Object getTag() { + return mCategoryTitle; + } + /** * Procedure meant to load the Carousel Item Layout items, bound by this Carousel Category Layout. * @param items the {@link RecyclerView} which will hold the Carousel Item Layout items. diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselCategoryItemWithOptionLayout.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselCategoryItemWithOptionLayout.java index 1b3b304..b0bb1b0 100644 --- a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselCategoryItemWithOptionLayout.java +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselCategoryItemWithOptionLayout.java @@ -47,6 +47,10 @@ loadItems(holder.getItems()); } + @Override public Object getTag() { + return mCategoryTitle; + } + /** * Procedure meant to load the Carousel Item Layout items, bound by this Carousel Category Layout. * @param items the {@link RecyclerView} which will hold the Carousel Item Layout items. diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselItemLayout.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselItemLayout.java index 9e501b8..06067cb 100644 --- a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselItemLayout.java +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselItemLayout.java @@ -47,6 +47,10 @@ holder.getCover().setImageResource(mCoverResource); } + @Override public Object getTag() { + return mTitle; + } + /** Class meant to define the {@link RecyclerView.ViewHolder} for a Carousel Item Layout instance. */ class CarouselItemViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { @Getter private TextView mTitle; diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselItemWithOptionLayout.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselItemWithOptionLayout.java index 3d09a34..983d3fc 100644 --- a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselItemWithOptionLayout.java +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselItemWithOptionLayout.java @@ -49,6 +49,10 @@ holder.getCover().setImageResource(mCoverResource); } + @Override public Object getTag() { + return mTitle; + } + /** Class meant to define the {@link RecyclerView.ViewHolder} for a Carousel Item Layout instance. */ class CarouselItemViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { @Getter private TextView mTitle; diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/SingleImageItemLayout.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/SingleImageItemLayout.java index 77f4d52..606aca8 100644 --- a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/SingleImageItemLayout.java +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/SingleImageItemLayout.java @@ -17,6 +17,7 @@ import pt.simdea.gmlrva.lib.GenericMultipleLayoutAdapter; import pt.simdea.gmlrva.lib.GenericRecyclerViewLayout; import pt.simdea.gmlrva.sample.R; +import pt.simdea.gmlrva.sample.utilities.ClickListener; import static pt.simdea.gmlrva.sample.utilities.GMLRVAConstants.UNSUPPORTED_ERROR; @@ -31,6 +32,7 @@ implements GenericRecyclerViewLayout { private final int mCoverResource; + private final ClickListener listener; @Override public SingleImageItemViewHolder createViewHolder(@NonNull final ViewGroup parent) { final View view = LayoutInflater.from(parent.getContext()) @@ -42,6 +44,10 @@ holder.getCover().setImageResource(mCoverResource); } + @Override public Object getTag() { + return mCoverResource; + } + /** Class meant to define the {@link RecyclerView.ViewHolder} for a Single Image Layout instance. */ class SingleImageItemViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { @Getter private ImageView mCover; @@ -68,6 +74,9 @@ class SingleImageItemViewHolder extends RecyclerView.ViewHolder implements View. /** Procedure meant to handle a Single Image Layout click action. */ private void handleCoverClick() { Toast.makeText(itemView.getContext(), "Cover Click!", Toast.LENGTH_SHORT).show(); + if (listener != null) { + listener.onClick(); + } } /** Procedure meant to bind this {@link RecyclerView.ViewHolder}'s listeners. */ diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/utilities/ClickListener.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/utilities/ClickListener.java new file mode 100644 index 0000000..f4dd9c6 --- /dev/null +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/utilities/ClickListener.java @@ -0,0 +1,9 @@ +package pt.simdea.gmlrva.sample.utilities; + +/** + * TODO... + * Created by Paulo on 9/26/2017. + */ +public interface ClickListener { + void onClick(); +} diff --git a/tools/rules-proguard-debug.pro b/tools/rules-proguard-debug.pro index dc66fe7..2fe916e 100644 --- a/tools/rules-proguard-debug.pro +++ b/tools/rules-proguard-debug.pro @@ -58,6 +58,25 @@ java.lang.Object readResolve(); } +##--------------- Begin: proguard configuration for Retrofit2 ---------- +# Platform calls Class.forName on types which do not exist on Android to determine platform. +-dontnote retrofit2.Platform +# Platform used when running on Java 8 VMs. Will not be used at runtime. +-dontwarn retrofit2.Platform$Java8 +# Retain generic type information for use by reflection by converters and adapters. +-keepattributes Signature +# Retain declared checked exceptions for use by a Proxy instance. +-keepattributes Exceptions + +-keepclasseswithmembers class * { + @retrofit2.http.* ; +} +-dontwarn com.squareup.okhttp3.** +-keep class com.squareup.okhttp3.** { *; } +-dontwarn okio.** +##--------------- End: proguard configuration for Retrofit2 ---------- + + # Your library may contain more items that need to be preserved; # typically classes that are dynamically created using Class.forName: -keep public class pt.simdea.gmlrva.lib.** diff --git a/tools/rules-proguard.pro b/tools/rules-proguard.pro index 72f8909..a716607 100644 --- a/tools/rules-proguard.pro +++ b/tools/rules-proguard.pro @@ -65,6 +65,25 @@ java.lang.Object readResolve(); } +##--------------- Begin: proguard configuration for Retrofit2 ---------- +# Platform calls Class.forName on types which do not exist on Android to determine platform. +-dontnote retrofit2.Platform +# Platform used when running on Java 8 VMs. Will not be used at runtime. +-dontwarn retrofit2.Platform$Java8 +# Retain generic type information for use by reflection by converters and adapters. +-keepattributes Signature +# Retain declared checked exceptions for use by a Proxy instance. +-keepattributes Exceptions + +-keepclasseswithmembers class * { + @retrofit2.http.* ; +} +-dontwarn com.squareup.okhttp3.** +-keep class com.squareup.okhttp3.** { *; } +-dontwarn okio.** +##--------------- End: proguard configuration for Retrofit2 ---------- + + # Your library may contain more items that need to be preserved; # typically classes that are dynamically created using Class.forName: -keep public class pt.simdea.gmlrva.lib.** From 3e54fd69415d1f2cd9da1628abf4b53940ac14a6 Mon Sep 17 00:00:00 2001 From: Paulo Date: Thu, 28 Sep 2017 23:10:28 +0100 Subject: [PATCH 3/6] [Support] Correction of the DiffUtil logic (fully tested and working). [Support] Minor code refactoring. --- .../lib/GenericMultipleLayoutAdapter.java | 143 +++++------------- .../pt/simdea/gmlrva/lib/GenericPayload.java | 23 ++- .../gmlrva/lib/GenericRecyclerViewLayout.java | 13 +- .../simdea/gmlrva/lib/GmlrvaDiffCallback.java | 21 ++- gmlrva-sample/src/main/AndroidManifest.xml | 4 +- .../gmlrva/sample/data/ClickListener.java | 21 +++ .../gmlrva/sample/data/FakeDataObject.java | 11 +- .../gmlrva/sample/data/FakeDataProvider.java | 30 +++- .../layouts/CarouselCategoryItemLayout.java | 6 +- .../CarouselCategoryItemWithOptionLayout.java | 6 +- .../sample/layouts/CarouselItemLayout.java | 6 +- .../layouts/CarouselItemWithOptionLayout.java | 6 +- .../sample/layouts/SingleImageItemLayout.java | 8 +- .../sample/{ => ui}/SampleActivity.java | 15 +- .../sample/{ => ui}/SplashActivity.java | 7 +- .../sample/utilities/ClickListener.java | 9 -- .../sample/utilities/GMLRVAConstants.java | 14 +- .../gmlrva/sample/utilities/GenericUtils.java | 4 +- 18 files changed, 176 insertions(+), 171 deletions(-) create mode 100644 gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/data/ClickListener.java rename gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/{ => ui}/SampleActivity.java (94%) rename gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/{ => ui}/SplashActivity.java (90%) delete mode 100644 gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/utilities/ClickListener.java diff --git a/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericMultipleLayoutAdapter.java b/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericMultipleLayoutAdapter.java index 29bba0f..d6bc47d 100644 --- a/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericMultipleLayoutAdapter.java +++ b/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericMultipleLayoutAdapter.java @@ -10,6 +10,7 @@ import android.support.v7.widget.RecyclerView; import android.view.ViewGroup; +import java.util.ArrayList; import java.util.List; import lombok.AllArgsConstructor; @@ -17,7 +18,7 @@ import static pt.simdea.gmlrva.lib.GenericPayload.UPDATE_ITEM; /** - * Generic {@link RecyclerView.Adapter} base class reponsible for binding "all intents and purposes" layout + * Generic {@link RecyclerView.Adapter} base class responsible for binding "all intents and purposes" layout * implementations applied to {@link RecyclerView} instances. * * @param Generic Layout Implementation to be handled by this adapter. @@ -26,34 +27,26 @@ * Simdea © All Rights Reserved. * andre.rosa@simdea.pt */ -@SuppressWarnings("unused") -@AllArgsConstructor -public class GenericMultipleLayoutAdapter +@SuppressWarnings({"unused", "unchecked"}) +@AllArgsConstructor public class GenericMultipleLayoutAdapter extends RecyclerView.Adapter { - private final List mDataSet; + private List mDataSet = new ArrayList<>(); @Override public RecyclerView.ViewHolder onCreateViewHolder(@NonNull final ViewGroup parent, final int viewType) { return mDataSet.get(viewType).createViewHolder(parent); } - @SuppressWarnings("unchecked") @Override public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, - final int position) { + @Override public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, final int position) { mDataSet.get(position).setElements(holder); } - @SuppressWarnings("unchecked") @Override public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, - final int position, - @NonNull final List payloads) { + @Override public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, final int position, + @NonNull final List payloads) { if (payloads.isEmpty()) { onBindViewHolder(holder, position); } else { - final Bundle o = (Bundle) payloads.get(0); - for (final String key : o.keySet()) { - if ("CENAS".equals(key)) { - mDataSet.get(position).setElements(holder); - } - } + applyPayloads(payloads, position); } } @@ -65,113 +58,45 @@ public class GenericMultipleLayoutAdapter return position; } - /** - * Procedure meant to insert a Generic Layout Implementation item on this adapter's data set. - * @param item a Generic Layout Implementation item. - */ - public void add(@NonNull final T item) { - final int index = validateItemPosition(item); - mDataSet.add(item); - notifyItemInserted(index); - } - - /** - * Procedure meant to insert a list of Generic Layout Implementation item on this adapter's data set. - * @param items the list of Generic Layout Implementation items to be inserted. - */ - public void add(@NonNull final List items) { - final int index = validateLastItemPosition(); - mDataSet.addAll(items); - notifyItemRangeChanged(index, items.size()); - } - - /** - * Procedure meant to insert a Generic Layout Implementation item on this adapter's data set, at a target position. - * @param item a Generic Layout Implementation item. - * @param position the target position for this item to be inserted. - * @throws IndexOutOfBoundsException if the position is out of range - * (position < 0 || position > size()) - */ - public void add(@NonNull final T item, final int position) { - mDataSet.add(position, item); - notifyItemChanged(position); - } - - /** - * Procedure meant to remove a Generic Layout Implementation item on this adapter's data set, at a target position. - * @param position the target position for this item to be removed. - */ - public void remove(final int position) { - if (!mDataSet.isEmpty() && validateItemPosition(position)) { - mDataSet.remove(position); - notifyItemRemoved(position); - } - } - - /** - * Procedure meant to remove a list of Generic Layout Implementation item on this adapter's data set. - * @param items the list of Generic Layout Implementation items to be removed. - */ - public void remove(@NonNull final List items) { - if (!mDataSet.isEmpty() && !items.isEmpty()) { - final int index = validateLastItemPosition(); - mDataSet.removeAll(items); - notifyItemRangeRemoved(index, items.size()); - } - } - - /** - * Procedure meant to update a Generic Layout Implementation item present on this adapter's data set. - * @param item a Generic Layout Implementation item. - */ - public void update(@NonNull final T item) { - add(item); - } - /** * Procedure meant to update this adapter's entire data set. - * @param items the list of Generic Layout Implementation items to be added. + * This procedure checks for the changes made to this adapter's data set and applies these changes exclusively, + * meaning there are no wasted operations. + * @param items the list of Generic Layout Implementation items for the data set. */ public void updateList(@NonNull final List items) { - DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new GmlrvaDiffCallback<>(this.mDataSet, items)); + final DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new GmlrvaDiffCallback<>(this.mDataSet, items)); + mDataSet = items; diffResult.dispatchUpdatesTo(this); } /** - * Procedure meant to swap this adapter's entire data set. - * @param items the list of Generic Layout Implementation items to be added. + * Procedure meant to apply a given payload to this adapter's data set. + * @param payloads the payload bundle object with the updates. + * @param position the adapter's position to be updated. */ - public void swap(@NonNull final List items) { - if (!items.isEmpty()) { - mDataSet.clear(); - mDataSet.addAll(items); - notifyDataSetChanged(); + private void applyPayloads(@NonNull final List payloads, final int position) { + final Bundle payload = (Bundle) payloads.get(0); + if (payload != null && payload.keySet() != null) { + for (final String key : payload.keySet()) { + if (UPDATE_ITEM.equals(key)) { + applyPayloadChange(position, payload, key); + } + } } } /** - * Procedure meant to perform an integrity check on a target index. - * @param index the target index. - * @return whether the target index is in range on this adapter's data set. - */ - private boolean validateItemPosition(final int index) { - return index > 0 && index < getItemCount(); - } - - /** - * Procedure meant to check the position of a target item on the data set. - * @param item the target Generic Layout Implementation item. - * @return the position of a target item on the data set if it exists, else returns the next position to be filled. + * Procedure meant to apply a given {@link RecyclerView.ViewHolder} change on this adapter's data set. + * @param position the adapter's position to be updated. + * @param payload the payload bundle object with the updates. + * @param key the payload key for the update value object. */ - private int validateItemPosition(@NonNull final T item) { - return mDataSet.contains(item) ? mDataSet.indexOf(item) : getItemCount(); + private void applyPayloadChange(final int position, @NonNull final Bundle payload, @NonNull final String key) { + final RecyclerView.ViewHolder newHolder = (RecyclerView.ViewHolder) payload.get(key); + if (newHolder != null) { + mDataSet.get(position).setElements(newHolder); + } } - /** - * Procedure meant to check the last known filled position on the data set. - * @return the last known filled position on the data set. - */ - private int validateLastItemPosition() { - return getItemCount() - 1 < 0 ? 0 : getItemCount() - 1; - } } diff --git a/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericPayload.java b/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericPayload.java index 71bdfad..009a962 100644 --- a/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericPayload.java +++ b/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericPayload.java @@ -1,6 +1,10 @@ +/* + * Copyright (c) 2017. Simdea. + */ + package pt.simdea.gmlrva.lib; -import android.support.annotation.IntDef; +import android.support.annotation.StringDef; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -8,18 +12,21 @@ import lombok.AllArgsConstructor; /** - * TODO... - * Created by Paulo on 9/26/2017. + * Magic Constant Annotation Enum containing the possible {@link GenericPayload} change key options. + * + * Created by Paulo Ribeiro on 9/26/2017. + * Simdea © All Rights Reserved. + * paulo.ribeiro@simdea.pt */ -@AllArgsConstructor public class GenericPayload { +@AllArgsConstructor class GenericPayload { /* Constants */ - /** UPDATE_ITEM representing an item that needs to be update. */ - public static final int UPDATE_ITEM = 0; + /** UPDATE_ITEM representing an item that needs to be updated. */ + static final String UPDATE_ITEM = "UPDATE_ITEM"; - // Declare the @IntDef for these constants - @IntDef({ UPDATE_ITEM }) + // Declare the @StringDef for these constants + @StringDef({ UPDATE_ITEM }) @Retention(RetentionPolicy.SOURCE) public @interface GenericPayloadConstants { /* Do nothing here ... */ } diff --git a/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericRecyclerViewLayout.java b/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericRecyclerViewLayout.java index 2a6f8d6..b53ba1d 100644 --- a/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericRecyclerViewLayout.java +++ b/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericRecyclerViewLayout.java @@ -8,6 +8,8 @@ import android.support.v7.widget.RecyclerView; import android.view.ViewGroup; +import java.io.Serializable; + /** * Interface meant to define a contract in which we specify the rules for building a Generic {@link RecyclerView} Layout * (used for binding the data). @@ -18,14 +20,15 @@ * Simdea © All Rights Reserved. * andre.rosa@simdea.pt */ -@SuppressWarnings("WeakerAccess") public interface GenericRecyclerViewLayout { +@SuppressWarnings("WeakerAccess") +public interface GenericRecyclerViewLayout extends Serializable { /** * Procedure meant to handle the ViewHolder instance creation. * @param parent the root ViewGroup {@link ViewGroup} for the ViewHolder instance. * @return the created ViewHolder instance. */ - T createViewHolder(@NonNull final ViewGroup parent); + @NonNull T createViewHolder(@NonNull final ViewGroup parent); /** * Procedure meant to bind the target data from a model to the ViewHolder item {@link RecyclerView.ViewHolder}. @@ -33,6 +36,10 @@ */ void setElements(@NonNull final T holder); - Object getTag(); + /** + * Procedure meant to define a tag for the ViewHolder item {@link RecyclerView.ViewHolder}. + * @return the {@link Object} representing the ViewHolder item {@link RecyclerView.ViewHolder}'s tag. + */ + @NonNull Object getTag(); } diff --git a/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GmlrvaDiffCallback.java b/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GmlrvaDiffCallback.java index 4f78741..c846e07 100644 --- a/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GmlrvaDiffCallback.java +++ b/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GmlrvaDiffCallback.java @@ -1,8 +1,13 @@ +/* + * Copyright (c) 2017. Simdea. + */ + package pt.simdea.gmlrva.lib; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.util.DiffUtil; +import android.support.v7.widget.RecyclerView; import java.util.List; @@ -11,12 +16,17 @@ import static pt.simdea.gmlrva.lib.GenericPayload.UPDATE_ITEM; /** - * TODO... - * Created by Paulo on 9/26/2017. + * Generic {@link DiffUtil.Callback} base class responsible for parsing changes to the + * {@link GenericMultipleLayoutAdapter} implementation applied to {@link RecyclerView} instances. + * + * Created by Paulo Ribeiro on 9/26/2017. + * Simdea © All Rights Reserved. + * paulo.ribeiro@simdea.pt */ -@AllArgsConstructor public class GmlrvaDiffCallback extends DiffUtil.Callback { +@SuppressWarnings("MismatchedQueryAndUpdateOfCollection") +@AllArgsConstructor class GmlrvaDiffCallback extends DiffUtil.Callback { - private List mOldList; + private final List mOldList; private final List mNewList; @Override public int getOldListSize() { @@ -40,9 +50,8 @@ final T newItem = mNewList.get(oldItemPosition); final Bundle diffBundle = new Bundle(); if (!newItem.getTag().equals(oldItem.getTag())) { - diffBundle.putString("CENAS", (String) newItem.getTag()); + diffBundle.putSerializable(UPDATE_ITEM, newItem); } - if (diffBundle.size() == 0) { return null; } diff --git a/gmlrva-sample/src/main/AndroidManifest.xml b/gmlrva-sample/src/main/AndroidManifest.xml index e19c5c7..1ae255f 100644 --- a/gmlrva-sample/src/main/AndroidManifest.xml +++ b/gmlrva-sample/src/main/AndroidManifest.xml @@ -14,7 +14,7 @@ - + diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/data/ClickListener.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/data/ClickListener.java new file mode 100644 index 0000000..c99e2f9 --- /dev/null +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/data/ClickListener.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2017. Simdea. + */ + +package pt.simdea.gmlrva.sample.data; + +import pt.simdea.gmlrva.lib.GenericRecyclerViewLayout; + +/** + * {@link GenericRecyclerViewLayout} view listener meant to deal with click call to actions. + * + * Created by Paulo Ribeiro on 9/26/2017. + * Simdea © All Rights Reserved. + * paulo.ribeiro@simdea.pt + */ +public interface ClickListener { + + /** Procedure meant to handle click call to actions applied to the target {@link GenericRecyclerViewLayout}. */ + void onClick(); + +} diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/data/FakeDataObject.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/data/FakeDataObject.java index 7ceb6bd..66df30a 100644 --- a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/data/FakeDataObject.java +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/data/FakeDataObject.java @@ -1,3 +1,7 @@ +/* + * Copyright (c) 2017. Simdea. + */ + package pt.simdea.gmlrva.sample.data; import android.support.annotation.NonNull; @@ -6,8 +10,11 @@ import lombok.Getter; /** - * TODO... - * Created by Paulo on 9/26/2017. + * Class meant to model a random fake data object. + * + * Created by Paulo Ribeiro on 9/26/2017. + * Simdea © All Rights Reserved. + * paulo.ribeiro@simdea.pt */ @AllArgsConstructor @Getter public final class FakeDataObject implements Comparable { diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/data/FakeDataProvider.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/data/FakeDataProvider.java index 6579938..cffd311 100644 --- a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/data/FakeDataProvider.java +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/data/FakeDataProvider.java @@ -1,30 +1,48 @@ +/* + * Copyright (c) 2017. Simdea. + */ + package pt.simdea.gmlrva.sample.data; -import java.util.ArrayList; -import java.util.List; +import android.support.annotation.NonNull; + import java.util.Random; import lombok.NoArgsConstructor; /** - * TODO... - * Created by Paulo on 9/26/2017. + * Class meant to provide random fake data. + * + * Created by Paulo Ribeiro on 9/26/2017. + * Simdea © All Rights Reserved. + * paulo.ribeiro@simdea.pt */ @NoArgsConstructor public class FakeDataProvider { private static final int MAX_LENGTH = 10; private final RandomStringGenerator generator = new RandomStringGenerator(); - public FakeDataObject provideFakeData() { + /** + * Procedure meant to return a {@link FakeDataObject} instance, containing the randomly generated data. + * @return the {@link FakeDataObject} instance, containing the randomly generated data. + */ + @NonNull public FakeDataObject provideFakeData() { final Random random = new Random(); return new FakeDataObject(generator.getRandomString(random.nextInt(MAX_LENGTH)), generator.getRandomString(random.nextInt(MAX_LENGTH))); } + /** Auxiliary class meant to handle the random generation of data. */ private final class RandomStringGenerator { + private static final String ALLOWED_CHARACTERS ="0123456789qwertyuiopasdfghjklzxcvbnm"; - String getRandomString(final int sizeOfRandomString) { + /** + * Procedure meant to generate and return a {@link String} object containing randomly generated output. + * @param sizeOfRandomString the desired size of the resulting {@link String} object. + * @return the {@link String} object containing randomly generated output. + */ + @NonNull String getRandomString(final int sizeOfRandomString) { final Random random = new Random(); final StringBuilder sb = new StringBuilder(sizeOfRandomString); for (int i = 0; i < sizeOfRandomString; i++) { diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselCategoryItemLayout.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselCategoryItemLayout.java index f5f1bbb..11f646c 100644 --- a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselCategoryItemLayout.java +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselCategoryItemLayout.java @@ -36,7 +36,7 @@ private final List mCategoryData; private final Context mContext; - @Override public CarouselCategoryViewHolder createViewHolder(@NonNull final ViewGroup parent) { + @NonNull @Override public CarouselCategoryViewHolder createViewHolder(@NonNull final ViewGroup parent) { final View view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.gmlrva_layout_carousel_category_item, parent, false); return new CarouselCategoryViewHolder(view); @@ -47,7 +47,7 @@ loadItems(holder.getItems()); } - @Override public Object getTag() { + @NonNull @Override public Object getTag() { return mCategoryTitle; } @@ -80,5 +80,7 @@ private void bindViews(@NonNull final View view) { mTitle = (TextView) view.findViewById(R.id.tvCarouselCategoryItemTitle); mItems = (RecyclerView) view.findViewById(R.id.rvCarouselCategoryItemData); } + } + } diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselCategoryItemWithOptionLayout.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselCategoryItemWithOptionLayout.java index b0bb1b0..7550228 100644 --- a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselCategoryItemWithOptionLayout.java +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselCategoryItemWithOptionLayout.java @@ -36,7 +36,7 @@ private final List mCategoryData; private final Context mContext; - @Override public CarouselCategoryViewHolder createViewHolder(@NonNull final ViewGroup parent) { + @NonNull @Override public CarouselCategoryViewHolder createViewHolder(@NonNull final ViewGroup parent) { final View view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.gmlrva_layout_carousel_category_item, parent, false); return new CarouselCategoryViewHolder(view); @@ -47,7 +47,7 @@ loadItems(holder.getItems()); } - @Override public Object getTag() { + @NonNull @Override public Object getTag() { return mCategoryTitle; } @@ -80,5 +80,7 @@ private void bindViews(@NonNull final View view) { mTitle = (TextView) view.findViewById(R.id.tvCarouselCategoryItemTitle); mItems = (RecyclerView) view.findViewById(R.id.rvCarouselCategoryItemData); } + } + } diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselItemLayout.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselItemLayout.java index 06067cb..8ffc026 100644 --- a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselItemLayout.java +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselItemLayout.java @@ -35,7 +35,7 @@ private final String mDescription; private final int mCoverResource; - @Override public CarouselItemViewHolder createViewHolder(@NonNull final ViewGroup parent) { + @NonNull @Override public CarouselItemViewHolder createViewHolder(@NonNull final ViewGroup parent) { final View view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.gmlrva_layout_carousel_item, parent, false); return new CarouselItemViewHolder(view); @@ -47,7 +47,7 @@ holder.getCover().setImageResource(mCoverResource); } - @Override public Object getTag() { + @NonNull @Override public Object getTag() { return mTitle; } @@ -109,5 +109,7 @@ private void bindViews(@NonNull final View view) { mDescription = (TextView) view.findViewById(R.id.tvCarouselItemDescription); mCover = (ImageView) view.findViewById(R.id.ivCarouselItemCover); } + } + } diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselItemWithOptionLayout.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselItemWithOptionLayout.java index 983d3fc..b0fe31a 100644 --- a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselItemWithOptionLayout.java +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselItemWithOptionLayout.java @@ -10,7 +10,6 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; @@ -37,7 +36,7 @@ private final String mDescription; private final int mCoverResource; - @Override public CarouselItemViewHolder createViewHolder(@NonNull final ViewGroup parent) { + @NonNull @Override public CarouselItemViewHolder createViewHolder(@NonNull final ViewGroup parent) { final View view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.gmlrva_layout_carousel_item_option, parent, false); return new CarouselItemViewHolder(view); @@ -49,7 +48,7 @@ holder.getCover().setImageResource(mCoverResource); } - @Override public Object getTag() { + @NonNull @Override public Object getTag() { return mTitle; } @@ -146,6 +145,7 @@ private void bindViews(@NonNull final View view) { mLeftOption = view.findViewById(R.id.vOptionsSectionLeft); mRightOption = view.findViewById(R.id.vOptionsSectionRight); } + } } diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/SingleImageItemLayout.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/SingleImageItemLayout.java index 606aca8..ebd3ee9 100644 --- a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/SingleImageItemLayout.java +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/SingleImageItemLayout.java @@ -17,7 +17,7 @@ import pt.simdea.gmlrva.lib.GenericMultipleLayoutAdapter; import pt.simdea.gmlrva.lib.GenericRecyclerViewLayout; import pt.simdea.gmlrva.sample.R; -import pt.simdea.gmlrva.sample.utilities.ClickListener; +import pt.simdea.gmlrva.sample.data.ClickListener; import static pt.simdea.gmlrva.sample.utilities.GMLRVAConstants.UNSUPPORTED_ERROR; @@ -34,7 +34,7 @@ private final int mCoverResource; private final ClickListener listener; - @Override public SingleImageItemViewHolder createViewHolder(@NonNull final ViewGroup parent) { + @NonNull @Override public SingleImageItemViewHolder createViewHolder(@NonNull final ViewGroup parent) { final View view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.gmlrva_layout_generic_single_image_item, parent, false); return new SingleImageItemViewHolder(view); @@ -44,7 +44,7 @@ holder.getCover().setImageResource(mCoverResource); } - @Override public Object getTag() { + @NonNull @Override public Object getTag() { return mCoverResource; } @@ -88,5 +88,7 @@ private void bindListeners() { private void bindViews(@NonNull final View view) { mCover = (ImageView) view.findViewById(R.id.ivSingleImageItemLayoutCover); } + } + } diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/SampleActivity.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/ui/SampleActivity.java similarity index 94% rename from gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/SampleActivity.java rename to gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/ui/SampleActivity.java index bcd7d8b..583ef00 100644 --- a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/SampleActivity.java +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/ui/SampleActivity.java @@ -2,7 +2,7 @@ * Copyright (c) 2017. Simdea. */ -package pt.simdea.gmlrva.sample; +package pt.simdea.gmlrva.sample.ui; import android.content.Context; import android.content.Intent; @@ -12,13 +12,14 @@ import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; -import android.widget.Toast; import java.util.ArrayList; import java.util.List; import pt.simdea.gmlrva.lib.GenericMultipleLayoutAdapter; import pt.simdea.gmlrva.lib.GenericRecyclerViewLayout; +import pt.simdea.gmlrva.sample.R; +import pt.simdea.gmlrva.sample.data.ClickListener; import pt.simdea.gmlrva.sample.data.FakeDataObject; import pt.simdea.gmlrva.sample.data.FakeDataProvider; import pt.simdea.gmlrva.sample.layouts.CarouselCategoryItemLayout; @@ -26,10 +27,8 @@ import pt.simdea.gmlrva.sample.layouts.CarouselItemLayout; import pt.simdea.gmlrva.sample.layouts.CarouselItemWithOptionLayout; import pt.simdea.gmlrva.sample.layouts.SingleImageItemLayout; -import pt.simdea.gmlrva.sample.utilities.ClickListener; import pt.simdea.gmlrva.sample.utilities.GenericUtils; - /** * Class responsible for the Sample Screen for the (GMLRVA) library. * @@ -37,11 +36,11 @@ * Simdea © All Rights Reserved. * paulo.ribeiro@simdea.pt */ +@SuppressWarnings("unchecked") public class SampleActivity extends AppCompatActivity implements ClickListener { private RecyclerView mGenericTest; private FakeDataProvider dataProvider = new FakeDataProvider(); - private List carouselItemData = new ArrayList<>(); private List carouselItemDataWithOptions = new ArrayList<>(); @@ -93,13 +92,15 @@ private void rebuildGenericListExample() { exampleHolders.add(singleItemLayout); /* Add a Carousel (Category + List) Item Example */ + carouselItemData = buildCarouselItemData(20); final CarouselCategoryItemLayout carouselCategoryItemLayout - = new CarouselCategoryItemLayout("Carousel sadsadsadf", carouselItemData, this); + = new CarouselCategoryItemLayout("Carousel Title", carouselItemData, this); exampleHolders.add(carouselCategoryItemLayout); /* Add a Carousel (Category + List with options) Item Example */ + carouselItemDataWithOptions = buildCarouselItemWithOptionsData(20); final CarouselCategoryItemWithOptionLayout carouselCategoryItemWithOptionsLayout - = new CarouselCategoryItemWithOptionLayout("Carousel Title With Option dasdasdasdas", + = new CarouselCategoryItemWithOptionLayout("Carousel Title With Option", carouselItemDataWithOptions, this); exampleHolders.add(carouselCategoryItemWithOptionsLayout); diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/SplashActivity.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/ui/SplashActivity.java similarity index 90% rename from gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/SplashActivity.java rename to gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/ui/SplashActivity.java index 6b52f3c..ead5dcd 100644 --- a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/SplashActivity.java +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/ui/SplashActivity.java @@ -1,4 +1,8 @@ -package pt.simdea.gmlrva.sample; +/* + * Copyright (c) 2017. Simdea. + */ + +package pt.simdea.gmlrva.sample.ui; import android.os.Bundle; import android.support.annotation.Nullable; @@ -22,4 +26,5 @@ public class SplashActivity extends AppCompatActivity { SampleActivity.start(this); // Start home activity finish(); // close splash activity } + } diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/utilities/ClickListener.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/utilities/ClickListener.java deleted file mode 100644 index f4dd9c6..0000000 --- a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/utilities/ClickListener.java +++ /dev/null @@ -1,9 +0,0 @@ -package pt.simdea.gmlrva.sample.utilities; - -/** - * TODO... - * Created by Paulo on 9/26/2017. - */ -public interface ClickListener { - void onClick(); -} diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/utilities/GMLRVAConstants.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/utilities/GMLRVAConstants.java index 7b6ba13..9d72717 100644 --- a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/utilities/GMLRVAConstants.java +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/utilities/GMLRVAConstants.java @@ -1,3 +1,7 @@ +/* + * Copyright (c) 2017. Simdea. + */ + package pt.simdea.gmlrva.sample.utilities; /** @@ -8,7 +12,9 @@ * paulo.ribeiro@simdea.pt */ -@SuppressWarnings("WeakerAccess") public final class GMLRVAConstants { +@SuppressWarnings("WeakerAccess") +public final class GMLRVAConstants { + /** Logs */ public static final String LOG_TAG = "GMLRVA"; public static final String ERROR = "Error"; @@ -18,11 +24,11 @@ public static final String UNSUPPORTED_ERROR = "Unsupported operation."; /** - * Instantiates a new SimpleCarouselConstants. + * Instantiates a new GMLRVAConstants. * Private to prevent instantiation. */ private GMLRVAConstants() { - // Throw an exception if this *is* ever called - throw new AssertionError(ASSERTION_ERROR); + throw new AssertionError(ASSERTION_ERROR); // Throw an exception if this *is* ever called } + } diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/utilities/GenericUtils.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/utilities/GenericUtils.java index 9e074f8..ab4a133 100644 --- a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/utilities/GenericUtils.java +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/utilities/GenericUtils.java @@ -23,8 +23,7 @@ public final class GenericUtils { * Private to prevent instantiation. */ private GenericUtils() { - // Throw an exception if this *is* ever called - throw new AssertionError("Instantiating utility class."); + throw new AssertionError("Instantiating utility class."); // Throw an exception if this *is* ever called } /** @@ -38,4 +37,5 @@ public static void setOptimalConfigurationForRecyclerView(@NonNull final Recycle recyclerView.setHasFixedSize(true); recyclerView.setNestedScrollingEnabled(true); } + } From 6bf62ca91814ab65502c6bf6187d18864f148d1b Mon Sep 17 00:00:00 2001 From: Paulo Date: Tue, 3 Oct 2017 22:03:03 +0100 Subject: [PATCH 4/6] [Fix] Correction of issues reported by check gradle tasks. --- build.gradle | 2 +- gmlrva-lib/build.gradle | 2 +- gmlrva-lib/src/main/AndroidManifest.xml | 6 ++-- .../pt/simdea/gmlrva/lib/GenericPayload.java | 4 +-- .../simdea/gmlrva/lib/GmlrvaDiffCallback.java | 2 ++ gmlrva-sample/src/main/AndroidManifest.xml | 14 +++++--- .../gmlrva/sample/data/FakeDataObject.java | 4 ++- .../gmlrva/sample/data/FakeDataProvider.java | 13 ++++---- .../layouts/CarouselCategoryItemLayout.java | 5 ++- .../CarouselCategoryItemWithOptionLayout.java | 5 ++- .../sample/layouts/CarouselItemLayout.java | 7 ++-- .../layouts/CarouselItemWithOptionLayout.java | 7 ++-- .../sample/layouts/SingleImageItemLayout.java | 16 +++++---- .../gmlrva/sample/ui/SampleActivity.java | 33 ++++++++++--------- .../sample/utilities/GMLRVAConstants.java | 1 + .../res/layout/gmlrva_activity_sample.xml | 8 ++--- gmlrva-sample/src/main/res/values/dimens.xml | 1 - gmlrva-sample/src/main/res/values/strings.xml | 1 - 18 files changed, 78 insertions(+), 53 deletions(-) diff --git a/build.gradle b/build.gradle index a2026ac..dd47d23 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:2.3.3' - classpath 'pt.simdea.verifier:verifier:3.5.7SNAP3' + classpath 'pt.simdea.verifier:verifier:3.5.8' classpath 'com.novoda:bintray-release:0.5.0' // NOTE: Do not place your application dependencies here; they belong diff --git a/gmlrva-lib/build.gradle b/gmlrva-lib/build.gradle index cf34556..3fa8fd9 100644 --- a/gmlrva-lib/build.gradle +++ b/gmlrva-lib/build.gradle @@ -22,7 +22,7 @@ android { debuggable true zipAlignEnabled true minifyEnabled true - shrinkResources false + shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), "$project.rootDir/tools/rules-proguard-debug.pro" } diff --git a/gmlrva-lib/src/main/AndroidManifest.xml b/gmlrva-lib/src/main/AndroidManifest.xml index 169731b..07e4da3 100644 --- a/gmlrva-lib/src/main/AndroidManifest.xml +++ b/gmlrva-lib/src/main/AndroidManifest.xml @@ -1,10 +1,12 @@ + android:label="@string/gmlrva_app_name" + android:supportsRtl="true" + tools:replace="android:label"/> diff --git a/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericPayload.java b/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericPayload.java index 009a962..3ef260d 100644 --- a/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericPayload.java +++ b/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericPayload.java @@ -18,12 +18,12 @@ * Simdea © All Rights Reserved. * paulo.ribeiro@simdea.pt */ -@AllArgsConstructor class GenericPayload { +@SuppressWarnings("WeakerAccess") @AllArgsConstructor public class GenericPayload { /* Constants */ /** UPDATE_ITEM representing an item that needs to be updated. */ - static final String UPDATE_ITEM = "UPDATE_ITEM"; + public static final String UPDATE_ITEM = "UPDATE_ITEM"; // Declare the @StringDef for these constants @StringDef({ UPDATE_ITEM }) diff --git a/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GmlrvaDiffCallback.java b/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GmlrvaDiffCallback.java index c846e07..64c3e39 100644 --- a/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GmlrvaDiffCallback.java +++ b/gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GmlrvaDiffCallback.java @@ -19,6 +19,8 @@ * Generic {@link DiffUtil.Callback} base class responsible for parsing changes to the * {@link GenericMultipleLayoutAdapter} implementation applied to {@link RecyclerView} instances. * + * @param an instance of {@link GenericRecyclerViewLayout}. + * * Created by Paulo Ribeiro on 9/26/2017. * Simdea © All Rights Reserved. * paulo.ribeiro@simdea.pt diff --git a/gmlrva-sample/src/main/AndroidManifest.xml b/gmlrva-sample/src/main/AndroidManifest.xml index 1ae255f..1804053 100644 --- a/gmlrva-sample/src/main/AndroidManifest.xml +++ b/gmlrva-sample/src/main/AndroidManifest.xml @@ -4,21 +4,25 @@ package="pt.simdea.gmlrva.sample"> + tools:node="replace" + tools:replace="android:label"> - + + { +@AllArgsConstructor @Getter @EqualsAndHashCode(exclude = "mDescription") public final class FakeDataObject implements + Comparable { private String mTitle, mDescription; diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/data/FakeDataProvider.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/data/FakeDataProvider.java index cffd311..a0174a8 100644 --- a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/data/FakeDataProvider.java +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/data/FakeDataProvider.java @@ -17,10 +17,9 @@ * Simdea © All Rights Reserved. * paulo.ribeiro@simdea.pt */ -@NoArgsConstructor public class FakeDataProvider { +@NoArgsConstructor public final class FakeDataProvider { private static final int MAX_LENGTH = 10; - private final RandomStringGenerator generator = new RandomStringGenerator(); /** * Procedure meant to return a {@link FakeDataObject} instance, containing the randomly generated data. @@ -28,21 +27,21 @@ */ @NonNull public FakeDataObject provideFakeData() { final Random random = new Random(); - return new FakeDataObject(generator.getRandomString(random.nextInt(MAX_LENGTH)), - generator.getRandomString(random.nextInt(MAX_LENGTH))); + return new FakeDataObject(RandomStringGenerator.getRandomString(random.nextInt(MAX_LENGTH)), + RandomStringGenerator.getRandomString(random.nextInt(MAX_LENGTH))); } /** Auxiliary class meant to handle the random generation of data. */ - private final class RandomStringGenerator { + private static final class RandomStringGenerator { - private static final String ALLOWED_CHARACTERS ="0123456789qwertyuiopasdfghjklzxcvbnm"; + private static final String ALLOWED_CHARACTERS = "0123456789qwertyuiopasdfghjklzxcvbnm"; /** * Procedure meant to generate and return a {@link String} object containing randomly generated output. * @param sizeOfRandomString the desired size of the resulting {@link String} object. * @return the {@link String} object containing randomly generated output. */ - @NonNull String getRandomString(final int sizeOfRandomString) { + @NonNull private static String getRandomString(final int sizeOfRandomString) { final Random random = new Random(); final StringBuilder sb = new StringBuilder(sizeOfRandomString); for (int i = 0; i < sizeOfRandomString; i++) { diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselCategoryItemLayout.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselCategoryItemLayout.java index 11f646c..52108e8 100644 --- a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselCategoryItemLayout.java +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselCategoryItemLayout.java @@ -75,7 +75,10 @@ class CarouselCategoryViewHolder extends RecyclerView.ViewHolder { bindViews(view); } - /** Procedure meant to bind this {@link RecyclerView.ViewHolder}'s views. */ + /** + * Procedure meant to bind this {@link RecyclerView.ViewHolder}'s views. + * @param view this {@link CarouselCategoryViewHolder}'s root view. + */ private void bindViews(@NonNull final View view) { mTitle = (TextView) view.findViewById(R.id.tvCarouselCategoryItemTitle); mItems = (RecyclerView) view.findViewById(R.id.rvCarouselCategoryItemData); diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselCategoryItemWithOptionLayout.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselCategoryItemWithOptionLayout.java index 7550228..2c0636d 100644 --- a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselCategoryItemWithOptionLayout.java +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselCategoryItemWithOptionLayout.java @@ -75,7 +75,10 @@ class CarouselCategoryViewHolder extends RecyclerView.ViewHolder { bindViews(view); } - /** Procedure meant to bind this {@link RecyclerView.ViewHolder}'s views. */ + /** + * Procedure meant to bind this {@link RecyclerView.ViewHolder}'s views. + * @param view this {@link CarouselCategoryViewHolder}'s root view. + */ private void bindViews(@NonNull final View view) { mTitle = (TextView) view.findViewById(R.id.tvCarouselCategoryItemTitle); mItems = (RecyclerView) view.findViewById(R.id.rvCarouselCategoryItemData); diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselItemLayout.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselItemLayout.java index 8ffc026..0fe9367 100644 --- a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselItemLayout.java +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselItemLayout.java @@ -97,13 +97,16 @@ private void handleTitleClick() { /** Procedure meant to bind this {@link RecyclerView.ViewHolder}'s listeners. */ private void bindListeners() { - final View[] clickableViews = { mTitle, mCover, mDescription }; + final View[] clickableViews = {mTitle, mCover, mDescription}; for (final View view : clickableViews) { view.setOnClickListener(this); } } - /** Procedure meant to bind this {@link RecyclerView.ViewHolder}'s views. */ + /** + * Procedure meant to bind this {@link RecyclerView.ViewHolder}'s views. + * @param view this {@link CarouselItemViewHolder}'s root view. + */ private void bindViews(@NonNull final View view) { mTitle = (TextView) view.findViewById(R.id.tvCarouselItemTitle); mDescription = (TextView) view.findViewById(R.id.tvCarouselItemDescription); diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselItemWithOptionLayout.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselItemWithOptionLayout.java index b0fe31a..51b9bc1 100644 --- a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselItemWithOptionLayout.java +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/CarouselItemWithOptionLayout.java @@ -129,13 +129,16 @@ private void handleTitleClick() { /** Procedure meant to bind this {@link RecyclerView.ViewHolder}'s listeners. */ private void bindListeners() { - final View[] clickableViews = { mTitle, mCover, mDescription, mOption, mLeftOption, mRightOption }; + final View[] clickableViews = {mTitle, mCover, mDescription, mOption, mLeftOption, mRightOption}; for (final View view : clickableViews) { view.setOnClickListener(this); } } - /** Procedure meant to bind this {@link RecyclerView.ViewHolder}'s views. */ + /** + * Procedure meant to bind this {@link RecyclerView.ViewHolder}'s views. + * @param view this {@link CarouselItemViewHolder}'s root view. + */ private void bindViews(@NonNull final View view) { mTitle = (TextView) view.findViewById(R.id.tvCarouselItemTitle); mDescription = (TextView) view.findViewById(R.id.tvCarouselItemDescription); diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/SingleImageItemLayout.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/SingleImageItemLayout.java index ebd3ee9..fbee3f8 100644 --- a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/SingleImageItemLayout.java +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/layouts/SingleImageItemLayout.java @@ -31,8 +31,8 @@ @AllArgsConstructor public class SingleImageItemLayout implements GenericRecyclerViewLayout { - private final int mCoverResource; - private final ClickListener listener; + protected final int mCoverResource; + protected final ClickListener mListener; @NonNull @Override public SingleImageItemViewHolder createViewHolder(@NonNull final ViewGroup parent) { final View view = LayoutInflater.from(parent.getContext()) @@ -49,7 +49,8 @@ } /** Class meant to define the {@link RecyclerView.ViewHolder} for a Single Image Layout instance. */ - class SingleImageItemViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { + final class SingleImageItemViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { + @Getter private ImageView mCover; /** @@ -74,8 +75,8 @@ class SingleImageItemViewHolder extends RecyclerView.ViewHolder implements View. /** Procedure meant to handle a Single Image Layout click action. */ private void handleCoverClick() { Toast.makeText(itemView.getContext(), "Cover Click!", Toast.LENGTH_SHORT).show(); - if (listener != null) { - listener.onClick(); + if (mListener != null) { + mListener.onClick(); } } @@ -84,7 +85,10 @@ private void bindListeners() { mCover.setOnClickListener(this); } - /** Procedure meant to bind this {@link RecyclerView.ViewHolder}'s views. */ + /** + * Procedure meant to bind this {@link RecyclerView.ViewHolder}'s views. + * @param view this {@link SingleImageItemViewHolder}'s root view. + */ private void bindViews(@NonNull final View view) { mCover = (ImageView) view.findViewById(R.id.ivSingleImageItemLayoutCover); } diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/ui/SampleActivity.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/ui/SampleActivity.java index 583ef00..ea194dd 100644 --- a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/ui/SampleActivity.java +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/ui/SampleActivity.java @@ -40,9 +40,9 @@ public class SampleActivity extends AppCompatActivity implements ClickListener { private RecyclerView mGenericTest; - private FakeDataProvider dataProvider = new FakeDataProvider(); - private List carouselItemData = new ArrayList<>(); - private List carouselItemDataWithOptions = new ArrayList<>(); + private final FakeDataProvider mDataProvider = new FakeDataProvider(); + private List mCarouselItemData = new ArrayList<>(); + private List mCarouselItemDataWithOptions = new ArrayList<>(); /** * Starter procedure for SampleActivity. @@ -84,6 +84,7 @@ public class SampleActivity extends AppCompatActivity implements ClickListener { } } + /** Procedure meant to rebuild the existing data list. */ private void rebuildGenericListExample() { final List exampleHolders = new ArrayList<>(); @@ -92,16 +93,16 @@ private void rebuildGenericListExample() { exampleHolders.add(singleItemLayout); /* Add a Carousel (Category + List) Item Example */ - carouselItemData = buildCarouselItemData(20); + mCarouselItemData = buildCarouselItemData(20); final CarouselCategoryItemLayout carouselCategoryItemLayout - = new CarouselCategoryItemLayout("Carousel Title", carouselItemData, this); + = new CarouselCategoryItemLayout("Carousel Title", mCarouselItemData, this); exampleHolders.add(carouselCategoryItemLayout); /* Add a Carousel (Category + List with options) Item Example */ - carouselItemDataWithOptions = buildCarouselItemWithOptionsData(20); + mCarouselItemDataWithOptions = buildCarouselItemWithOptionsData(20); final CarouselCategoryItemWithOptionLayout carouselCategoryItemWithOptionsLayout = new CarouselCategoryItemWithOptionLayout("Carousel Title With Option", - carouselItemDataWithOptions, this); + mCarouselItemDataWithOptions, this); exampleHolders.add(carouselCategoryItemWithOptionsLayout); final GenericMultipleLayoutAdapter adapter = (GenericMultipleLayoutAdapter) mGenericTest.getAdapter(); @@ -121,16 +122,16 @@ private List buildGenericListExample() { exampleHolders.add(singleItemLayout); /* Add a Carousel (Category + List) Item Example */ - carouselItemData = buildCarouselItemData(10); + mCarouselItemData = buildCarouselItemData(10); final CarouselCategoryItemLayout carouselCategoryItemLayout - = new CarouselCategoryItemLayout("Carousel Title", carouselItemData, this); + = new CarouselCategoryItemLayout("Carousel Title", mCarouselItemData, this); exampleHolders.add(carouselCategoryItemLayout); /* Add a Carousel (Category + List with options) Item Example */ - carouselItemDataWithOptions = buildCarouselItemWithOptionsData(10); + mCarouselItemDataWithOptions = buildCarouselItemWithOptionsData(10); final CarouselCategoryItemWithOptionLayout carouselCategoryItemWithOptionsLayout = new CarouselCategoryItemWithOptionLayout("Carousel Title With Option", - carouselItemDataWithOptions, this); + mCarouselItemDataWithOptions, this); exampleHolders.add(carouselCategoryItemWithOptionsLayout); return exampleHolders; @@ -145,11 +146,12 @@ private List buildGenericListExample() { private List buildCarouselItemData(final int maxItemNumber) { final List carouselItemData = new ArrayList<>(); - String title, description; + String title; + String description; final int resource = R.mipmap.gmlrva_ic_launcher_round; FakeDataObject item; for (int i = 0; i < maxItemNumber; i++) { - item = dataProvider.provideFakeData(); + item = mDataProvider.provideFakeData(); title = item.getTitle(); description = item.getDescription(); carouselItemData.add(new CarouselItemLayout(title, description, resource)); @@ -167,11 +169,12 @@ private List buildCarouselItemData(final int maxItemNumber) private List buildCarouselItemWithOptionsData(final int maxItemNumber) { final List carouselItemData = new ArrayList<>(); - String title, description; + String title; + String description; final int resource = R.mipmap.gmlrva_ic_launcher_round; FakeDataObject item; for (int i = 0; i < maxItemNumber; i++) { - item = dataProvider.provideFakeData(); + item = mDataProvider.provideFakeData(); title = item.getTitle(); description = item.getDescription(); carouselItemData.add(new CarouselItemWithOptionLayout(title, description, resource)); diff --git a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/utilities/GMLRVAConstants.java b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/utilities/GMLRVAConstants.java index 9d72717..4e7971b 100644 --- a/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/utilities/GMLRVAConstants.java +++ b/gmlrva-sample/src/main/java/pt/simdea/gmlrva/sample/utilities/GMLRVAConstants.java @@ -18,6 +18,7 @@ public final class GMLRVAConstants { /** Logs */ public static final String LOG_TAG = "GMLRVA"; public static final String ERROR = "Error"; + public static final String EMPTY_STRING = ""; /** Exception Messages */ public static final String ASSERTION_ERROR = "Instantiating utility class."; diff --git a/gmlrva-sample/src/main/res/layout/gmlrva_activity_sample.xml b/gmlrva-sample/src/main/res/layout/gmlrva_activity_sample.xml index 3f92ab4..1e77868 100644 --- a/gmlrva-sample/src/main/res/layout/gmlrva_activity_sample.xml +++ b/gmlrva-sample/src/main/res/layout/gmlrva_activity_sample.xml @@ -1,12 +1,10 @@ - + - + diff --git a/gmlrva-sample/src/main/res/values/dimens.xml b/gmlrva-sample/src/main/res/values/dimens.xml index c2cfc0a..4d8afe3 100644 --- a/gmlrva-sample/src/main/res/values/dimens.xml +++ b/gmlrva-sample/src/main/res/values/dimens.xml @@ -1,7 +1,6 @@ - 0dp 5dp 40dp 80dp diff --git a/gmlrva-sample/src/main/res/values/strings.xml b/gmlrva-sample/src/main/res/values/strings.xml index 55f8afb..f0d79eb 100644 --- a/gmlrva-sample/src/main/res/values/strings.xml +++ b/gmlrva-sample/src/main/res/values/strings.xml @@ -1,4 +1,3 @@ - gmlrva Hello\u003F From 37eed2536a7761be5e70080f030320073c48ffef Mon Sep 17 00:00:00 2001 From: Paulo Date: Tue, 3 Oct 2017 22:27:49 +0100 Subject: [PATCH 5/6] [Fix] Correction of issues reported by Travis. --- gmlrva-lib/build.gradle | 3 ++- gmlrva-sample/build.gradle | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gmlrva-lib/build.gradle b/gmlrva-lib/build.gradle index 3fa8fd9..cb4eb4a 100644 --- a/gmlrva-lib/build.gradle +++ b/gmlrva-lib/build.gradle @@ -22,7 +22,7 @@ android { debuggable true zipAlignEnabled true minifyEnabled true - shrinkResources true + shrinkResources false proguardFiles getDefaultProguardFile('proguard-android.txt'), "$project.rootDir/tools/rules-proguard-debug.pro" } @@ -44,6 +44,7 @@ android { exclude 'META-INF/LICENSE' exclude 'META-INF/NOTICE' } + } dependencies { diff --git a/gmlrva-sample/build.gradle b/gmlrva-sample/build.gradle index 51ca915..ba9614d 100644 --- a/gmlrva-sample/build.gradle +++ b/gmlrva-sample/build.gradle @@ -29,7 +29,7 @@ android { debuggable true zipAlignEnabled true minifyEnabled true - shrinkResources true + shrinkResources false versionNameSuffix project.DEV_VERSION_NAME_SUFFIX proguardFiles getDefaultProguardFile('proguard-android.txt'), "$project.rootDir/tools/rules-proguard-debug.pro" @@ -44,6 +44,7 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), "$project.rootDir/tools/rules-proguard.pro" } } + } android.variantFilter { variant -> From e60acab7b5accbe925d2c9fda1e0c5431b25e39c Mon Sep 17 00:00:00 2001 From: Paulo Date: Tue, 3 Oct 2017 22:49:02 +0100 Subject: [PATCH 6/6] [Build] Bumped to version 1.3 --- README.md | 2 +- gmlrva-lib/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5af7570..ebfc773 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Configuration ```gradle dependencies { ... - compile 'pt.simdea:gmlrva.lib:1.2' + compile 'pt.simdea:gmlrva.lib:1.3' ... } ``` diff --git a/gmlrva-lib/build.gradle b/gmlrva-lib/build.gradle index cb4eb4a..79d21ac 100644 --- a/gmlrva-lib/build.gradle +++ b/gmlrva-lib/build.gradle @@ -64,7 +64,7 @@ project.ext { description = 'Generic RecyclerView Adapter that supports multiple layouts.' groupId = 'pt.simdea' artifactId = 'gmlrva.lib' - version = "1.2" + version = "1.3" website = 'https://github.com/simdea/gmlrva' scm = 'https://github.com/simdea/gmlrva' tags = ['android', 'recyclerview', 'adapter', 'generic', 'multiple', 'layout']