This file contains hidden or 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
| private func layoutImages() { | |
| let w = scrollView.frame.size.width | |
| let h = scrollView.frame.size.height | |
| imageViews.enumerated().forEach { (index: Int, imageView: UIImageView) in | |
| imageView.image = images[index] | |
| imageView.frame = CGRect(x: w * CGFloat(index), | |
| y: 0, | |
| width: w, | |
| height: h) | |
| } |
This file contains hidden or 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 MainActivityFragment : Fragment() { | |
| // Discard permanent reference to the adapter | |
| val adapter = MainRecyclerViewAdapter() | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| return inflater.inflate(R.layout.fragment_activity_main, container, false) | |
| } | |
| + override fun onDestroyView() { |
This file contains hidden or 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 MainActivityFragment : Fragment() { | |
| // Discard permanent reference to the adapter | |
| - val adapter = MainRecyclerViewAdapter() | |
| - | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| return inflater.inflate(R.layout.fragment_activity_main, container, false) | |
| } | |
| override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
This file contains hidden or 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 MainActivityFragment : Fragment() { | |
| // Fragment keeps the reference to the RecyclerView adapter | |
| private lateinit var adapter: MainRecyclerViewAdapter | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| adapter = MainRecyclerViewAdapter() | |
| retainInstance = true | |
| } |
This file contains hidden or 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
| // | |
| // Usage : | |
| // onView(withId(R.id...) | |
| // .check( | |
| // ViewAssertions.matches( | |
| // BackgroundViewMatchers.backgroundHasBorder() | |
| // ) | |
| // ) | |
| // ) | |
| // |
This file contains hidden or 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
| #!/bin/sh | |
| PREFIX="Screenshot-$(date +%Y%m%d-%H%M%S)" | |
| BASE="/sdcard/$PREFIX" | |
| OUTPUT="$YOUR_OUT_PUT_DIRECTORY" # Need to modify this to suit your environment | |
| DELAY=30 | |
| trap ctrl_c INT | |
| function clean_up() { |
This file contains hidden or 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
| #!/bin/bash | |
| # Starts and stops recording in the simulator | |
| # Set your prefered output directory here | |
| outputDirectory=~/Desktop/ | |
| # Open recordings in the default app when ending recording | |
| openRecordings=true |
This file contains hidden or 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 snapHelper = object : LinearSnapHelper() { | |
| override fun findTargetSnapPosition( | |
| layoutManager: RecyclerView.LayoutManager?, | |
| velocityX: Int, | |
| velocityY: Int | |
| ): Int { | |
| val centerView = findSnapView(layoutManager!!) ?: return RecyclerView.NO_POSITION | |
| var targetPosition = layoutManager.getPosition(centerView) | |
| if (currentPosition != targetPosition) { |
This file contains hidden or 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
| //: Playground - noun: a place where people can play | |
| import Foundation | |
| // DispatchGroup sample. | |
| // we are waiting for all async blocks to be finished before typing "[Dispatch Group] sample has finished" | |
| let group = DispatchGroup() | |
| let q1 = DispatchQueue.global(qos: .background) | |
| let q2 = DispatchQueue.global(qos: .background) |
This file contains hidden or 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
| #!/bin/bash | |
| file=$1 | |
| function tile() { | |
| convert $file -scale ${s}%x -crop 256x256 \ | |
| -set filename:tile "%[fx:page.x/256]_%[fx:page.y/256]" \ | |
| +repage +adjoin "${file%.*}_${s}_%[filename:tile].${file#*.}" | |
| } | |
| s=100 | |
| tile | |
| s=50 |