Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".CoinDetailActivity"
android:name=".presentation.CoinDetailActivity"
android:exported="false" />
<activity
android:name=".CoinPriceListActivity"
android:name=".presentation.CoinPriceListActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.example.cryptoapp.database
package com.example.cryptoapp.data.database

import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import com.example.cryptoapp.pojo.CoinPriceInfo
import com.example.cryptoapp.data.model.CoinPriceInfo

@Database(entities = [CoinPriceInfo::class], version = 1, exportSchema = false)
abstract class AppDatabase : RoomDatabase() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.example.cryptoapp.database
package com.example.cryptoapp.data.database

import androidx.lifecycle.LiveData
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.example.cryptoapp.pojo.CoinPriceInfo
import com.example.cryptoapp.data.model.CoinPriceInfo

@Dao
interface CoinPriceInfoDao {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.cryptoapp.pojo
package com.example.cryptoapp.data.model

import com.google.gson.annotations.Expose
import com.google.gson.annotations.SerializedName
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.cryptoapp.pojo
package com.example.cryptoapp.data.model

import com.google.gson.annotations.Expose
import com.google.gson.annotations.SerializedName
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.example.cryptoapp.pojo
package com.example.cryptoapp.data.model

import androidx.room.Entity
import androidx.room.PrimaryKey
import com.example.cryptoapp.api.ApiFactory.BASE_IMAGE_URL
import com.example.cryptoapp.data.network.ApiFactory.BASE_IMAGE_URL
import com.example.cryptoapp.utils.convertTimestampToTime
import com.google.gson.annotations.Expose
import com.google.gson.annotations.SerializedName
Expand Down Expand Up @@ -128,6 +128,7 @@ data class CoinPriceInfo(
@Expose
val imageUrl: String?
) {

fun getFormattedTime(): String {
return convertTimestampToTime(lastUpdate)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.cryptoapp.pojo
package com.example.cryptoapp.data.model

import com.google.gson.JsonObject
import com.google.gson.annotations.Expose
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.cryptoapp.pojo
package com.example.cryptoapp.data.model

import com.google.gson.annotations.Expose
import com.google.gson.annotations.SerializedName
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.cryptoapp.api
package com.example.cryptoapp.data.network

import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.example.cryptoapp.api
package com.example.cryptoapp.data.network

import com.example.cryptoapp.pojo.CoinInfoListOfData
import com.example.cryptoapp.pojo.CoinPriceInfoRawData
import com.example.cryptoapp.data.model.CoinInfoListOfData
import com.example.cryptoapp.data.model.CoinPriceInfoRawData
import io.reactivex.Single
import retrofit2.http.GET
import retrofit2.http.Query
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/java/com/example/cryptoapp/domain/CoinInfo.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.example.cryptoapp.domain

data class CoinInfo(
val fromSymbol: String,
val toSymbol: String?,
val price: String?,
val lastUpdate: Long?,
val highDay: String?,
val lowDay: String?,
val lastMarket: String?,
val imageUrl: String?
)
10 changes: 10 additions & 0 deletions app/src/main/java/com/example/cryptoapp/domain/CoinRepository.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.example.cryptoapp.domain

import androidx.lifecycle.LiveData

interface CoinRepository {

fun getCoinInfoList(): LiveData<List<CoinInfo>>

fun getCoinInfo(fromSymbol: String): LiveData<CoinInfo>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.example.cryptoapp.domain

class GetCoinInfoListUseCase(private val repository: CoinRepository) {

operator fun invoke() = repository.getCoinInfoList()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.example.cryptoapp.domain

class GetCoinInfoUseCase(private val repository: CoinRepository) {

operator fun invoke(fromSymbol: String) = repository.getCoinInfo(fromSymbol)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.cryptoapp
package com.example.cryptoapp.presentation

import android.content.Context
import android.content.Intent
Expand All @@ -8,6 +8,7 @@ import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import com.example.cryptoapp.R
import com.squareup.picasso.Picasso

class CoinDetailActivity : AppCompatActivity() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.example.cryptoapp
package com.example.cryptoapp.presentation

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.RecyclerView
import com.example.cryptoapp.adapters.CoinInfoAdapter
import com.example.cryptoapp.pojo.CoinPriceInfo
import com.example.cryptoapp.R
import com.example.cryptoapp.presentation.adapters.CoinInfoAdapter
import com.example.cryptoapp.data.model.CoinPriceInfo

class CoinPriceListActivity : AppCompatActivity() {

Expand All @@ -29,7 +30,7 @@ class CoinPriceListActivity : AppCompatActivity() {
rvCoinPriceList.adapter = adapter
viewModel = ViewModelProvider(this)[CoinViewModel::class.java]
viewModel.priceList.observe(this, Observer {
adapter.coinInfoList = it
adapter.coinInfoList = it
})
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.example.cryptoapp
package com.example.cryptoapp.presentation

import android.app.Application
import android.util.Log
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
import com.example.cryptoapp.api.ApiFactory
import com.example.cryptoapp.database.AppDatabase
import com.example.cryptoapp.pojo.CoinPriceInfo
import com.example.cryptoapp.pojo.CoinPriceInfoRawData
import com.example.cryptoapp.data.network.ApiFactory
import com.example.cryptoapp.data.database.AppDatabase
import com.example.cryptoapp.data.model.CoinPriceInfo
import com.example.cryptoapp.data.model.CoinPriceInfoRawData
import com.google.gson.Gson
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.schedulers.Schedulers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.cryptoapp.adapters
package com.example.cryptoapp.presentation.adapters

import android.content.Context
import android.view.LayoutInflater
Expand All @@ -8,7 +8,7 @@ import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.example.cryptoapp.R
import com.example.cryptoapp.pojo.CoinPriceInfo
import com.example.cryptoapp.data.model.CoinPriceInfo
import com.squareup.picasso.Picasso

class CoinInfoAdapter(private val context: Context) :
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_coin_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".CoinDetailActivity">
tools:context=".presentation.CoinDetailActivity">

<ImageView
android:id="@+id/ivLogoCoin"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_coin_prce_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".CoinPriceListActivity">
tools:context=".presentation.CoinPriceListActivity">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvCoinPriceList"
Expand Down