Skip to content

Commit

Permalink
refactor: Adds release build apk & refactors code
Browse files Browse the repository at this point in the history
  • Loading branch information
Haid-Faiz committed Oct 31, 2021
1 parent 9318bcf commit 02b3818
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .idea/misc.xml

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

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ android {
minSdkVersion 23
targetSdkVersion 31
versionCode 2
versionName "v2.0"
versionName "v2.0.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Expand Down Expand Up @@ -102,4 +102,4 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
}
Binary file added app/release/news_land_v2.0.0.apk
Binary file not shown.
2 changes: 1 addition & 1 deletion app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"filters": [],
"attributes": [],
"versionCode": 2,
"versionName": "v2.0",
"versionName": "v2.0.0",
"outputFile": "app-release.apk"
}
],
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/example/newsapp/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class MainActivity : AppCompatActivity() {

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
// Running Android OS version is less than Android 10 i.e. Android Q
_isNightMode = it ?: false // Updating _isNightMode value
_isNightMode = it ?: false // Updating _isNightMode value
if (_isNightMode)
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ class NewsListFragment : Fragment() {
header = PagingErrorAdapter { adapter.retry() },
footer = PagingErrorAdapter { adapter.retry() }
)
adapter.addLoadStateListener {
when (it.refresh) {
adapter.addLoadStateListener { loadStates ->
when (loadStates.refresh) {
is LoadState.NotLoading -> {
binding.apply {
newsListRecyclerview.isVisible = true
Expand All @@ -103,13 +103,13 @@ class NewsListFragment : Fragment() {
}
}
is LoadState.Error -> {
handleExceptions((it.refresh as LoadState.Error).error)
binding.apply {
newsListRecyclerview.isVisible = false
statusBox.isVisible = true
shimmerProgress.stopShimmer()
shimmerProgress.isVisible = false
}
handleExceptions((loadStates.refresh as LoadState.Error).error)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/example/newsapp/utils/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ fun TextView.formatDate(article: Article) {
this.text = timeAgo
}

fun View.showSnackBar(message: String, retryFun: (() -> Unit)? = null) {
Snackbar.make(this, message, Snackbar.LENGTH_LONG).show()
fun View?.showSnackBar(message: String, retryFun: (() -> Unit)? = null) {
this?.let { Snackbar.make(it, message, Snackbar.LENGTH_LONG).show() }
}

// fun Fragment.handleApiError(failure: Resource.Error) {
Expand All @@ -51,6 +51,6 @@ fun View.showSnackBar(message: String, retryFun: (() -> Unit)? = null) {
fun Fragment.handleExceptions(throwable: Throwable) {
when (throwable) {
is HttpException -> view?.showSnackBar("Oops.. Something went wrong !")
is IOException -> view?.showSnackBar("Please check your internet connection")
is IOException -> this.view?.showSnackBar("Please check your internet connection")
}
}
20 changes: 12 additions & 8 deletions app/src/main/res/layout/fragment_news_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<include layout="@layout/news_list_item_shimmer" />

<include layout="@layout/news_list_item_shimmer" />

<include layout="@layout/news_list_item_shimmer" />
</LinearLayout>

Expand All @@ -38,6 +41,7 @@
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/_72sdp"
android:orientation="vertical"
android:layout_marginTop="@dimen/_24sdp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
Expand All @@ -60,10 +64,10 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/_16sdp"
android:layout_marginStart="@dimen/_16sdp"
android:layout_marginTop="@dimen/_8sdp"
android:layout_marginEnd="@dimen/_16sdp"
android:layout_marginBottom="@dimen/_12sdp"
android:layout_marginBottom="@dimen/_24sdp"
android:fontFamily="@font/montserrat"
android:gravity="center_horizontal"
android:text="You didn't bookmarked anything yet !"
Expand All @@ -73,17 +77,17 @@

<com.google.android.material.button.MaterialButton
android:id="@+id/retry_button"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_gravity="center_horizontal"
android:fontFamily="@font/open_sans"
android:text="Retry"
android:textAllCaps="false"
android:visibility="invisible"
android:textColor="@color/primary_text"
android:fontFamily="@font/open_sans"
android:visibility="invisible"
app:strokeColor="@color/shimmerColor"
tools:visibility="visible"
android:layout_gravity="center_horizontal"
android:text="Retry" />
tools:visibility="visible" />

</LinearLayout>

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/page_error_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
android:indeterminateTint="@color/primary_text"
android:layout_width="@dimen/_22sdp"
android:layout_height="@dimen/_22sdp"
android:layout_marginBottom="@dimen/_26sdp"
android:layout_marginTop="@dimen/_16sdp"
android:layout_marginBottom="@dimen/_40sdp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
Expand Down

0 comments on commit 02b3818

Please sign in to comment.