Java Code Examples for com.gianlu.commonutils.CommonUtils#setRecyclerViewTopMargin()

The following examples show how to use com.gianlu.commonutils.CommonUtils#setRecyclerViewTopMargin() . 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: DiagnosticsAdapter.java    From DNSHero with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onBindViewHolder(@NonNull final ViewHolder holder, int position) {
    Domain.Diagnostic diagnostic = diagnostics.get(position);


    switch (diagnostic.status) {
        case PASSED:
            CommonUtils.setTextColor(holder.title, R.color.passed);
            break;
        case FAILED:
            CommonUtils.setTextColor(holder.title, R.color.failed);
            holder.recommendationImage.setImageResource(R.drawable.baseline_error_outline_24);
            break;
        default:
        case SKIPPED:
            CommonUtils.setTextColorFromAttr(holder.title, R.attr.colorOnSurface);
            holder.recommendationImage.setImageResource(R.drawable.outline_info_24);
            break;
        case INFO:
            CommonUtils.setTextColor(holder.title, R.color.info);
            holder.recommendationImage.setImageResource(R.drawable.outline_info_24);
            break;
    }

    holder.title.setText(diagnostic.name);
    holder.description.setText(diagnostic.description);
    holder.recommendationText.setText(diagnostic.recommendation);

    holder.toggle.setVisibility(diagnostic.recommendation != null ? View.VISIBLE : View.GONE);
    holder.toggle.setOnClickListener(v -> CommonUtils.handleCollapseClick(holder.toggle, holder.recommendation));

    CommonUtils.setRecyclerViewTopMargin(holder);
}
 
Example 2
Source File: GamesAdapter.java    From PretendYoureXyzzyAndroid with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onSetupViewHolder(@NonNull final ViewHolder holder, int position, @NonNull final Game game) {
    holder.name.setText(game.host);
    holder.players.setHtml(R.string.players, game.players.size(), game.options.playersLimit);
    holder.goal.setHtml(R.string.goal, game.options.scoreLimit);
    holder.locked.setImageResource(game.hasPassword(false) ? R.drawable.outline_lock_24 : R.drawable.baseline_lock_open_24);
    CommonUtils.setImageTintColor(holder.locked, game.hasPassword(false) ? R.color.red : R.color.green);
    holder.status.setImageResource(game.status == Game.Status.LOBBY ? R.drawable.baseline_hourglass_empty_24 : R.drawable.baseline_casino_24);
    holder.timerMultiplier.setHtml(R.string.timerMultiplier, game.options.timerMultiplier);
    holder.blankCards.setHtml(R.string.blankCards, game.options.blanksLimit);
    holder.cardsets.setHtml(R.string.cardSets, game.options.cardSets.isEmpty() ? "<i>none</i>" : CommonUtils.join(pyx.firstLoad().createCardSetNamesList(game.options.cardSets), ", "));

    if (game.options.spectatorsLimit == 0)
        holder.spectators.setHtml(R.string.spectatorsNotAllowed);
    else
        holder.spectators.setHtml(R.string.spectators, game.spectators.size(), game.options.spectatorsLimit);

    holder.spectate.setOnClickListener(v -> {
        if (listener != null) listener.spectateGame(game);
    });

    holder.join.setOnClickListener(v -> {
        if (listener != null) listener.joinGame(game);
    });

    holder.expand.setOnClickListener(v -> CommonUtils.handleCollapseClick(holder.expand, holder.details));

    CommonUtils.setRecyclerViewTopMargin(holder);
}
 
Example 3
Source File: DownloadCardsAdapter.java    From Aria2App with GNU General Public License v3.0 4 votes vote down vote up
public void update(@NonNull DownloadWithUpdate download) {
    DownloadWithUpdate.SmallUpdate last = download.update();
    if (last.status == Download.Status.ACTIVE) {
        detailsChart.setVisibility(View.VISIBLE);

        LineData data = detailsChart.getData();
        if (data == null) {
            Utils.setupChart(detailsChart, true);
            data = detailsChart.getData();
        }

        if (data != null) {
            int pos = data.getEntryCount() / 2 + 1;
            data.addEntry(new Entry(pos, last.downloadSpeed), Utils.CHART_DOWNLOAD_SET);
            data.addEntry(new Entry(pos, last.uploadSpeed), Utils.CHART_UPLOAD_SET);
            data.notifyDataChanged();
            detailsChart.notifyDataSetChanged();

            detailsChart.setVisibleXRangeMaximum(90);
            detailsChart.moveViewToX(pos - 91);
        }
    } else {
        detailsChart.clear();
        detailsChart.setVisibility(View.GONE);
    }

    if (last.status == Download.Status.ERROR || last.status == Download.Status.REMOVED || last.status == Download.Status.COMPLETE)
        toggleNotification.setVisibility(View.GONE);
    else
        toggleNotification.setVisibility(View.VISIBLE);

    donutProgress.setProgress(last.getProgress());
    downloadName.setText(last.getName());
    if (last.status == Download.Status.ERROR) {
        if (last.errorMessage == null)
            downloadStatus.setText(String.format(Locale.getDefault(), "%s #%d", last.status.getFormal(context, true), last.errorCode));
        else
            downloadStatus.setText(String.format(Locale.getDefault(), "%s #%d: %s", last.status.getFormal(context, true), last.errorCode, last.errorMessage));
    } else {
        downloadStatus.setText(last.status.getFormal(context, true));
    }

    customInfo.update(last);

    detailsCompletedLength.setHtml(R.string.completed_length, CommonUtils.dimensionFormatter(last.completedLength, false));

    if (last.isTorrent()) {
        detailsUploadLength.setHtml(R.string.uploaded_length, CommonUtils.dimensionFormatter(last.uploadLength, false));
        detailsUploadLength.setVisibility(View.VISIBLE);
    } else {
        detailsUploadLength.setVisibility(View.GONE);
    }

    setupActions(download);

    CommonUtils.setRecyclerViewTopMargin(this);
}