Java Code Examples for com.gianlu.commonutils.misc.RecyclerMessageView#loadListData()

The following examples show how to use com.gianlu.commonutils.misc.RecyclerMessageView#loadListData() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DiagnosticFragment.java    From DNSHero with GNU General Public License v3.0 6 votes vote down vote up
@Nullable
@Override
@SuppressWarnings("unchecked")
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    RecyclerMessageView layout = new RecyclerMessageView(requireContext());
    layout.disableSwipeRefresh();

    Bundle args = getArguments();
    ArrayList<Domain.Diagnostic> diagnostics;
    if (args == null || (diagnostics = (ArrayList<Domain.Diagnostic>) args.getSerializable("diagnostics")) == null) {
        layout.showError(R.string.failedLoading);
        return layout;
    }

    layout.linearLayoutManager(RecyclerView.VERTICAL, false);
    layout.loadListData(new DiagnosticsAdapter(requireContext(), diagnostics));

    return layout;
}
 
Example 2
Source File: NameserversFragment.java    From DNSHero with GNU General Public License v3.0 6 votes vote down vote up
@Nullable
@Override
@SuppressWarnings("unchecked")
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    RecyclerMessageView layout = new RecyclerMessageView(requireContext());
    layout.disableSwipeRefresh();

    Bundle args = getArguments();
    ArrayList<Domain.NS> authoritative;
    if (getContext() == null || args == null || (authoritative = (ArrayList<Domain.NS>) args.getSerializable("authoritative")) == null) {
        layout.showError(R.string.failedLoading);
        return layout;
    }

    layout.linearLayoutManager(RecyclerView.VERTICAL, false);
    layout.loadListData(new NSAdapter(getContext(), authoritative));

    return layout;
}
 
Example 3
Source File: DNSRecordFragment.java    From DNSHero with GNU General Public License v3.0 5 votes vote down vote up
@NonNull
@Override
@SuppressWarnings("unchecked")
public final View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    RecyclerMessageView layout = new RecyclerMessageView(requireContext());
    layout.disableSwipeRefresh();

    Bundle args = getArguments();
    Domain.DNSRecordsArrayList<E> authoritative;
    Domain.DNSRecordsArrayList<E> resolver;
    Class<A> adapterClass;
    if (getContext() == null || args == null
            || (adapterClass = (Class<A>) args.getSerializable("adapterClass")) == null
            || (authoritative = (Domain.DNSRecordsArrayList<E>) args.getSerializable("authoritative")) == null
            || (resolver = (Domain.DNSRecordsArrayList<E>) args.getSerializable("resolver")) == null) {

        layout.showError(R.string.failedLoading);
        return layout;
    }

    layout.linearLayoutManager(RecyclerView.VERTICAL, false);

    if (authoritative.hasSomethingRelevant()) {
        try {
            layout.loadListData(adapterClass.getConstructor(Context.class, Domain.DNSRecordsArrayList.class, Domain.DNSRecordsArrayList.class).newInstance(getContext(), authoritative, resolver));
        } catch (java.lang.InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException ex) {
            Log.e(TAG, "Failed loading list data.", ex);
            layout.showError(R.string.failedLoading);
            return layout;
        }
    } else {
        layout.showInfo(R.string.noRecords);
    }

    return layout;
}
 
Example 4
Source File: LoadingActivity.java    From PretendYoureXyzzyAndroid with GNU General Public License v3.0 5 votes vote down vote up
private void changeServerDialog(boolean dismissible) {
    MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(this);
    builder.setTitle(R.string.changeServer)
            .setCancelable(dismissible)
            .setNeutralButton(R.string.manage, (dialog, which) -> {
                startActivity(new Intent(this, ManageServersActivity.class));
                dialog.dismiss();
            });

    if (dismissible)
        builder.setNegativeButton(android.R.string.cancel, null);

    RecyclerMessageView rmv = new RecyclerMessageView(this);
    builder.setView(rmv);

    rmv.disableSwipeRefresh();
    rmv.linearLayoutManager(RecyclerView.VERTICAL, false);
    rmv.dividerDecoration(RecyclerView.VERTICAL);
    rmv.loadListData(new ServersAdapter(this, Pyx.Server.loadAllServers(), new ServersAdapter.Listener() {
        @Override
        public void shouldUpdateItemCount(int count) {
        }

        @Override
        public void serverSelected(@NonNull Pyx.Server server) {
            setServer(server);
            loading.setVisibility(View.VISIBLE);
            register.setVisibility(View.GONE);
            dismissDialog();

            discoveryApi.firstLoad(LoadingActivity.this, null, LoadingActivity.this);
        }
    }));

    showDialog(builder);
}