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
| #!/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
| #!/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
| // | |
| // 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
| 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
| 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() { | |
| // 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
| 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
| extension UILabel { | |
| @objc var substituteFontName: String { | |
| get { | |
| return font.fontName | |
| } | |
| set { | |
| font = UIFont(name: newValue, size: font.pointSize) | |
| } | |
| } | |
| } |
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 AppDelegate: UIResponder, UIApplicationDelegate { | |
| ... | |
| func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: | |
| [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
| ... | |
| UILabel.appearance().substituteFontName = "Gills Sans" | |
| ... | |
| return true |