Skip to content

Instantly share code, notes, and snippets.

View ValeraSetrakov's full-sized avatar
🏠
Working from home

Valerii Setrakov ValeraSetrakov

🏠
Working from home
View GitHub Profile
data class Category (
val id: Long
)
data class SubCategory (
val id: Long,
val categoryId: Long
)
class CustomDialog : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return AlertDialog.Builder(requireContext())
.setMessage("Привет")
.setNegativeButton("Закрыть") {_,_ -> }
.create()
}
}
fun showCustomDialog(activity: AppCompatActivity) {
@Module
class AppModule(
private val applicationContext: Context
) {
@Singleton
@Provides
fun provideContext(): Context {
return applicationContext
}
@Module
class AppModule(
private val applicationContext: Context
) {
@Singleton
@Provides
fun provideContext(): Context {
return applicationContext
}
@Module
class AppModule(
private val applicationContext: Context
) {
@Singleton
@Provides
fun provideContext(): Context {
return applicationContext
}
@Module
public class AppModule {
private Context appContext;
public AppModule(Context appContext){
this.appContext = appContext;
}
@Provides
class ActivityA: AppCompatActivity() {
companion object {
private const val SOME_CODE = 1
}
private fun someAction() {
ActivityB.startForResult(this, "some param", SOME_CODE)
}
class CustomActivity: AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_test)
val rv = findViewById<RecyclerView>(R.id.rv_test)
rv.layoutManager = LinearLayoutManager(this)
rv.adapter = CustomAdapter(listOf("Text 1", "Text 2"))
}
}
thread {
Thread.sleep(10_000)
val handler = Handler(mainLooper)
handler.post{
// do something at main thread
}
}