AndroidX lib refactor
This commit is contained in:
parent
08f0b5e76e
commit
a8dfe106bb
233 changed files with 3254 additions and 9769 deletions
|
@ -0,0 +1,61 @@
|
|||
package code.name.monkey.retromusic.views;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import code.name.monkey.retromusic.R;
|
||||
|
||||
import static code.name.monkey.retromusic.util.RetroUtil.openUrl;
|
||||
|
||||
public class ContributorsView extends FrameLayout {
|
||||
public ContributorsView(@NonNull Context context) {
|
||||
super(context);
|
||||
init(context, null);
|
||||
}
|
||||
|
||||
public ContributorsView(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
public ContributorsView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
private void init(Context context, AttributeSet attributeSet) {
|
||||
final TypedArray attributes = context.obtainStyledAttributes(attributeSet, R.styleable.ContributorsView, 0, 0);
|
||||
if (attributes != null) {
|
||||
final View layout = LayoutInflater.from(context).inflate(R.layout.item_contributor, this);
|
||||
|
||||
NetworkImageView networkImageView = layout.findViewById(R.id.image);
|
||||
String url = attributes.getString(R.styleable.ContributorsView_profile_url);
|
||||
networkImageView.setImageUrl(url);
|
||||
|
||||
String name = attributes.getString(R.styleable.ContributorsView_profile_name);
|
||||
TextView title = layout.findViewById(R.id.title);
|
||||
title.setText(name);
|
||||
|
||||
String summary = attributes.getString(R.styleable.ContributorsView_profile_summary);
|
||||
TextView text = layout.findViewById(R.id.text);
|
||||
text.setText(summary);
|
||||
|
||||
String link = attributes.getString(R.styleable.ContributorsView_profile_link);
|
||||
layout.setOnClickListener(v -> {
|
||||
if (link == null) {
|
||||
return;
|
||||
}
|
||||
openUrl((Activity) getContext(), link);
|
||||
});
|
||||
attributes.recycle();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -28,14 +28,21 @@ public class NetworkImageView extends CircularImageView {
|
|||
init(context, attrs);
|
||||
}
|
||||
|
||||
private void init(Context context, AttributeSet attributeSet) {
|
||||
TypedArray attributes = context
|
||||
.obtainStyledAttributes(attributeSet, R.styleable.NetworkImageView, 0, 0);
|
||||
String url = attributes.getString(R.styleable.NetworkImageView_url_link);
|
||||
Glide.with(context).load(url).asBitmap()
|
||||
public void setImageUrl(String imageUrl) {
|
||||
setImageUrl(getContext(), imageUrl);
|
||||
}
|
||||
|
||||
public void setImageUrl(Context context, String imageUrl) {
|
||||
Glide.with(context).load(imageUrl).asBitmap()
|
||||
.error(R.drawable.ic_person_flat)
|
||||
.placeholder(R.drawable.ic_person_flat)
|
||||
.into(this);
|
||||
}
|
||||
|
||||
private void init(Context context, AttributeSet attributeSet) {
|
||||
TypedArray attributes = context.obtainStyledAttributes(attributeSet, R.styleable.NetworkImageView, 0, 0);
|
||||
String url = attributes.getString(R.styleable.NetworkImageView_url_link);
|
||||
setImageUrl(context, url);
|
||||
attributes.recycle();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,11 +3,15 @@ package code.name.monkey.retromusic.views;
|
|||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import code.name.monkey.appthemehelper.ThemeStore;
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil;
|
||||
import code.name.monkey.retromusic.R;
|
||||
|
|
|
@ -2,10 +2,13 @@ package code.name.monkey.retromusic.views;
|
|||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.text.TextPaint;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
|
||||
public class VerticalTextView extends androidx.appcompat.widget.AppCompatTextView {
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
|
||||
public class VerticalTextView extends AppCompatTextView {
|
||||
final boolean topDown;
|
||||
|
||||
public VerticalTextView(Context context, AttributeSet attrs) {
|
||||
|
@ -25,20 +28,25 @@ public class VerticalTextView extends androidx.appcompat.widget.AppCompatTextVie
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean setFrame(int l, int t, int r, int b) {
|
||||
return super.setFrame(l, t, l + (b - t), t + (r - l));
|
||||
}
|
||||
protected void onDraw(Canvas canvas) {
|
||||
TextPaint textPaint = getPaint();
|
||||
textPaint.setColor(getCurrentTextColor());
|
||||
textPaint.drawableState = getDrawableState();
|
||||
|
||||
canvas.save();
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
if (topDown) {
|
||||
canvas.translate(getHeight(), 0);
|
||||
canvas.translate(getWidth(), 0);
|
||||
canvas.rotate(90);
|
||||
} else {
|
||||
canvas.translate(0, getWidth());
|
||||
canvas.translate(0, getHeight());
|
||||
canvas.rotate(-90);
|
||||
}
|
||||
canvas.clipRect(0, 0, getWidth(), getHeight(), android.graphics.Region.Op.REPLACE);
|
||||
super.draw(canvas);
|
||||
|
||||
|
||||
canvas.translate(getCompoundPaddingLeft(), getExtendedPaddingTop());
|
||||
|
||||
getLayout().draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue