Я пытаюсь добавить progressBar в своем коде, на кнопке входа в систему я должен показать прогрессбар, а затем он должен go следующий. помогите как мне этого добиться. Где я в этом ошибаюсь.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
tools:context="com.tecnotree.selfcare.ui.login.LoginActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/tecnotree_selfcare"
android:src="@drawable/background_image"
android:scaleType="matrix"/>
<!-- Login progress -->
<ScrollView
android:id="@+id/login_form"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/email_login_form"
android:layout_width="match_parent"
android:padding="@dimen/paddingLarge"
android:layout_height="wrap_content"
android:orientation="vertical">
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin"
android:layout_marginBottom="@dimen/marginLarge"
android:layout_gravity="center"
android:id="@+id/language_selector"/>
<LinearLayout
android:layout_width="match_parent"
android:background="@drawable/sc_card_rounded"
android:orientation="vertical"
android:padding="@dimen/paddingLarge"
android:layout_marginTop="@dimen/margin"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/login_title"
android:layout_marginTop="@dimen/margin"
style="@style/AppTheme.TextLargePrimaryBold"
android:textAlignment="center"/>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/marginLarge">
<AutoCompleteTextView
android:id="@+id/email"
android:drawableStart="@drawable/icon_person"
android:drawableLeft="@drawable/icon_person"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/AppTheme.EditTextAuto"
android:hint="@string/prompt_email"
android:drawablePadding="@dimen/padding"
android:inputType="textEmailAddress"
android:maxLines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/marginLarge">
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_password"
android:imeActionId="6"
style="@style/AppTheme.EditText"
android:drawablePadding="@dimen/padding"
android:drawableLeft="@drawable/icon_password"
android:drawableStart="@drawable/icon_password"
android:imeActionLabel="@string/action_sign_in_short"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/email_sign_in_button"
style="@style/AppTheme.ButtonSecondaryRounded"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/marginLarge"
android:text="@string/action_sign_in"
android:elevation="0dp"
android:textStyle="bold" />
<TextView
android:id="@+id/forgot_password_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/marginLarge"
android:text="@string/forgot_password"
style="@style/AppTheme.TextSecondaryRegular"
android:textAlignment="center"/>
<LinearLayout
android:layout_gravity="center"
android:layout_marginTop="@dimen/marginLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/AppTheme.TextBodyRegular"
android:text="@string/new_user"/>
<TextView
android:id="@+id/register_now_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/paddingSmall"
style="@style/AppTheme.TextSecondaryRegularBold"
android:text="@string/register_now"/>
</LinearLayout>
</LinearLayout>
<ProgressBar
android:id="@+id/progressBar2"
style="?android:attr/progressBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
///////////////////// java код
package com.tecnotree.selfcare.ui.login;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;
import android.widget.ProgressBar;
import com.tecnotree.selfcare.App;
import com.tecnotree.selfcare.R;
import javax.inject.Inject;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
public class LoginActivity extends AppCompatActivity implements LoginScreenContract.View {
@Inject
LoginScreenPresenter loginPresenter;
@BindView(R.id.email)
EditText usernameInput;
@BindView(R.id.password)
EditText passwordInput;
@BindView(R.id.progressBar2)
ProgressBar progressBar;
@OnClick(R.id.email_sign_in_button)
void delegateLogin() {
loginPresenter.doLogin(usernameInput.getText().toString(), passwordInput.getText().toString());
}
@OnClick(R.id.register_now_button)
void registerNow(){
loginPresenter.doOpenRegisterScreen(this);
}
@OnClick(R.id.forgot_password_button)
void forgotPassword(){
loginPresenter.doOpenForgotPasswordScreen(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
ButterKnife.bind(this);
DaggerLoginScreenComponent.builder()
.loginScreenModule(new LoginScreenModule(this))
.appComponent(App.getInstance().getApplicationWideDeps())
.build()
.inject(this);
loginPresenter.initScreen();
}
@Override
public void enableLogin() {
}
@Override
public void showValidationError() {
}
@Override
public void showCommunicationError(String message) {
Snackbar snackBar = Snackbar.make(passwordInput, message, Snackbar.LENGTH_LONG);
snackBar.show();
}
@Override
public void setCredentials(String username, String password) {
usernameInput.setText(username);
passwordInput.setText(password);
}
}
///////
package com.tecnotree.selfcare.ui.login;
import android.app.ProgressDialog;
import android.content.Context;
import android.util.Base64;
import android.util.Log;
import com.tecnotree.selfcare.App;
import com.tecnotree.selfcare.R;
import com.tecnotree.selfcare.api.auth.model.Auth;
import com.tecnotree.selfcare.api.selfcare.model.LocaleConfiguration;
import com.tecnotree.selfcare.backendmodel.AuthManager;
import com.tecnotree.selfcare.backendmodel.ManagerFactory;
import com.tecnotree.selfcare.backendmodel.SelfCareManager;
import com.tecnotree.selfcare.configuration.AssemblyMode;
import com.tecnotree.selfcare.configuration.Configuration;
import com.tecnotree.selfcare.ui.utils.ActivityHelper;
import com.tecnotree.selfcare.volatiles.VolatileKey;
import com.tecnotree.selfcare.volatiles.VolatileOps;
import javax.inject.Inject;
public class LoginScreenPresenter implements LoginScreenContract.Presenter,
AuthManager.LoginResultCallback,
SelfCareManager.LocaleConfigurationResultCallback {
private LoginScreenContract.View view;
private ManagerFactory managerFactory;
private AuthManager authManager;
private VolatileOps volatileOps;
private Configuration configuration;
@Inject
public LoginScreenPresenter(
LoginScreenContract.View view,
ManagerFactory managerFactory,
VolatileOps volatileOps,
Configuration configuration) {
this.view = view;
this.managerFactory = managerFactory;
this.authManager = managerFactory.getAuthManager();
this.volatileOps = volatileOps;
this.configuration = configuration;
}
@Override
public void initScreen(){
if(configuration.getAssemblyMode() == AssemblyMode.DEBUG){
view.setCredentials("52584890", "Velan290409*");
}
}
@Override
public void doLogin(String userName, String passWord) {
Log.d("test1", "userName : " + userName + ", passwordInput : " + passWord);
String uName= Base64.encodeToString(userName.getBytes(), Base64.DEFAULT);
String pass= Base64.encodeToString(passWord.getBytes(), Base64.DEFAULT);
authManager.login(uName, pass, this);
}
@Override
public void doOpenRegisterScreen(Context context) {
ActivityHelper.launchRegisterActivity(context);
}
@Override
public void doOpenForgotPasswordScreen(Context context) {
ActivityHelper.launchForgotPasswordActivity(context);
}
@Override
public void onLoginSuccess(Auth auth) {
ProgressDialog loading;
// progressBar progressBar;
//loading = ProgressDialog.show(LoginActivity.this, "Fetching Data", "Wait...", false, false);
managerFactory.invalidateSelfCareManager();
volatileOps.setAndDecodeToken(auth.getToken());
Log.d("test2", "success, token : " + volatileOps.getString(VolatileKey.AUTH_TOKEN));
managerFactory.getSelfCareManager().getLocaleConfigurations(true,this);
}
@Override
public void onLoginError(String errorMsg) {
view.showCommunicationError(errorMsg);
Log.d("test2", "miserable failure : " + errorMsg);
}
@Override
public void onLocaleConfigurationReceived(LocaleConfiguration localeConfiguration) {
//volatileOps.setString(VolatileKey.CURRENCY_SYMBOL, localeConfiguration.getCurrency().getCode());
//Set currency symbol to euro for demo
volatileOps.setString(VolatileKey.CURRENCY_SYMBOL, "€");
volatileOps.setString(VolatileKey.LOYALTY_POINTS_SYMBOL, App.getInstance().getApplicationWideDeps().application().getResources().getString(R.string.loyalty_points));
volatileOps.setString(VolatileKey.DATE_FORMAT, localeConfiguration.getDateFormat());
volatileOps.setString(VolatileKey.LOCALE_CODE, localeConfiguration.getLocale());
ActivityHelper.launchMainActivity();
}
@Override
public void onLocaleConfigurationRequestError(String errorMessage) {
Log.d("LSP", "Locale configuration request error: " + errorMessage);
}
}