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
plugins { | |
id 'com.android.application' | |
id 'kotlin-android' | |
// id 'kotlin-kapt' not needed anymore | |
id "com.google.devtools.ksp" version "1.6.10-1.0.2" | |
} | |
dependencies { | |
... | |
implementation "androidx.room:room-runtime:$room_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
import timber.log.Timber | |
inline fun logDebug(message: () -> String) { | |
Timber.d(message()) | |
} | |
inline fun logInfo(message: () -> String) { | |
Timber.i(message()) | |
} |
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
import androidx.lifecycle.* | |
inline fun <T> Resource<T>.mapData(crossinline mapper: (T) -> T?): Resource<T> { | |
val data = this.toData() ?: return this | |
val processedData = mapper(data) | |
return when (this) { | |
is Resource.Progress -> Resource.loading(progression, processedData) | |
is Resource.Success -> Resource.success(processedData) | |
is Resource.Failure -> Resource.failure(this.throwable, processedData) |
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
import android.content.Context | |
import android.graphics.Color | |
import android.graphics.PorterDuff | |
import android.graphics.PorterDuffColorFilter | |
import android.graphics.Typeface | |
import android.graphics.drawable.GradientDrawable | |
import android.view.LayoutInflater | |
import android.view.View | |
import android.view.ViewGroup | |
import android.view.WindowManager |
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
@Entity(tableName = "favorites") | |
public class Movie implements Parcelable { | |
@Ignore | |
private double popularity; | |
private int vote_count; | |
private boolean video; | |
private String poster_path; | |
private int id; | |
@Ignore |
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 BlogAdapter(private val listener: BlogItemListener) : RecyclerView.Adapter<BlogViewHolder>() { | |
interface BlogItemListener { | |
fun onClickedBlog(blogTitle: CharSequence) | |
} | |
private val items = ArrayList<Blog>() | |
private lateinit var blog: Blog | |
fun setItems(items: ArrayList<Blog>) { |
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
@ExperimentalCoroutinesApi | |
@AndroidEntryPoint | |
class MainActivity : AppCompatActivity(), BlogAdapter.BlogItemListener { | |
private val viewModel: MainViewModel by viewModels() | |
private lateinit var adapter: BlogAdapter | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
setupRecyclerView() |
NewerOlder