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
/** | |
* Check if a point cliked is in the are of a line. | |
*/ | |
class CheckLineClicked { | |
/** | |
* Returns the distance between a point(clickPosition) and a line(start and end point). | |
*/ | |
fun checkLineClicked(clickPosition: PointF, startPoint: PointF, endPointF: PointF): Float { | |
val x = clickPosition.x |
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
class MyAmazingActivity: AppCompatActivity { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
if (resources.getBoolean(R.bool.portrait_only)) { | |
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) | |
} else { | |
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR) | |
} | |
} |
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
<View | |
.... | |
app:layout_constraintHorizontal_bias="0" | |
android:layout_width="0dp" | |
app:layout_constraintWidth_default="wrap" > | |
</View> |
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
class CurrencyAdapter: RecyclerView.Adapter<CurrencyAdapter.ViewHolder>() { | |
var data: List<YourModelName> = emptyList() | |
set(value) { | |
field = value | |
notifyDataSetChanged() | |
} | |
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | |
return ViewHolder(parent) |
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
import io.reactivex.Single | |
import io.reactivex.SingleSource | |
import io.reactivex.SingleTransformer | |
/** | |
* Sealed class to handle ViewStates. | |
* | |
* When an error happens it will return a [ViewState.Failed] with a [ViewState.Failed.throwable] field | |
* |
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
//more plugins here.... | |
apply plugin: 'kotlin-kapt' | |
android { | |
//your stuff... | |
buildTypes { | |
release { | |
//your stuff... | |
buildConfigField "String", "BASE_URL", "\"https://your.api.url//\"" |
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
<?xml version="1.0" encoding="utf-8"?> | |
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | |
<item android:state_checked="true"> | |
<shape android:shape="rectangle"> | |
<solid android:color="#3B5A9A" /> | |
<corners android:bottomLeftRadius="4dp" | |
android:topLeftRadius="4dp"/> | |
</shape> | |
</item> |
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
//Preparing the request | |
val filePart = MultipartBody.Part | |
.createFormData("file", "fileName", | |
RequestBody.create(MediaType.parse("image/jpeg"), File("/your/File/Path.jpg"))) | |
//service.sendFile(id, filePart) | |
//Request definition retrofit | |
@PUT("https://www.yourdomain.com/api/file/{id}") | |
@Multipart | |
fun sendFile(@Path("id") id: Long, @Part file: MultipartBody.Part ) : Observable<YourModel> |
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
private MarkerOptions createMarkerIcon(LatLng position) { | |
FrameLayout frameLayout = new FrameLayout(getContext()); | |
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( | |
FrameLayout.LayoutParams.WRAP_CONTENT, | |
FrameLayout.LayoutParams.WRAP_CONTENT); | |
frameLayout.setLayoutParams(params); | |
View markerView = getActivity().getLayoutInflater().inflate(R.layout.custom_map_marker, frameLayout); | |
BitmapDescriptor bitmapMerged = BitmapDescriptorFactory.fromBitmap(BitmapUtils.createDrawableFromView(getContext(), markerView)); |
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
val subscription = Observable.interval(0, 5, TimeUnit.SECONDS) | |
.timeInterval() | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribeOn(Schedulers.io()) | |
.subscribe { | |
//TODO | |
} |
NewerOlder