Android RecyclerView strange endAllStagingAnimators error

匿名 (未验证) 提交于 2019-12-03 02:22:01

问题:

I have very strange problem with displaying item in RecyclerView. first of all it does not display items (strange D/OpenGLRenderer: endAllStagingAnimators on 0x6dd9c400 (CardView) with handle 0x6861d090 appears - never happened before) and back button does not work (it appears but does not react). Ok lets start. I have some Fragment (here is that fragment with RecyclerView:

I also have 1 identical fragment to that but one of them conatins as you can see kitchen types and second one has meal types. When I click on one of list items, in both cases action redirects me to new activity

When I click on some of that items f.e first one, here it is what happen inside this RecyclerView adapter:

@Override public void onBindViewHolder(ViewHolder holder, int position) {     KitchenTypeItem kitchenItem = kitchenItems.get(position);     holder.kitchenTypeName.setText("Kuchnia " + kitchenItem.getKitchenName());     holder.kitchenTypeImgThumbnail.setImageResource(kitchenItem.getKitchenThumbnail());     holder.kitchenTypeDescription.setText(kitchenItem.getKitchenDescription());      holder.setClickListener(new ItemClickListener() {          @Override         public void onClick(View view, int position) {             KitchenTypeItem kitchenItem = kitchenItems.get(position);              Intent intent = new Intent(context, RecipeActivity.class);             intent.putExtra(TYPE_NAME, kitchenItem.getKitchenName());             intent.putExtra(DISPLAY_TYPE, 0);             context.startActivity(intent);         }      }); } 

When I press one of that items I send 2 parameters to new activity which are: TYPE_NAME - helps me to get know if I will be using newly opened activity to download data from server containing kitchen types recipes or meal types recipes and DISPLAY_TYPE - used to send request to MySQL database. This is some code from 2nd adapter (as you can almost identical):

        Intent intent = new Intent(context, RecipeActivity.class);         intent.putExtra(TYPE_NAME, mealItem.getMealName());         intent.putExtra(DISPLAY_TYPE, 1);         context.startActivity(intent); 

This is what I get inside newly opened activity:

As you can see nothing is displying despite the fact RecipeAdapter is made correctly I think:

Here you have it's code:

public class RecipeAdapter extends RecyclerView.Adapter<RecipeAdapter.ViewHolder> {      private static String TAG = RecipeAdapter.class.getSimpleName().toString();      private Context context;     private ArrayList<RecipeItem> recipeItems;     private CoordinatorLayout coordinatorLayout;      public RecipeAdapter(Context context, ArrayList<RecipeItem> recipeItems) {         this.context = context;         this.recipeItems = recipeItems;     }      @Override     public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {         View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.recipe_item, parent,                 false);          return new ViewHolder(v);     }      @Override     public void onBindViewHolder(ViewHolder holder, int position) {         RecipeItem recipeItem = recipeItems.get(position);         Picasso.with(context).load(recipeItem.getRecipeImgThumbnailLink()).into(                 holder.recipeItemImgThumbnail);         holder.recipeItemTitle.setText(recipeItem.getRecipeTitle());         holder.recipeItemKitchenMealType.setText("Kuchnia " + recipeItem.getRecipeKitchenType() +                 ", " + recipeItem.getRecipeMealType());         holder.recipeItemAddDate.setText(recipeItem.getRecipeAddDate());         holder.recipeItemLikeCount.setText(recipeItem.getRecipeLikeCount());         holder.setClickListener(new ItemClickListener2() {              @Override             public void onClick(View view, int position, boolean isLongClick) {                 if (!isLongClick) {                     // go to recipes site                 } else {                     RecipeItem recipeItem = recipeItems.get(position);                     FragmentActivity fragmentActivity = (FragmentActivity)(context);                     FragmentManager fragmentManager = fragmentActivity.getSupportFragmentManager();                     RecipeAddDialogFragment recipeDialogFragment = new RecipeAddDialogFragment();                     Log.d(TAG, "Ustawiono recipeUniqueId, coordinatorLayout oraz " +                             "recipeDialogFragment w klasie RecipeAddDialogFragment");                     recipeDialogFragment.setReferences(recipeItem.getRecipeUniqueID(),                             coordinatorLayout, recipeDialogFragment);                      Log.d(TAG, "Uruchamiam okno dialogowe RecipeAddDialogFragment");                     recipeDialogFragment.show(fragmentManager, "recipeDialogFragment");                 }             }          });     }      @Override     public int getItemCount() {         return recipeItems.size();     }      // Recipe Item Holder     class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener,             View.OnLongClickListener {          private ImageView recipeItemImgThumbnail;         private TextView recipeItemTitle;         private TextView recipeItemKitchenMealType;         private TextView recipeItemAddDate;         private TextView recipeItemLikeCount;         private ItemClickListener2 clickListener2;          public ViewHolder(View itemView) {             super(itemView);             recipeItemImgThumbnail = (ImageView) itemView.findViewById(                     R.id.recipe_item_img_thumbnail);             recipeItemTitle = (TextView) itemView.findViewById(R.id.recipe_item_title);             recipeItemKitchenMealType = (TextView) itemView.findViewById(                     R.id.recipe_item_kitchen_meal_type);             recipeItemAddDate = (TextView) itemView.findViewById(R.id.recipe_item_add_date);             recipeItemLikeCount = (TextView) itemView.findViewById(R.id.recipe_item_like_count);              itemView.setOnClickListener(this);             itemView.setOnLongClickListener(this);         }          public void setClickListener(ItemClickListener2 itemClickListener2) {             this.clickListener2 = itemClickListener2;         }          @Override         public void onClick(View view) {             clickListener2.onClick(view, getAdapterPosition(), false);         }          @Override         public boolean onLongClick(View view) {             clickListener2.onClick(view, getAdapterPosition(), true);              return true;         }     }      public void setCoordinatorLayout(CoordinatorLayout coordinatorLayout) {         this.coordinatorLayout = coordinatorLayout;     } } 

Here is XML file of that activity:

<?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout     xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:id="@+id/recipe_activity_coordinator_layout"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:fitsSystemWindows="true"     tools:context=".RecipeActivity">      <LinearLayout         android:layout_width="match_parent"         android:layout_height="match_parent"         android:background="@color/log_reg_background"         android:orientation="vertical">          <!-- Toolbar -->         <include             android:id="@+id/toolbar"             layout="@layout/tool_bar"             android:layout_width="match_parent"             android:layout_height="wrap_content" />          <android.support.v7.widget.RecyclerView             android:id="@+id/activity_recipe_recyclerview"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:paddingBottom="8dp"             android:clipToPadding="false"/>      </LinearLayout>  </android.support.design.widget.CoordinatorLayout> 

This is main code of the activity:

I can guarantee that everything is fine with downloading and putExtra works fine so the parameters are send correctly. Just the problem with displaying it and that strange error: D/OpenGLRenderer: endAllStagingAnimators on 0x6dd9c400 (CardView) with handle 0x6861d090 and not working up button. Can sb help me?

回答1:

I add

<application android:hardwareAccelerated="false"> <activity android:hardwareAccelerated="true" /> </application> 

in Manifest and solve my problem.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!