Skip to content

Instantly share code, notes, and snippets.

@udfvirus
udfvirus / Test.cs
Last active November 28, 2025 12:08
public abstract class BaseRxMonoBehaviour : BaseMonoBehaviour
{
protected virtual void SubscribeWithProgress<T>(Observable<T> observable, Action<T> onNext = null,
Action<Exception> onError = null, Action<Result> onCompleted = null,
Action onShowProgress = null, Action onHideProgress = null)
{
Timber.D("BaseRxMonoBehaviour.SubscribeWithProgress")
Subscribe(
class InfoContainerFragment :
BaseBindingFragment<FragmentInfoContainerBinding, InfoContainerViewModel>(R.layout.fragment_info_container) {
override fun getViewModelClass() = InfoContainerViewModel::class
private var downloadManager: DownloadManager? = null
private val onCompleteDownloadReceiver: BroadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(ctxt: Context, intent: Intent) {
hideProgress()
@udfvirus
udfvirus / Main.java
Created February 2, 2022 18:55
Product of digits
int productOfDigits(int number) {
String numberStr = Integer.toString(number);
int result = 1;
for (int i = 0; i < numberStr.length(); i++) {
int num = Integer.parseInt(Character.toString(numberStr.charAt(i)));
result *= num;
}
return result;
}
fun scanFiles() {
val files: MutableList<String> = ArrayList()
val contentResolver = context.contentResolver
val uri = MediaStore.Files.getContentUri("internal")
val projection: Array<String>? = null
val selection = MediaStore.Files.FileColumns.MEDIA_TYPE + "=?"
@udfvirus
udfvirus / TrackInformationFragment.kt
Created July 29, 2021 15:44
Code executed only once
class TrackInformationFragment :
BaseFragment<TrackInformationViewModel>(R.layout.fragment_track_information) {
private val args: TrackInformationFragmentArgs by navArgs()
override val model: TrackInformationViewModel by viewModel()
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val filesTextView = view.findView<TextView>(R.id.filesTextView)
class MainActivity : BaseActivity() {
private val model: MainViewModel by viewModels()
private val userAdapter = UserAdapter()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
class CacheControlInterceptor @Inject constructor(private val context: Context) : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
val modifyRequest = modifyRequest(chain.request())
val response = chain.proceed(modifyRequest)
return response
}
private fun modifyRequest(originRequest: Request) =
if (context.isNetworkAvailable()) {
@udfvirus
udfvirus / Test.java
Created April 6, 2020 13:58
Work with properties(JAVA)
import java.util.*;
import java.io.*;
public class Test {
public static void main(String[] args)throws Exception{
FileReader reader=new FileReader("db.properties");
Properties p=new Properties();
p.load(reader);
System.out.println(p.getProperty("user"));
public static void setAppAsSystem(String name, boolean system) throws Exception
{
Process p = Runtime.getRuntime().exec("su -c sh");
final BufferedInputStream bis = new BufferedInputStream(p.getInputStream());
new Thread(new Runnable() {
@Override
public void run() {
int ch = 0;
try {
@udfvirus
udfvirus / Car.java
Last active January 14, 2020 16:00
Sample of repository
package model.entity;
public class Car {
String brand;
String model;
int color;