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
<fragment android:name="my.package.MyFragment"
android:id="@+id/my_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
MyCustomView customView = new MyCustomView(context);
parentView.removeAllViews();
parentView.add(customView);
MyFragment fragment = MyFragment.newInstance(index);
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.parent, fragment);
ft.commit();
plop.addHelper('lowerCase', (text) => text.toLowerCase());
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();
fun availableMemorySize(): Long {
val path: File = Environment.getDataDirectory()
val stat: StatFs = StatFs(path.getPath())
return stat.getAvailableBlocksLong() * stat.getBlockSizeLong()
}
fun isLowMemory(): Boolean {
val memoryLimit: Long = (getTotalInternalMemorySize() * DEFAULT_THRESHOLD_PERCENTAGE) / 100;
return availableMemorySize() <= tenPercentLimit;
}
fun totalMemorySize(): Long {
val path: File = Environment.getDataDirectory()
val stat: StatFs = StatFs(path.getPath())
return stat.getBlockCountLong() * stat.getBlockSizeLong()
}
private static final int DEFAULT_THRESHOLD_PERCENTAGE = 10;
case ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW:
case ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL: