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 main() { | |
// coldFlow() | |
hotFlow() | |
} | |
fun coldFlow() { | |
val scope = CoroutineScope(Dispatchers.IO) | |
var count = 10 | |
val coldFlow = flow { | |
while (count > 0) { |
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
/* // use side | |
* channelAvatarPicture.setOnClickListener { | |
* startActivityForResult(Intent(this@ChannelActivity, ImagePickingActivity::class.java), ImagePickingActivity.REQUEST_IMAGE_CAPTURE) | |
* } | |
* override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { | |
* super.onActivityResult(requestCode, resultCode, data) | |
* if (requestCode == ImagePickingActivity.REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) { | |
* data?.getStringExtra(ImagePickingActivity.CHOSEN_IMAGE_PATH)?.ofType<String> { chosenImagePath -> | |
* // use 'chosenImagePath' | |
* } |
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
override fun onTouchEvent(event: MotionEvent): Boolean { | |
// swapping the motionEvent's x and y, so that when finger moves right, it becomes moving down | |
// for VerticalViewPager effect | |
event.swapXY() | |
// this portion is used for injection ACTION_DOWN | |
if (firstTime && event.actionMasked == MotionEvent.ACTION_MOVE) { | |
injectActionDown(event) | |
firstTime = false | |
} |
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
override fun onInterceptTouchEvent(event: MotionEvent): Boolean { | |
val action = event.actionMasked | |
val currentPoint = Point(event.x.toInt(), event.y.toInt()) | |
if (action == MotionEvent.ACTION_DOWN) { | |
// mark the beginning, when finger touched down | |
initialTouchPoint = Point(currentPoint) | |
} else if (action == MotionEvent.ACTION_UP) { | |
// reset the marking, when finger is lifted up | |
initialTouchPoint = Point(0, 0) |
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
override fun onInterceptTouchEvent(event: MotionEvent): Boolean { | |
val action = event.actionMasked | |
val currentPoint = Point(event.x.toInt(), event.y.toInt()) | |
if (action == MotionEvent.ACTION_DOWN) { | |
// mark the beginning, when finger touched down | |
initialTouchPoint = Point(currentPoint) | |
} else if (action == MotionEvent.ACTION_UP) { | |
// reset the marking, when finger is lifted up | |
initialTouchPoint = Point(0, 0) |
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
override fun onInterceptTouchEvent(event: MotionEvent): Boolean { | |
val action = event.actionMasked | |
val currentPoint = Point(event.x.toInt(), event.y.toInt()) | |
if (action == MotionEvent.ACTION_DOWN) { | |
// mark the beginning, when finger touched down | |
initialTouchPoint = Point(currentPoint) | |
} else if (action == MotionEvent.ACTION_UP) { | |
// reset the marking, when finger is lifted up | |
initialTouchPoint = Point(0, 0) |
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 RandomAdapter(val dataArray: List) : AccordionAdapter { | |
override fun onCreateViewHolderForTitle(parent: ViewGroup): AccordionView.ViewHolder { | |
return TitleViewHolder.create(parent) | |
} | |
override fun onCreateViewHolderForContent(parent: ViewGroup): AccordionView.ViewHolder { | |
return ContentViewHolder.create(parent) | |
} | |
override fun onBindViewForTitle(viewHolder: AccordionView.ViewHolder, position: Int, arrowDirection: AccordionAdapter.ArrowDirection) { |
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
interface AccordianAdapter { | |
fun onCreateViewHolderForTitle(parent: ViewGroup): AccordionView.ViewHolder | |
fun onCreateViewHolderForContent(parent: ViewGroup): AccordionView.ViewHolder | |
fun onBindViewForTitle(viewHolder: AccordionView.ViewHolder, position: Int, arrowDirection: ArrowDirection) | |
fun onBindViewForContent(viewHolder: AccordionView.ViewHolder, position: Int) | |
fun getItemCount(): Int | |
} |
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 set = ConstraintSet() | |
set.clone(constraintLayout) | |
set.clear(titleView4.id, ConstraintSet.TOP) | |
set.applyTo(constraintLayout) |
NewerOlder