Last active
October 25, 2016 18:13
-
-
Save gamebusterz/fb1ba3b9fd18f733b2cc55177e217758 to your computer and use it in GitHub Desktop.
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
package com.example.yankee.cw; | |
import android.app.ProgressDialog; | |
import android.content.Intent; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.view.View.OnClickListener; | |
import android.widget.Button; | |
import android.widget.EditText; | |
import android.widget.Toast; | |
import com.sinch.android.rtc.SinchError; | |
public class LoginActivity extends BaseActivity implements SinchService.StartFailedListener { | |
// private Button mLoginButton; | |
// private EditText mLoginName; | |
private ProgressDialog mSpinner; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.login); | |
// mLoginName = (EditText) findViewById(R.id.loginName); | |
// mLoginButton = (Button) findViewById(R.id.loginButton); | |
// mLoginButton.setEnabled(false); | |
// mLoginButton.setOnClickListener(new OnClickListener() { | |
// @Override | |
// public void onClick(View v) { | |
// loginClicked(); | |
// } | |
// }); | |
loginClicked(); | |
} | |
@Override | |
protected void onServiceConnected() { | |
// mLoginButton.setEnabled(true); | |
getSinchServiceInterface().setStartListener(this); | |
} | |
@Override | |
protected void onPause() { | |
if (mSpinner != null) { | |
mSpinner.dismiss(); | |
} | |
super.onPause(); | |
} | |
@Override | |
public void onStartFailed(SinchError error) { | |
Toast.makeText(this, error.toString(), Toast.LENGTH_LONG).show(); | |
if (mSpinner != null) { | |
mSpinner.dismiss(); | |
} | |
} | |
@Override | |
public void onStarted() { | |
openPlaceCallActivity(); | |
} | |
private void loginClicked() { | |
String userName = "User1"; | |
// if (userName.isEmpty()) { | |
// Toast.makeText(this, "Please enter a name", Toast.LENGTH_LONG).show(); | |
// return; | |
// } | |
if (!getSinchServiceInterface().isStarted()) { | |
getSinchServiceInterface().startClient(userName); | |
showSpinner(); | |
} else { | |
openPlaceCallActivity(); | |
} | |
} | |
private void openPlaceCallActivity() { | |
Intent mainActivity = new Intent(this, PlaceCallActivity.class); | |
startActivity(mainActivity); | |
} | |
private void showSpinner() { | |
mSpinner = new ProgressDialog(this); | |
mSpinner.setTitle("Logging in"); | |
mSpinner.setMessage("Please wait..."); | |
mSpinner.show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment