test and connection to API
Register and Login with query balance for user Hash
This commit is contained in:
parent
a494c02d90
commit
961519e6f5
Binary file not shown.
|
@ -113,6 +113,7 @@ public class RegisterActivity extends AppCompatActivity {
|
||||||
try{
|
try{
|
||||||
if(result!=null){
|
if(result!=null){
|
||||||
if(result.getInt("status") == 200){
|
if(result.getInt("status") == 200){
|
||||||
|
System.out.println(result);
|
||||||
Intent accountIntent = new Intent(RegisterActivity.this, UserAccountActivity.class);
|
Intent accountIntent = new Intent(RegisterActivity.this, UserAccountActivity.class);
|
||||||
accountIntent.putExtra("userHash", result.getString("userHash"));
|
accountIntent.putExtra("userHash", result.getString("userHash"));
|
||||||
RegisterActivity.this.startActivity(accountIntent);
|
RegisterActivity.this.startActivity(accountIntent);
|
||||||
|
|
|
@ -24,5 +24,5 @@ public class Config {
|
||||||
|
|
||||||
//BLOCKCHAIN
|
//BLOCKCHAIN
|
||||||
static private String BASE_URL_QUERY = BASE_URL+"/api/rest/query/";
|
static private String BASE_URL_QUERY = BASE_URL+"/api/rest/query/";
|
||||||
static public String QUERY_BALANCE = BASE_URL_QUERY+"/balance?name=";
|
static public String QUERY_BALANCE = BASE_URL_QUERY+"/balance?userHash=";
|
||||||
}
|
}
|
|
@ -6,6 +6,7 @@ import android.support.v7.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
@ -26,10 +27,7 @@ import monnethic.mobile.transaction.MakePayementActivity;
|
||||||
import monnethic.mobile.transaction.ReceivePayementActivity;
|
import monnethic.mobile.transaction.ReceivePayementActivity;
|
||||||
|
|
||||||
public class UserAccountActivity extends AppCompatActivity {
|
public class UserAccountActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private TextView balance;
|
private TextView balance;
|
||||||
private String strUrl = Config.QUERY_BALANCE;
|
|
||||||
private String result;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -41,7 +39,6 @@ public class UserAccountActivity extends AppCompatActivity {
|
||||||
Button buttonReceive = findViewById(R.id.buttonReceive);
|
Button buttonReceive = findViewById(R.id.buttonReceive);
|
||||||
Button buttonSettings = findViewById(R.id.buttonSettings);
|
Button buttonSettings = findViewById(R.id.buttonSettings);
|
||||||
Button buttonRefresh = findViewById(R.id.buttonRefreshBalance);
|
Button buttonRefresh = findViewById(R.id.buttonRefreshBalance);
|
||||||
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
String userHash = intent.getStringExtra("userHash");
|
String userHash = intent.getStringExtra("userHash");
|
||||||
userHashView.setText(userHash);
|
userHashView.setText(userHash);
|
||||||
|
@ -71,7 +68,7 @@ public class UserAccountActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
String[] params = {strUrl,"b"};
|
String[] params = {userHash};
|
||||||
new GetUserBalanceTask().execute(params);
|
new GetUserBalanceTask().execute(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +103,12 @@ public class UserAccountActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(String s) {
|
protected void onPostExecute(String s) {
|
||||||
balance.setText(s);
|
if(s!=null){
|
||||||
|
balance.setText(s);
|
||||||
|
}else{
|
||||||
|
balance.setText("0");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -115,8 +117,13 @@ public class UserAccountActivity extends AppCompatActivity {
|
||||||
String url = Config.QUERY_BALANCE+params[0];
|
String url = Config.QUERY_BALANCE+params[0];
|
||||||
HttpCallHandler httpCallHandler = new HttpCallHandler();
|
HttpCallHandler httpCallHandler = new HttpCallHandler();
|
||||||
JSONObject json = new JSONObject(httpCallHandler.executeGetBalance(url));
|
JSONObject json = new JSONObject(httpCallHandler.executeGetBalance(url));
|
||||||
Double balance = json.getDouble("userBalance");
|
if(json.get("userBalance")!=null){
|
||||||
return balance.toString();
|
Double balance = json.getDouble("userBalance");
|
||||||
|
return balance.toString();
|
||||||
|
}else{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -59,6 +59,7 @@
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/balanceView"
|
android:id="@+id/balanceView"
|
||||||
|
android:inputType="none"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="35dp"
|
android:layout_height="35dp"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
|
@ -81,12 +82,14 @@
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/userHash"
|
android:id="@+id/userHash"
|
||||||
|
android:textIsSelectable="true"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:layout_marginStart="0dp"
|
android:layout_marginLeft="30dp"
|
||||||
android:layout_marginTop="93dp"
|
android:layout_marginRight="30dp"
|
||||||
|
android:layout_marginTop="90dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textSize="15sp" />
|
android:textSize="15sp" />
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue