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 MainActivity: AppCompatActivity() { | |
private var lensFacing = CameraX.LensFacing.BACK | |
private val TAG = "MainActivity" | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
view_finder.post { startCamera() } |
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
// Use the most recent version of CameraX, currently that is alpha04 | |
def camerax_version = "1.0.0-alpha04" | |
implementation "androidx.camera:camera-core:${camerax_version}" | |
implementation "androidx.camera:camera-camera2:${camerax_version}" |
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
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:background="@color/activity_background" | |
android:orientation="vertical"> | |
<com.savyour.util.ui.CustomSwipeToRefresh | |
android:id="@+id/swipe_refresh" |
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
<LinearLayout | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:orientation="vertical"> | |
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout | |
android:id="@+id/swipeRefresh" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content"> |
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
dependencies { configurations -> | |
implementation "android.arch.lifecycle:extensions:1.1.1" | |
annotationProcessor "android.arch.lifecycle:compiler:1.1.1" | |
} |
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
open class MyObseravble : ViewModel() | |
{ | |
val data = MutableLiveData<String>() | |
fun data(item: String) { | |
data.value = item | |
} | |
} |
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
package com.roomdatabase | |
import android.annotation.SuppressLint | |
import android.os.Bundle | |
import android.support.v7.app.AppCompatActivity | |
import android.util.Log | |
import androidx.room.Room | |
class MainActivity : AppCompatActivity() { |
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
//Insert Case | |
val thread = Thread { | |
var bookEntity = BookEntity() | |
bookEntity.bookId = 1 | |
bookEntity.bookName = "Kotlin for Android Developer" | |
db.bookDao().saveBooks(bookEntity) | |
//fetch Records | |
db.bookDao().getAllBooks().forEach() |
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
package com.roomdatabase | |
import androidx.room.Dao | |
import androidx.room.Insert | |
import androidx.room.Query | |
@Dao | |
interface BookDAO | |
{ | |
@Insert |
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
package com.roomdatabase | |
import androidx.room.ColumnInfo | |
import androidx.room.Entity | |
import androidx.room.PrimaryKey | |
@Entity | |
class BookEntity { | |
@PrimaryKey |