com.gianlu.commonutils.misc.SuperTextView Java Examples
The following examples show how to use
com.gianlu.commonutils.misc.SuperTextView.
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: RootNameserverFragment.java From DNSHero with GNU General Public License v3.0 | 5 votes |
@Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { ScrollView layout = (ScrollView) inflater.inflate(R.layout.fragment_root_nameserver, container, false); Bundle args = getArguments(); Domain.RootNameserver root; if (getContext() == null || args == null || (root = (Domain.RootNameserver) args.getSerializable("root")) == null) return null; SuperTextView name = layout.findViewById(R.id.rootNsFragment_name); Utils.clickToCopy(name); name.setText(root.name); SuperTextView rtt = layout.findViewById(R.id.rootNsFragment_rtt); rtt.setHtml(R.string.rtt, Utils.formatRTT(root.rtt)); final LinearLayout nameservers = layout.findViewById(R.id.rootNsFragment_nameservers); for (String nameserver : root.nameservers) { TextView text = (TextView) inflater.inflate(R.layout.item_secondary_text, nameservers, false); text.setText(nameserver); Utils.clickToCopy(text); nameservers.addView(text); } final ImageButton toggleNs = layout.findViewById(R.id.rootNsFragment_toggleNs); toggleNs.setOnClickListener(v -> CommonUtils.handleCollapseClick(toggleNs, nameservers)); GlueView glue = layout.findViewById(R.id.rootNsFragment_glue); glue.setGlue(root.glue); return layout; }
Example #2
Source File: CustomDownloadInfo.java From Aria2App with GNU General Public License v3.0 | 5 votes |
public void setText(String text) { SuperTextView textView = (SuperTextView) getChildAt(1); if (textView == null) { textView = SuperTextView.text(getContext(), text); textView.setTextColor(Color.WHITE); textView.setPaddingRelative(0, 0, dp16 / 2, 0); addView(textView); return; } textView.setText(text); }
Example #3
Source File: TestFragment.java From Aria2App with GNU General Public License v3.0 | 5 votes |
@Override public void addItem(@NonNull String message, @NonNull BaseTester.Color color) { if (testResults != null && isAdded()) { testResults.addView(SuperTextView.builder(requireContext()) .text(message) .color(color.getColor(requireContext())) .build()); testResults.postDelayed(() -> ((ScrollView) testResults.getParent()).fullScroll(ScrollView.FOCUS_DOWN), 100); } }
Example #4
Source File: GamesAdapter.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 5 votes |
@Override public void onBindViewHolder(@NonNull ViewHolder holder, int position) { final SessionHistory.Game game = games.get(position); ((SuperTextView) holder.itemView).setHtml(R.string.gameStartedAt, CommonUtils.getFullVerbalDateFormatter().format(new Date(game.timestamp))); holder.itemView.setOnClickListener(v -> { if (listener != null) listener.onGameSelected(game); }); }
Example #5
Source File: OngoingGameFragment.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 5 votes |
private void showSpectators() { if (manager == null || getContext() == null) return; Collection<String> spectators = manager.spectators(); SuperTextView text = SuperTextView.html(getContext(), spectators.isEmpty() ? "<i>none</i>" : CommonUtils.join(spectators, ", ")); int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24, getResources().getDisplayMetrics()); text.setPadding(padding, padding, padding, padding); MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getContext()); builder.setTitle(R.string.spectatorsLabel) .setView(text) .setPositiveButton(android.R.string.ok, null); DialogUtils.showDialog(getActivity(), builder); }
Example #6
Source File: Dialogs.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 5 votes |
@NonNull @SuppressLint("InflateParams") public static MaterialAlertDialogBuilder gameOptions(@NonNull Context context, @NonNull Game.Options options, @NonNull FirstLoad firstLoad) { ScrollView layout = (ScrollView) LayoutInflater.from(context).inflate(R.layout.dialog_game_options, null, false); SuperTextView scoreLimit = layout.findViewById(R.id.gameOptions_scoreLimit); scoreLimit.setHtml(R.string.scoreLimit, options.scoreLimit); SuperTextView playerLimit = layout.findViewById(R.id.gameOptions_playerLimit); playerLimit.setHtml(R.string.playerLimit, options.playersLimit); SuperTextView spectatorLimit = layout.findViewById(R.id.gameOptions_spectatorLimit); spectatorLimit.setHtml(R.string.spectatorLimit, options.spectatorsLimit); SuperTextView timerMultiplier = layout.findViewById(R.id.gameOptions_timerMultiplier); timerMultiplier.setHtml(R.string.timerMultiplier, options.timerMultiplier); SuperTextView cardSets = layout.findViewById(R.id.gameOptions_cardSets); cardSets.setHtml(R.string.cardSets, options.cardSets.isEmpty() ? "<i>none</i>" : CommonUtils.join(firstLoad.createCardSetNamesList(options.cardSets), ", ")); SuperTextView blankCards = layout.findViewById(R.id.gameOptions_blankCards); blankCards.setHtml(R.string.blankCards, options.blanksLimit); SuperTextView password = layout.findViewById(R.id.gameOptions_password); if (options.password == null || options.password.isEmpty()) password.setVisibility(View.GONE); else password.setHtml(R.string.password, options.password); MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context); builder.setTitle(R.string.gameOptions) .setView(layout) .setPositiveButton(android.R.string.ok, null); return builder; }
Example #7
Source File: ChatAdapter.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 5 votes |
@Override public void onBindViewHolder(@NonNull ViewHolder holder, int position) { PollMessage message = messages.get(position); holder.text.setHtml(SuperTextView.makeBold(message.sender) + ": " + message.message); holder.itemView.setOnClickListener(v -> { if (listener != null) listener.onChatItemSelected(message.sender); }); if (message.emote) CommonUtils.setTextColor(holder.text, R.color.purple); else if (message.wall) CommonUtils.setTextColor(holder.text, R.color.red); else CommonUtils.setTextColorFromAttr(holder.text, android.R.attr.textColorSecondary); }
Example #8
Source File: TopCountriesView.java From Aria2App with GNU General Public License v3.0 | 4 votes |
public void clear() { topCountries.clear(); removeAllViews(); addView(SuperTextView.text(getContext(), R.string.noActivity)); }
Example #9
Source File: DirectorySheet.java From Aria2App with GNU General Public License v3.0 | 4 votes |
@Override protected void onCreateBody(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent, @NonNull SetupPayload payload) { inflater.inflate(R.layout.sheet_dir, parent, true); currentDir = payload.dir; final DownloadWithUpdate download = payload.download; SuperTextView indexes = parent.findViewById(R.id.dirSheet_indexes); indexes.setHtml(R.string.indexes, CommonUtils.join(currentDir.indexes, ", ")); SuperTextView path = parent.findViewById(R.id.dirSheet_path); path.setHtml(R.string.path, download.update().dir + currentDir.path); length = parent.findViewById(R.id.dirSheet_length); selected = parent.findViewById(R.id.dirSheet_selected); completedLength = parent.findViewById(R.id.dirSheet_completedLength); update(currentDir); if (download.update().canDeselectFiles()) { selected.setEnabled(true); selected.setOnCheckedChangeListener((buttonView, isChecked) -> download.changeSelection(currentDir.indexes.toArray(new Integer[0]), isChecked, new AbstractClient.OnResult<Download.ChangeSelectionResult>() { @Override public void onResult(@NonNull Download.ChangeSelectionResult result) { if (!isAdded()) return; Toaster toaster = Toaster.build(); toaster.extra(result); switch (result) { case EMPTY: toaster.message(R.string.cannotDeselectAllFiles); break; case SELECTED: toaster.message(R.string.fileSelected); break; case DESELECTED: toaster.message(R.string.fileDeselected); break; default: toaster.message(R.string.failedAction); break; } dismissAllowingStateLoss(); DialogUtils.showToast(getContext(), toaster); } @Override public void onException(@NonNull Exception ex) { if (!isAdded()) return; dismissAllowingStateLoss(); Log.e(TAG, "Failed changing selection.", ex); DialogUtils.showToast(getContext(), Toaster.build().message(R.string.failedFileChangeSelection)); } })); } else { selected.setEnabled(false); } isLoading(false); }
Example #10
Source File: FileSheet.java From Aria2App with GNU General Public License v3.0 | 4 votes |
@Override protected void onCreateBody(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent, @NonNull SetupPayload payload) { inflater.inflate(R.layout.sheet_file, parent, true); final DownloadWithUpdate download = payload.download; final AriaFile file = payload.file; SuperTextView index = parent.findViewById(R.id.fileSheet_index); index.setHtml(R.string.index, file.index); SuperTextView path = parent.findViewById(R.id.fileSheet_path); path.setHtml(R.string.path, file.path); length = parent.findViewById(R.id.fileSheet_length); completedLength = parent.findViewById(R.id.fileSheet_completedLength); selected = parent.findViewById(R.id.fileSheet_selected); update(file); if (download.update().canDeselectFiles()) { selected.setEnabled(true); selected.setOnCheckedChangeListener((buttonView, isChecked) -> download.changeSelection(new Integer[]{file.index}, isChecked, new AbstractClient.OnResult<Download.ChangeSelectionResult>() { @Override public void onResult(@NonNull Download.ChangeSelectionResult result) { if (!isAdded()) return; Toaster toaster = Toaster.build(); toaster.extra(result); switch (result) { case EMPTY: toaster.message(R.string.cannotDeselectAllFiles); break; case SELECTED: file.selected = true; toaster.message(R.string.fileSelected); break; case DESELECTED: file.selected = false; toaster.message(R.string.fileDeselected); break; default: toaster.message(R.string.failedAction); break; } dismissAllowingStateLoss(); DialogUtils.showToast(getContext(), toaster); } @Override public void onException(@NonNull Exception ex) { if (!isAdded() || getContext() == null) return; dismissAllowingStateLoss(); Log.e(TAG, "Failed changing selection.", ex); DialogUtils.showToast(getContext(), Toaster.build().message(R.string.failedFileChangeSelection)); } })); } else { selected.setEnabled(false); } isLoading(false); }
Example #11
Source File: UserInfoDialog.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 4 votes |
@Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.dialog_user_info, container, false); WhoisResult user = getUser(); if (user == null) return null; TextView name = layout.findViewById(R.id.userInfoDialog_name); name.setText(user.nickname); SuperTextView sigil = layout.findViewById(R.id.userInfoDialog_sigil); sigil.setHtml(R.string.sigil, user.sigil.getFormal(getContext())); SuperTextView idCode = layout.findViewById(R.id.userInfoDialog_idCode); if (user.idCode.isEmpty()) { idCode.setVisibility(View.GONE); } else { idCode.setVisibility(View.VISIBLE); idCode.setHtml(R.string.idCode, user.idCode); } SuperTextView connAt = layout.findViewById(R.id.userInfoDialog_connAt); connAt.setHtml(R.string.connectedAt, CommonUtils.getFullDateFormatter().format(new Date(user.connectedAt))); SuperTextView idleFrom = layout.findViewById(R.id.userInfoDialog_idle); idleFrom.setHtml(R.string.idleFor, CommonUtils.timeFormatter(user.idle / 1000)); SuperTextView ipAddr = layout.findViewById(R.id.userInfoDialog_ipAddr); if (user.ipAddress() == null) { ipAddr.setVisibility(View.GONE); } else { ipAddr.setVisibility(View.VISIBLE); ipAddr.setHtml(R.string.ipAddress, user.ipAddress()); } SuperTextView client = layout.findViewById(R.id.userInfoDialog_client); if (user.clientName() == null) { client.setVisibility(View.GONE); } else { client.setVisibility(View.VISIBLE); client.setHtml(R.string.clientName, user.clientName()); } Button blockUser = layout.findViewById(R.id.userInfoDialog_block); if (BlockedUsers.isBlocked(user.nickname)) { blockUser.setVisibility(View.GONE); } else { blockUser.setVisibility(View.VISIBLE); blockUser.setOnClickListener(v -> { BlockedUsers.block(user.nickname); dismissAllowingStateLoss(); }); } Button viewGame = layout.findViewById(R.id.userInfoDialog_viewGame); SuperTextView game = layout.findViewById(R.id.userInfoDialog_game); final Game gameInfo = user.game(); if (gameInfo == null) { game.setVisibility(View.GONE); viewGame.setVisibility(View.GONE); } else { game.setVisibility(View.VISIBLE); Object[] args = new Object[3]; args[0] = gameInfo.host; args[1] = gameInfo.players.size(); args[2] = gameInfo.options.playersLimit; if (gameInfo.hasPassword(false)) { if (gameInfo.status.isStarted()) game.setHtml(R.string.gameStartedLockedDetails, args); else game.setHtml(R.string.gameLobbyLockedDetails, args); } else { if (gameInfo.status.isStarted()) game.setHtml(R.string.gameStartedOpenDetails, args); else game.setHtml(R.string.gameLobbyOpenDetails, args); } if (listener != null && listener.canViewGame()) { viewGame.setVisibility(View.VISIBLE); viewGame.setOnClickListener(v -> { if (listener != null) { listener.viewGame(gameInfo.gid, gameInfo.hasPassword(false)); dismissAllowingStateLoss(); } }); } else { viewGame.setVisibility(View.GONE); } } return layout; }
Example #12
Source File: NamesAdapter.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 4 votes |
@Override protected void onSetupViewHolder(@NonNull ViewHolder holder, int position, @NonNull final Name name) { ((SuperTextView) holder.itemView).setHtml(name.sigil() == Name.Sigil.NORMAL_USER ? name.withSigil() : (SuperTextView.makeBold(name.sigil().symbol()) + name.noSigil())); holder.itemView.setOnClickListener(v -> listener.onNameSelected(name.noSigil())); }
Example #13
Source File: ChatAdapter.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 4 votes |
ViewHolder(ViewGroup parent) { super(inflater.inflate(R.layout.item_chat, parent, false)); text = (SuperTextView) itemView; }