Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

John Matthews grndvl1

🎯
Focusing
  • Rightpoint
  • Chicago
View GitHub Profile
@grndvl1
grndvl1 / RecordVideoInAppium.txt
Last active Mar 18, 2020
Record Video Using Appium
View RecordVideoInAppium.txt
// So I found out that its not easy to do this without the right code.
// Funny thing is that it puts a recording on the phone with some random name.mp4
// The hard thing was actually saving it locally.
// When you stop the recording its in a string 64 base you have to decode and then write that byte array to a file.
protected void screenRecordVideo() throws InterruptedException, IOException {
if (platform == OperatingSystem.ANDROID) {
((CanRecordScreen)driver).startRecordingScreen(
new AndroidStartScreenRecordingOptions()
.withVideoSize("1280x720")
View gist:57150b22f724006bb9303e25a161cc53
Most code I saw for this was to create custom layout. Project I did not want to do this but do it for only a specific activity. Here is how to do it in the activity in onStart()
override fun onStart() {
super.onStart()
val toolbarViewGroup = findViewById<ViewGroup>(R.id.action_bar) // standard action layout from theme
toolbarViewGroup?.let{ viewGroup ->
// find the textview title since its in combined layout
val textView = viewGroup.children.find { (it is TextView) } as TextView
@grndvl1
grndvl1 / gist:8ab2fdea6e269726a253761571986665
Created Apr 2, 2019
Fix JobIntentService Crash for 8.x Phones
View gist:8ab2fdea6e269726a253761571986665
1. Create a new package in your app with name android.support.v4.app This is a workaround to override package-private methods.
2. Create or Edit your Own ServiceClass to Override dequeueWork() method and surround super.dequeueWork() call with try/catch block like the coming snippet.
Any code that uses JobIntent Service override with this class
(Important Note: This fix should be tracked from time to time as any change in the support libraries might break it.)
public abstract class MyServiceImpl extends JobIntentService {
// This method is the main reason for the bug and crash
// the dequeueWork method is called only when the worker service is done
@grndvl1
grndvl1 / SectionWithHeader.txt
Last active Mar 26, 2019
Custom LinearLayout
View SectionWithHeader.txt
This is how you set up a custom layout in kotlin, with a linearlayout and 3 textviews but these are embedded so a little
trick here to get the properties setters and getters needs to be done. May not be the most efficient way but it works
attrs.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="DetailSectionHeaderText">
<attr name="title" format="string" />
@grndvl1
grndvl1 / WhiteNotificationBar_BlackIcons
Created Feb 20, 2018
Android Notification Bar White with Black Icons - Programatically
View WhiteNotificationBar_BlackIcons
Window window = this.getWindow();
// clear FLAG_TRANSLUCENT_STATUS flag:
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
// finally change the color
You can’t perform that action at this time.