Skip to content

Instantly share code, notes, and snippets.

kishansinh parmar kishansinhparmar

Block or report user

Report or block kishansinhparmar

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View SingleLiveEvent
class SingleLiveEvent<T> : MutableLiveData<T>() {
private val mPending = AtomicBoolean(false)
@MainThread
override fun observe(owner: LifecycleOwner, observer: Observer<in T>) {
if (hasActiveObservers()) {
Log.w(TAG, "Multiple observers registered but only one will be notified of changes.");
}
View recyclerviewadapter
class $CLASS_NAME$Adapter(private var list: MutableList<$DT$>) :
RecyclerView.Adapter<$CLASS_NAME$Adapter.$CLASS_NAME$ViewHolder>() {
override fun getItemCount() = list.size
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): $CLASS_NAME$ViewHolder {
return $CLASS_NAME$ViewHolder(
LayoutInflater.from(parent.context).inflate(
R.layout.$LAYOUT_NAME$,
parent,
@kishansinhparmar
kishansinhparmar / vminflate.kt
Created Jul 19, 2019
This template will inflate and initialize common code.
View vminflate.kt
binding = DataBindingUtil.inflate(inflater, R.layout.$layout_file$, container, false)
val vm by lazy {
ViewModelProviders.of(this, $VIEWMODEL_CLASS$Factory(repo))
.get($VIEWMODEL_CLASS$::class.java)
}
binding.$VIEWMODEL_VARIABLE_NAME_FROM_XML$ = vm
binding.lifecycleOwner = this
@kishansinhparmar
kishansinhparmar / vmfactory.kt
Created Jul 19, 2019
View model with repository
View vmfactory.kt
class $viewModelName$Factory(val repo: RepoModel) : ViewModelProvider.Factory {
override fun <T : ViewModel?> create(modelClass: Class<T>): T = $viewModelName$(repo) as T
}
@kishansinhparmar
kishansinhparmar / vmclass.kt
Last active Jul 19, 2019
This will create a VM class with repo param.
View vmclass.kt
class $CLASS_NAME$VM(private var repo: RepoModel) : ViewModel() {
}
@kishansinhparmar
kishansinhparmar / main.dart
Last active Apr 28, 2018
Flutter Hello World!
View main.dart
//material package to use material widgets
import 'package:flutter/material.dart';
//Main method to run app
void main() => runApp(new MyApp());
//MyApp class
class MyApp extends StatelessWidget {
@override
View Activity.java
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT,
"Performance app: https://play.google.com/store/apps/details?id=com."
+ ".packageid");
sendIntent.setType("text/plain");
startActivity(sendIntent);
You can’t perform that action at this time.