diff options
author | Cameron Mace <cameron@mapbox.com> | 2016-12-16 16:19:15 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-16 16:19:15 -0500 |
commit | 20b958301eb208fe9ed0ae8edfb14b6f3741d8f2 (patch) | |
tree | 94ae0ce250cda159be13f9a21cc70c92d4908974 /platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter | |
parent | f95b4838ea816b9da0c151a953a1f98f97c79a39 (diff) | |
download | qtlocation-mapboxgl-20b958301eb208fe9ed0ae8edfb14b6f3741d8f2.tar.gz |
Adds checkstyle to CI (#7442)
* adds checkstyle to CI
* fixed gradlew path
* resolved testapp checkstyle violations
* added back mapboxMap variable for test
* checkstyle annotations
* checkstyle SDK round 1
* maps package checkstyle
* rest of SDK checkstyle
* checkstyle gesture library
* checkstyle test
* finished rest of test checkstyle
* resolved all checkstyle errors
* fixed class name
* removed old test file
* fixed camera postion test
* fixed native crash
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter')
2 files changed, 166 insertions, 165 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter/FeatureAdapter.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter/FeatureAdapter.java index 71adba8ac7..a935c2134f 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter/FeatureAdapter.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter/FeatureAdapter.java @@ -15,41 +15,41 @@ import java.util.List; public class FeatureAdapter extends RecyclerView.Adapter<FeatureAdapter.ViewHolder> { - private List<Feature> features; + private List<Feature> features; - public static class ViewHolder extends RecyclerView.ViewHolder { + public static class ViewHolder extends RecyclerView.ViewHolder { - public TextView labelView; - public TextView descriptionView; + public TextView labelView; + public TextView descriptionView; - public ViewHolder(View view) { - super(view); - Typeface typeface = FontCache.get("Roboto-Regular.ttf",view.getContext()); - labelView = (TextView) view.findViewById(R.id.nameView); - labelView.setTypeface(typeface); - descriptionView = (TextView) view.findViewById(R.id.descriptionView); - descriptionView.setTypeface(typeface); - } - } - - public FeatureAdapter(List<Feature> features) { - this.features = features; - } - - @Override - public FeatureAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { - View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_main_feature, parent, false); - return new ViewHolder(view); - } - - @Override - public void onBindViewHolder(ViewHolder holder, int position) { - holder.labelView.setText(features.get(position).getLabel()); - holder.descriptionView.setText(features.get(position).getDescription()); - } - - @Override - public int getItemCount() { - return features.size(); + public ViewHolder(View view) { + super(view); + Typeface typeface = FontCache.get("Roboto-Regular.ttf", view.getContext()); + labelView = (TextView) view.findViewById(R.id.nameView); + labelView.setTypeface(typeface); + descriptionView = (TextView) view.findViewById(R.id.descriptionView); + descriptionView.setTypeface(typeface); } + } + + public FeatureAdapter(List<Feature> features) { + this.features = features; + } + + @Override + public FeatureAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_main_feature, parent, false); + return new ViewHolder(view); + } + + @Override + public void onBindViewHolder(ViewHolder holder, int position) { + holder.labelView.setText(features.get(position).getLabel()); + holder.descriptionView.setText(features.get(position).getDescription()); + } + + @Override + public int getItemCount() { + return features.size(); + } }
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter/FeatureSectionAdapter.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter/FeatureSectionAdapter.java index d86e06ea6d..012bbed4ca 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter/FeatureSectionAdapter.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter/FeatureSectionAdapter.java @@ -18,161 +18,162 @@ import java.util.Comparator; public class FeatureSectionAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { - private static final int SECTION_TYPE = 0; - - private final Context context; - private final SparseArray<Section> sections; - private final RecyclerView.Adapter adapter; - - @LayoutRes - private final int sectionRes; - - @IdRes - private final int textRes; - - private boolean valid = true; - - public FeatureSectionAdapter(Context ctx, int sectionResourceId, int textResourceId, RecyclerView.Adapter baseAdapter) { - context = ctx; - sectionRes = sectionResourceId; - textRes = textResourceId; - adapter = baseAdapter; - sections = new SparseArray<>(); - adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() { - @Override - public void onChanged() { - valid = adapter.getItemCount() > 0; - notifyDataSetChanged(); - } - - @Override - public void onItemRangeChanged(int positionStart, int itemCount) { - valid = adapter.getItemCount() > 0; - notifyItemRangeChanged(positionStart, itemCount); - } - - @Override - public void onItemRangeInserted(int positionStart, int itemCount) { - valid = adapter.getItemCount() > 0; - notifyItemRangeInserted(positionStart, itemCount); - } - - @Override - public void onItemRangeRemoved(int positionStart, int itemCount) { - valid = adapter.getItemCount() > 0; - notifyItemRangeRemoved(positionStart, itemCount); - } - }); - } + private static final int SECTION_TYPE = 0; + + private final Context context; + private final SparseArray<Section> sections; + private final RecyclerView.Adapter adapter; + + @LayoutRes + private final int sectionRes; + + @IdRes + private final int textRes; + + private boolean valid = true; + + public FeatureSectionAdapter(Context ctx, int sectionResourceId, int textResourceId, + RecyclerView.Adapter baseAdapter) { + context = ctx; + sectionRes = sectionResourceId; + textRes = textResourceId; + adapter = baseAdapter; + sections = new SparseArray<>(); + adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() { + @Override + public void onChanged() { + valid = adapter.getItemCount() > 0; + notifyDataSetChanged(); + } + @Override + public void onItemRangeChanged(int positionStart, int itemCount) { + valid = adapter.getItemCount() > 0; + notifyItemRangeChanged(positionStart, itemCount); + } - public static class SectionViewHolder extends RecyclerView.ViewHolder { + @Override + public void onItemRangeInserted(int positionStart, int itemCount) { + valid = adapter.getItemCount() > 0; + notifyItemRangeInserted(positionStart, itemCount); + } - public TextView title; + @Override + public void onItemRangeRemoved(int positionStart, int itemCount) { + valid = adapter.getItemCount() > 0; + notifyItemRangeRemoved(positionStart, itemCount); + } + }); + } - public SectionViewHolder(@NonNull View view, @IdRes int textRes) { - super(view); - title = (TextView) view.findViewById(textRes); - title.setTypeface(FontCache.get("Roboto-Medium.ttf", view.getContext())); - } - } - @Override - public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int typeView) { - if (typeView == SECTION_TYPE) { - final View view = LayoutInflater.from(context).inflate(sectionRes, parent, false); - return new SectionViewHolder(view, textRes); - } else { - return adapter.onCreateViewHolder(parent, typeView - 1); - } - } + public static class SectionViewHolder extends RecyclerView.ViewHolder { - @Override - public void onBindViewHolder(RecyclerView.ViewHolder sectionViewHolder, int position) { - if (isSectionHeaderPosition(position)) { - ((SectionViewHolder) sectionViewHolder).title.setText(sections.get(position).title); - } else { - adapter.onBindViewHolder(sectionViewHolder, getConvertedPosition(position)); - } + public TextView title; + public SectionViewHolder(@NonNull View view, @IdRes int textRes) { + super(view); + title = (TextView) view.findViewById(textRes); + title.setTypeface(FontCache.get("Roboto-Medium.ttf", view.getContext())); } - - @Override - public int getItemViewType(int position) { - return isSectionHeaderPosition(position) - ? SECTION_TYPE - : adapter.getItemViewType(getConvertedPosition(position)) + 1; + } + + @Override + public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int typeView) { + if (typeView == SECTION_TYPE) { + final View view = LayoutInflater.from(context).inflate(sectionRes, parent, false); + return new SectionViewHolder(view, textRes); + } else { + return adapter.onCreateViewHolder(parent, typeView - 1); } - - - public static class Section { - int firstPosition; - int sectionedPosition; - CharSequence title; - - public Section(int firstPosition, CharSequence title) { - this.firstPosition = firstPosition; - this.title = title; - } - - public CharSequence getTitle() { - return title; - } + } + + @Override + public void onBindViewHolder(RecyclerView.ViewHolder sectionViewHolder, int position) { + if (isSectionHeaderPosition(position)) { + ((SectionViewHolder) sectionViewHolder).title.setText(sections.get(position).title); + } else { + adapter.onBindViewHolder(sectionViewHolder, getConvertedPosition(position)); } + } - public void setSections(Section[] sections) { - this.sections.clear(); + @Override + public int getItemViewType(int position) { + return isSectionHeaderPosition(position) + ? SECTION_TYPE + : adapter.getItemViewType(getConvertedPosition(position)) + 1; + } - Arrays.sort(sections, new Comparator<Section>() { - @Override - public int compare(Section o, Section o1) { - return (o.firstPosition == o1.firstPosition) - ? 0 - : ((o.firstPosition < o1.firstPosition) ? -1 : 1); - } - }); - int offset = 0; - for (Section section : sections) { - section.sectionedPosition = section.firstPosition + offset; - this.sections.append(section.sectionedPosition, section); - ++offset; - } + public static class Section { + int firstPosition; + int sectionedPosition; + CharSequence title; - notifyDataSetChanged(); + public Section(int firstPosition, CharSequence title) { + this.firstPosition = firstPosition; + this.title = title; } - public int getConvertedPosition(int sectionedPosition) { - if (isSectionHeaderPosition(sectionedPosition)) { - return RecyclerView.NO_POSITION; - } - - int offset = 0; - for (int i = 0; i < sections.size(); i++) { - if (sections.valueAt(i).sectionedPosition > sectionedPosition) { - break; - } - --offset; - } - return sectionedPosition + offset; + public CharSequence getTitle() { + return title; } - - public boolean isSectionHeaderPosition(int position) { - return sections.get(position) != null; + } + + + public void setSections(Section[] sections) { + this.sections.clear(); + + Arrays.sort(sections, new Comparator<Section>() { + @Override + public int compare(Section section, Section section1) { + return (section.firstPosition == section1.firstPosition) + ? 0 + : ((section.firstPosition < section1.firstPosition) ? -1 : 1); + } + }); + + int offset = 0; + for (Section section : sections) { + section.sectionedPosition = section.firstPosition + offset; + this.sections.append(section.sectionedPosition, section); + ++offset; } + notifyDataSetChanged(); + } - @Override - public long getItemId(int position) { - return isSectionHeaderPosition(position) - ? Integer.MAX_VALUE - sections.indexOfKey(position) - : adapter.getItemId(getConvertedPosition(position)); + public int getConvertedPosition(int sectionedPosition) { + if (isSectionHeaderPosition(sectionedPosition)) { + return RecyclerView.NO_POSITION; } - @Override - public int getItemCount() { - return (valid ? adapter.getItemCount() + sections.size() : 0); + int offset = 0; + for (int i = 0; i < sections.size(); i++) { + if (sections.valueAt(i).sectionedPosition > sectionedPosition) { + break; + } + --offset; } + return sectionedPosition + offset; + } + + public boolean isSectionHeaderPosition(int position) { + return sections.get(position) != null; + } + + + @Override + public long getItemId(int position) { + return isSectionHeaderPosition(position) + ? Integer.MAX_VALUE - sections.indexOfKey(position) + : adapter.getItemId(getConvertedPosition(position)); + } + + @Override + public int getItemCount() { + return (valid ? adapter.getItemCount() + sections.size() : 0); + } }
\ No newline at end of file |