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 infiniteTransition = rememberInfiniteTransition() | |
val animationDuration = 5000 | |
val color1 by infiniteTransition.animateColor( | |
initialValue = Color.Green, | |
targetValue = Color.Cyan, | |
animationSpec = infiniteRepeatable( | |
animation = tween(animationDuration, easing = FastOutSlowInEasing), | |
repeatMode = RepeatMode.Reverse | |
) | |
) |
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
// apply touch listener on ViewPager RecyclerView | |
val recyclerView = binding.viewPager[0] as? RecyclerView | |
if (recyclerView != null) { | |
recyclerView.addOnItemTouchListener(swipeControlTouchListener) | |
} else { | |
Log.w(localClassName, "RecyclerView is null, API/Version changed ?!") | |
} |
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
swipeControlTouchListener.setSwipeDirection(SwipeDirection.LEFT) |
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
private fun isSwipeAllowed(event: MotionEvent): Boolean { | |
if (direction === SwipeDirection.ALL) return true | |
if (direction == SwipeDirection.NONE) //disable any swipe | |
return false | |
if (event.action == MotionEvent.ACTION_DOWN) { | |
initialXValue = event.x | |
return true | |
} | |
if (event.action == MotionEvent.ACTION_MOVE) { | |
try { |
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
enum class SwipeDirection { | |
ALL, // swipe allowed in left and right both directions | |
LEFT, // swipe allowed in only Left direction | |
RIGHT, // only right | |
NONE // swipe is disabled completely | |
} |
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
with(binding) { | |
progressBar.setVisible(false) | |
adapter.addItems(item) | |
recyclerView.setVisible(true) | |
successText.setVisible(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
private fun showSuccessState(item: List<String>) { | |
binding.progressBar.setVisible(false) | |
binding.adapter.addItems(item) | |
binding.recyclerView.setVisible(true) | |
binding.successText.setVisible(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
private fun showSuccessState(item: List<String>) { | |
progressBar.setVisible(false) | |
adapter.addItems(item) | |
recyclerView.setVisible(true) | |
successText.setVisible(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
class DemoFragment : Fragment(R.layout.fragment_demo) { | |
private val binding by viewBinding(FragmentDemoBinding::bind) | |
} |
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 DemoFragment : Fragment() { | |
// declare binding | |
private var binding: FragmentDemoBinding? = null | |
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, | |
savedInstanceState: Bundle?): View? { | |
// inflate and return view | |
binding = FragmentDemoBinding.inflate(inflater, container, false) | |
return binding?.root | |
} |
NewerOlder