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 void uploadFile(File file){ | |
RequestBody videoBody = RequestBody.create(MediaType.parse("video/"), file); | |
MultipartBody.Part vFile = MultipartBody.Part.createFormData("upload-file", file.getName(), videoBody); | |
UploadVideoService videoService = RetrofitClientInstance.Companion.getRetrofitInstance(); | |
Call<ResponseBody> serverCom=videoService.uploadVideo(vFile); | |
serverCom.enqueue(new Callback<ResponseBody>() { | |
@Override | |
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) { | |
ResponseBody body = response.body(); | |
try { |
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
// having "with" | |
with(viewModel){ | |
val balanceText = this.balanceText | |
val category = this.category.run { | |
value = false | |
} | |
} | |
// without using "with" | |
val balanceText = viewmodel.balanceText |
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
// Without run | |
fun printPersonName(person : Person){ | |
print(person.name) | |
} | |
// With run | |
fun printPersonName(person : Person) = person.run{ | |
print(name) | |
} |
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
// Without Let | |
if(person!=null){ | |
doSomething() | |
} | |
// With Let | |
person?.let{ | |
doSomething() | |
} |
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 person = Person().apply{ | |
name = "aveek" | |
tel = "+98234552344" | |
}.also{ | |
Log.d("test",it.name) | |
} |
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
activity.setResult(Activity.RESULT_OK, Intent().apply { // this:intent | |
putExtra("response", true) | |
putExtra("message", "success") | |
putExtra("result", "ok") | |
}) | |
activity.setResult(Activity.RESULT_OK, Intent().also { // it:intent | |
it.putExtra("response", true) | |
it.putExtra("message", "success") | |
it.putExtra("result", "ok") |
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
const val addFragment = 1 | |
const val replaceFragment = 2 | |
private inline fun generateFragmentTransaction(fragmentToReplaceOrAdd : Fragment, addOrReplace: Int) : FragmentTransaction { | |
return when(addOrReplace) { | |
addFragment -> supportFragmentManager.beginTransaction().add(R.id.container_frame, fragmentToReplaceOrAdd) | |
else -> supportFragmentManager.beginTransaction().replace(R.id.container_frame, fragmentToReplaceOrAdd) | |
} | |
} | |
private fun fragmentAddOrReplacer(name : String, transaction : ()-> FragmentTransaction){ | |
transaction().apply { |
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
/** Represents Module for Test Management | |
* @author Aveek | |
* @author www.myproject.com | |
* @version 1 | |
* @since 4.4.0 - Version | |
*/ | |
@Module | |
internal class TestModule (val context : TestManagement) { | |
/** | |
* provides viewModel of the XML |
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
interface IBaseStrategy { | |
fun isEnable(enable : Boolean) | |
} | |
interface IPendingStrategy : IBaseStrategy{ | |
} | |
interface IErrorStrategy : IBaseStrategy{ | |
var OnReUpload : (result : Result)-> Unit | |
} | |
interface IManageStrategy : IBaseStrategy{ |
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 StateViewHolder(binding: ViewDataBinding) : RecyclerView.ViewHolder(binding.root) { | |
lateinit var viewModel: BaseViewModel | |
fun bind(info: Pair<Pair<Boolean, String>, Int>, remaining: Int) { | |
@DrawableRes val icon: Int | |
val stateContext: BaseStateContext | |
if (AppFlavor.country == Country.Bangladesh) { | |
icon=R.drawable.ico_state_1 |
NewerOlder