2024-03-31 18:40:15 +02:00
|
|
|
package de.danoeh.antennapod.ui.episodeslist;
|
2014-11-10 21:01:41 +01:00
|
|
|
|
|
|
|
import android.view.View;
|
|
|
|
import android.widget.ImageView;
|
|
|
|
import android.widget.ProgressBar;
|
2024-04-05 19:20:27 +02:00
|
|
|
import de.danoeh.antennapod.R;
|
2014-11-10 21:01:41 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Utility methods for the more_content_list_footer layout.
|
|
|
|
*/
|
|
|
|
public class MoreContentListFooterUtil {
|
|
|
|
|
|
|
|
private final View root;
|
|
|
|
|
|
|
|
private boolean loading;
|
|
|
|
|
|
|
|
private Listener listener;
|
|
|
|
|
|
|
|
public MoreContentListFooterUtil(View root) {
|
|
|
|
this.root = root;
|
code cleaning:
- lambda expressions, method references,
- multi catches,
- remove unnecessary keywords (public keyword on interface method signatures, static on interfaces or enums, final on private method signatures),
- == false expressions,
- diamond type (<>) expressions,
- replace StringBuffer with StringBuilder for local variables used by a single thread,
- replace Arrays.asList with Collections.singletonList whenever applicable,
- inline variable returns (whenever the variable name's meaning is not important to understand the code),
- replace some chains of if/else if/... with switch/case,
- break append(a + b) into append(a).append(b) for StringBuilder objects,
- unused import statements,
- reduce log TAGs to 23 characters,
- MaterialDialog callback deprecated,
- ActionBarActivity for AppCompatActivity,
2016-03-22 07:07:26 +01:00
|
|
|
root.setOnClickListener(v -> {
|
|
|
|
if (listener != null && !loading) {
|
|
|
|
listener.onClick();
|
2014-11-10 21:01:41 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLoadingState(boolean newState) {
|
2018-10-08 04:04:44 +02:00
|
|
|
final ImageView imageView = root.findViewById(R.id.imgExpand);
|
|
|
|
final ProgressBar progressBar = root.findViewById(R.id.progBar);
|
2014-11-10 21:01:41 +01:00
|
|
|
if (newState) {
|
|
|
|
imageView.setVisibility(View.GONE);
|
|
|
|
progressBar.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
imageView.setVisibility(View.VISIBLE);
|
|
|
|
progressBar.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
loading = newState;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setClickListener(Listener l) {
|
|
|
|
listener = l;
|
|
|
|
}
|
|
|
|
|
code cleaning:
- lambda expressions, method references,
- multi catches,
- remove unnecessary keywords (public keyword on interface method signatures, static on interfaces or enums, final on private method signatures),
- == false expressions,
- diamond type (<>) expressions,
- replace StringBuffer with StringBuilder for local variables used by a single thread,
- replace Arrays.asList with Collections.singletonList whenever applicable,
- inline variable returns (whenever the variable name's meaning is not important to understand the code),
- replace some chains of if/else if/... with switch/case,
- break append(a + b) into append(a).append(b) for StringBuilder objects,
- unused import statements,
- reduce log TAGs to 23 characters,
- MaterialDialog callback deprecated,
- ActionBarActivity for AppCompatActivity,
2016-03-22 07:07:26 +01:00
|
|
|
public interface Listener {
|
|
|
|
void onClick();
|
2014-11-10 21:01:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public View getRoot() {
|
|
|
|
return root;
|
|
|
|
}
|
|
|
|
}
|