Skip to content

Commit

Permalink
Lint errors fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Przemyslaw committed Dec 8, 2016
1 parent 4b269a3 commit 0a5dc6e
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import com.codefactory.przemyslawdabrowski.nearinpost.view.base.BaseFragment
fun BaseFragment.hideKeyboard(windowToken: IBinder) {
if (activity != null) {
val inputMethodManager = activity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
inputMethodManager.hideSoftInputFromWindow(windowToken, 0);
inputMethodManager.hideSoftInputFromWindow(windowToken, 0)
}
}

Expand All @@ -32,7 +32,7 @@ inline fun BaseFragment.givenPermission(permissions: Array<String>, requestCode:
return
}
if (activity !is BaseActivity) {
throw IllegalArgumentException("Application should use only BaseActivity class, error class: ${activity.toString()}")
throw IllegalArgumentException("Application should use only BaseActivity class, error class: $activity")
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (arePermissionsGranted(activity as BaseActivity, permissions)) {
Expand Down Expand Up @@ -63,12 +63,7 @@ fun askForPermissions(activity: BaseActivity, permissions: Array<String>, reques
* @return Value determinate if permissions are granted.
*/
fun arePermissionsGranted(activity: BaseActivity, permissions: Array<String>): Boolean {
for (permission in permissions) {
if (!isPermissionGranted(activity, permission)) {
return false
}
}
return true
return permissions.any { isPermissionGranted(activity, it) }
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class AddressComponent() {
var shortName: String? = null

/**
* List of component types, e.g [country].
* List of component types, e.g country.
*/
@SerializedName("types")
@Expose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ open class MachineDb(@PrimaryKey open var name: String = "",
open var longitude: Float? = null,
open var distance: Double? = null,
open var locationDescription: String? = null,
open var searchPostalCode: String = "") : RealmObject() {}
open var searchPostalCode: String = "") : RealmObject()
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package com.codefactory.przemyslawdabrowski.nearinpost.presenter
* Base presenter to implement.
*/
//TODO: Add unbind(view: V) and unbind in on destroy view!!!
interface Presenter<V> {
interface Presenter<in V> {

/**
* Bind view to presenter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import android.view.View
/**
* Base implementation for view holder.
*/
abstract class BaseHolder<I>(itemView: View?) : RecyclerView.ViewHolder(itemView) {
abstract class BaseHolder<in I>(itemView: View?) : RecyclerView.ViewHolder(itemView) {

/**
* Bind item to view holder.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import com.codefactory.przemyslawdabrowski.nearinpost.R
/**
* Layout that can slide down all content.
*/
class BottomSlideLayout(context: Context?, attrs: AttributeSet?, defStyleAttr: Int)
: FrameLayout(context, attrs, defStyleAttr) {
open class BottomSlideLayout(context: Context?, attrs: AttributeSet?, defStyleAttr: Int)
: FrameLayout(context, attrs, defStyleAttr) {

/**
* Rate od change of BottomSlideLayout position with respect to time.
Expand Down Expand Up @@ -118,7 +118,7 @@ class BottomSlideLayout(context: Context?, attrs: AttributeSet?, defStyleAttr: I
if (dragView != null) {
throw UnsupportedOperationException("BottomSheet must only have 1 child view")
}
dragView = child;
dragView = child
if (dragView != null) {
dragViewOffsetHelper = ViewOffsetHelper(dragView as View)
if (hasScrollingChild) {
Expand Down Expand Up @@ -221,15 +221,15 @@ class BottomSlideLayout(context: Context?, attrs: AttributeSet?, defStyleAttr: I

settleAnim.duration = 200L
settleAnim.interpolator = AnimationUtils.loadInterpolator(context,
android.R.interpolator.fast_out_slow_in);
android.R.interpolator.fast_out_slow_in)
if (dismiss) {
settleAnim.addListener(object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator?) {
dispatchDismissCallback()
}
})
}
settleAnim.start();
settleAnim.start()
}

/**
Expand All @@ -251,7 +251,7 @@ class BottomSlideLayout(context: Context?, attrs: AttributeSet?, defStyleAttr: I
* Dispatch drag callback to all listeners.
*/
protected fun dispatchDragCallback() {
if (listeners.size > 0) {
if (listeners.isNotEmpty()) {
for (listener in listeners) {
listener.onDrag(top)
}
Expand All @@ -262,7 +262,7 @@ class BottomSlideLayout(context: Context?, attrs: AttributeSet?, defStyleAttr: I
* Dispatch dismiss callback to all listeners.
*/
protected fun dispatchDismissCallback() {
if (listeners.size > 0) {
if (listeners.isNotEmpty()) {
for (listener in listeners) {
listener.onDragDismissed()
}
Expand Down Expand Up @@ -302,7 +302,7 @@ class BottomSlideLayout(context: Context?, attrs: AttributeSet?, defStyleAttr: I
override fun onViewReleased(releasedChild: View?, xvel: Float, yvel: Float) {
if (yvel >= FLING_VELOCITY) {
isDismissing = true
doDismiss();
doDismiss()
} else {
// settle back into position
viewDragHelper.settleCapturedViewAt(dragViewLeft, dragViewTop)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ class ViewOffsetHelper(view: View) {
fun setTopAndBottomOffset(offset: Int): Boolean {
if (mOffsetTop != offset) {
mOffsetTop = offset
updateOffsets();
return true;
updateOffsets()
return true
}
return false;
return false
}

fun getTopAndBottomOffset() = mOffsetTop
Expand All @@ -68,17 +68,17 @@ class ViewOffsetHelper(view: View) {
private fun updateOffsets() {
// Translate view positions.
fun tickleInvalidationFlag(view: View) {
val x: Float = ViewCompat.getTranslationX(view);
ViewCompat.setTranslationY(view, x + 1);
ViewCompat.setTranslationY(view, x);
val x: Float = ViewCompat.getTranslationX(view)
ViewCompat.setTranslationY(view, x + 1)
ViewCompat.setTranslationY(view, x)
}

ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.top - mLayoutTop))
ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.left - mLayoutLeft))
// Manually invalidate the view and parent to make sure we get drawn pre-M
if (Build.VERSION.SDK_INT < 23) {
tickleInvalidationFlag(mView)
val vp: ViewParent = mView.parent;
val vp: ViewParent = mView.parent
if (vp is View) {
tickleInvalidationFlag(vp)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class MachineDetailsActivity : BaseActivity(), OnMapReadyCallback {
}

val inPostLocation: LatLng = LatLng((machineUi.latitude as Float).toDouble()
, (machineUi.longitude as Float).toDouble());
, (machineUi.longitude as Float).toDouble())
p0?.addMarker(MarkerOptions().icon(BitmapDescriptorFactory
.fromResource(R.drawable.machine_details_loc_icon))
.anchor(1F, 1F)
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/layout/custom_location_search_view.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView 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="wrap_content"
android:layout_marginBottom="@dimen/custom_location_card_margin_bottom"
Expand All @@ -20,7 +21,8 @@
<EditText
android:id="@+id/customLocationSearch"
style="@style/MainSearchViewStyle"
android:layout_toStartOf="@+id/customLocationCurrent" />
android:layout_toStartOf="@+id/customLocationCurrent"
tools:ignore="LabelFor" />
<!--Image button for searching current location-->
<ImageView
android:id="@+id/customLocationCurrent"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Paczkomaty obok</string>
<string name="main_nearest_in_post">Znajdź najbliższe paczkomaty</string>
<string name="machine_details_city_title">Miasto:</string>
<string name="machine_details_street_title">Ulica:</string>
Expand Down

0 comments on commit 0a5dc6e

Please sign in to comment.