<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Moses Asiago</title>
    <description>The latest articles on DEV Community by Moses Asiago (@mozeago).</description>
    <link>https://dev.to/mozeago</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F97644%2Fa711fcdb-a252-45a2-ba5f-29f0b29778c0.jpg</url>
      <title>DEV Community: Moses Asiago</title>
      <link>https://dev.to/mozeago</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mozeago"/>
    <language>en</language>
    <item>
      <title>Jetpack Compose Loading/How to load a YouTube video or YouTube Livestream channel to your Android application.</title>
      <dc:creator>Moses Asiago</dc:creator>
      <pubDate>Mon, 27 Nov 2023 09:06:35 +0000</pubDate>
      <link>https://dev.to/mozeago/jetpack-compose-loadinghow-to-load-a-youtube-video-or-youtube-livestream-channel-to-your-android-application-4ffc</link>
      <guid>https://dev.to/mozeago/jetpack-compose-loadinghow-to-load-a-youtube-video-or-youtube-livestream-channel-to-your-android-application-4ffc</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr7p4md9tk3ix9ckt1a2o.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr7p4md9tk3ix9ckt1a2o.jpeg" alt="Jetpack Compose Loading/How to load a YouTube video or YouTube Livestream channel to your Android application"&gt;&lt;/a&gt;&lt;br&gt;
I recently got an Android job to develop a Local Church TV android application. My choice was to go with the latest tech stack on the Android application. One of the features they wanted be implemented was the YouTube live stream to be loaded into the app. I had to research the best way to implement it, and the library: &lt;code&gt;implementation("com.pierfrancescosoffritti.androidyoutubeplayer:core:12.1.0")&lt;/code&gt; became handy in this. I will outline the steps you may follow to have your YouTube or video loaded into the Jetpack Compose Android application.&lt;/p&gt;

&lt;h2&gt;
  
  
  STEP 1
&lt;/h2&gt;

&lt;p&gt;On your Android studio, left-hand side of the editor, open the &lt;code&gt;project explorer&lt;/code&gt;, expand the Gradle folder to get to the &lt;code&gt;build.gradle--Module:app&lt;/code&gt; as in the image below&lt;br&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxr2mrb94bm37vz4geg5c.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxr2mrb94bm37vz4geg5c.jpeg" alt="com.pierfrancescosoffritti.androidyoutubeplayer:core:12.1.0"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
open the file. I like separating my third-party dependencies from the default editor dependencies, so I will have the&lt;br&gt;&lt;br&gt;
&lt;code&gt;//    third-party dependencies&lt;br&gt;
    implementation("com.pierfrancescosoffritti.androidyoutubeplayer:core:12.1.0")&lt;br&gt;
//    end third-party dependencies&lt;/code&gt; loaded to the build.gradle file. Sync the project and test running the application on your device to confirm the import didn't break the application.  &lt;/p&gt;

&lt;h2&gt;
  
  
  STEP 2
&lt;/h2&gt;

&lt;p&gt;Create a composable,  for this case, I have called it &lt;code&gt;LiveTvScreen&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

@Composable
fun LiveTvScreen(
    videoId: String
) {
    val ctx = LocalContext.current
        AndroidView(factory = {
            var view = YouTubePlayerView(it)
            val fragment = view.addYouTubePlayerListener(
            object : AbstractYouTubePlayerListener() {
                override fun onReady(youTubePlayer: 
            YouTubePlayer) {
                    super.onReady(youTubePlayer)
                    youTubePlayer.loadVideo(videoId, 0f)
                }
            }
        )
        view
    })} 


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Then in your &lt;code&gt;MainActivity&lt;/code&gt; load the &lt;code&gt;LiveTvScreen&lt;/code&gt;composable as below.  &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            LiveTvScreen("BJ3Yv572V1A")
           //'BJ3Yv572V1A' is the channel ID from 
           https://youtu.be/BJ3Yv572V1A
        }
    }
} 


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;That it, when you run the application, it should show as the first image shown in this article. Thank you.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Jetpack compose creating a Column or Row composable with rounded corners on the edges; border-radius</title>
      <dc:creator>Moses Asiago</dc:creator>
      <pubDate>Fri, 24 Nov 2023 07:14:48 +0000</pubDate>
      <link>https://dev.to/mozeago/jetpack-compose-creating-a-column-or-row-composable-with-rounded-corners-on-the-edges-border-radius-ef</link>
      <guid>https://dev.to/mozeago/jetpack-compose-creating-a-column-or-row-composable-with-rounded-corners-on-the-edges-border-radius-ef</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnceuoth60fo0wvn0y5xg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnceuoth60fo0wvn0y5xg.png" alt="Row composable with rounded corners on the edges; border-radius"&gt;&lt;/a&gt;&lt;br&gt;
