summaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authormohit <42018918+mohitshah3111999@users.noreply.github.com>2020-10-28 14:23:58 +0530
committerGitHub <noreply@github.com>2020-10-28 09:53:58 +0100
commit109e5716ed06f924b1b3c4324f8f3bf8fedc3de8 (patch)
tree43048a35077f625ed8acbc851d54b6ab8317e275 /app/src/main
parent15ba3f8f609cc141d6c354fe6486371a864ad296 (diff)
downloadAntennaPod-109e5716ed06f924b1b3c4324f8f3bf8fedc3de8.zip
Use of ViewBinding in OnlineFeedViewActivity.java class (#4399)
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java84
-rw-r--r--app/src/main/res/layout/onlinefeedview_activity.xml28
2 files changed, 49 insertions, 63 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java
index 3bacdc75f..3f58e4a92 100644
--- a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java
+++ b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java
@@ -13,11 +13,6 @@ import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
-import android.widget.Button;
-import android.widget.ImageView;
-import android.widget.ListView;
-import android.widget.ProgressBar;
-import android.widget.Spinner;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.UiThread;
@@ -28,7 +23,6 @@ import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.adapter.FeedItemlistDescriptionAdapter;
-import de.danoeh.antennapod.core.ClientConfig;
import de.danoeh.antennapod.core.dialog.DownloadRequestErrorDialogCreator;
import de.danoeh.antennapod.core.event.DownloadEvent;
import de.danoeh.antennapod.core.event.FeedListUpdateEvent;
@@ -61,6 +55,7 @@ import de.danoeh.antennapod.core.util.URLChecker;
import de.danoeh.antennapod.core.util.playback.RemoteMedia;
import de.danoeh.antennapod.core.util.syndication.FeedDiscoverer;
import de.danoeh.antennapod.core.util.syndication.HtmlToPlainText;
+import de.danoeh.antennapod.databinding.OnlinefeedviewActivityBinding;
import de.danoeh.antennapod.dialog.AuthenticationDialog;
import de.danoeh.antennapod.discovery.PodcastSearcherRegistry;
import io.reactivex.Observable;
@@ -101,26 +96,24 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
private boolean didPressSubscribe = false;
private Dialog dialog;
- private ListView listView;
- private Button subscribeButton;
- private ProgressBar progressBar;
- private Button stopPreviewButton;
private Disposable download;
private Disposable parser;
private Disposable updater;
+ private OnlinefeedviewActivityBinding viewBinding;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(UserPreferences.getTranslucentTheme());
super.onCreate(savedInstanceState);
StorageUtils.checkStorageAvailability(this);
- setContentView(R.layout.onlinefeedview_activity);
- listView = findViewById(R.id.listview);
- progressBar = findViewById(R.id.progressBar);
- findViewById(R.id.transparentBackground).setOnClickListener(v -> finish());
- findViewById(R.id.card).setOnClickListener(null);
+ viewBinding = OnlinefeedviewActivityBinding.inflate(getLayoutInflater());
+ setContentView(viewBinding.getRoot());
+
+ viewBinding.transparentBackground.setOnClickListener(v -> finish());
+ viewBinding.card.setOnClickListener(null);
String feedUrl = null;
if (getIntent().hasExtra(ARG_FEEDURL)) {
@@ -166,8 +159,8 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
* Displays a progress indicator.
*/
private void setLoadingLayout() {
- progressBar.setVisibility(View.VISIBLE);
- findViewById(R.id.feedDisplay).setVisibility(View.GONE);
+ viewBinding.progressBar.setVisibility(View.VISIBLE);
+ viewBinding.feedDisplayContainer.setVisibility(View.GONE);
}
@Override
@@ -389,27 +382,20 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
* This method is executed on the GUI thread.
*/
private void showFeedInformation(final Feed feed, Map<String, String> alternateFeedUrls) {
- progressBar.setVisibility(View.GONE);
- findViewById(R.id.feedDisplay).setVisibility(View.VISIBLE);
+ viewBinding.progressBar.setVisibility(View.GONE);
+ viewBinding.feedDisplayContainer.setVisibility(View.VISIBLE);
this.feed = feed;
this.selectedDownloadUrl = feed.getDownload_url();
- ImageView cover = findViewById(R.id.imgvCover);
- ImageView headerBackground = findViewById(R.id.imgvBackground);
- headerBackground.setColorFilter(new LightingColorFilter(0xff828282, 0x000000));
- TextView title = findViewById(R.id.txtvTitle);
- TextView author = findViewById(R.id.txtvAuthor);
- Spinner spAlternateUrls = findViewById(R.id.spinnerAlternateUrls);
+ viewBinding.backgroundImage.setColorFilter(new LightingColorFilter(0xff828282, 0x000000));
View header = View.inflate(this, R.layout.onlinefeedview_header, null);
- listView.addHeaderView(header);
- listView.setSelector(android.R.color.transparent);
- listView.setAdapter(new FeedItemlistDescriptionAdapter(this, 0, feed.getItems()));
- TextView description = header.findViewById(R.id.txtvDescription);
+ viewBinding.listView.addHeaderView(header);
+ viewBinding.listView.setSelector(android.R.color.transparent);
+ viewBinding.listView.setAdapter(new FeedItemlistDescriptionAdapter(this, 0, feed.getItems()));
- subscribeButton = findViewById(R.id.butSubscribe);
- stopPreviewButton = findViewById(R.id.butStopPreview);
+ TextView description = header.findViewById(R.id.txtvDescription);
if (StringUtils.isNotBlank(feed.getImageUrl())) {
Glide.with(this)
@@ -420,7 +406,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
.diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
.fitCenter()
.dontAnimate())
- .into(cover);
+ .into(viewBinding.coverImage);
Glide.with(this)
.load(feed.getImageUrl())
.apply(new RequestOptions()
@@ -429,14 +415,14 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
.diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
.transform(new FastBlurTransformation())
.dontAnimate())
- .into(headerBackground);
+ .into(viewBinding.backgroundImage);
}
- title.setText(feed.getTitle());
- author.setText(feed.getAuthor());
+ viewBinding.titleLabel.setText(feed.getTitle());
+ viewBinding.authorLabel.setText(feed.getAuthor());
description.setText(feed.getDescription());
- subscribeButton.setOnClickListener(v -> {
+ viewBinding.subscribeButton.setOnClickListener(v -> {
if (feedInFeedlist(feed)) {
openFeed();
} else {
@@ -454,7 +440,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
}
});
- stopPreviewButton.setOnClickListener(v -> {
+ viewBinding.stopPreviewButton.setOnClickListener(v -> {
PlaybackPreferences.writeNoMediaPlaying();
IntentUtils.sendLocalBroadcast(this, PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE);
});
@@ -471,9 +457,9 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
});
if (alternateFeedUrls.isEmpty()) {
- spAlternateUrls.setVisibility(View.GONE);
+ viewBinding.alternateUrlsSpinner.setVisibility(View.GONE);
} else {
- spAlternateUrls.setVisibility(View.VISIBLE);
+ viewBinding.alternateUrlsSpinner.setVisibility(View.VISIBLE);
final List<String> alternateUrlsList = new ArrayList<>();
final List<String> alternateUrlsTitleList = new ArrayList<>();
@@ -488,8 +474,8 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
}
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, alternateUrlsTitleList);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- spAlternateUrls.setAdapter(adapter);
- spAlternateUrls.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ viewBinding.alternateUrlsSpinner.setAdapter(adapter);
+ viewBinding.alternateUrlsSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
selectedDownloadUrl = alternateUrlsList.get(position);
@@ -515,19 +501,19 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
}
private void handleUpdatedFeedStatus(Feed feed) {
- if (subscribeButton != null && feed != null) {
+ if (feed != null) {
if (DownloadRequester.getInstance().isDownloadingFile(feed.getDownload_url())) {
- subscribeButton.setEnabled(false);
- subscribeButton.setText(R.string.subscribing_label);
+ viewBinding.subscribeButton.setEnabled(false);
+ viewBinding.subscribeButton.setText(R.string.subscribing_label);
} else if (feedInFeedlist(feed)) {
- subscribeButton.setEnabled(true);
- subscribeButton.setText(R.string.open_podcast);
+ viewBinding.subscribeButton.setEnabled(true);
+ viewBinding.subscribeButton.setText(R.string.open_podcast);
if (didPressSubscribe) {
openFeed();
}
} else {
- subscribeButton.setEnabled(true);
- subscribeButton.setText(R.string.subscribe_label);
+ viewBinding.subscribeButton.setEnabled(true);
+ viewBinding.subscribeButton.setText(R.string.subscribe_label);
}
}
}
@@ -582,7 +568,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
public void playbackStateChanged(PlayerStatusEvent event) {
boolean isPlayingPreview =
PlaybackPreferences.getCurrentlyPlayingMediaType() == RemoteMedia.PLAYABLE_TYPE_REMOTE_MEDIA;
- stopPreviewButton.setVisibility(isPlayingPreview ? View.VISIBLE : View.GONE);
+ viewBinding.stopPreviewButton.setVisibility(isPlayingPreview ? View.VISIBLE : View.GONE);
}
/**
diff --git a/app/src/main/res/layout/onlinefeedview_activity.xml b/app/src/main/res/layout/onlinefeedview_activity.xml
index 996db7d36..88ffbb8b6 100644
--- a/app/src/main/res/layout/onlinefeedview_activity.xml
+++ b/app/src/main/res/layout/onlinefeedview_activity.xml
@@ -28,7 +28,7 @@
android:layout_gravity="center"/>
<LinearLayout
- android:id="@+id/feedDisplay"
+ android:id="@+id/feed_display_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
@@ -39,13 +39,13 @@
android:background="@color/feed_image_bg">
<ImageView
- android:id="@+id/imgvBackground"
+ android:id="@+id/backgroundImage"
style="@style/BigBlurryBackground"
android:layout_width="match_parent"
android:layout_height="@dimen/feeditemlist_header_height"/>
<ImageView
- android:id="@+id/imgvCover"
+ android:id="@+id/coverImage"
android:layout_width="@dimen/thumbnail_length_onlinefeedview"
android:layout_height="@dimen/thumbnail_length_onlinefeedview"
android:layout_alignParentLeft="true"
@@ -60,7 +60,7 @@
tools:src="@tools:sample/avatars"/>
<TextView
- android:id="@+id/txtvTitle"
+ android:id="@+id/titleLabel"
style="@style/AntennaPod.TextView.Heading"
android:layout_width="0dp"
android:layout_height="wrap_content"
@@ -73,8 +73,8 @@
android:layout_marginEnd="16dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
- android:layout_toRightOf="@id/imgvCover"
- android:layout_toEndOf="@id/imgvCover"
+ android:layout_toRightOf="@id/coverImage"
+ android:layout_toEndOf="@id/coverImage"
android:ellipsize="end"
android:maxLines="2"
android:shadowColor="@color/black"
@@ -83,10 +83,10 @@
tools:text="Podcast title"/>
<TextView
- android:id="@+id/txtvAuthor"
+ android:id="@+id/author_label"
android:layout_width="0dip"
android:layout_height="wrap_content"
- android:layout_below="@id/txtvTitle"
+ android:layout_below="@id/titleLabel"
android:layout_marginBottom="16dp"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
@@ -94,8 +94,8 @@
android:layout_marginEnd="16dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
- android:layout_toRightOf="@id/imgvCover"
- android:layout_toEndOf="@id/imgvCover"
+ android:layout_toRightOf="@id/coverImage"
+ android:layout_toEndOf="@id/coverImage"
android:ellipsize="end"
android:lines="1"
android:shadowColor="@color/black"
@@ -106,7 +106,7 @@
</RelativeLayout>
<Spinner
- android:id="@+id/spinnerAlternateUrls"
+ android:id="@+id/alternate_urls_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
@@ -117,7 +117,7 @@
android:textSize="@dimen/text_size_micro"/>
<Button
- android:id="@+id/butSubscribe"
+ android:id="@+id/subscribeButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
@@ -125,7 +125,7 @@
android:text="@string/subscribe_label"/>
<Button
- android:id="@+id/butStopPreview"
+ android:id="@+id/stopPreviewButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
@@ -136,7 +136,7 @@
android:visibility="gone" />
<ListView
- android:id="@+id/listview"
+ android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>