-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f816312
commit 2f3f48b
Showing
19 changed files
with
306 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" | ||
android:gravity="center" | ||
android:orientation="vertical" | ||
android:paddingBottom="30dp"> | ||
|
||
<ImageView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" | ||
android:adjustViewBounds="true" | ||
android:src="@mipmap/error2" /> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" | ||
android:layout_margin="20dp" | ||
android:text="失败了吧!!!!" | ||
android:textColor="#666666" | ||
android:textSize="16sp" /> | ||
|
||
<TextView | ||
android:id="@id/xloading_retry" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" | ||
android:background="@drawable/xloading_btn_selector" | ||
android:gravity="center" | ||
android:minWidth="120dp" | ||
android:padding="10dp" | ||
android:text="加载失败,点击重试~~" | ||
android:textColor="#999999" | ||
android:textSize="16sp" /> | ||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
xframe/src/main/java/com/youth/xframe/entity/DateDifference.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
/** | ||
* 路由 | ||
* 目的:解耦,模块化开发时组件间通讯或者跳转 | ||
*/ | ||
public class XRouter { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
|
||
import com.youth.xframe.XFrame; | ||
|
||
|
||
public class XLogConfig { | ||
|
||
private boolean showThreadInfo = true; | ||
|
138 changes: 138 additions & 0 deletions
138
xframe/src/main/java/com/youth/xframe/widget/XRoundButton.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
package com.youth.xframe.widget; | ||
|
||
|
||
import android.content.Context; | ||
import android.content.res.ColorStateList; | ||
import android.content.res.TypedArray; | ||
import android.graphics.Color; | ||
import android.graphics.Rect; | ||
import android.graphics.RectF; | ||
import android.graphics.drawable.GradientDrawable; | ||
import android.util.AttributeSet; | ||
import android.view.Gravity; | ||
import android.widget.TextView; | ||
|
||
import com.youth.xframe.R; | ||
import com.youth.xframe.utils.XOutdatedUtils; | ||
|
||
|
||
public final class XRoundButton extends TextView { | ||
|
||
public XRoundButton(Context context) { | ||
this(context, null); | ||
} | ||
|
||
public XRoundButton(Context context, AttributeSet attrs) { | ||
this(context, attrs, 0); | ||
} | ||
|
||
public XRoundButton(Context context, AttributeSet attrs, int defStyle) { | ||
super(context, attrs, defStyle); | ||
|
||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.XRoundButton); | ||
|
||
float pressedRatio = a.getFloat(R.styleable.XRoundButton_btnPressedRatio, 0.80f); | ||
int cornerRadius = a.getLayoutDimension(R.styleable.XRoundButton_btnCornerRadius, 0); | ||
|
||
ColorStateList solidColor = a.getColorStateList(R.styleable.XRoundButton_btnSolidColor); | ||
int strokeColor = a.getColor(R.styleable.XRoundButton_btnStrokeColor, 0x0); | ||
int strokeWidth = a.getDimensionPixelSize(R.styleable.XRoundButton_btnStrokeWidth, 0); | ||
int strokeDashWidth = a.getDimensionPixelSize(R.styleable.XRoundButton_btnStrokeDashWidth, 0); | ||
int strokeDashGap = a.getDimensionPixelSize(R.styleable.XRoundButton_btnStrokeDashGap, 0); | ||
|
||
a.recycle(); | ||
|
||
setSingleLine(true); | ||
setGravity(Gravity.CENTER); | ||
|
||
RoundDrawable rd = new RoundDrawable(cornerRadius == -1); | ||
rd.setCornerRadius(cornerRadius == -1 ? 0 : cornerRadius); | ||
rd.setStroke(strokeWidth, strokeColor, strokeDashWidth, strokeDashGap); | ||
|
||
if (solidColor == null) { | ||
solidColor = ColorStateList.valueOf(0); | ||
} | ||
if (solidColor.isStateful()) { | ||
rd.setSolidColors(solidColor); | ||
} else if (pressedRatio > 0.0001f) { | ||
rd.setSolidColors(csl(solidColor.getDefaultColor(), pressedRatio)); | ||
} else { | ||
rd.setColor(solidColor.getDefaultColor()); | ||
} | ||
XOutdatedUtils.setBackground(this,rd); | ||
} | ||
|
||
// 灰度 | ||
int greyer(int color) { | ||
int blue = (color & 0x000000FF) >> 0; | ||
int green = (color & 0x0000FF00) >> 8; | ||
int red = (color & 0x00FF0000) >> 16; | ||
int grey = Math.round(red * 0.299f + green * 0.587f + blue * 0.114f); | ||
return Color.argb(0xff, grey, grey, grey); | ||
} | ||
|
||
// 明度 | ||
int darker(int color, float ratio) { | ||
color = (color >> 24) == 0 ? 0x22808080 : color; | ||
float[] hsv = new float[3]; | ||
Color.colorToHSV(color, hsv); | ||
hsv[2] *= ratio; | ||
return Color.HSVToColor(color >> 24, hsv); | ||
} | ||
|
||
ColorStateList csl(int normal, float ratio) { | ||
// int disabled = greyer(normal); | ||
int pressed = darker(normal, ratio); | ||
int[][] states = new int[][]{{android.R.attr.state_pressed}, {}}; | ||
int[] colors = new int[]{pressed, normal}; | ||
return new ColorStateList(states, colors); | ||
} | ||
|
||
private static class RoundDrawable extends GradientDrawable { | ||
private boolean mIsStadium = false; | ||
|
||
private ColorStateList mSolidColors; | ||
private int mFillColor; | ||
|
||
public RoundDrawable(boolean isStadium) { | ||
mIsStadium = isStadium; | ||
} | ||
|
||
public void setSolidColors(ColorStateList colors) { | ||
mSolidColors = colors; | ||
setColor(colors.getDefaultColor()); | ||
} | ||
|
||
@Override | ||
protected void onBoundsChange(Rect bounds) { | ||
super.onBoundsChange(bounds); | ||
if (mIsStadium) { | ||
RectF rect = new RectF(getBounds()); | ||
setCornerRadius((rect.height() > rect.width() ? rect.width() : rect.height()) / 2); | ||
} | ||
} | ||
|
||
@Override | ||
public void setColor(int argb) { | ||
mFillColor = argb; | ||
super.setColor(argb); | ||
} | ||
|
||
@Override | ||
protected boolean onStateChange(int[] stateSet) { | ||
if (mSolidColors != null) { | ||
final int newColor = mSolidColors.getColorForState(stateSet, 0); | ||
if (mFillColor != newColor) { | ||
setColor(newColor); | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isStateful() { | ||
return super.isStateful() || (mSolidColors != null && mSolidColors.isStateful()); | ||
} | ||
} | ||
} |
Oops, something went wrong.