Skip to content

Instantly share code, notes, and snippets.

View allenatwork's full-sized avatar

Allen Walker allenatwork

View GitHub Profile
@erseno
erseno / PagedRecyclerViewAdapter.java
Last active April 21, 2020 07:55
A base adapter for RecyclerView to handle the loading of more data once a scroll threshold has been reached. Also shows a progress bar as a footer view to show that the next page is loading. If the next page fails to load, a retry button is displayed along with an error message so that the page can be retried.
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
/**
public void onBackPressed() {
if (getChildFragmentManager().popBackStackImmediate()) {
BaseDialogFragment bdf = (BaseDialogFragment) getChildFragmentManager().getFragments()
.get(getChildFragmentManager().getFragments().size() — 1);
String title = getString(R.string.account_info);
if (bdf == null && getChildFragmentManager().findFragmentByTag(getString(R.string.order_history)) != null && getChildFragmentManager().findFragmentByTag(getString(R.string.order_history)).isVisible()) {
title = getString(R.string.order_history);
}
if (bdf != null) {
title = getNewTitle(bdf.getTitle());
@lopspower
lopspower / README.md
Last active May 18, 2024 12:14
All Android Directory Path

All Android Directory Path

Twitter

1) System directories

⚠️ We can't write to these folers

Method Result
@beta
beta / MainActivity.java
Last active August 2, 2016 06:51
Switching fragments
// Blablabla
/**
* Loads and switches to a new fragment.
* If a fragment with {@code tag} has already been loaded and was detached from the container,
* this method will detach the current fragment and reattach the fragment back again, instead
* of creating a new instance of the target fragment.
*
* @param cls {@code Class} of the new fragment
* @param tag a tag to identify a fragment
import android.app.Activity;
import android.app.Dialog;
import android.support.v4.app.DialogFragment;
/**
* Base dialog fragment.
* @param <Listener> listener type.
*/
public abstract class BaseDialogFragment<Listener> extends DialogFragment {