I had a task recently of converting an Android application design made from Adobe XD to a functioning Android application in Jetpack Compose.&lt;br&gt;
To achieve the above image with &lt;code&gt;topStart&lt;/code&gt; and &lt;code&gt;topEnd&lt;/code&gt; with rounded corners we follow the below steps.&lt;/p&gt;

&lt;h3&gt;
  
  
  STEP:
&lt;/h3&gt;

&lt;p&gt;Create your main Row composable, and add two Columns inside it as the below code:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

Row(
                modifier = Modifier
                    .align(CenterHorizontally)
                    .fillMaxWidth()
                    .padding(start = 10.dp, top = 5.dp, end = 10.dp, bottom = 0.dp)
            ) {
                Column(
                    modifier = Modifier
                        .clip(
                            RoundedCornerShape(
                                topStart = 20.dp,
                            )
                        )
                        .sizeIn(73.dp)
                        .background(Color(android.graphics.Color.parseColor("#E80000"))),
                ) {
                    Text(
                        style = LocalTextStyle.current.merge(
                            TextStyle(
                                color = Color(0xFFF67C37),
                                fontSize = 80.sp / LocalDensity.current.fontScale,
                                drawStyle = Stroke(width = 6f, join = StrokeJoin.Round)
                            )
                        ),
                        modifier = Modifier.padding(10.dp),
                        text = "LIVE",
                        color = Color.White,
                        fontSize = 39.sp / LocalDensity.current.fontScale,
                        fontFamily = FontFamily(Font(R.font.headlines_regular, FontWeight.Normal)),

                        )
                }
                Column(
                    modifier = Modifier
                        .clip(
                            RoundedCornerShape(
                                topEnd = 20.dp
                            )
                        )
                        .background(Color.White)
                        .padding(16.dp)
                ) {
                    Text(
                        text = "everyday",
                        color = Color(android.graphics.Color.parseColor("#FC830C")),
                        fontStyle = FontStyle.Normal,
                        fontSize = 40.sp / LocalDensity.current.fontScale,
                        fontFamily = FontFamily(Font(R.font.flood_std_regular, FontWeight.Normal)),
                        modifier = Modifier.align(Alignment.CenterHorizontally)
                    )
                    Row {
                        Column(modifier = Modifier.padding(5.dp)) {
                            Row() {
                                Image(
                                    painter = painterResource(id = R.drawable.ic_youtube),
                                    contentDescription = "youtube logo image",
                                    modifier = Modifier
                                        .size(32.dp, 32.dp)
                                )
                                Image(
                                    painter = painterResource(id = R.drawable.ic_facebook),
                                    contentDescription = "facebook logo image",
                                    modifier = Modifier.size(32.dp, 32.dp)
                                )
                            }
                            Column {
                                Text(
                                    text = "@Truelight Andrew",
                                    color = Color.Black,
                                    fontSize = 14.sp / LocalDensity.current.fontScale,
                                    fontFamily = FontFamily(
                                        Font(
                                            R.font.headlines_regular, FontWeight.Normal
                                        )
                                    ),
                                )
                            }
                        }
                        Column {
                            Image(
                                painter = painterResource(id = R.drawable.ic_facebook),
                                contentDescription = "truelight tv website address",
                                modifier = Modifier.size(32.dp, 32.dp)
                            )
                            Text(
                                text = "www.truelighttv.co.ke",
                                color = Color.Black,
                                fontSize = 14.sp / LocalDensity.current.fontScale,
                                fontFamily = FontFamily(
                                    Font(
                                        R.font.headlines_regular, FontWeight.Normal
                                    )
                                ),
                            )
                        }
                    }
                }
            }
        }


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From the above code, notice the &lt;code&gt;.clip( RoundedCornerShape(topStart = 20.dp))&lt;/code&gt;, this is the one responsible for making the rounded corner on the &lt;code&gt;topStart&lt;/code&gt; of the Red &lt;code&gt;Column&lt;/code&gt; and the &lt;code&gt;topEnd&lt;/code&gt; of the white &lt;code&gt;Column&lt;/code&gt;&lt;code&gt;.clip(RoundedCornerShape(topEnd = 20.dp))&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I hope this gives you what you wanted to achieve.cheers! Like and share&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
