Skip to content

Instantly share code, notes, and snippets.

View FireZenk's full-sized avatar
🌍
Improving the world

Jorge Garrido FireZenk

🌍
Improving the world
View GitHub Profile
fun isLowMemory(): Boolean {
val memoryLimit: Long = (getTotalInternalMemorySize() * DEFAULT_THRESHOLD_PERCENTAGE) / 100;
return availableMemorySize() <= tenPercentLimit;
}
package {{lowerCase package}}.{{lowerCase feature}};
public class {{properCase feature}}PresenterImpl implements {{properCase feature}}Presenter, {{properCase feature}}Interactor.On{{properCase feature}}FinishedListener {
private {{properCase feature}}View {{lowerCase feature}}View;
private {{properCase feature}}Interactor {{lowerCase feature}}Interactor;
public {{properCase feature}}PresenterImpl({{properCase feature}}View {{lowerCase feature}}View) {
this.{{lowerCase feature}}View = {{lowerCase feature}}View;
this.{{lowerCase feature}}Interactor = new {{properCase feature}}InteractorImpl();
plop.addHelper('lowerCase', (text) => text.toLowerCase());
plop.setGenerator('feature', {
description: 'creates a new mvp-based feature',
prompts: [{
type: 'input',
name: 'package',
message: 'Package name?'
},{
type: 'input',
name: 'feature',
message: 'Feature name?'
module.exports = function (plop) {
plop.addHelper('lowerCase', (text) => text.toLowerCase());
// add more helpers here
plop.setGenerator('feature', {
description: 'creates a new mvp-based feature',
prompts: [{
type: 'input',
MyFragment fragment = MyFragment.newInstance(index);
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.parent, fragment);
ft.commit();
MyCustomView customView = new MyCustomView(context);
parentView.removeAllViews();
parentView.add(customView);
<fragment android:name="my.package.MyFragment"
android:id="@+id/my_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<my.package.MyCustomView
android:id="@+id/my_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
@FireZenk
FireZenk / SignalrSocket.kt
Created January 11, 2018 14:38
Signalr socket rx implementation
object SignalrSocket {
private lateinit var broadcaster: FlowableEmitter<String>
private lateinit var disposable: Disposable
private val flowable = Flowable.create(FlowableOnSubscribe<String> { emitter -> broadcaster = emitter }, BackpressureStrategy.BUFFER)
private lateinit var mHubConnection: HubConnection
private lateinit var mHubProxy: HubProxy
@Throws(InterruptedException::class, ExecutionException::class)