Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update comments as a part of the Hello Kii tutorial in kiidocs #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/com/kii/world/HelloKii.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
//
// Copyright 2012 Kii Corporation
// Copyright 2017 Kii Corporation
// http://kii.com
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -30,7 +30,7 @@ public class HelloKii extends Application {
public void onCreate() {
super.onCreate();

// initialize the Kii SDK!
// Initialize the Kii Cloud SDK.
Kii.initialize("__KII_APP_ID__", "__KII_APP_KEY__", __KII_APP_SITE__);
}

Expand Down
56 changes: 28 additions & 28 deletions src/com/kii/world/LoginActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
//
// Copyright 2012 Kii Corporation
// Copyright 2017 Kii Corporation
// http://kii.com
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -36,97 +36,97 @@ public class LoginActivity extends Activity {

private static final String TAG = "LoginActivity";

// define our UI elements
// Define the UI elements.
private TextView mUsernameField;
private TextView mPasswordField;
private ProgressDialog mProgress;

// called by the 'Log In' button on the UI
// Called by the "Log In" button.
public void handleLogin(View v) {

// show a loading progress dialog
// Show a progress dialog.
mProgress = ProgressDialog.show(LoginActivity.this, "", "Signing in...", true);

// get the username/password combination from the UI
// Get the username and password from the UI.
String username = mUsernameField.getText().toString();
String password = mPasswordField.getText().toString();
Log.v(TAG, "Logging in: " + username + ":" + password);

// authenticate the user asynchronously
// Authenticate the user asynchronously.
KiiUser.logIn(new KiiUserCallBack() {

// catch the callback's "done" request
// Catch the result from the callback method.
public void onLoginCompleted(int token, KiiUser user, Exception e) {

// hide our progress UI element
// Hide the progress dialog.
mProgress.cancel();

// check for an exception (successful request if e==null)
// Check for an exception. The request was successfully processed if e==null.
if(e == null) {

// tell the console and the user it was a success!
// Tell the console and the user that the login was successful.
Log.v(TAG, "Logged in: " + user.toString());
Toast.makeText(LoginActivity.this, "User authenticated!", Toast.LENGTH_SHORT).show();

// go to the main screen
// Go to the main screen.
Intent myIntent = new Intent(LoginActivity.this, MainActivity.class);
LoginActivity.this.startActivity(myIntent);

}

// otherwise, something bad happened in the request
// A failure occurred when processing the request.
else {

// tell the console and the user there was a failure
Log.v(TAG, "Error registering: " + e.getLocalizedMessage());
Toast.makeText(LoginActivity.this, "Error registering: " + e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
// Tell the console and the user that the login failed.
Log.v(TAG, "Error authenticating: " + e.getLocalizedMessage());
Toast.makeText(LoginActivity.this, "Error authenticating: " + e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
}

}

}, username, password);
}

// called by the 'Sign Up' button on the UI
// Called by the "Sign Up" button.
public void handleSignUp(View v) {

// show a loading progress dialog
// Show a progress dialog.
mProgress = ProgressDialog.show(LoginActivity.this, "", "Signing up...", true);

// get the username/password combination from the UI
// Get the username and password from the UI.
String username = mUsernameField.getText().toString();
String password = mPasswordField.getText().toString();
Log.v(TAG, "Registering: " + username + ":" + password);

// create a KiiUser object
// Create a KiiUser object.
try {
KiiUser user = KiiUser.createWithUsername(username);
// register the user asynchronously
// Register the user asynchronously.
user.register(new KiiUserCallBack() {

// catch the callback's "done" request
// Catch the result from the callback method.
public void onRegisterCompleted(int token, KiiUser user, Exception e) {

// hide our progress UI element
// Hide the progress dialog.
mProgress.cancel();

// check for an exception (successful request if e==null)
// Check for an exception. The request was successfully processed if e==null.
if(e == null) {

// tell the console and the user it was a success!
// Tell the console and the user that the registration was successful.
Log.v(TAG, "Registered: " + user.toString());
Toast.makeText(LoginActivity.this, "User registered!", Toast.LENGTH_SHORT).show();

// go to the next screen
// Go to the main screen.
Intent myIntent = new Intent(LoginActivity.this, MainActivity.class);
LoginActivity.this.startActivity(myIntent);

}

// otherwise, something bad happened in the request
// A failure occurred when processing the request.
else {

// tell the console and the user there was a failure
// Tell the console and the user that the registration failed.
Log.v(TAG, "Error registering: " + e.getLocalizedMessage());
Toast.makeText(LoginActivity.this, "Error Registering: " + e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
}
Expand All @@ -149,7 +149,7 @@ public void onCreate(Bundle savedInstanceState) {

setContentView(R.layout.login);

// link our variables to UI elements
// Link the variables to the UI elements.
mUsernameField = (TextView) findViewById(R.id.username_field);
mPasswordField = (TextView) findViewById(R.id.password_field);

Expand Down
Loading