Search in sources :

Example 1 with NonNull

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);
}
Also used : NonNull(android.support.annotation.NonNull) MultiTypeAdapter(me.drakeet.multitype.MultiTypeAdapter) FlatTypeClassAdapter(me.drakeet.multitype.FlatTypeClassAdapter)

Example 2 with NonNull

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;
}
Also used : ArrayList(java.util.ArrayList) SuppressLint(android.annotation.SuppressLint) NonNull(android.support.annotation.NonNull)

Example 3 with NonNull

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;
}
Also used : ArrayList(java.util.ArrayList) SuppressLint(android.annotation.SuppressLint) NonNull(android.support.annotation.NonNull)

Example 4 with NonNull

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;
}
Also used : SimpleOnTouchListener(eu.davidea.common.SimpleOnTouchListener) NonNull(android.support.annotation.NonNull)

Example 5 with NonNull

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;
}
Also used : Movie(com.esoxjem.movieguide.Movie) JSONObject(org.json.JSONObject) ArrayList(java.util.ArrayList) JSONArray(org.json.JSONArray) NonNull(android.support.annotation.NonNull)

Aggregations

NonNull (android.support.annotation.NonNull)610 TextView (android.widget.TextView)65 View (android.view.View)64 ArrayList (java.util.ArrayList)57 Test (org.junit.Test)45 Intent (android.content.Intent)38 Cursor (android.database.Cursor)35 ContentValues (android.content.ContentValues)32 Bundle (android.os.Bundle)32 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)29 IOException (java.io.IOException)27 DialogAction (com.afollestad.materialdialogs.DialogAction)25 AlertDialog (android.support.v7.app.AlertDialog)24 Override (java.lang.Override)24 DialogInterface (android.content.DialogInterface)22 File (java.io.File)21 WorkerThread (android.support.annotation.WorkerThread)19 RecyclerView (android.support.v7.widget.RecyclerView)19 ImageView (android.widget.ImageView)19 HashMap (java.util.HashMap)19