Skip to content

Instantly share code, notes, and snippets.

View wangerekaharun's full-sized avatar

Harun Wangereka wangerekaharun

View GitHub Profile
@wangerekaharun
wangerekaharun / SessionsRepo.kt
Created July 24, 2019 17:25
Get speaker details using associateBy and onEach
val speakerById : Map<Int, SpeakersModel> = getSpeakerInfo().associateBy { it.id}
val sessionList : List<SessionsModel> = snapshots.toObjects()
sessionList.onEach { sessionsModel ->
sessionsModel.speaker_id.mapNotNull {
speakerById[it]?.let { speakerModel ->
sessionsModel.speakerList.add(speakerModel)
}
}
}
@wangerekaharun
wangerekaharun / SessionsRepo.kt
Created July 24, 2019 12:07
Getting Speakers from speaker ID
val speakersList :List<SpeakersModel> = getSpeakersInfo()
val sessionList : List<SessionsModel> = snapshots.toObjects<SessionsModel>()
sessionList.map { sessionModel ->
val sessionSpeakerIdList = sessionModel.speaker_id
sessionSpeakerIdList.forEach { speakerId ->
speakersList.forEach {speakerModel ->
if (sessionSpeakerIdList.contains(speakerModel.id)){
sessionModel.speakerList.add(speakerModel)
}
}
StockViewHolder(View itemView) {
super(itemView);
cv = itemView.findViewById(R.id.card);
name = itemView.findViewById(R.id.name);
quantity = itemView.findViewById(R.id.quantity);
category = itemView.findViewById(R.id.category);
no = itemView.findViewById(R.id.no);
itemView.setOnClickListener(v->{
mObserver.onCardClicked(getAdapterPosition(), stockFiltered.get(getAdapterPosition()).name);
@wangerekaharun
wangerekaharun / colors.xml
Created July 3, 2019 10:52
Colors Values
<!--Theme Colors -->
<color name="color_primary_variant">#000000</color>
<color name="color_on_primary">#FFFFFF</color>
<color name="color_secondary">#b869c7</color>
<color name="color_secondary_variant">#560768</color>
<color name="color_on_secondary">#FFFFFF</color>
<color name="color_error">#F44336</color>
<color name="color_on_error">#FFFFFF</color>
<color name="color_surface">#FFFFFF</color>
<color name="color_on_surface">#000000</color>
@wangerekaharun
wangerekaharun / styles.xml
Created July 3, 2019 10:51
Values on styles
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorOnPrimary">@color/colorOnPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorSecondary">@color/color_secondary</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="colorSurface">@color/color_surface</item>
<item name="colorOnSurface">@color/color_on_surface</item>
<item name="colorOnBackground">@color/color_on_background</item>
@wangerekaharun
wangerekaharun / gist:82512e5e1a203667680997e2a256dc9c
Created June 26, 2019 20:14 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: ๐Ÿ˜„ :smile: ๐Ÿ˜† :laughing:
๐Ÿ˜Š :blush: ๐Ÿ˜ƒ :smiley: โ˜บ๏ธ :relaxed:
๐Ÿ˜ :smirk: ๐Ÿ˜ :heart_eyes: ๐Ÿ˜˜ :kissing_heart:
๐Ÿ˜š :kissing_closed_eyes: ๐Ÿ˜ณ :flushed: ๐Ÿ˜Œ :relieved:
๐Ÿ˜† :satisfied: ๐Ÿ˜ :grin: ๐Ÿ˜‰ :wink:
๐Ÿ˜œ :stuck_out_tongue_winking_eye: ๐Ÿ˜ :stuck_out_tongue_closed_eyes: ๐Ÿ˜€ :grinning:
๐Ÿ˜— :kissing: ๐Ÿ˜™ :kissing_smiling_eyes: ๐Ÿ˜› :stuck_out_tongue:
/*
* Copyright (c) Amwollo Victor 2019.
*/
package com.ovicko.viewmodelandroid;
import android.arch.lifecycle.Observer;
import android.arch.lifecycle.ViewModelProviders;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
//called when we get data back from adapter
public void setImageAdapter(List<Hit> hitList){
this.hitList =hitList;
notifyDataSetChanged();
}
interface ApiService {
@GET("/endpoint")
suspend fun loadData(): List<Data>
}
//support for the view model saved state
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:1.0.0-alpha01"