use of android.support.annotation.NonNull in project MultiType by drakeet.
the class OneDataToManyActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list);
recyclerView = (RecyclerView) findViewById(R.id.list);
adapter = new MultiTypeAdapter();
adapter.setFlatTypeAdapter(new FlatTypeClassAdapter() {
@NonNull
@Override
public Class onFlattenClass(@NonNull Object item) {
return ((Data) item).typeClass;
}
});
adapter.register(Data.Type1.class, new DataType1ViewBinder());
adapter.register(Data.Type2.class, new DataType2ViewBinder());
List<Data> dataList = getDataFromService();
// 如果 Data 们不会自动把 int type -> Class typeClass 的话,
// 需要自行处理,示例如下:
// for (Data data : dataList) {
// data.typeClass = Data.getTypeClass(data.type);
// }
adapter.setItems(dataList);
adapter.notifyDataSetChanged();
assertAllRegistered(adapter, dataList);
recyclerView.setAdapter(adapter);
assertHasTheSameAdapter(recyclerView, adapter);
}
use of android.support.annotation.NonNull in project FlexibleAdapter by davideas.
the class FlexibleAdapter method getExpandedPositions.
/**
* Provides a list of all expandable positions that are currently expanded.
*
* @return a list with the global positions of all expanded items
* @see #getSiblingsOf(IFlexible)
* @see #getExpandedItems()
* @since 5.0.0-b1
*/
@NonNull
public List<Integer> getExpandedPositions() {
List<Integer> expandedPositions = new ArrayList<>();
int startPosition = Math.max(0, mScrollableHeaders.size() - 1);
int endPosition = getItemCount() - mScrollableFooters.size() - 1;
for (int i = startPosition; i < endPosition; i++) {
if (isExpanded(mItems.get(i)))
expandedPositions.add(i);
}
return expandedPositions;
}
use of android.support.annotation.NonNull in project FlexibleAdapter by davideas.
the class FlexibleAdapter method getSectionItemPositions.
/**
* Provides all the item positions that belongs to the section represented by the provided
* header.
*
* @param header the {@code IHeader} item that represents the section
* @return NonNull list of all item positions in the provided section
* @since 5.0.0-b8
*/
@NonNull
public List<Integer> getSectionItemPositions(@NonNull IHeader header) {
List<Integer> sectionItemPositions = new ArrayList<>();
int startPosition = getGlobalPositionOf(header);
T item = getItem(++startPosition);
while (hasSameHeader(item, header)) {
sectionItemPositions.add(++startPosition);
}
return sectionItemPositions;
}
use of android.support.annotation.NonNull in project FlexibleAdapter by davideas.
the class BottomSheetDialog method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
mBottomSheetDialog = new android.support.design.widget.BottomSheetDialog(getActivity(), R.style.AppTheme_BottomSheetDialog);
mBottomSheetDialog.setContentView(getArguments().getInt(ARG_LAYOUT));
mBottomSheetDialog.findViewById(R.id.select_item_type).setOnClickListener(this);
mBottomSheetDialog.findViewById(R.id.select_item_type).setOnTouchListener(new SimpleOnTouchListener(getContext()));
mBottomSheetDialog.findViewById(R.id.select_reference_button).setOnClickListener(this);
mBottomSheetDialog.findViewById(R.id.select_reference_button).setOnTouchListener(new SimpleOnTouchListener(getContext()));
mBottomSheetDialog.findViewById(R.id.new_item).setOnClickListener(this);
createPopUps();
return mBottomSheetDialog;
}
use of android.support.annotation.NonNull in project MovieGuide by esoxjem.
the class MoviesListingParser method parse.
@NonNull
public static List<Movie> parse(String json) throws JSONException {
List<Movie> movies = new ArrayList<>(24);
JSONObject response = new JSONObject(json);
if (!response.isNull(RESULTS)) {
JSONArray results = response.getJSONArray(RESULTS);
for (int i = 0; i < results.length(); i++) {
movies.add(getMovie(results.getJSONObject(i)));
}
} else {
// No results
}
return movies;
}
Aggregations