[go: nahoru, domu]

Skip to content

Commit

Permalink
added README.md
Browse files Browse the repository at this point in the history
removed unused methods
  • Loading branch information
jarin committed Mar 28, 2022
1 parent 6949d2c commit 9c2a3a4
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 15 deletions.
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# MVI-Pattern

* Click this link [ https://gnews.io/ ] signup and create an api-key,this wont take more than two minutes.
Open Constants file replace the API_KEY with your own api-key.
2 changes: 1 addition & 1 deletion app/src/main/java/com/example/mvipattern/Constants.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.example.mvipattern

object Constants {
const val API_KEY : String = "e3f5358258e8944d4fe9698cf25d453e"
const val API_KEY : String = "api-key" // Replace with your api key
const val BASE_URL : String = "https://gnews.io/api/v4/"
}
4 changes: 1 addition & 3 deletions app/src/main/java/com/example/mvipattern/NewsViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ package com.example.mvipattern

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.mvipattern.NewsIntents
import com.example.mvipattern.NewsStates
import com.example.mvipattern.repository.RepositoryImpl
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.consumeAsFlow
import kotlinx.coroutines.launch

class NewsViewModel() : ViewModel() {
class NewsViewModel : ViewModel() {

val newsChannel = Channel<NewsIntents>()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import retrofit2.http.GET

interface NewsService {

@GET("top-headlines?token=${Constants.API_KEY}")
@GET("top-headlines?lang=en&token=${Constants.API_KEY}")
suspend fun getTopHeadlines() : Response<NewsData>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ import com.example.mvipattern.NewsStates
import kotlinx.coroutines.flow.Flow

interface Repository {
suspend fun getEverything()
suspend fun getTopHeadlines() : Flow<NewsStates>
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ package com.example.mvipattern.repository
import com.example.mvipattern.NewsStates
import kotlinx.coroutines.flow.flow

class RepositoryImpl() : Repository {

override suspend fun getEverything() {

}
class RepositoryImpl : Repository {

override suspend fun getTopHeadlines() = flow {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@

public class RetrofitClient {

private Retrofit retrofit;
private static OkHttpClient.Builder httpClient =
private static final OkHttpClient.Builder httpClient =
new OkHttpClient.Builder();
private static RetrofitClient instance = null;
private static NewsService service = null;
private static HttpLoggingInterceptor logging =
private static final HttpLoggingInterceptor logging =
new HttpLoggingInterceptor();

private RetrofitClient() {
Expand All @@ -33,7 +32,7 @@ private RetrofitClient() {
// add logging as last interceptor
httpClient.addInterceptor(logging);
}
retrofit = new Retrofit.Builder().client(httpClient.build()).
Retrofit retrofit = new Retrofit.Builder().client(httpClient.build()).
baseUrl(Constants.BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
Expand Down

0 comments on commit 9c2a3a4

Please sign in to comment.