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

The following examples show how to use com.gianlu.commonutils.misc.RecyclerMessageView#linearLayoutManager() . 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: UserHistoryFragment.java    From PretendYoureXyzzyAndroid with GNU General Public License v3.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    rmv = new RecyclerMessageView(requireContext());
    rmv.linearLayoutManager(RecyclerView.VERTICAL, false);
    rmv.dividerDecoration(RecyclerView.VERTICAL);
    rmv.startLoading();

    try {
        pyx = RegisteredPyx.get();
    } catch (LevelMismatchException ex) {
        rmv.showError(R.string.failedLoading);
        return rmv;
    }

    pyx.getUserHistory(null, this);

    return rmv;
}
 
Example 4
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 5
Source File: CardcastFragment.java    From PretendYoureXyzzyAndroid with GNU General Public License v3.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    RecyclerMessageView rmv = new RecyclerMessageView(requireContext());
    rmv.linearLayoutManager(RecyclerView.VERTICAL, false);
    rmv.showInfo(R.string.cardcastGoneMessage);
    rmv.message().text().setLinksClickable(true);
    return rmv;
}
 
Example 6
Source File: ManageServersActivity.java    From PretendYoureXyzzyAndroid with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    rmv = new RecyclerMessageView(this);
    setContentView(rmv);
    setTitle(R.string.manageServers);

    rmv.disableSwipeRefresh();
    rmv.linearLayoutManager(RecyclerView.VERTICAL, false);
    rmv.dividerDecoration(RecyclerView.VERTICAL);
    loadServers();
}
 
Example 7
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);
}
 
Example 8
Source File: NamesFragment.java    From PretendYoureXyzzyAndroid with GNU General Public License v3.0 4 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    rmv = new RecyclerMessageView(requireContext());
    rmv.linearLayoutManager(RecyclerView.VERTICAL, false);

    try {
        pyx = RegisteredPyx.get();
    } catch (LevelMismatchException ex) {
        rmv.showError(R.string.failedLoading);
        return rmv;
    }

    rmv.enableSwipeRefresh(() -> {
        adapter = null;
        pyx.request(PyxRequests.getNamesList(), null, NamesFragment.this);
    }, R.color.colorAccent);

    pyx.polling().addListener(new Pyx.OnEventListener() {
        @Override
        public void onPollMessage(@NonNull PollMessage msg) throws JSONException {
            switch (msg.event) {
                case NEW_PLAYER:
                    if (adapter != null)
                        adapter.itemChangedOrAdded(new Name(msg.obj.getString("n")));
                    break;
                case PLAYER_LEAVE:
                    if (adapter != null) adapter.removeItem(msg.obj.getString("n"));
                    break;
                case GAME_LIST_REFRESH:
                    adapter = null;
                    pyx.request(PyxRequests.getNamesList(), null, NamesFragment.this);
                    break;
            }
        }

        @Override
        public void onStoppedPolling() {
        }
    });

    pyx.request(PyxRequests.getNamesList(), null, this);
    return rmv;
}