-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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
Showing
36 changed files
with
589 additions
and
197 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
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 |
---|---|---|
|
@@ -28,5 +28,4 @@ public void testCallback(Callback callback) { | |
callback.call(); | ||
} | ||
} | ||
|
||
} |
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
28 changes: 28 additions & 0 deletions
28
feature/utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/mvp/IMvp.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,28 @@ | ||
package com.blankj.utilcode.pkg.feature.mvp; | ||
|
||
import com.blankj.utilcode.util.Utils; | ||
|
||
/** | ||
* <pre> | ||
* author: blankj | ||
* blog : http://blankj.com | ||
* time : 2019/11/26 | ||
* desc : | ||
* </pre> | ||
*/ | ||
public interface IMvp { | ||
|
||
interface View { | ||
void setLoadingVisible(boolean visible); | ||
|
||
void showMsg(CharSequence msg); | ||
} | ||
|
||
interface Presenter { | ||
void updateMsg(); | ||
} | ||
|
||
interface Model { | ||
void requestUpdateMsg(final Utils.Func1<Void, String> func1); | ||
} | ||
} |
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
44 changes: 44 additions & 0 deletions
44
feature/utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/mvp/MvpModel.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,44 @@ | ||
package com.blankj.utilcode.pkg.feature.mvp; | ||
|
||
import com.blankj.base.mvp.BaseModel; | ||
import com.blankj.utilcode.util.ThreadUtils; | ||
import com.blankj.utilcode.util.Utils; | ||
|
||
/** | ||
* <pre> | ||
* author: blankj | ||
* blog : http://blankj.com | ||
* time : 2019/11/26 | ||
* desc : | ||
* </pre> | ||
*/ | ||
public class MvpModel extends BaseModel implements IMvp.Model { | ||
|
||
private int index; | ||
|
||
@Override | ||
public void onCreateModel() { | ||
index = 0; | ||
} | ||
|
||
@Override | ||
public void onDestroyModel() { | ||
|
||
} | ||
|
||
@Override | ||
public void requestUpdateMsg(final Utils.Func1<Void, String> func1) { | ||
ThreadUtils.executeByCached(addAutoDestroyTask(new ThreadUtils.SimpleTask<String>() { | ||
@Override | ||
public String doInBackground() throws Throwable { | ||
Thread.sleep(1000); | ||
return "msg: " + index++; | ||
} | ||
|
||
@Override | ||
public void onSuccess(String result) { | ||
func1.call(result); | ||
} | ||
})); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
feature/utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/mvp/MvpPresenter.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,33 @@ | ||
package com.blankj.utilcode.pkg.feature.mvp; | ||
|
||
import com.blankj.base.mvp.BasePresenter; | ||
import com.blankj.utilcode.util.Utils; | ||
|
||
/** | ||
* <pre> | ||
* author: blankj | ||
* blog : http://blankj.com | ||
* time : 2019/11/26 | ||
* desc : | ||
* </pre> | ||
*/ | ||
public class MvpPresenter extends BasePresenter<MvpView> | ||
implements IMvp.Presenter { | ||
|
||
@Override | ||
public void onAttachView() { | ||
} | ||
|
||
@Override | ||
public void updateMsg() { | ||
getView().setLoadingVisible(true); | ||
getModel(MvpModel.class).requestUpdateMsg(new Utils.Func1<Void, String>() { | ||
@Override | ||
public Void call(String param) { | ||
getView().showMsg(param); | ||
getView().setLoadingVisible(false); | ||
return null; | ||
} | ||
}); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
feature/utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/mvp/MvpView.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,61 @@ | ||
package com.blankj.utilcode.pkg.feature.mvp; | ||
|
||
import android.support.v4.app.FragmentActivity; | ||
import android.view.View; | ||
import android.widget.TextView; | ||
|
||
import com.blankj.base.mvp.BaseView; | ||
import com.blankj.utilcode.pkg.R; | ||
import com.blankj.utilcode.util.ClickUtils; | ||
import com.blankj.utilcode.util.ToastUtils; | ||
|
||
/** | ||
* <pre> | ||
* author: blankj | ||
* blog : http://blankj.com | ||
* time : 2019/11/26 | ||
* desc : | ||
* </pre> | ||
*/ | ||
public class MvpView extends BaseView<MvpView> | ||
implements IMvp.View { | ||
|
||
private TextView mvpTv; | ||
|
||
public MvpView(FragmentActivity activity) { | ||
super(activity); | ||
mvpTv = activity.findViewById(R.id.mvpUpdateTv); | ||
ClickUtils.applyPressedBgDark(mvpTv); | ||
mvpTv.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
getPresenter(MvpPresenter.class).updateMsg(); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void setLoadingVisible(boolean visible) { | ||
final MvpActivity activity = getActivity(); | ||
if (visible) { | ||
activity.showLoading(new Runnable() { | ||
@Override | ||
public void run() { | ||
activity.finish(); | ||
} | ||
}); | ||
} else { | ||
activity.dismissLoading(); | ||
} | ||
} | ||
|
||
@Override | ||
public void showMsg(CharSequence msg) { | ||
ToastUtils.showLong(msg); | ||
} | ||
|
||
@Override | ||
public void onDestroyView() { | ||
|
||
} | ||
} |
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,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="oval"> | ||
|
||
<solid android:color="@color/colorAccent" /> | ||
|
||
</shape> |
Oops, something went wrong.