This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mainViewModel = ViewModelProvider(activity!!).get(MainViewModel::class.java) | |
// New observer | |
mainViewModel.getAllData()?.observe(viewLifecycleOwner, | |
Observer { subjectsAndRemindersPair -> | |
view.sro_subject_list.adapter = SubjectRecyclerViewAdapter( | |
subjectsAndRemindersPair.first, | |
subjectsAndRemindersPair.second, | |
listener) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SubjectRecyclerViewAdapter( | |
val subjects: List<Subject>, | |
val reminders: List<Reminder>, | |
val listener: OnListFragmentInteractionListener? | |
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun getSubjects(): LiveData<List<Subject>>? { | |
return sroRepository.getSubjects() | |
} | |
fun getReminders(): LiveData<List<Reminder>>? { | |
return sroRepository.getReminders() | |
} | |
fun getAllData(): CombinedSubjectReminders? { | |
var ldSubjects = getSubjects() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.lifecycle.LiveData | |
import androidx.lifecycle.MediatorLiveData | |
// This class ia a MediatorLiveData created since I have two different sources of data: | |
// - subjects table | |
// - reminders table | |
// Since they then become two separate LiveData, and I need both to fill in the data | |
// on the main RecyclerView, then we're using a MediatorLiveData to grab both LiveData | |
// and add them as sources, so that we can notify observers when any of the data gets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Using R.layout.activity_main from the 'main' source set | |
import kotlinx.android.synthetic.main.activity_main.* | |
class MyActivity : Activity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
// Instead of findViewById<TextView>(R.id.textView) | |
textView.setText("Hello, world!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val sharedPreferences = EncryptedSharedPreferences.create( | |
WPFC_SHARED_PREFS_FILENAME, | |
masterKeyAlias, | |
this, | |
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV, | |
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package studio.oldblack.wpflightcontrol | |
const val WPFC_SHARED_PREFS_FILENAME = "wpfc_prefs" | |
const val WPFC_WPCOM_AUTH_ENDPOINT = "https://public-api.wordpress.com/oauth2/authorize" | |
const val WPFC_WPCOM_TOKEN_ENDPOINT = "https://public-api.wordpress.com/oauth2/token" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add REST API support to an already registered taxonomy. | |
*/ | |
add_filter( 'register_taxonomy_args', 'my_taxonomy_args', 10, 2 ); | |
function my_taxonomy_args( $args, $taxonomy_name ) { | |
if ( 'freebbble-type' === $taxonomy_name || 'freebbble-license' === $taxonomy_name ) { | |
$args['show_in_rest'] = true; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add class to body class on single post template | |
function themeprefix_body_class_blocks( $classes ) { | |
if ( is_singular() && has_blocks() ) { | |
$classes[] = 'made-with-gutenberg'; | |
} | |
return $classes; | |
} | |
add_filter( 'body_class', 'themeprefix_body_class_blocks' ); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(e,t,n,r){function b(){var t=u;if(p==0&&c){if(!O())return}if(t.steps[p].popup.type!="modal"&&t.steps[p].popup.type!="nohighlight"){m.html("");if(t.steps[p].wrapper==""||t.steps[p].wrapper==r){alert('Your walkthrough position is: "'+t.steps[p].popup.type+'" but wrapper is empty or undefined. Please check your "'+a+'" wrapper parameter.');return}var i=B(e(t.steps[p].wrapper).offset().top);var s=B(e(t.steps[p].wrapper).offset().left);var o=B(e(t.steps[p].wrapper).innerWidth())||B(e(t.steps[p].wrapper).width());var f=B(e(t.steps[p].wrapper).innerHeight())||B(e(t.steps[p].wrapper).height());var l=F(t.steps[p].margin,"top"),h=F(t.steps[p].margin,"right"),d=F(t.steps[p].margin,"bottom"),v=F(t.steps[p].margin,"left"),g=30,y="",b="";var x={height:B(parseInt(i)-(parseInt(l)+g))};var T={top:x.height,width:B(parseInt(s)-(parseInt(v)+g)),height:B(parseInt(f)+g*2+parseInt(l)+parseInt(d))};if(t.steps[p].overlay==r||t.steps[p].overlay){y="overlay"}else{y="noOverlay";b="killOverlay"}var N=e('<div id="overlayTop" clas |
NewerOlder