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
data class Category ( | |
val id: Long | |
) | |
data class SubCategory ( | |
val id: Long, | |
val categoryId: Long | |
) |
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 CustomDialog : DialogFragment() { | |
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | |
return AlertDialog.Builder(requireContext()) | |
.setMessage("Привет") | |
.setNegativeButton("Закрыть") {_,_ -> } | |
.create() | |
} | |
} | |
fun showCustomDialog(activity: AppCompatActivity) { |
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 AppModule( | |
private val applicationContext: Context | |
) { | |
@Singleton | |
@Provides | |
fun provideContext(): Context { | |
return applicationContext | |
} |
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 AppModule( | |
private val applicationContext: Context | |
) { | |
@Singleton | |
@Provides | |
fun provideContext(): Context { | |
return applicationContext | |
} |
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 AppModule( | |
private val applicationContext: Context | |
) { | |
@Singleton | |
@Provides | |
fun provideContext(): Context { | |
return applicationContext | |
} |
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 | |
public class AppModule { | |
private Context appContext; | |
public AppModule(Context appContext){ | |
this.appContext = appContext; | |
} | |
@Provides |
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 ActivityA: AppCompatActivity() { | |
companion object { | |
private const val SOME_CODE = 1 | |
} | |
private fun someAction() { | |
ActivityB.startForResult(this, "some param", SOME_CODE) | |
} |
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 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")) | |
} | |
} |
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
thread { | |
Thread.sleep(10_000) | |
val handler = Handler(mainLooper) | |
handler.post{ | |
// do something at main thread | |
} | |
} |