Created
September 17, 2016 02:10
-
-
Save rcgonzalezf/396b073f9df063dc3c943579c93f1be9 to your computer and use it in GitHub Desktop.
Help for Progress Bar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="fill_parent" | |
android:layout_height="fill_parent" | |
android:paddingBottom="@dimen/activity_vertical_margin" | |
android:paddingLeft="@dimen/activity_horizontal_margin" | |
android:paddingRight="@dimen/activity_horizontal_margin" | |
android:paddingTop="@dimen/activity_vertical_margin" | |
tools:context=".MainActivity" | |
android:orientation="vertical" | |
> | |
<ProgressBar | |
style="?android:attr/progressBarStyleLarge" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:id="@+id/progressBar" | |
android:layout_centerVertical="true" | |
android:layout_centerHorizontal="true" | |
android:indeterminate="false" | |
android:layout_gravity="center" | |
/> | |
<RelativeLayout | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:id="@+id/container" | |
> | |
<EditText | |
android:layout_width="fill_parent" | |
android:layout_height="wrap_content" | |
android:id="@+id/password" | |
android:layout_below="@+id/email" | |
android:layout_centerHorizontal="true" | |
android:hint="Password" | |
android:layout_margin="10dp" | |
/> | |
<EditText | |
android:layout_width="fill_parent" | |
android:layout_height="wrap_content" | |
android:id="@+id/username" | |
android:layout_alignParentTop="true" | |
android:layout_centerHorizontal="true" | |
android:hint="UserName / Restaurant Name" | |
android:layout_margin="10dp" | |
/> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:textAppearance="?android:attr/textAppearanceMedium" | |
android:text="Existing User? Please Login here->" | |
android:id="@+id/login" | |
android:layout_below="@+id/submit" | |
android:layout_centerHorizontal="true" | |
android:layout_margin="10dp" | |
/> | |
<Button | |
android:layout_width="fill_parent" | |
android:layout_height="wrap_content" | |
android:text="Submit Registration" | |
android:id="@+id/submit" | |
android:layout_below="@+id/password" | |
android:layout_centerHorizontal="true" | |
android:layout_margin="10dp" | |
/> | |
<EditText | |
android:layout_width="fill_parent" | |
android:layout_height="wrap_content" | |
android:id="@+id/email" | |
android:layout_below="@+id/username" | |
android:layout_centerHorizontal="true" | |
android:hint="Email " | |
android:layout_margin="10dp" | |
/> | |
</RelativeLayout> | |
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Intent; | |
import android.os.Bundle; | |
import android.support.v7.app.AlertDialog; | |
import android.support.v7.app.AppCompatActivity; | |
import android.view.View; | |
import android.widget.Button; | |
import android.widget.EditText; | |
import android.widget.ProgressBar; | |
import android.widget.RelativeLayout; | |
import android.widget.TextView; | |
import org.json.JSONException; | |
import org.json.JSONObject; | |
public class MainActivity extends AppCompatActivity { | |
ProgressBar progressBar; | |
RelativeLayout container; | |
@Override protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
progressBar = (ProgressBar) findViewById(R.id.progressBar); | |
progressBar.setVisibility(View.GONE); | |
container = (RelativeLayout) findViewById(R.id.container); | |
final EditText username = (EditText) findViewById(R.id.username); | |
final EditText email = (EditText) findViewById(R.id.email); | |
final EditText password = (EditText) findViewById(R.id.password); | |
final Button submit = (Button) findViewById(R.id.submit); | |
submit.setOnClickListener(new View.OnClickListener() { | |
@Override public void onClick(View view) { | |
progressBar.setVisibility(View.VISIBLE); | |
container.setVisibility(View.GONE); | |
final String get_username = username.getText().toString(); | |
final String get_email = email.getText().toString(); | |
final String get_password = password.getText().toString(); | |
Response.Listener<String> response_listener = new Response.Listener<String>() { | |
@Override public void onResponse(String response) { | |
try { | |
JSONObject jsonObject = new JSONObject(response); | |
boolean result = jsonObject.getBoolean("register_result"); | |
progressBar.setVisibility(View.GONE); | |
container.setVisibility(View.VISIBLE); | |
if (result) { | |
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); | |
builder.setMessage("Registration Done!") | |
.setNegativeButton("Back", null) | |
.create() | |
.show(); | |
} else { | |
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); | |
builder.setMessage("User already existed! Please try different Email") | |
.setNegativeButton("Back", null) | |
.create() | |
.show(); | |
} | |
} catch (JSONException e) { | |
e.printStackTrace(); | |
} | |
} | |
}; | |
RegisterRequest register_request = | |
new RegisterRequest(get_username, get_email, get_password, response_listener); | |
RequestQueue queue = Volley.newRequestQueue(MainActivity.this); | |
queue.add(register_request); | |
} | |
}); | |
TextView register = (TextView) findViewById(R.id.login); | |
register.setOnClickListener(new View.OnClickListener() { | |
@Override public void onClick(View view) { | |
Intent intent = new Intent(MainActivity.this, LoginActivity.class); | |
MainActivity.this.startActivity(intent); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment