Skip to content

Instantly share code, notes, and snippets.

Jorge Garrido FireZenk

Block or report user

Report or block FireZenk

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 FragmentVsCustomView1.java
MyFragment fragment = MyFragment.newInstance(index);
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.parent, fragment);
ft.commit();
View PlopSnippet3.js
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',
View PlopSnippet2.js
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?'
View PlopSnippet1.js
plop.addHelper('lowerCase', (text) => text.toLowerCase());
View PlopSnippet1.hbs
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();
View MemoryTrimSnippet6.kt
fun isLowMemory(): Boolean {
val memoryLimit: Long = (getTotalInternalMemorySize() * DEFAULT_THRESHOLD_PERCENTAGE) / 100;
return availableMemorySize() <= tenPercentLimit;
}
View MemoryTrimSnippet5.kt
fun availableMemorySize(): Long {
val path: File = Environment.getDataDirectory()
val stat: StatFs = StatFs(path.getPath())
return stat.getAvailableBlocksLong() * stat.getBlockSizeLong()
}
View MemoryTrimSnippet4.kt
fun totalMemorySize(): Long {
val path: File = Environment.getDataDirectory()
val stat: StatFs = StatFs(path.getPath())
return stat.getBlockCountLong() * stat.getBlockSizeLong()
}
View MemoryTrimSnippet3.java
private static final int DEFAULT_THRESHOLD_PERCENTAGE = 10;
View MemoryTrimSnippet2.java
case ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW:
case ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL:
You can’t perform that action at this time.