DT @07.01.2016: Ein wenig refactoring
This commit is contained in:
@@ -39,8 +39,6 @@ import java.util.Map;
|
||||
public class LoginActivity extends AppCompatActivity implements FacebookButtonFragment.OnFragmentInteractionListener, GooglePlusButtonFragment.OnFragmentInteractionListener, TwitterButtonFragment.OnFragmentInteractionListener{
|
||||
|
||||
private final static String TAG = LoginActivity.class.getSimpleName();
|
||||
private final static String EXTRA_MESSAGE = "org.deke.risk.riskahead.MESSAGE";
|
||||
private final static String mActivityTitle = "RiskAhead";
|
||||
|
||||
private String msg_intent;
|
||||
|
||||
@@ -59,23 +57,30 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
|
||||
session = new SessionManager(getApplicationContext());
|
||||
|
||||
pDialog = new ProgressDialog(this);
|
||||
pDialog.setMessage("Sending data...");
|
||||
pDialog.setCancelable(false);
|
||||
|
||||
Intent intent = getIntent();
|
||||
msg_intent = intent.getStringExtra(LoginActivity.EXTRA_MESSAGE);
|
||||
|
||||
if(msg_intent.equals("login")){
|
||||
initLoginView();
|
||||
}else if(msg_intent.equals("register")){
|
||||
initRegisterView();
|
||||
}
|
||||
initProgressDialog();
|
||||
handleIntentAndInitView();
|
||||
|
||||
initSocialLoginButtons();
|
||||
initMyLoginButton();
|
||||
}
|
||||
|
||||
private void handleIntentAndInitView() {
|
||||
Intent intent = getIntent();
|
||||
msg_intent = intent.getStringExtra(AppConfig.EXTRA_MESSAGE);
|
||||
|
||||
if(msg_intent.equals(AppConfig.INTENT_NORMALLOGIN)){
|
||||
initLoginView();
|
||||
}else if(msg_intent.equals(AppConfig.INTENT_REGISTER)){
|
||||
initRegisterView();
|
||||
}
|
||||
}
|
||||
|
||||
private void initProgressDialog() {
|
||||
pDialog = new ProgressDialog(this);
|
||||
pDialog.setMessage(getString(R.string.progress_getdata_text));
|
||||
pDialog.setCancelable(false);
|
||||
}
|
||||
|
||||
private void initLoginView() {
|
||||
setContentView(R.layout.activity_login);
|
||||
|
||||
@@ -201,14 +206,15 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
Intent intent = new Intent(
|
||||
LoginActivity.this,
|
||||
MainActivity.class);
|
||||
intent.putExtra(EXTRA_MESSAGE, "Social Media Login");
|
||||
intent.putExtra(AppConfig.EXTRA_MESSAGE, AppConfig.INTENT_SOCIALMEDIALOGIN);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
String tag_string_req = "sociallogin";
|
||||
session.removeUser();
|
||||
showDialog();
|
||||
|
||||
String tag_string_req = "sociallogin";
|
||||
StringRequest strReq = getStringRequestSocialMediaLogin(key, providerType, username, email);
|
||||
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
|
||||
}
|
||||
@@ -274,7 +280,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
Intent intent = new Intent(
|
||||
LoginActivity.this,
|
||||
MainActivity.class);
|
||||
intent.putExtra(EXTRA_MESSAGE, "Social Media Login");
|
||||
intent.putExtra(AppConfig.EXTRA_MESSAGE, AppConfig.INTENT_SOCIALMEDIALOGIN);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
} else {
|
||||
@@ -362,8 +368,8 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
.show();
|
||||
}else {
|
||||
session.addUser(id, username, name, surname, email, status, providerType, created_at, updated_at, lastlogin_at, token);
|
||||
|
||||
session.setLogin(true);
|
||||
|
||||
hideDialog();
|
||||
|
||||
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
|
||||
@@ -422,7 +428,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
Intent intent = new Intent(
|
||||
LoginActivity.this,
|
||||
LoginActivity.class);
|
||||
intent.putExtra(EXTRA_MESSAGE, "login");
|
||||
intent.putExtra(AppConfig.EXTRA_MESSAGE, AppConfig.INTENT_NORMALLOGIN);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
@@ -500,7 +506,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
@Override
|
||||
protected Map<String, String> getParams() {
|
||||
// Posting params to register url
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("tag", "requestpwreset");
|
||||
params.put("email", email);
|
||||
|
||||
@@ -568,7 +574,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
if (pDialog.isShowing())
|
||||
pDialog.dismiss();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_common, menu);
|
||||
|
||||
@@ -32,6 +32,7 @@ public class MainActivity extends BaseActivity{
|
||||
|
||||
private final static String mActivityTitle = "RiskAhead";
|
||||
private final static String TAG = MainActivity.class.getSimpleName();
|
||||
|
||||
public String msg_input;
|
||||
|
||||
public static FragmentManager fragmentManager;
|
||||
|
||||
@@ -3,16 +3,17 @@ package org.deke.risk.riskahead;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
import org.deke.risk.riskahead.helper.AppConfig;
|
||||
import org.deke.risk.riskahead.helper.SessionManager;
|
||||
|
||||
public class StartActivity extends AppCompatActivity {
|
||||
|
||||
private final static String EXTRA_MESSAGE = "org.deke.risk.riskahead.MESSAGE";
|
||||
private final static String TAG = StartActivity.class.getSimpleName();
|
||||
|
||||
Button btnLogin;
|
||||
@@ -22,6 +23,8 @@ public class StartActivity extends AppCompatActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Log.d(TAG,"RiskAhead started.");
|
||||
|
||||
setContentView(R.layout.activity_start);
|
||||
|
||||
btnLogin = (Button) findViewById(R.id.btn_start_login);
|
||||
@@ -29,6 +32,7 @@ public class StartActivity extends AppCompatActivity {
|
||||
|
||||
SessionManager session = new SessionManager(getApplicationContext());
|
||||
if (session.isLoggedIn()) {
|
||||
Log.d(TAG,"User found in sharedPrefs and is therefore logged in. Continue to internal Area.");
|
||||
Intent intent = new Intent(StartActivity.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
@@ -37,13 +41,13 @@ public class StartActivity extends AppCompatActivity {
|
||||
|
||||
public void gotoLogin(View view) {
|
||||
Intent intent = new Intent(this, LoginActivity.class);
|
||||
intent.putExtra(EXTRA_MESSAGE, "login");
|
||||
intent.putExtra(AppConfig.EXTRA_MESSAGE, AppConfig.INTENT_LOGIN);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
public void gotoRegister(View view) {
|
||||
Intent intent = new Intent(this, LoginActivity.class);
|
||||
intent.putExtra(EXTRA_MESSAGE, "register");
|
||||
intent.putExtra(AppConfig.EXTRA_MESSAGE, AppConfig.INTENT_REGISTER);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@@ -55,8 +59,7 @@ public class StartActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,4 +7,10 @@ public class AppConfig {
|
||||
public static String URL_ENCRYPTED = "https://www.riskahead.de/helper/rest/";
|
||||
|
||||
public static String URL_DEFAULT = "http://www.riskahead.de/helper/rest/";
|
||||
|
||||
public final static String EXTRA_MESSAGE = "org.deke.risk.riskahead.MESSAGE";
|
||||
public final static String INTENT_LOGIN = "login";
|
||||
public final static String INTENT_REGISTER = "register";
|
||||
public final static String INTENT_NORMALLOGIN = "normallogin";
|
||||
public final static String INTENT_SOCIALMEDIALOGIN = "socialmedialogin";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user