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 checkInternetConnection(context : Context) : Boolean { | |
val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | |
var activeNetworkInfo: NetworkInfo? = null | |
activeNetworkInfo = cm.activeNetworkInfo | |
return activeNetworkInfo != null && activeNetworkInfo.isConnectedOrConnecting | |
} |
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
abstract class BaseActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(provideLayoutId()) | |
setupView(savedInstanceState) | |
} | |
@LayoutRes | |
protected abstract fun provideLayoutId(): Int |
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 MainActivity : BaseActivity(){ | |
override fun provideLayoutId(): Int = R.layout.activity_main | |
override fun setupView(savedInstanceState: Bundle?) { | |
//do operations with views like this. | |
//btnSubmit.setOnClickListener{ | |
// Log.d("TAG", "CLICKED") | |
//} | |
} |
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 Pizza { | |
var toppingType : Topping? = null, | |
var baseType : Base? = null | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.pizza_activity) | |
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 Base { | |
var pizzaBaseType : String? = null | |
} |
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
@Module | |
class PizzaStock { | |
@Provides | |
@Singleton | |
fun providePizzaTopping() = Topping().toppingType = "Chicken" | |
@Provides | |
@Singleton | |
fun providePizzaBase() = Base().pizzaBaseType = "CheeseBurst" |
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
@Component(modules = [PizzaStock::class]) | |
interface PizzaComponent { | |
fun inject(pizzaClass : Pizza) | |
} |
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 Pizza { | |
@Inject | |
lateinit var pizzaBase : String | |
@Inject | |
lateinit var pizzaTopping : String | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) |
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 list = arrayListOf("Monday", "Tuesday","Wednesday", "Thursday", "Friday") | |
val commaSeparatedString = list.joinToString {it} |