Coroutines with Retrofit



Project Structure

Project 
  • build.gradle
  • MyAPI.kt
  • MyInterceptor.kt
  • Comment.kt
  • Manifest.xml
  • MainActivity.kt
  • MainActivityWithCt.kt

 retrofit without coroutines

build.gradle

dependencies {

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9")
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.3'
}

MyAPI.kt
import com.rayhub.coroutinesretrofit.data.Comment
import retrofit2.Call
import retrofit2.Response
import retrofit2.http.GET

interface MyAPI {

//Coroutines
@GET("/comments")
fun getComments(): Response<List<Comment>>

//Default
@GET("/comments")
fun getCommentsCall(): Call<List<Comment>>
}

MyInterceptor.kt
import okhttp3.Interceptor
import okhttp3.Response

class MyInterceptor : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
val request = chain.request()
.newBuilder()
.addHeader("Context-Type", "application/json")
.build()
return chain.proceed(request)
}
}

Manifest.xml


<uses-permission android:name="android.permission.INTERNET" />


Comment.kt
data class Comment(
val body: String,
val email: String,
val id: Int,
val name: String,
val postId: Int
)

MainActivity.kt

package com.rayhub.coroutinesretrofit

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import com.rayhub.coroutinesretrofit.api.MyAPI
import com.rayhub.coroutinesretrofit.api.MyInterceptor
import com.rayhub.coroutinesretrofit.data.Comment
import okhttp3.OkHttpClient
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import okhttp3.logging.HttpLoggingInterceptor


const val BASE_URL = "https://jsonplaceholder.typicode.com"

class MainActivity : AppCompatActivity() {

val TAG = "MainActivity"

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

val logging : HttpLoggingInterceptor = HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)
var client = OkHttpClient.Builder().apply {
addInterceptor(MyInterceptor())
addInterceptor(logging)
}.build()

val api = Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.client(client)
.build()
.create(MyAPI::class.java)

api.getComments().enqueue(object : Callback<List<Comment>>{
override fun onFailure(call: Call<List<Comment>>, t: Throwable) {
Log.e(TAG, "ERROR: $t")
}

override fun onResponse(call: Call<List<Comment>>, response: Response<List<Comment>>) {
if(response.isSuccessful){
response.body()?.let {
for (comment in it){
Log.d(TAG, comment.toString())
}
}
}
}
})

}
}

retrofit with coroutines

MainActivityWithCt.kt


import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import com.rayhub.coroutinesretrofit.api.MyAPI
import com.rayhub.coroutinesretrofit.api.MyInterceptor
import com.rayhub.coroutinesretrofit.data.Comment
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import okhttp3.Dispatcher
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.*
import retrofit2.converter.gson.GsonConverterFactory
import kotlin.math.log

class MainActivityWithCt : AppCompatActivity() {

val BASE_URL = "https://jsonplaceholder.typicode.com"
val TAG = "MainActivity"

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main_with_ct)

val logging : HttpLoggingInterceptor = HttpLoggingInterceptor().setLevel(
HttpLoggingInterceptor.Level.BODY)
var client = OkHttpClient.Builder().apply {
addInterceptor(MyInterceptor())
addInterceptor(logging)
}.build()

val api = Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.client(client)
.build()
.create(MyAPI::class.java)

// GlobalScope.launch(Dispatchers.IO) {
// val comments = api.getComments().await()
// for (comment in comments){
// Log.d(TAG, comment.toString())
// }
// }

GlobalScope.launch(Dispatchers.IO) {
val response = api.getComments()
if(response.isSuccessful){
for (comment in response.body()!!){
Log.d(TAG, comment.toString())
}
}
}

}
}

Install/Setup Nodejs 14.17.3(LTS) on cpanel



1. Log in to your account using SS

2. Download the NodeJS

wget https://nodejs.org/dist/latest/node-v14.17.3-linux-arm64.tar.xz

 

3. Extract

tar xvf node-v14.17.3-linux-arm64.tar.xz

 

4. Now rename the folder to nodejs name, to do this type the following command

mv node-v14.17.3-linux nodejs

 

5. Now install node and npm binaries, type the next commands:

mkdir ~/bin
cp nodejs/bin/node ~/bin
cd ~/bin
ln -s ../nodejs/lib/node_modules/npm/bin/npm-cli.js npm

 

6. Node.js and npm are installed on your account. To verify, type the following commands

node --version
npm --version

 

7. Start Node.js Application

npm start

 

9. Integrating a Node.js application with the web server(optional)

In a text editor, add the following lines to the .htaccess file in the/home/username/public_html directory

RewriteEngine On
RewriteRule ^$ http://127.0.0.1:portno/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1:portno/$1 [P,L]

 

Using Flash in Nodejs ejs


 Flash ကို အသုံးပြုဖို့ အရင်ဆုံး flash ကို install လုပ်ဖို့ လိုပါမယ်..


npm i express-flash --save


app.js မှာ express flash ကို import လုပ်ပါ


const flash = require('express-flash');


var app = express();


app.use(flash());


ejs မှာ

<% if (messages.error) { %>
          <div class="alert alert-danger"><%- messages.error %></div>
        <% } %>
        <% if (messages.success) { %>
          <div class="alert alert-success"><%- messages.success %></div>
 <% } %>


controller မှာ

req.flash('error'"Password not match!");



Installing Yeoman | Brower and Grunt Cli in ubuntu


 Nodejs Scaffold Generator တစ်ခုဖြစ်တဲ့ yeoman , package Manager ဖြစ်တဲ့ bower နဲ့ Build tool တစ်ခုဖြစ်တဲ့ grunt-cli ကို global အနေနဲ့ install ပြုလုပ်ခြင်း

sudo apt-get install nodejs nodejs-legacy

sudo npm install -g yo bower grunt-cli

 

နမူနာ boilerplate generator များ အဆင်သင့် install ပြုလုပ်ထားခြင်း


sudo npm install -g generator-webapp

sudo npm install -g generator-backbone

 

Thanks.

youtube channel apis


23To get channels list :
Get Channels list by forUserName:
Get channels list by channel id:
Get Channel sections:
To get Playlists :
Get Playlists by Channel ID:
Get Playlists by Channel ID with pageToken:
To get PlaylistItems :
Get PlaylistItems list by PlayListId:
To get videos :
Get videos list by video id:
Get videos list by multiple videos id:
Get comments list
Get Comment list by video ID:
Get Comment list by channel ID:
Get Comment list by allThreadsRelatedToChannelId:
Here all api's are Get approach.
Based on channel id we con't get all videos directly, that's the important point here.

Git - Version Control System


Git ကို install လုပ်ပါ
terminal ထဲမှာ အသုံးပြုသူရဲ့ နာမည်နဲ့ email ကို git config လုပ်ပါ
git config --global user.name "username"
git config --global user.email "username@mail.com"
version မှတ်တမ်းတင်မယ့် folder တစ်ခု create လုပ်ပါ
mkdir git-work-flow
folder ထဲသို့ဝင်ပါ
cd git-work-flow
အသုံးပြုမယ့် folder သို့မဟုတ် မိမိဖန်တီးခဲ့တဲ့ folder ကို initialized လုပ်ပေးပါ
git init
project နဲ့သက်ဆိုင်တဲ့ file တွေ အလုပ်တွေ စလုပ်ပါ။ ပြီးရင် version control စလုပ်ပါ
git status
version control လုပ်ရန်ဖိုင်များကိုတွေ့ရမည်ဖြစ်ပါသည်
၎င်းဖိုင်များအား စတင်မှတ်တမ်းတင်ရန် vcs folder ထဲသို့ ထည့်ပေးပါ
git add .
git status
version control စတင်မှတ်တမ်းတင်နိုင်ပါပြီ
git commit -m "first commit"
ဖိုင်အသစ်တွေဖန်တီးပါ git status နဲ့ကြည့်ပါ
git add .
git commit -m "second commit"
version မှတ်တမ်းများကို ပြန်ကြည့်ရန် git log ကို သုံးပါ

git log (or) 
git log --pretty=oneline 
သိမ်းဆည်းထားတဲ့ version မှတ်တမ်းကို အပြန်အလှန်သွားရန် hash id ကိုရယူပါ
git checkout  hashidကိုcopyယူထည့်ပါ (ပထမ commit သို့သွားရန်)
git checkout master  (နောက်ဆုံး commit သို့သွားရန်)
hash id နဲ့မသွားပဲ tag ပေးပြီးသွားလို့လည်းရပါတယ်
git checkout  629524d55ab8c0ffb00d6d0adcdda4c27363d7a7 
git tag 13.1.2020 (date ပဲဖြစ်ဖြစ် version no ပဲဖြစ်ဖြစ်ပေးပါ)
branch ခွဲပြီးမှတ်တမ်းတင်နည်း (စမ်းသပ်ဖြည့်စွက်လိုသော တစ်ချို့ code method တွေကိုစမ်းလို့ရအောင်)
main code base ကနေ branch ခွဲထုတ်ပြီးပြင်ဆင်ဖြည့်စွက်နည်း
git branch
git branch branchname
git checkout branchname 
code အသစ်ထပ်ထည့်ပါ
git add .
git commit "third commit"
git log --pretty=oneline 

