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{
|
||||
if(result!=null){
|
||||
if(result.getInt("status") == 200){
|
||||
System.out.println(result);
|
||||
Intent accountIntent = new Intent(RegisterActivity.this, UserAccountActivity.class);
|
||||
accountIntent.putExtra("userHash", result.getString("userHash"));
|
||||
RegisterActivity.this.startActivity(accountIntent);
|
||||
|
|
|
@ -24,5 +24,5 @@ public class Config {
|
|||
|
||||
//BLOCKCHAIN
|
||||
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.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -26,10 +27,7 @@ import monnethic.mobile.transaction.MakePayementActivity;
|
|||
import monnethic.mobile.transaction.ReceivePayementActivity;
|
||||
|
||||
public class UserAccountActivity extends AppCompatActivity {
|
||||
|
||||
private TextView balance;
|
||||
private String strUrl = Config.QUERY_BALANCE;
|
||||
private String result;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -41,7 +39,6 @@ public class UserAccountActivity extends AppCompatActivity {
|
|||
Button buttonReceive = findViewById(R.id.buttonReceive);
|
||||
Button buttonSettings = findViewById(R.id.buttonSettings);
|
||||
Button buttonRefresh = findViewById(R.id.buttonRefreshBalance);
|
||||
|
||||
Intent intent = getIntent();
|
||||
String userHash = intent.getStringExtra("userHash");
|
||||
userHashView.setText(userHash);
|
||||
|
@ -71,7 +68,7 @@ public class UserAccountActivity extends AppCompatActivity {
|
|||
}
|
||||
});
|
||||
|
||||
String[] params = {strUrl,"b"};
|
||||
String[] params = {userHash};
|
||||
new GetUserBalanceTask().execute(params);
|
||||
}
|
||||
|
||||
|
@ -106,7 +103,12 @@ public class UserAccountActivity extends AppCompatActivity {
|
|||
|
||||
@Override
|
||||
protected void onPostExecute(String s) {
|
||||
balance.setText(s);
|
||||
if(s!=null){
|
||||
balance.setText(s);
|
||||
}else{
|
||||
balance.setText("0");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -115,8 +117,13 @@ public class UserAccountActivity extends AppCompatActivity {
|
|||
String url = Config.QUERY_BALANCE+params[0];
|
||||
HttpCallHandler httpCallHandler = new HttpCallHandler();
|
||||
JSONObject json = new JSONObject(httpCallHandler.executeGetBalance(url));
|
||||
Double balance = json.getDouble("userBalance");
|
||||
return balance.toString();
|
||||
if(json.get("userBalance")!=null){
|
||||
Double balance = json.getDouble("userBalance");
|
||||
return balance.toString();
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
|
||||
<TextView
|
||||
android:id="@+id/balanceView"
|
||||
android:inputType="none"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="35dp"
|
||||
android:layout_alignParentTop="true"
|
||||
|
@ -81,12 +82,14 @@
|
|||
|
||||
<TextView
|
||||
android:id="@+id/userHash"
|
||||
android:textIsSelectable="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginStart="0dp"
|
||||
android:layout_marginTop="93dp"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:layout_marginRight="30dp"
|
||||
android:layout_marginTop="90dp"
|
||||
android:gravity="center"
|
||||
android:textSize="15sp" />
|
||||
|
||||
|
|
Loading…
Reference in a new issue