diff options
author | Martin Fietz <martin.fietz@gmail.com> | 2018-01-10 23:35:18 +0100 |
---|---|---|
committer | Martin Fietz <martin.fietz@gmail.com> | 2018-01-13 17:36:04 +0100 |
commit | 7257a6c76e002e39eef8d1f28c70b654e9954d4e (patch) | |
tree | b10089c7e5b2d9499f6f5c731235d9f91e4dce2e /app/src | |
parent | 648b6c9529398c7ef01c83c490e54a0d4de49a12 (diff) | |
download | AntennaPod-7257a6c76e002e39eef8d1f28c70b654e9954d4e.zip |
Refactor
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/activity/DownloadAuthenticationActivity.java | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/DownloadAuthenticationActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/DownloadAuthenticationActivity.java index 166138af4..0346cc717 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/DownloadAuthenticationActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/DownloadAuthenticationActivity.java @@ -3,15 +3,14 @@ package de.danoeh.antennapod.activity; import android.app.Activity; import android.content.Intent; import android.os.Bundle; -import android.support.v7.app.ActionBarActivity; -import android.util.Log; +import android.support.v7.app.ActionBar; +import android.support.v7.app.AppCompatActivity; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import org.apache.commons.lang3.Validate; -import de.danoeh.antennapod.BuildConfig; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.service.download.DownloadRequest; @@ -23,7 +22,7 @@ import de.danoeh.antennapod.core.storage.DownloadRequester; * Other arguments are optional. * The activity's result will be the same DownloadRequest with the entered username and password. */ -public class DownloadAuthenticationActivity extends ActionBarActivity { +public class DownloadAuthenticationActivity extends AppCompatActivity { /** * The download request object that contains information about the resource that requires a username and a password @@ -35,47 +34,39 @@ public class DownloadAuthenticationActivity extends ActionBarActivity { */ public static final String ARG_SEND_TO_DOWNLOAD_REQUESTER_BOOL = "send_to_downloadrequester"; - public static final String RESULT_REQUEST = "request"; + private static final String RESULT_REQUEST = "request"; private EditText etxtUsername; private EditText etxtPassword; - private Button butConfirm; - private Button butCancel; - private TextView txtvDescription; - - private DownloadRequest request; - private boolean sendToDownloadRequester; @Override protected void onCreate(Bundle savedInstanceState) { setTheme(UserPreferences.getTheme()); super.onCreate(savedInstanceState); - getSupportActionBar().hide(); - setContentView(R.layout.download_authentication_activity); + ActionBar actionBar = getSupportActionBar(); + if(actionBar != null) { + actionBar.hide(); + } + setContentView(R.layout.download_authentication_activity); + TextView txtvDescription = (TextView) findViewById(R.id.txtvDescription); etxtUsername = (EditText) findViewById(R.id.etxtUsername); etxtPassword = (EditText) findViewById(R.id.etxtPassword); - butConfirm = (Button) findViewById(R.id.butConfirm); - butCancel = (Button) findViewById(R.id.butCancel); - txtvDescription = (TextView) findViewById(R.id.txtvDescription); + Button butConfirm = (Button) findViewById(R.id.butConfirm); + Button butCancel = (Button) findViewById(R.id.butCancel); Validate.isTrue(getIntent().hasExtra(ARG_DOWNLOAD_REQUEST), "Download request missing"); + DownloadRequest request = getIntent().getParcelableExtra(ARG_DOWNLOAD_REQUEST); + boolean sendToDownloadRequester = getIntent().getBooleanExtra(ARG_SEND_TO_DOWNLOAD_REQUESTER_BOOL, false); - request = getIntent().getParcelableExtra(ARG_DOWNLOAD_REQUEST); - sendToDownloadRequester = getIntent().getBooleanExtra(ARG_SEND_TO_DOWNLOAD_REQUESTER_BOOL, false); + String newDescription = txtvDescription.getText() + ":\n\n" + request.getTitle(); + txtvDescription.setText(newDescription); if (savedInstanceState != null) { etxtUsername.setText(savedInstanceState.getString("username")); etxtPassword.setText(savedInstanceState.getString("password")); } - txtvDescription.setText(txtvDescription.getText() + ":\n\n" + request.getTitle()); - - butCancel.setOnClickListener(v -> { - setResult(Activity.RESULT_CANCELED); - finish(); - }); - butConfirm.setOnClickListener(v -> { String username = etxtUsername.getText().toString(); String password = etxtPassword.getText().toString(); @@ -90,6 +81,12 @@ public class DownloadAuthenticationActivity extends ActionBarActivity { } finish(); }); + + butCancel.setOnClickListener(v -> { + setResult(Activity.RESULT_CANCELED); + finish(); + }); + } @Override |