branch code တွေကို main code base တွင်ပေါင်းစပ်နည်း
git checkout master
git merge branchname

team အဖွဲ့လိုက် module ပေါင်းစပ်ရေးသားနည်း (github server အသုံးပြုပြီး)
1. git clone (ရှိပြီးသား git repo ကို copy လုပ်နည်း)
git clone  ./git-work-flow  git-work-flow-two
2.git pull (မူရင်း repo လုပ်ဆောင်ချက်များကို clone repo မှ ရယူခြင်း)
clone repo ထဲသွားပါ
git pull origin master
3.git push (clone repo ကပြုလုပ်ချက်များကို မူရင်း repo သို့ လှမ်းပို့ခြင်း)

TalKie Droid Android Application (Beta Version)




App Name : TalKie Droid Android Application
Developer : Moe Kyaw Soe (Gateway Technology)
Version : Beta
Release Date : 10.10.2019

Download Links

GDirect
https://drive.google.com/uc?export=download&id=1-aUdJERSFGMwfzC52jLV_44HLX68-kZF

GDrive
https://drive.google.com/file/d/1-aUdJERSFGMwfzC52jLV_44HLX68-kZF/view?usp=sharing

ShortLink
http://bit.ly/33sCMrg

OneDrive
https://1drv.ms/u/s!ApugiICvemEGkBV8d2RYP9U_BQuv?e=JrmWr0
MediaFire
http://www.mediafire.com/file/fipndeaivdnr24p/base.apk/file

Talkie Droid အသုံးပြုနည်း


Unicode
Talkie Droid Android App သည် wifi ကိုအသုံးပြုပြီး mobile phone အချင်းချင်းစကားပြောသည့်စနစ်ဖြစ်သဖြင့် စမ်းသပ်အသုံးပြုရန် user နှစ်ဦးလိုအပ်မည်။
walkie tolkie အစား wifi အသုံးပြုပြီး android phone ဖြင့်စကားပြောနိုင်မည်ဖြစ်သည်။

Router ဖြင့်အသုံးပြုနည်း

  • Router wifi ကို အသုံးပြုမည့် android phone / android tablet များတွင် access လုပ်ပါ
  • software ကိုဖွင့်ပါ
  • software ထဲတွင် user access ဖြစ်ပါက mic button ကိုနှိပ်ပြီးစကားပြောနိုင်ပါသည်
  • wifi connection အားနည်းပါက စကားမပြောမီ ၂ စက္ကန့် နှိပ်ပြီးနှင့်စကားပြောပြီး ၂ စက္ကန့်နေမှ button ကိုလွှတ်ပါ
  • setting ထဲက use volume buttons to talk ကို အမှန်ခြစ်ထားပါက အခြား software တစ်ခုကိုအသုံးပြုနေရင်း volume button ကိုနှိပ်ပြီးစကားပြောနိုင်ပါသည်
  • Station Name ကို လုပ်ငန်းသုံးဆိုပါက မိမိတာဝန်ယူထားသည့်အပိုင်းကို ရေးထားပါ

Mobile Hostpot ဖြင့်အသုံးပြုနည်း

  • Mobile ဖုန်း ၂ လုံးဖြင့်စမ်းသပ်ပါက တစ်လုံးကို mobile hotspot လုပ်ထားပါ
  • နောက်တစ်လုံးမှ wifi ဖွင့်ပြီး hotspot ကို access လုပ်ပါ
  • software ထဲတွင် user access ဖြစ်ပါက စကားစမ်းပြောကြည့်ပါ
ကျေးဇူးတင်ပါသည်
beta version ဖြစ်သောကြောင့် အဆင်မပြေမှုများရှိပါက moekyawsoe109@gmail.com သို့ 09253268310 သို့အကြောင်းကြားနိုင်ပါသည်

Zawgyi
Talkie Droid Android App သည္ wifi ကိုအသုံးျပဳၿပီး mobile phone အခ်င္းခ်င္းစကားေျပာသည့္စနစ္ျဖစ္သျဖင့္ စမ္းသပ္အသုံးျပဳရန္ user ႏွစ္ဦးလိုအပ္မည္။
walkie tolkie အစား wifi အသုံးျပဳၿပီး android phone ျဖင့္စကားေျပာႏိုင္မည္ျဖစ္သည္။

