Я преобразовал Java-класс в kotlin и получаю упомянутое сообщение об ошибке. Для непосредственных аргументов супертипа недопустимы проекции
Java-класс
public class RecipeViewHolder extends ParentViewHolder {
private static final float INITIAL_POSITION = 0.0f;
private static final float ROTATED_POSITION = 180f;
@NonNull
private final ImageView mArrowExpandImageView;
private TextView mRecipeTextView;
private TextView position;
private TextView total;
public RecipeViewHolder(@NonNull View itemView) {
super(itemView);
mRecipeTextView = (TextView) itemView.findViewById(R.id.recipe_textview);
position = (TextView) itemView.findViewById(R.id.textViewPosition);
total = (TextView) itemView.findViewById(R.id.textViewTotal);
mArrowExpandImageView = (ImageView) itemView.findViewById(R.id.arrow_expand_imageview);
}
public void bind(@NonNull Recipe recipe) {
mRecipeTextView.setText(recipe.getName());
try {
position.setText("Position: " + recipe.getJson().getString("position"));
total.setText("Total Bid Amount: " + recipe.getJson().getString("type"));
} catch (JSONException e) {
e.printStackTrace();
}
}
}
Преобразованный класс Kotlinis
//Error occurs here in Parentvireholder<*,*>
class RecipeViewHolder(itemView: View) : ParentViewHolder<*, *>(itemView) {
private val mArrowExpandImageView: ImageView
private val mRecipeTextView: TextView
private val position: TextView
private val total: TextView
init {
mRecipeTextView = itemView.findViewById<View>(R.id.recipe_textview) as TextView
position = itemView.findViewById<View>(R.id.textViewPosition) as TextView
total = itemView.findViewById<View>(R.id.textViewTotal) as TextView
mArrowExpandImageView = itemView.findViewById<View>(R.id.arrow_expand_imageview) as ImageView
}
fun bind(recipe: Recipe) {
mRecipeTextView.text = recipe.name
try {
position.text = "Position: " + recipe.json!!.getString("position")
total.text = "Total Bid Amount: " + recipe.json!!.getString("type")
} catch (e: JSONException) {
e.printStackTrace()
}
}
}
Ошибка в отображаемом комментарии.Я попробовал исправление Any, но это показывает, что аргументы типа не выходят за его пределы