Skip to content

Commit

Permalink
Integrated NEWS
Browse files Browse the repository at this point in the history
  • Loading branch information
adityasimant committed Nov 9, 2022
1 parent 317669f commit 698f39f
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.example.cryptorobin.Fragments

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.View.GONE
import android.view.ViewGroup
import android.webkit.WebView
import android.webkit.WebViewClient
import com.example.cryptorobin.R
import com.example.cryptorobin.databinding.FragmentNewsBinding

class NewsFragment : Fragment() {

private lateinit var binding : FragmentNewsBinding
// var API_KEY : String = "bd8124378ae248d1abf8c02cf3d6bbf0"

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {

binding = FragmentNewsBinding.inflate(layoutInflater)


binding.NewsWebiew.settings.javaScriptEnabled = true
binding.NewsWebiew.webViewClient = object :WebViewClient(){
override fun onPageFinished(view: WebView?, url: String?) {
super.onPageFinished(view, url)
binding.spinKitNView.visibility = GONE

}

}




binding.NewsWebiew.loadUrl("https://www.cnbc.com/finance/")




return binding.root
}

}
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_baseline_article_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:autoMirrored="true" android:height="24dp"
android:tint="#FFFFFF" android:viewportHeight="24"
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M19,3L5,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2zM14,17L7,17v-2h7v2zM17,13L7,13v-2h10v2zM17,9L7,9L7,7h10v2z"/>
</vector>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/currency_item_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
android:layout_marginStart="12dp"
android:layout_marginEnd="8dp"
android:textColor="@color/white"
android:textSize="14sp"
android:textSize="17sp"
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="@+id/currencyPriceTextView"
app:layout_constraintStart_toEndOf="@+id/currencyImageView"
Expand Down
33 changes: 33 additions & 0 deletions app/src/main/res/layout/fragment_news.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/DarkBlue"
tools:context=".Fragments.NewsFragment">

<WebView
android:id="@+id/NewsWebiew"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:background="@color/DarkBlue"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<com.github.ybq.android.spinkit.SpinKitView
style="@style/SpinKitView.ThreeBounce"
android:id="@+id/spinKitNView"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:visibility="visible"
app:SpinKit_Color="@color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
8 changes: 7 additions & 1 deletion app/src/main/res/menu/bottom_nav.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@
<item android:id="@+id/watchlistFragment"
android:enabled="true"
android:icon="@drawable/ic_baseline_bookmark_24"
android:title="Watchlist"
android:title="Saved"
app:showAsAction="always"/>

<item android:id="@+id/NewsFragment"
android:enabled="true"
android:icon="@drawable/ic_baseline_article_24"
android:title="News"
app:showAsAction="always"/>


Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/navigation/nav.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,9 @@
android:id="@+id/action_detailsFragment_to_homeFragment"
app:destination="@id/homeFragment" />
</fragment>
<fragment
android:id="@+id/NewsFragment"
android:name="com.example.cryptorobin.Fragments.NewsFragment"
android:label="fragment_news"
tools:layout="@layout/fragment_news" />
</navigation>

0 comments on commit 698f39f

Please sign in to comment.