android/GameAdapter: Fix the getColor calls using the wrong context

This commit is contained in:
FearlessTobi 2020-04-17 10:29:47 +02:00 committed by bunnei
parent 1cfa0e97a2
commit fc0ace03d2
2 changed files with 4 additions and 4 deletions

View File

@ -16,7 +16,6 @@ import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import org.citra.citra_emu.CitraApplication;
import org.citra.citra_emu.R; import org.citra.citra_emu.R;
import org.citra.citra_emu.activities.EmulationActivity; import org.citra.citra_emu.activities.EmulationActivity;
import org.citra.citra_emu.model.GameDatabase; import org.citra.citra_emu.model.GameDatabase;
@ -101,7 +100,8 @@ public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> impl
holder.company = mCursor.getString(GameDatabase.GAME_COLUMN_COMPANY); holder.company = mCursor.getString(GameDatabase.GAME_COLUMN_COMPANY);
final int backgroundColorId = isValidGame(holder.path) ? R.color.card_view_background : R.color.card_view_disabled; final int backgroundColorId = isValidGame(holder.path) ? R.color.card_view_background : R.color.card_view_disabled;
holder.setBackgroundColor(ContextCompat.getColor(CitraApplication.getAppContext(), backgroundColorId)); View itemView = holder.getItemView();
itemView.setBackgroundColor(ContextCompat.getColor(itemView.getContext(), backgroundColorId));
} else { } else {
Log.error("[GameAdapter] Can't bind view; Cursor is not valid."); Log.error("[GameAdapter] Can't bind view; Cursor is not valid.");
} }

View File

@ -40,7 +40,7 @@ public class GameViewHolder extends RecyclerView.ViewHolder {
textFileName = itemView.findViewById(R.id.text_filename); textFileName = itemView.findViewById(R.id.text_filename);
} }
public void setBackgroundColor(int color){ public View getItemView() {
itemView.setBackgroundColor(color); return itemView;
} }
} }