Skip to content

Commit

Permalink
Refactor SendActivity
Browse files Browse the repository at this point in the history
  • Loading branch information
erasmospunk committed Apr 23, 2016
1 parent 7b3bb5c commit 251545d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 34 deletions.
38 changes: 7 additions & 31 deletions wallet/src/main/java/com/coinomi/wallet/ui/SendActivity.java
Original file line number Diff line number Diff line change
@@ -1,48 +1,24 @@
package com.coinomi.wallet.ui;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;

import com.coinomi.core.wallet.WalletAccount;
import com.coinomi.wallet.R;

import org.bitcoinj.core.Transaction;

import com.coinomi.wallet.Constants;

/**
* // TODO use WalletActivity to process URIs
* @author John L. Jegutanis
*/
@Deprecated
public class SendActivity extends BaseWalletActivity implements SendFragment.Listener {
public class SendActivity extends BaseWalletActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_fragment_wrapper);

if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, SendFragment.newInstance(getIntent().getData()))
.commit();
}
}

@Override
public void onTransactionBroadcastSuccess(WalletAccount pocket, Transaction transaction) {
Toast.makeText(this, getString(R.string.sent_msg), Toast.LENGTH_LONG).show();
finish();
}

@Override
public void onTransactionBroadcastFailure(WalletAccount pocket, Transaction transaction) {
Toast.makeText(this, getString(R.string.get_tx_broadcast_error), Toast.LENGTH_LONG).show();
finish();
}
Intent intent = new Intent(this, WalletActivity.class);
intent.putExtra(Constants.ARG_URI, getIntent().getDataString());
startActivity(intent);

@Override
public void showPayToDialog(String addressStr) {
Toast.makeText(this, getString(R.string.error_generic), Toast.LENGTH_LONG).show();
finish();
}
}
4 changes: 1 addition & 3 deletions wallet/src/main/java/com/coinomi/wallet/ui/SendFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,14 @@ public static SendFragment newInstance(String accountId) {
* @param uri the payment uri
* @return A new instance of fragment WalletSendCoins.
*/
public static SendFragment newInstance(Uri uri) {
public static SendFragment newInstance(String accountId, CoinURI uri) {
SendFragment fragment = new SendFragment();
Bundle args = new Bundle();
args.putString(Constants.ARG_URI, uri.toString());
fragment.setArguments(args);
return fragment;
}



public SendFragment() {
// Required empty public constructor
}
Expand Down
13 changes: 13 additions & 0 deletions wallet/src/main/java/com/coinomi/wallet/ui/WalletActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ final public class WalletActivity extends BaseWalletActivity implements
private static final int SET_URI = 2;
private static final int OPEN_ACCOUNT = 3;
private static final int OPEN_OVERVIEW = 4;
private static final int PROCESS_URI = 5;

// Fragment tags
private static final String ACCOUNT_TAG = "account_tag";
Expand Down Expand Up @@ -164,6 +165,11 @@ protected void onCreate(Bundle savedInstanceState) {
navDrawerItems);

lastAccountId = getWalletApplication().getConfiguration().getLastAccountId();

if (getIntent().hasExtra(Constants.ARG_URI)) {
handler.sendMessage(handler.obtainMessage(PROCESS_URI,
getIntent().getStringExtra(Constants.ARG_URI)));
}
}

private void setOverviewTitle() {
Expand Down Expand Up @@ -820,6 +826,13 @@ protected void weakHandleMessage(WalletActivity ref, Message msg) {
case OPEN_OVERVIEW:
ref.openOverview();
break;
case PROCESS_URI:
try {
ref.processUri((String) msg.obj);
} catch (CoinURIParseException e) {
ref.showScanFailedMessage(e);
}
break;
}
}
}
Expand Down

0 comments on commit 251545d

Please sign in to comment.