-
Notifications
You must be signed in to change notification settings - Fork 21
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
wecodexyz
committed
Oct 27, 2017
1 parent
54e5e19
commit 52c188b
Showing
16 changed files
with
187 additions
and
38 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
43 changes: 43 additions & 0 deletions
43
core/src/main/java/net/angrycode/core/network/BaseMultipartRequest.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,43 @@ | ||
package net.angrycode.core.network; | ||
|
||
import android.content.Context; | ||
|
||
import java.io.File; | ||
|
||
import okhttp3.MediaType; | ||
import okhttp3.MultipartBody; | ||
import okhttp3.RequestBody; | ||
|
||
/** | ||
* Created by wecodexyz@gmail.com on 2017/10/26 上午11:07. | ||
* GitHub - https://github.com/wecodexyz | ||
* Description: | ||
*/ | ||
|
||
public abstract class BaseMultipartRequest<T> extends RequestWrapper { | ||
private static final MediaType MEDIA_TYPE_PNG = MediaType.parse("image/png"); | ||
|
||
public BaseMultipartRequest(Context context) { | ||
super(context); | ||
} | ||
|
||
protected RequestBody requestBody() { | ||
MultipartBody.Builder builder = new MultipartBody.Builder() | ||
.setType(MultipartBody.FORM) | ||
.addPart(super.requestBody()) | ||
.addFormDataPart(getName(), getFileName(), | ||
RequestBody.create(MEDIA_TYPE_PNG, new File(getFilePath()))); | ||
return builder.build(); | ||
} | ||
|
||
protected abstract String getFilePath(); | ||
|
||
protected abstract String getName(); | ||
|
||
protected abstract String getFileName(); | ||
|
||
@Override | ||
public HttpMethod getHttpMethod() { | ||
return HttpMethod.POST; | ||
} | ||
} |
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
7 changes: 7 additions & 0 deletions
7
core/src/main/java/net/angrycode/core/network/OnRequestCallback.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,7 @@ | ||
package net.angrycode.core.network; | ||
|
||
public interface OnRequestCallback<T> { | ||
void callback(T t); | ||
|
||
void onError(Exception e); | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...rycode/toolkit/view/CheckedImageView.java → ...code/toolkit/widget/CheckedImageView.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
57 changes: 57 additions & 0 deletions
57
core/src/main/java/net/angrycode/toolkit/widget/ClickableImageView.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,57 @@ | ||
package net.angrycode.toolkit.widget; | ||
|
||
import android.content.Context; | ||
import android.graphics.Color; | ||
import android.graphics.PorterDuff; | ||
import android.support.v7.widget.AppCompatImageView; | ||
import android.util.AttributeSet; | ||
import android.view.MotionEvent; | ||
|
||
|
||
/** | ||
* Created by wecodexyz@gmail.com on 2017/10/27 上午11:29. | ||
* GitHub - https://github.com/wecodexyz | ||
* Description: | ||
*/ | ||
|
||
public class ClickableImageView extends AppCompatImageView { | ||
|
||
private int mColorSelected; | ||
private int mColorTransparent; | ||
|
||
public ClickableImageView(Context context) { | ||
super(context); | ||
init(); | ||
} | ||
|
||
public ClickableImageView(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
init(); | ||
} | ||
|
||
public ClickableImageView(Context context, AttributeSet attrs, int defStyleAttr) { | ||
super(context, attrs, defStyleAttr); | ||
init(); | ||
} | ||
|
||
private void init() { | ||
setClickable(true); | ||
mColorSelected = Color.parseColor("#33555555"); | ||
mColorTransparent = Color.TRANSPARENT; | ||
} | ||
|
||
@Override | ||
public boolean onTouchEvent(MotionEvent event) { | ||
switch (event.getAction()) { | ||
case MotionEvent.ACTION_DOWN: | ||
setColorFilter(mColorSelected, PorterDuff.Mode.SRC_ATOP); | ||
break; | ||
case MotionEvent.ACTION_UP: | ||
case MotionEvent.ACTION_HOVER_MOVE: | ||
case MotionEvent.ACTION_CANCEL: | ||
setColorFilter(mColorTransparent, PorterDuff.Mode.SRC_ATOP); | ||
break; | ||
} | ||
return super.onTouchEvent(event); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...a/net/angrycode/toolkit/view/Dialogs.java → ...net/angrycode/toolkit/widget/Dialogs.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
2 changes: 1 addition & 1 deletion
2
.../angrycode/toolkit/view/LinkTextView.java → ...ngrycode/toolkit/widget/LinkTextView.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
2 changes: 1 addition & 1 deletion
2
...code/toolkit/view/QuickClearEditText.java → ...de/toolkit/widget/QuickClearEditText.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
2 changes: 1 addition & 1 deletion
2
...ycode/toolkit/view/SimpleDrawingView.java → ...ode/toolkit/widget/SimpleDrawingView.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
2 changes: 1 addition & 1 deletion
2
...ycode/toolkit/view/SimpleTextWatcher.java → ...ode/toolkit/widget/SimpleTextWatcher.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
59 changes: 59 additions & 0 deletions
59
core/src/main/java/net/angrycode/toolkit/widget/TintableImageView.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,59 @@ | ||
package net.angrycode.toolkit.widget; | ||
|
||
import android.content.Context; | ||
import android.content.res.ColorStateList; | ||
import android.content.res.TypedArray; | ||
import android.util.AttributeSet; | ||
import android.widget.ImageView; | ||
|
||
import net.angrycode.core.R; | ||
|
||
|
||
/** | ||
* https://gist.github.com/tylerchesley/5d15d859be4f3ce31213 | ||
*/ | ||
public class TintableImageView extends ImageView { | ||
|
||
private ColorStateList tint; | ||
|
||
public TintableImageView(Context context) { | ||
super(context); | ||
} | ||
|
||
public TintableImageView(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
init(context, attrs, 0); | ||
} | ||
|
||
public TintableImageView(Context context, AttributeSet attrs, int defStyle) { | ||
super(context, attrs, defStyle); | ||
init(context, attrs, defStyle); | ||
} | ||
|
||
private void init(Context context, AttributeSet attrs, int defStyle) { | ||
TypedArray a = context.obtainStyledAttributes( | ||
attrs, R.styleable.TintableImageView, defStyle, 0); | ||
tint = a.getColorStateList( | ||
R.styleable.TintableImageView_tintColor); | ||
a.recycle(); | ||
} | ||
|
||
@Override | ||
protected void drawableStateChanged() { | ||
super.drawableStateChanged(); | ||
if (tint != null && tint.isStateful()) { | ||
updateTintColor(); | ||
} | ||
} | ||
|
||
public void setColorFilter(ColorStateList tint) { | ||
this.tint = tint; | ||
super.setColorFilter(tint.getColorForState(getDrawableState(), 0)); | ||
} | ||
|
||
private void updateTintColor() { | ||
int color = tint.getColorForState(getDrawableState(), 0); | ||
setColorFilter(color); | ||
} | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
...net/angrycode/toolkit/view/ViewUtils.java → ...t/angrycode/toolkit/widget/ViewUtils.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