forked from ankitbisht/trending-git
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Other resource files updated - App screenshots added - Readme updated
- Loading branch information
ankitb
committed
Sep 10, 2018
1 parent
58c2158
commit f94d336
Showing
22 changed files
with
331 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,14 @@ | ||
# trending-git | ||
Trending Git App | ||
|
||
- MVVM (KOTLIN) | ||
- ViewModel | ||
- LiveData | ||
- Navigation Component | ||
- Data binding | ||
|
||
Screen Shots | ||
|
||
 | ||
 | ||
 |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
14 changes: 14 additions & 0 deletions
14
app/src/main/java/com/ankit/trendinggit/view/adapter/viewHolders/RepoListViewHolder.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,30 @@ | ||
package com.ankit.trendinggit.view.adapter.viewHolders | ||
|
||
import androidx.databinding.ViewDataBinding | ||
import androidx.navigation.findNavController | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.ankit.trendinggit.BR | ||
import com.ankit.trendinggit.R | ||
import com.ankit.trendinggit.model.Item | ||
import com.ankit.trendinggit.view.ui.repolist.RepoListViewModel | ||
import com.squareup.picasso.Picasso | ||
import kotlinx.android.synthetic.main.view_repo_list_item.view.* | ||
import org.jetbrains.anko.bundleOf | ||
import org.jetbrains.anko.sdk25.coroutines.onClick | ||
|
||
class RepoListViewHolder constructor(private val dataBinding: ViewDataBinding, private val repoListViewModel: RepoListViewModel) | ||
: RecyclerView.ViewHolder(dataBinding.root) { | ||
|
||
val avatarImage = itemView.item_avatar | ||
fun setup(itemData: Item) { | ||
dataBinding.setVariable(BR.itemData, itemData) | ||
dataBinding.executePendingBindings() | ||
|
||
Picasso.get().load(itemData.owner.avatar_url).into(avatarImage); | ||
|
||
itemView.onClick { | ||
val bundle = bundleOf("url" to itemData.html_url) | ||
itemView.findNavController().navigate(R.id.action_repoListFragment_to_repoDetailFragment, bundle) | ||
} | ||
} | ||
} |
This file contains 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
82 changes: 82 additions & 0 deletions
82
app/src/main/java/com/ankit/trendinggit/view/ui/repodetail/RepoDetailFragment.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package com.ankit.trendinggit.view.ui.repodetail | ||
|
||
import android.graphics.Bitmap | ||
import android.os.Build | ||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.webkit.WebSettings | ||
import android.webkit.WebView | ||
import android.webkit.WebViewClient | ||
import androidx.fragment.app.Fragment | ||
import com.ankit.trendinggit.R | ||
import kotlinx.android.synthetic.main.fragment_repo_detail.* | ||
import org.jetbrains.anko.sdk25.coroutines.onClick | ||
|
||
|
||
class RepoDetailFragment : Fragment() { | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | ||
return inflater.inflate(R.layout.fragment_repo_detail, container, false) | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
val url = RepoDetailFragmentArgs.fromBundle(arguments).url | ||
|
||
setupWebView() | ||
setClickListeners() | ||
|
||
repo_web_view.loadUrl(url) | ||
} | ||
|
||
private fun setClickListeners() { | ||
repo_back_button.onClick { | ||
repo_web_view.goBack() | ||
} | ||
|
||
repo_forward_button.onClick { | ||
repo_web_view.goForward() | ||
} | ||
|
||
repo_refresh_button.onClick { | ||
repo_web_view.reload() | ||
} | ||
} | ||
|
||
private fun setupWebView() { | ||
repo_web_view.setInitialScale(1) | ||
val webSettings = repo_web_view.settings | ||
webSettings.setAppCacheEnabled(false) | ||
webSettings.builtInZoomControls = true | ||
webSettings.displayZoomControls = false | ||
webSettings.javaScriptEnabled = true | ||
webSettings.useWideViewPort = true | ||
webSettings.domStorageEnabled = true | ||
|
||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | ||
webSettings.mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW; | ||
} | ||
|
||
repo_web_view.webViewClient = object : WebViewClient() { | ||
override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) { | ||
super.onPageStarted(view, url, favicon) | ||
if (repo_back_button != null && repo_forward_button != null && repo_web_view != null && repo_progress_view != null) { | ||
repo_back_button.isEnabled = repo_web_view.canGoBack() | ||
repo_forward_button.isEnabled = repo_web_view.canGoForward() | ||
repo_progress_view.visibility = View.VISIBLE | ||
} | ||
} | ||
|
||
override fun onPageFinished(view: WebView?, url: String?) { | ||
super.onPageFinished(view, url) | ||
if (repo_back_button != null && repo_forward_button != null && repo_web_view != null && repo_progress_view != null) { | ||
repo_back_button.isEnabled = repo_web_view.canGoBack() | ||
repo_forward_button.isEnabled = repo_web_view.canGoForward() | ||
repo_progress_view.visibility = View.GONE | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<vector android:height="24dp" android:tint="#828282" | ||
android:viewportHeight="24.0" android:viewportWidth="24.0" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="#FF000000" android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/> | ||
</vector> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<vector android:height="24dp" android:tint="#828282" | ||
android:viewportHeight="24.0" android:viewportWidth="24.0" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="#FF000000" android:pathData="M12,4l-1.41,1.41L16.17,11H4v2h12.17l-5.58,5.59L12,20l8,-8z"/> | ||
</vector> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<vector android:height="24dp" android:tint="#828282" | ||
android:viewportHeight="24.0" android:viewportWidth="24.0" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="#FF000000" android:pathData="M17.65,6.35C16.2,4.9 14.21,4 12,4c-4.42,0 -7.99,3.58 -7.99,8s3.57,8 7.99,8c3.73,0 6.84,-2.55 7.73,-6h-2.08c-0.82,2.33 -3.04,4 -5.65,4 -3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6c1.66,0 3.14,0.69 4.22,1.78L13,11h7V4l-2.35,2.35z"/> | ||
</vector> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24.0" | ||
android:viewportHeight="24.0"> | ||
<path | ||
android:fillColor="#FF000000" | ||
android:pathData="M12,17.27L18.18,21l-1.64,-7.03L22,9.24l-7.19,-0.61L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21z"/> | ||
</vector> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" | ||
tools:context=".view.ui.MainActivity"> | ||
|
||
<WebView | ||
android:id="@+id/repo_web_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:layout_above="@+id/repo_btn_container" /> | ||
|
||
<RelativeLayout | ||
android:id="@+id/repo_btn_container" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_alignParentBottom="true" | ||
android:padding="@dimen/_20dp"> | ||
|
||
<Button | ||
android:id="@+id/repo_back_button" | ||
android:layout_width="@dimen/_20dp" | ||
android:layout_height="@dimen/_20dp" | ||
android:layout_centerVertical="true" | ||
android:layout_marginStart="@dimen/_20dp" | ||
android:layout_marginEnd="@dimen/_20dp" | ||
android:background="@drawable/ic_arrow_backward" | ||
android:enabled="false" /> | ||
|
||
<Button | ||
android:id="@+id/repo_forward_button" | ||
android:layout_width="@dimen/_20dp" | ||
android:layout_height="@dimen/_20dp" | ||
android:layout_centerVertical="true" | ||
android:layout_marginStart="@dimen/_20dp" | ||
android:layout_marginEnd="@dimen/_20dp" | ||
android:layout_toEndOf="@id/repo_back_button" | ||
android:background="@drawable/ic_arrow_forward" | ||
android:enabled="false" /> | ||
|
||
<Button | ||
android:id="@+id/repo_refresh_button" | ||
android:layout_width="@dimen/_20dp" | ||
android:layout_height="@dimen/_20dp" | ||
android:layout_centerVertical="true" | ||
android:layout_marginStart="@dimen/_20dp" | ||
android:layout_marginEnd="@dimen/_20dp" | ||
android:layout_toEndOf="@id/repo_forward_button" | ||
android:background="@drawable/ic_refresh" /> | ||
|
||
<ProgressBar | ||
android:id="@+id/repo_progress_view" | ||
style="?android:attr/progressBarStyleLarge" | ||
android:layout_width="@dimen/_20dp" | ||
android:layout_height="@dimen/_20dp" | ||
android:layout_centerInParent="true" | ||
android:layout_marginStart="@dimen/_20dp" | ||
android:layout_toEndOf="@id/repo_refresh_button" /> | ||
</RelativeLayout> | ||
</RelativeLayout> |
Oops, something went wrong.