Skip to content

Commit

Permalink
some code cleanup/refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
justinvforvendetta committed Jul 27, 2024
1 parent ff7b297 commit 133d3f7
Show file tree
Hide file tree
Showing 49 changed files with 148 additions and 148 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ public void getUnspentTx(final AddressStatus status,
checkNotNull(stratumClient);

CallMessage message = new CallMessage("blockchain.address.listunspent",
Arrays.asList(status.getAddress().toString()));
Collections.singletonList(status.getAddress().toString()));
final ListenableFuture<ResultMessage> result = stratumClient.call(message);

Futures.addCallback(result, new FutureCallback<ResultMessage>() {
Expand Down Expand Up @@ -464,7 +464,7 @@ public void getHistoryTx(final AddressStatus status,
checkNotNull(stratumClient);

final CallMessage message = new CallMessage("blockchain.address.get_history",
Arrays.asList(status.getAddress().toString()));
Collections.singletonList(status.getAddress().toString()));
final ListenableFuture<ResultMessage> result = stratumClient.call(message);

Futures.addCallback(result, new FutureCallback<ResultMessage>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static Protos.Wallet toProtobuf(Wallet wallet) {
} else {
// Some other form of encryption has been specified that we do not know how to persist.
throw new RuntimeException("The wallet has encryption of type '" +
keyCrypter.getClass().toString() + "' but this WalletProtobufSerializer " +
keyCrypter.getClass() + "' but this WalletProtobufSerializer " +
"does not know how to persist this.");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public Map<Sha256Hash, NxtTransaction> getPendingTransactions() {

@Override
public List<AbstractAddress> getActiveAddresses() {
return ImmutableList.of((AbstractAddress) address);
return ImmutableList.of(address);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ final public class NxtFamilyWalletProtobufSerializer {
private static final Logger log = LoggerFactory.getLogger(NxtFamilyWalletProtobufSerializer.class);

// Used for de-serialization
private Map<ByteString, Transaction> txMap = new HashMap<ByteString, Transaction>();
private final Map<ByteString, Transaction> txMap = new HashMap<ByteString, Transaction>();

public static Protos.WalletPocket toProtobuf(NxtFamilyWallet account) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public List<AbstractOutput> getSentTo() {

@Override
public List<AbstractAddress> getReceivedFrom() {
return ImmutableList.of((AbstractAddress) new NxtAddress(type, tx.getSenderId()));
return ImmutableList.of(new NxtAddress(type, tx.getSenderId()));
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions wallet/src/main/java/com/vergepay/wallet/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ public class Constants {
}

public static final CoinType DEFAULT_COIN = VergeMain.get();
public static final List<CoinType> DEFAULT_COINS = ImmutableList.of((CoinType) VergeMain.get());
public static final List<CoinType> DEFAULT_COINS = ImmutableList.of(VergeMain.get());
public static final ArrayList<String> DEFAULT_TEST_COIN_IDS = Lists.newArrayList(
BitcoinTest.get().getId(),
LitecoinTest.get().getId()
);

public static final List<CoinType> SUPPORTED_COINS = ImmutableList.of(
(CoinType) VergeMain.get()
VergeMain.get()
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ public String toString() {
private String lastCryptoCurrency = null;

private static final String BASE_URL = "https://www.binance.com/api/v3/ticker/price?symbol=XVGUSDT";
private static final String TO_LOCAL_URL = BASE_URL + ""; // "/to-local/%s";
private static final String TO_CRYPTO_URL = BASE_URL + ""; //"/to-crypto/%s";
private static final String TO_LOCAL_URL = BASE_URL; // "/to-local/%s";
private static final String TO_CRYPTO_URL = BASE_URL; //"/to-crypto/%s";
private static final String COINOMI_SOURCE = "http://dvzs4zoxkg6z43dd.onion";

private static final Logger log = LoggerFactory.getLogger(ExchangeRatesProvider.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected void onCreate(Bundle savedInstanceState) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(false);

TextView version = (TextView) findViewById(R.id.about_version);
TextView version = findViewById(R.id.about_version);
if (getWalletApplication().packageInfo() != null) {
version.setText(getWalletApplication().packageInfo().versionName);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_account_details, container, false);

TextView publicKey = (TextView) view.findViewById(R.id.public_key);
TextView publicKey = view.findViewById(R.id.public_key);
publicKey.setOnClickListener(getPubKeyOnClickListener());
publicKey.setText(publicKeySerialized);

ImageView qrView = (ImageView) view.findViewById(R.id.qr_code_public_key);
ImageView qrView = view.findViewById(R.id.qr_code_public_key);
QrUtils.setQr(qrView, getResources(), publicKeySerialized);

return view;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ private void showNewAddressDialog() {
}

private void updateExchangeRate(ExchangeRate exchangeRate) {
amountCalculatorLink.setExchangeRate((ExchangeRate) exchangeRate);
amountCalculatorLink.setExchangeRate(exchangeRate);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ public View getView(final int position, View row, final ViewGroup parent) {
}

public void bindView(@Nonnull final View row, @Nonnull final AbstractAddress address) {
TextView addressLabel = (TextView) row.findViewById(R.id.address_row_label);
TextView addressRaw = (TextView) row.findViewById(R.id.address_row_address);
TextView addressLabel = row.findViewById(R.id.address_row_label);
TextView addressRaw = row.findViewById(R.id.address_row_address);

String label = resolveLabel(address);

Expand All @@ -147,8 +147,8 @@ public void bindView(@Nonnull final View row, @Nonnull final AbstractAddress add
addressRaw.setVisibility(View.GONE);
}

TextView addressUsageLabel = (TextView) row.findViewById(R.id.address_row_usage);
TextView addressUsageFontIcon = (TextView) row.findViewById(R.id.address_row_usage_font_icon);
TextView addressUsageLabel = row.findViewById(R.id.address_row_usage);
TextView addressUsageFontIcon = row.findViewById(R.id.address_row_usage_font_icon);
Fonts.setTypeface(addressUsageFontIcon, Fonts.Font.COINOMI_FONT_ICONS);

if (usedAddresses.contains(address)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public static AppLockFragment newInstance(Bundle args) {
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_app_lock, container, false);
fingerPrintButton = (Button) view.findViewById(R.id.fingerprint_button);
pincodeButton = (Button) view.findViewById(R.id.pincode_button);
skipButton = (Button) view.findViewById(R.id.skip_button);
fingerPrintButton = view.findViewById(R.id.fingerprint_button);
pincodeButton = view.findViewById(R.id.pincode_button);
skipButton = view.findViewById(R.id.skip_button);

pincodeButton.setOnClickListener(new View.OnClickListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

boolean hasPincodeHash = ((WalletApplication) getApplication()).getConfiguration().hasPincodeHash();

Button removeAppLock = (Button) findViewById(R.id.remove_app_lock);
Button removeAppLock = findViewById(R.id.remove_app_lock);

if (hasPincodeHash) {
removeAppLock.setOnClickListener(new View.OnClickListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public DialogBuilder(final Context context) {
super(context);

this.customTitle = LayoutInflater.from(context).inflate(R.layout.dialog_title, null);
this.iconView = (ImageView) customTitle.findViewById(android.R.id.icon);
this.titleView = (TextView) customTitle.findViewById(android.R.id.title);
this.iconView = customTitle.findViewById(android.R.id.icon);
this.titleView = customTitle.findViewById(android.R.id.title);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ public Dialog onCreateDialog(final Bundle savedInstanceState) {

final View view = inflater.inflate(R.layout.edit_address_book_entry_dialog, null);

final TextView viewAddress = (TextView) view.findViewById(R.id.edit_address_book_entry_address);
final TextView viewAddress = view.findViewById(R.id.edit_address_book_entry_address);
viewAddress.setText(GenericUtils.addressSplitToGroups(address));

final TextView viewLabel = (TextView) view.findViewById(R.id.edit_address_book_entry_label);
final TextView viewLabel = view.findViewById(R.id.edit_address_book_entry_label);
viewLabel.setText(label != null ? label : suggestedAddressLabel);

dialog.setView(view);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
super.onCreateView(inflater, container, savedInstanceState);
View view = inflater.inflate(R.layout.fragment_pincode, container, false);

pinCode1 = ((EditText) view.findViewById(R.id.pincode_1));
pinCode2 = ((EditText) view.findViewById(R.id.pincode_2));
pinCode3 = ((EditText) view.findViewById(R.id.pincode_3));
pinCode4 = ((EditText) view.findViewById(R.id.pincode_4));
pinCode1 = view.findViewById(R.id.pincode_1);
pinCode2 = view.findViewById(R.id.pincode_2);
pinCode3 = view.findViewById(R.id.pincode_3);
pinCode4 = view.findViewById(R.id.pincode_4);

pinCode1.addTextChangedListener(new ViewSwitcher(pinCode2));
pinCode2.addTextChangedListener(new ViewSwitcher(pinCode3));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public View onCreateView(final LayoutInflater inflater, final ViewGroup containe
@Override
public void setEmptyText(final CharSequence text) {
if (getView() != null) {
final TextView emptyView = (TextView) getView().findViewById(android.R.id.empty);
final TextView emptyView = getView().findViewById(android.R.id.empty);
emptyView.setText(text);
}
}
Expand Down Expand Up @@ -136,11 +136,11 @@ public void bindView(final View view, final Context context, final Cursor cursor
Fonts.setTypeface(errorIcon, Fonts.Font.COINOMI_FONT_ICONS);
Fonts.setTypeface(view.findViewById(R.id.exchange_arrow), Fonts.Font.COINOMI_FONT_ICONS);
final View progress = view.findViewById(R.id.exchange_status_progress);
final TextView statusText = (TextView) view.findViewById(R.id.exchange_status_text);
final TextView statusText = view.findViewById(R.id.exchange_status_text);
final View values = view.findViewById(R.id.exchange_values);
final Amount deposit = (Amount) view.findViewById(R.id.exchange_deposit);
final Amount withdraw = (Amount) view.findViewById(R.id.exchange_withdraw);
final AddressView addressView = (AddressView) view.findViewById(R.id.withdraw_address);
final Amount deposit = view.findViewById(R.id.exchange_deposit);
final Amount withdraw = view.findViewById(R.id.exchange_withdraw);
final AddressView addressView = view.findViewById(R.id.withdraw_address);

switch (entry.status) {
case ExchangeEntry.STATUS_INITIAL:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public View onCreateView(final LayoutInflater inflater, final ViewGroup containe

@Override
public void setEmptyText(final CharSequence text) {
final TextView emptyView = (TextView) getView().findViewById(android.R.id.empty);
final TextView emptyView = getView().findViewById(android.R.id.empty);
emptyView.setText(text);
}

Expand Down Expand Up @@ -279,10 +279,10 @@ public void bindView(final View view, final Context context, final Cursor cursor

view.setBackgroundResource(isDefaultCurrency ? R.color.bg_list_selected : R.color.bg_list);

final TextView currencyCodeView = (TextView) view.findViewById(R.id.exchange_rate_row_currency_code);
final TextView currencyCodeView = view.findViewById(R.id.exchange_rate_row_currency_code);
currencyCodeView.setText(exchangeRate.currencyCodeId);

final TextView currencyNameView = (TextView) view.findViewById(R.id.exchange_rate_row_currency_name);
final TextView currencyNameView = view.findViewById(R.id.exchange_rate_row_currency_name);
String currencyName = WalletUtils.getCurrencyName(exchangeRate.currencyCodeId);
if (currencyName != null) {
currencyNameView.setText(currencyName);
Expand All @@ -292,11 +292,11 @@ public void bindView(final View view, final Context context, final Cursor cursor
currencyNameView.setVisibility(View.INVISIBLE);
}

final Amount rateAmountUnitView = (Amount) view.findViewById(R.id.exchange_rate_row_rate_unit);
final Amount rateAmountUnitView = view.findViewById(R.id.exchange_rate_row_rate_unit);
rateAmountUnitView.setAmount(GenericUtils.formatCoinValue(type, rateBase, true));
rateAmountUnitView.setSymbol(type.getSymbol());

final Amount rateAmountView = (Amount) view.findViewById(R.id.exchange_rate_row_rate);
final Amount rateAmountView = view.findViewById(R.id.exchange_rate_row_rate);
Value fiatAmount = exchangeRate.rate.convert(type, rateBase);
rateAmountView.setAmount(GenericUtils.formatFiatValue(fiatAmount));
rateAmountView.setSymbol(fiatAmount.type.getSymbol());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_finalize_wallet_restoration, container, false);
status = (TextView) view.findViewById(R.id.restoration_status);
status = view.findViewById(R.id.restoration_status);
return view;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,

transactionInfo.setVisibility(View.GONE);

final TextView passwordLabelView = (TextView) view.findViewById(R.id.enter_password_label);
final TextView passwordLabelView = view.findViewById(R.id.enter_password_label);
if (sourceAccount != null && sourceAccount.isEncrypted()) {
passwordView.requestFocus();
passwordView.setVisibility(View.VISIBLE);
Expand All @@ -231,7 +231,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
tradeWithdrawSendOutput.setVisibility(View.GONE);
showTransaction();

TextView poweredByShapeShift = (TextView) view.findViewById(R.id.powered_by_shapeshift);
TextView poweredByShapeShift = view.findViewById(R.id.powered_by_shapeshift);
poweredByShapeShift.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_navigation_drawer, container, false);

mDrawerListView = (ListView) view.findViewById(R.id.coins_list);
mDrawerListView = view.findViewById(R.id.coins_list);
mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,

Fonts.setTypeface(view.findViewById(R.id.key_icon), Fonts.Font.COINOMI_FONT_ICONS);

TextView messageView = (TextView) view.findViewById(R.id.message);
TextView messageView = view.findViewById(R.id.message);
if (message != null) {
messageView.setText(message);
} else {
messageView.setVisibility(View.GONE);
}

final EditText password = (EditText) view.findViewById(R.id.password);
final EditText password = view.findViewById(R.id.password);

view.findViewById(R.id.button_confirm).setOnClickListener(new View.OnClickListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
}

// Setup accounts that we can send from directly
ViewGroup typeAccounts = (ViewGroup) view.findViewById(R.id.pay_with_layout);
ViewGroup typeAccounts = view.findViewById(R.id.pay_with_layout);
boolean canSend = false;
for (WalletAccount account : app.getAccounts(type)) {
if (account.getBalance().isPositive()) {
Expand All @@ -85,7 +85,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
}

// Setup possible exchange accounts
ViewGroup exchangeAccounts = (ViewGroup) view.findViewById(R.id.exchange_and_pay_layout);
ViewGroup exchangeAccounts = view.findViewById(R.id.exchange_and_pay_layout);
boolean canExchange = false;
for (WalletAccount account : app.getAllAccounts()) {
if (!account.isType(type) && account.getBalance().isPositive()) {
Expand All @@ -95,7 +95,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
}

if (canExchange) {
TextView poweredByShapeShift = (TextView) view.findViewById(R.id.powered_by_shapeshift);
TextView poweredByShapeShift = view.findViewById(R.id.powered_by_shapeshift);
poweredByShapeShift.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,

View view = inflater.inflate(R.layout.fragment_previous_addresses, container, false);

final ListView previousAddresses = (ListView) view.findViewById(R.id.previous_addresses);
final ListView previousAddresses = view.findViewById(R.id.previous_addresses);

// Set a space to the beginning and end of the list. If possible find a better way
View spacerView = new View(getActivity());
Expand Down
Loading

0 comments on commit 133d3f7

Please sign in to comment.