Advertisement
Guest User

Untitled

a guest
May 26th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.88 KB | None | 0 0
  1. package com.example.rina.agora_app.activities;
  2.  
  3. import android.app.AlertDialog;
  4. import android.content.DialogInterface;
  5. import android.os.Bundle;
  6. import android.os.Environment;
  7. import android.support.design.widget.FloatingActionButton;
  8.  
  9. import android.support.v7.app.AppCompatActivity;
  10.  
  11. import android.support.v7.widget.Toolbar;
  12. import android.view.LayoutInflater;
  13. import android.view.View;
  14.  
  15. import android.widget.EditText;
  16.  
  17. import com.example.rina.agora_app.R;
  18.  
  19. import org.web3j.crypto.CipherException;
  20. import org.web3j.crypto.Credentials;
  21. import org.web3j.crypto.ECKeyPair;
  22. import org.web3j.crypto.Wallet;
  23. import org.web3j.crypto.WalletUtils;
  24. import org.web3j.protocol.Web3j;
  25. import org.web3j.protocol.http.HttpService;
  26.  
  27. import java.io.IOException;
  28. import java.math.BigInteger;
  29.  
  30. import static android.os.Environment.DIRECTORY_DOWNLOADS;
  31. import static org.web3j.tx.Transfer.GAS_LIMIT;
  32. import static org.web3j.tx.gas.DefaultGasProvider.GAS_PRICE;
  33.  
  34. public class VoteActivity extends AppCompatActivity {
  35.  
  36. @Override
  37. protected void onCreate(Bundle savedInstanceState) {
  38. super.onCreate(savedInstanceState);
  39. setContentView(R.layout.activity_vote);
  40. Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  41. setSupportActionBar(toolbar);
  42. Bundle arguments = getIntent().getExtras();
  43. String password = arguments.get("hello1").toString();
  44.  
  45. FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
  46. fab.setOnClickListener(new View.OnClickListener() {
  47. @Override
  48. public void onClick(View view) {
  49. LayoutInflater li = LayoutInflater.from(VoteActivity.this);
  50. View promptsView = li.inflate(R.layout.dialog_send_vote, null);
  51. AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(VoteActivity.this);
  52. alertDialogBuilder.setView(promptsView);
  53.  
  54. final EditText editTextTitle = (EditText) promptsView.findViewById(R.id.editTextTitle);
  55. final EditText editTextMessage = (EditText) promptsView.findViewById(R.id.editTextMessage);
  56.  
  57. alertDialogBuilder
  58. .setCancelable(false)
  59. .setPositiveButton("Отправить",
  60. new DialogInterface.OnClickListener() {
  61. public void onClick(DialogInterface dialog, int id) {
  62. BigInteger param1= BigInteger.valueOf(6);
  63. BigInteger param2= BigInteger.valueOf(5);
  64. BigInteger param3= BigInteger.valueOf(0);
  65. String title = editTextTitle.getText().toString();
  66. String message = editTextMessage.getText().toString();
  67. Web3j web3j = Web3j.build(new HttpService("https://rinkeby.infura.io/v3/668457c0a6114bbd85551b53353ada9a"));
  68.  
  69. String passwordText = password;
  70. Credentials credentials = null;
  71. // try {
  72. // credentials=WalletUtils.g
  73. // // credentials = WalletUtils.loadCredentials( password, Environment.getExternalStoragePublicDirectory(DIRECTORY_DOWNLOADS));
  74. // } catch (IOException e) {
  75. // e.printStackTrace();
  76. // } catch (CipherException e) {
  77. // e.printStackTrace();
  78. // }
  79.  
  80.  
  81. // Congress congress = null;
  82. // try {
  83. // congress = Congress.deploy(web3j, credentials,
  84. // GAS_PRICE, GAS_LIMIT,param1,param2,param3).send();
  85. // } catch (Exception e) {
  86. // e.printStackTrace();
  87. // }
  88. // congress.getContractAddress();
  89.  
  90. }
  91. })
  92. .setNegativeButton("Закрыть",
  93. new DialogInterface.OnClickListener() {
  94. public void onClick(DialogInterface dialog, int id) {
  95. dialog.cancel();
  96. }
  97. });
  98. AlertDialog alertDialog = alertDialogBuilder.create();
  99. alertDialog.show();
  100.  
  101.  
  102. }
  103. });
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement