Skip to content

Instantly share code, notes, and snippets.

View rubenquadros's full-sized avatar

Ruben Quadros rubenquadros

View GitHub Profile
@rubenquadros
rubenquadros / IgnoreInspection.kt
Created May 1, 2022 19:01
Ignore the inspection for this file
fun ignoreInspection(
fileEditor: FileEditor,
psiFile: PsiFile,
project: Project
) {
if (isErrorHighlighted(psiFile, project)) {
HighlightLevelUtil.forceRootHighlighting(
psiFile,
FileHighlightingSetting.SKIP_HIGHLIGHTING
)
@rubenquadros
rubenquadros / AddAnnotation.kt
Last active May 3, 2022 09:09
Add missing annotation
fun addAnnotation(ktClass: KtClass, project: Project) {
val param = ktClass.getMissingAnnotationParam()
param?.let {
WriteCommandAction.runWriteCommandAction(project) {
param.addAnnotation(
annotationFqName =
FqName("com.google.gson.annotations.SerializedName"),
annotationInnerText = "\"${param.name}\""
)
JavaCodeStyleManager.getInstance(project)
@rubenquadros
rubenquadros / CreatePanel.kt
Last active May 1, 2022 18:58
Creating the notification to be displayed
fun createPanel(
psiFile: PsiFile,
project: Project,
name: String,
onAddClick: () -> Unit,
onIgnoreClick: () -> Unit
): EditorNotificationPanel? {
return if (isErrorHighlighted(psiFile, project)) {
val panel = EditorNotificationPanel()
panel.text("Add SerializedName annotation to $name params?")
@rubenquadros
rubenquadros / SerializedNameNotification.kt
Last active May 3, 2022 09:08
Editor notification for missing annotation
class SerializedNameNotification :
EditorNotifications.Provider<EditorNotificationPanel>() {
companion object {
val KEY =
Key.create<EditorNotificationPanel>("Add missing annotation?")
}
override fun getKey(): Key<EditorNotificationPanel> = KEY
@rubenquadros
rubenquadros / SerializedNameInspector.kt
Last active May 2, 2022 17:12
SerializedName inspector for data classes
class SerializedNameInspector : AbstractKotlinInspection() {
override fun buildVisitor(
holder: ProblemsHolder,
isOnTheFly: Boolean
): KtVisitorVoid {
return classVisitor { ktClass ->
if (ktClass.isData()) {
// check if serialized name annotation is required.
val param = ktClass.isSerializedNameAnnotationMissing()
@rubenquadros
rubenquadros / initial.plugin.xml
Last active May 1, 2022 15:28
Add localInspection extension to plugin.xml
<idea-plugin>
<id>com.ruben.codespector</id>
<name>Codespector</name>
<vendor email="support@yourcompany.com" url="http://www.yourcompany.com">YourCompany</vendor>
<description><![CDATA[
Enter short description for your plugin here.<br>
<em>most HTML tags may be used</em>
]]></description>
@rubenquadros
rubenquadros / GameVideoTest.kt
Created September 4, 2021 18:07
Testing game videos screen
class GameVideoTest() {
@get:Rule val composeTestRule = createComposeRule()
@Test
fun vide_player_and_playlist_show_be_shown() {
composeTestRule.setContent {
ShowGameVideos(
gameVideos =
FakeGamesData.getFakeGameVideos()
@rubenquadros
rubenquadros / VideoItemFinal.kt
Last active September 4, 2021 17:52
Final video item
@Composable
fun VideoItem(
index: Int,
video: VideoResultEntity,
currentPlaying: State<Int>,
onVideoChange: (Int) -> Unit
) {
val currentlyPlaying = remember {
mutableStateOf(false)
}
@rubenquadros
rubenquadros / VideoPlayListFinal.kt
Created September 4, 2021 16:26
Final video playlist
@Composable
fun VideoPlayList(
modifier: Modifier = Modifier,
gameVideos: List<VideoResultEntity>,
currentPlaying: State<Int>,
onVideoChange: (Int) -> Unit
) {
LazyColumn(modifier = modifier) {
itemsIndexed(
items = gameVideos,
@rubenquadros
rubenquadros / VideoPlayer.kt
Created September 4, 2021 16:24
Video player to play videos
@ExperimentalAnimationApi
@Composable
fun VideoPlayer(
modifier: Modifier = Modifier,
gameVideos: List<VideoResultEntity>,
currentPlaying: State<Int>,
onVideoChange: (Int) -> Unit
) {
val videoTitle = remember {