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
#!/usr/bin/env bash | |
VARIANT='free paid enterprise' | |
# connect to FTP | |
echo open $FTP_HOST >> ftp.txt | |
echo user $FTP_USER $FTP_PWD >> ftp.txt | |
# get FTP file | |
# param1: variant |
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
#!/usr/bin/env bash | |
# connect to FTP | |
echo open $FTP_HOST >> ftp.txt | |
echo user $FTP_USER $FTP_PWD >> ftp.txt | |
# archive file | |
echo "mmv -O $FTP_DIR/Archives $FTP_DIR/$FTP_FILE" >> ftp.txt | |
# upload to FTP |
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
#!/usr/bin/env bash | |
# connect to FTP | |
echo open $FTP_HOST >> ftp.txt | |
echo user $FTP_USER $FTP_PWD >> ftp.txt | |
# execute script | |
lftp -f ftp.txt | |
# cleanup |
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 MyActivity : AppCompatActivity() { | |
@Inject | |
lateinit var viewModelFactory: MyViewModel.Factory | |
private val viewModel: MyViewModel by assistedViewModel { viewModelFactory.create(it) } | |
} |
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
inline fun <reified VM : ViewModel> ComponentActivity.assistedViewModel( | |
crossinline viewModelProducer: (SavedStateHandle) -> VM, | |
): Lazy<VM> = lazy { | |
ViewModelProvider(this,createSavedStateViewModelFactory(intent.extras, viewModelProducer)) | |
.get(VM::class.java) | |
} | |
@PublishedApi | |
internal inline fun <reified VM : ViewModel> SavedStateRegistryOwner.createSavedStateViewModelFactory( | |
arguments: Bundle?, |
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 SavedStateViewModelFactory<T : ViewModel> { | |
fun create(savedStateHandle: SavedStateHandle): T | |
} | |
class MyViewModel @AssistedInject constructor( | |
private val repository: Repository, | |
@Assisted private val savedStateHandle: SavedStateHandle, | |
) : ViewModel() { | |
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
@HiltViewModel | |
class MyViewModel @Inject constructor( | |
private val repository: Repository, | |
private val savedStateHandle: SavedStateHandle, | |
) : ViewModel() | |
@AndroidEntryPoint | |
class MyActivity : AppCompatActivity() { | |
private val viewModel: MyViewModel by viewModels() |
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 MyActivity : AppCompatActivity() { | |
@Inject | |
lateinit var viewModelFactory: SavedStateViewModelFactory.Factory | |
private val viewModel: MyViewModel by viewModel(viewModelFactory) | |
} |
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
inline fun <reified VM : ViewModel> ComponentActivity.viewModel( | |
factory: SavedStateViewModelFactory.Factory, | |
): Lazy<VM> = lazy { | |
ViewModelProvider(this,factory.create(this, intent.extras)) | |
.get(VM::class.java) | |
} |
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 MyActivity : AppCompatActivity() { | |
@Inject | |
lateinit var viewModelFactory: SavedStateViewModelFactory.Factory | |
private val viewModel: MyViewModel by lazy { | |
ViewModelProvider(this, viewModelFactory.create(this, intent.extras)) | |
.get(MyViewModel::class.java) | |
} | |
} |
NewerOlder