Coder Social home page Coder Social logo

error: incompatible types: com.google.firebase.database.core.Context cannot be converted to android.content.Context about android-flat-button HOT 1 OPEN

hoang8f avatar hoang8f commented on July 30, 2024
error: incompatible types: com.google.firebase.database.core.Context cannot be converted to android.content.Context

from android-flat-button.

Comments (1)

Jsamouil avatar Jsamouil commented on July 30, 2024

import android.view.LayoutInflater;
//import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.example.fastfood1.Common.Common;
import com.example.fastfood1.Model.CategoryModel;
import com.example.fastfood1.R;
import com.google.firebase.database.core.Context;

import java.util.List;
import java.util.Locale;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

public class MyCategoriesAdapter extends RecyclerView.Adapter<MyCategoriesAdapter.MyViewHolder> {

Context context;
List<CategoryModel> categoryModelList;

public MyCategoriesAdapter(Context context, List<CategoryModel> categoryModelList) {
    this.context = context;
    this.categoryModelList = categoryModelList;
}

@NonNull
@Override
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
    return new MyViewHolder(LayoutInflater.from(context)
            .inflate(R.layout.layout_category_item, parent, false));
}

@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
    Glide.with(context).load(categoryModelList.get(position).getImage())
            .into(holder.category_iamge);
    holder.category_name.setText(new StringBuilder(categoryModelList.get(position).getName()));
}

@Override
public int getItemCount() {
    return categoryModelList.size();
}

public class MyViewHolder extends RecyclerView.ViewHolder {
    Unbinder unbinder;
    @BindView(R.id.img_category)
    ImageView category_iamge;
    @BindView(R.id.txt_category)
    TextView category_name;
    public MyViewHolder(@NonNull View itemView) {
        super(itemView);
        unbinder  = ButterKnife.bind(this,itemView);
    }
}


@Override
public int getItemViewType(int position) {
    if(categoryModelList.size() == 1)
    {
        return Common.DEAFAULT_COLUMN_COUNT;
    }
    else
    {
        if(categoryModelList.size() % 2 == 0)
            return Common.DEAFAULT_COLUMN_COUNT;
        else
            return (position > 1 && position == categoryModelList.size() - 1) ? Common.FULL_WIDTH_COLUMN:Common.DEAFAULT_COLUMN_COUNT;
    }
}

}

from android-flat-button.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.