Answer: The primary constructor is part of the class header. Unlike Java, you don't need to declare a constructor in the body of the class. Here's an example:
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
pragma solidity 0.6.6; | |
// ---------------------------------------------------------------------------- | |
// 'MarianaCoin' token contract | |
// | |
// Deployed to : 0x839731207ba6101BF7d4A2BEcb5FE07a22184B2A | |
// Symbol : MCO | |
// Name : MarianaCoin | |
// Total supply: 144 | |
// Decimals : 3 |
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
fun <T> LiveData<T>.observeOnce(lifecycleOwner: LifecycleOwner, observer: Observer<T>) { | |
observe(lifecycleOwner, object : Observer<T> { | |
override fun onChanged(t: T?) { | |
observer.onChanged(t) | |
removeObserver(this) | |
} | |
}) | |
} | |
//Using | |
liveData.observeOnce(this, Observer<Password> { |
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 AppRestService : IAppRestService { | |
override fun getAppRestService(): IRestService { | |
val httpClient = OkHttpClient().newBuilder() | |
val interceptor = Interceptor { chain -> | |
val request = chain?.request()?.newBuilder()?.addHeader("SomeHeader", "SomeHeaderProperty")?.build(); | |
chain?.proceed(request) | |
} | |
httpClient.networkInterceptors().add(interceptor) | |
val customGson = GsonBuilder().registerTypeAdapter(MyClassCloud::class.java, MyClassCloudDeserializer("1")).create() | |
val retrofit = Retrofit.Builder().baseUrl(IRestService.URL_BASE).addConverterFactory(GsonConverterFactory.create(customGson)).client(httpClient.build()).build() |
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
package com.gabesechan.android.reusable.receivers; | |
import java.util.Date; | |
import android.content.BroadcastReceiver; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.telephony.TelephonyManager; | |
public abstract class PhonecallReceiver extends BroadcastReceiver { |
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
package com.vadim.zasovin.workout.widget; | |
import android.graphics.Canvas; | |
import android.graphics.Paint; | |
import android.graphics.Rect; | |
import android.support.v7.widget.RecyclerView; | |
import android.support.v7.widget.RecyclerView.ItemDecoration; | |
import android.support.v7.widget.RecyclerView.LayoutManager; | |
import android.support.v7.widget.RecyclerView.State; | |
import android.view.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
put card.xml in your drawables directory, put colors.xml in your values directory or add the colors to your colors.xml file. | |
set the background of a view to card, | |
as you can see in card.xml the drawable handles the card margin, so you don't have to add a margin to your view | |
``` xml | |
<View | |
android:layout_width="fill_parent" |
- Related Setup: https://gist.github.com/hofmannsven/6814278
- Related Pro Tips: https://ochronus.com/git-tips-from-the-trenches/
- Interactive Beginners Tutorial: http://try.github.io/
- Git Cheatsheet by GitHub: https://services.github.com/on-demand/downloads/github-git-cheat-sheet/
Press minus + shift + s
and return
to chop/fold long lines!
NewerOlder