Skip to content

Instantly share code, notes, and snippets.

@PollyGlot
PollyGlot / BottomNavigation.kt
Created January 3, 2020 16:00
A method to control navigation graphs in bottomNavigationBar
/**
* Called on first creation and when restoring state.
*/
private fun setupBottomNavigationBar(recreated: Boolean) {
val bottomNavigationView = findViewById<BottomNavigationView>(R.id.bottomNavigation)
val navGraphIds = listOf(TABS.BROWSE.navId, TABS.SEARCH.navId, TABS.FEED.navId, TABS.PROFILE.navId, TABS.PLUS.navId)
// Setup the bottom navigation view with a list of navigation graphs
val controller = bottomNavigationView.setupWithNavController(
@PollyGlot
PollyGlot / NavigateToCommentsFragment.kt
Created January 3, 2020 15:57
A method to navigate to comments fragment from different types of posts in the feed adapter
private fun navigateToCommentsFragment(holder: ViewHolder) {
val timeLineObject = timelineList[holder.adapterPosition]
holder.itemView.findNavController().navigate(R.id.action_home_dest_to_comments_fragment, Bundle().apply {
putInt(CommentsFragment.EXTRA_COMMENTS, timeLineObject.comments)
putInt(CommentsFragment.EXTRA_LIKES_COUNT, timeLineObject.likes)
putBoolean(CommentsFragment.EXTRA_LIKED, timeLineObject.hasLiked)
putInt(CommentsFragment.EXTRA_POSITION, holder.adapterPosition)
putString(CommentsFragment.EXTRA_PROFILE_IMAGE, timeLineObject.user.avatarUrl)
@PollyGlot
PollyGlot / FilterActivity.kt
Created January 3, 2020 15:45
A filter functionality I was responsible for to filter videos / playlists in search results of a Kinomap application
package com.kinomap.trainingapps.helper
import android.annotation.SuppressLint
import android.content.Context
import android.content.SharedPreferences
import android.content.pm.ActivityInfo
import android.os.Bundle
import android.preference.PreferenceManager
import android.util.Log
import android.view.Menu
@PollyGlot
PollyGlot / Extensions.kt
Created January 3, 2020 15:42
A list of extension functions I created for a Kinomap project
package com.kinomap.kinomapcommon.util
import android.content.SharedPreferences
import android.content.res.Resources
import android.graphics.drawable.Drawable
import android.os.Build
import android.view.View
import androidx.annotation.DrawableRes
import androidx.annotation.PluralsRes
import androidx.fragment.app.FragmentManager
@PollyGlot
PollyGlot / VideosListAdapter.kt
Created January 3, 2020 15:39
RecyclerView adapter to show several recyclerviews with different orientations and types of headers
package com.kinomap.trainingapps.helper
import android.content.Intent
import android.os.Bundle
import android.preference.PreferenceManager
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion rootProject.compileSdkVersion
def versionPropsFile = file('version.properties')
def value = 0
Properties versionProps = new Properties()
private void userLogin(String email, String password) {
showProgressDialog();
mFirebaseAuth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
Log.d(TAG, "signInWithEmail:onComplete:" + task.isSuccessful());
if (!task.isSuccessful()) {
Log.w(TAG, "signInWithEmail", task.getException());