Router ျဖင့္အသုံးျပဳနည္း

  • Router wifi ကို အသုံးျပဳမည့္ android phone / android tablet မ်ားတြင္ access လုပ္ပါ
  • software ကိုဖြင့္ပါ
  • software ထဲတြင္ user access ျဖစ္ပါက mic button ကိုႏွိပ္ၿပီးစကားေျပာႏိုင္ပါသည္
  • wifi connection အားနည္းပါက စကားမေျပာမီ ၂ စကၠန႔္ ႏွိပ္ၿပီးႏွင့္စကားေျပာၿပီး ၂ စကၠန႔္ေနမွ button ကိုလႊတ္ပါ
  • setting ထဲက use volume buttons to talk ကို အမွန္ျခစ္ထားပါက အျခား software တစ္ခုကိုအသုံးျပဳေနရင္း volume button ကိုႏွိပ္ၿပီးစကားေျပာႏိုင္ပါသည္
  • Station Name ကို လုပ္ငန္းသုံးဆိုပါက မိမိတာဝန္ယူထားသည့္အပိုင္းကို ေရးထားပါ

Mobile Hostpot ျဖင့္အသုံးျပဳနည္း

  • Mobile ဖုန္း ၂ လုံးျဖင့္စမ္းသပ္ပါက တစ္လုံးကို mobile hotspot လုပ္ထားပါ
  • က္တစ္လုံးမွ wifi ဖြင့္ၿပီး hotspot ကို access လုပ္ပါ
  • software ထဲတြင္ user access ျဖစ္ပါက စကားစမ္းေျပာၾကည့္ပါ
ေက်းဇူးတင္ပါသည္
beta version ျဖစ္ေသာေၾကာင့္ အဆင္မေျပမႈမ်ားရွိပါက moekyawsoe109@gmail.com သို႔ 09253268310 သို႔အေၾကာင္းၾကားႏိုင္ပါသည္


Ubuntu user များ wordpress themes & plugins တွေ တင်ဖို့ FTP information တောင်းတာကို ဖြေရှင်းနည်း


Xampp အသုံးပြုသူများ
Ubuntu user များ wordpress themes & plugins တွေ တင်ဖို့ FTP information တောင်းတာကို ဖြေရှင်းဖို့ wordpress folder ထဲက wp-config.php မှာ အောက်ပါ command ဖြည့်စွက်ပေးလိုက်ပါ။

define ('FS_METHOD','direct');

Professional Android Developer Roadmap Detail


  1. Programming Language
    1. Kotlin
    2. Java
    3. xml
  2. Android Studio
    1. Debugger
    2. CPU Profiler
    3. Android SDK
      1. Android Debug Bridge
      2. Emulator
      3. SDK Manager
  3. App Manifest
    1. Data Backup
    2. Permissions
  4. App Components
    1. Activity
      1. Activity Lifecycle
      2. Tasks & Backstack
    2. Fragment
      1. Fragment Manager
      2. Fragment Transaction
      3. Fragment Lifecycle
    3. Broadcast Receiver
    4. Service
      1. Notifications
        1. Notification Channels
      2. Intent Service
    5. Intent
      1. Intent Filters
      2. Implict Intents
      3. Explict Intents
  5. User Interface
    1. Resources
      1. Strings
        1. Localizable Strings
        2. Quantity Strings
        3. String Array
        4. Spans
      2. Fonts
        1. xml fonts
        2. Downloadable fonts
      3. Styles
        1. Styleables
        2. Themes
      4. Drawables
        1. Adaptative Icons
        2. Vector Drawables
        3. Animation Drawables
        4. Bitmap
        5. Mipmap
    2. UI Components
      1. Input Fields – Input Methods
      2. Clickable Components
      3. AppBar / Toolbar
      4. Adapter View
      5. Multimedia Components
        1. Image Loaders
        2. Picasso
        3. Glide
    3. UI Layouts
      1. Linear Layout
      2. Constraint Layout
      3. Relative Layout
      4. Frame Layout
      5. Recycler View
  6. More User Interface
    1. Progress Bar
    2. Spinner
    3. Search Interface
    4. Toast & Snackbar
    5. Dialogs & Pickers
  7. Storage
    1. Data Storage
      1. SQLite
      2. Shared Preferences
      3. Realm
    2. File Storage
      1. File Provider
  8. Architecture
    1. Quality Assurance
      1. Linters
        1. Delekt
        2. KtLint
        3. Android Lint
      2. Tests
        1. Espresso
        2. Robolectric
        3. UI Automator
        4. JUnit
      3. Unit Tests
      4. Integration Tests
      5. Instrumentation Tests
      6. Somke Tests
    2. Dependency Injection
      1. Koin
      2. Kodein
      3. Dagger
    3. Code Architecture
      1. MVVM (Model – View – ViewModel)
      2. MVP (Model – View – Presenter)
      3. MVI ( Model – View – Intent)
      4. MVC (Model – View – Controller)
      5. VIPER
  9. Build Configuration
    1. Build Types
    2. Build Flavors
    3. Gradle
      1. Groovy
  10. Thread Handling
    1. Handlers
    2. Coroutines
    3. Async Task
  11. Network Handling
    1. Retrofit
    2. Volley
    3. Json Conventers
      1. Gson
      2. Moshi
  12. Android jetpack
    1. Material Design
    2. Emoji
    3. Navigation
    4. Data binding
    5. Architecture Components
    6. Androidx
      1. Support Library
    7. Multidex
      1. Slices
  13. Architecture Components
    1. Room (SQlite)
    2. Livedata
    3. ViewModel
    4. Paging Library
    5. WorkManager (Thread Handling)
  14. Google Libraries
    1. Firebase
      1. Authentication
      2. Firestore
      3. Remote Config
      4. ML Kit
      5. Analytics & Crashlytics
      6. Test lab
      7. Cloud Messaging
      8. App Indexing
      9. Dynamic Links
    2. Google Play Services
      1. Google Maps
  15. Security
    1. Proguard
    2. Keystore
  16. Sensors
    1. Position
    2. Enviroment
    3. Motion
    4. Camera
  17. Content Providers
    1. Contact Provider
    2. Calendar Provider
  18. Animation
    1. Object Animation
    2. Transition
  19. App Publishing
    1. Play Store
      1. App Billing
      2. App Links
      3. App Actions
      4. Intant Apps
    2. App APK
      1. App Bundle
  20. Accessibility
    1. Screen Readers
  21. Android Auto
    1. Android TV
    2. Android Wear
    3. Android Things
  22. Hybrid
    1. Flutter
    2. React Native
    3. Xamarin
    4. Ionic / Cordova
  23. Connectivity
    1. Download Manger
      1. Sync Adapter
      2. Connectivity Manager
    2. Wifi
      1. Telecom (SIM Card)
      2. Bluetooth
      3. NFC

STOICHIOMETRY


Stoichiometry

Stoichiometry is part of chemistry which deals with the quantities of substance taking part in chemical reactions is called stoichiometry.

One mole of a substance

One mole of a substance is the amount of that substance which contains the same number of particles as there are atoms in 12g of 12C.

mole = mass ( g ) / molar mass

1 mole = 1000 millimoles 

Java Identifiers


Java Identifiers ဆိုသည်မှာ Programming ဘာသာရပ်တစ်ခု၏ အမည်ပေးစနစ်ဖြစ်သည်။
Identifiers Naming System မှာအောက်ပါအတိုင်းဖြစ်သည်။

  1. A to Z အက္ခရာများဖြင့်စရမည်။ (eg. num1; (true) 1num(false)
  2. $ နှင့် (_) များဖြင့်စနိုင်သည်။ (eg. $dog; / _dog;)
  3. Class Name ကိုသာ အကြီးနဲ့စ။
  4. unknown character စသုံး၍မရ။
  5. keywords များသုံး၍မရ။
  6. Case Sensitive ဖြစ်ရမည်။

Java Basic Syntax


Java Program တစ်ခုကို Object များဖြင့်တည်ဆောက်နိုင်ပြီး သူ၏ method များဖြင့် ဆက်သွယ်ထားသည်။

Object တစ်ခုမှာ state နှင့် behaviours များရှိသည်။ ဥပမာ - ခွေးသည် object ဖြစ်ပြီး အဖြူရောင်အမွေးအမျှင်များရှိသည်မှာ ခွေး၏ state ဖြစ်သည်။ ၎င်းခွေးသည် အိပ်သည် စားသည်မှာ behaviours ဖြစ်သည်။
Object ဆိုသည်မှာ class တစ်ခုမှ​ မွေးဖွားလာခြင်းဖြစ်သည်။

Class ဆိုသည်မှာ ဆိုသည်မှာ object တစ်ခုမှာ ဘယ်လို state တွေ ဘယ်လို behaviour တွေရှိရမည်ဆိုသည်ကို အသေးစိတ်ဖော်ပြထားခြင်းသည်။

Methods သည် behaviours တူသည်။
Instance Variables ဆိုသည်မှာ Object တစ်ခုမှာ မတူညီသော တန်ဖိုးများ ရှိခြင်းဖြစ်သည်။