From b3a48b3fb389eb72a741b6fb259336e3cdc345a0 Mon Sep 17 00:00:00 2001 From: OlegKunitsyn Date: Tue, 26 Sep 2017 21:25:41 +0200 Subject: [PATCH] Material Design For android:Theme.Material --- .../android/reamp/mvp/ReampAppActivity.java | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 reamplib/src/main/java/etr/android/reamp/mvp/ReampAppActivity.java diff --git a/reamplib/src/main/java/etr/android/reamp/mvp/ReampAppActivity.java b/reamplib/src/main/java/etr/android/reamp/mvp/ReampAppActivity.java new file mode 100644 index 0000000..00a2f6b --- /dev/null +++ b/reamplib/src/main/java/etr/android/reamp/mvp/ReampAppActivity.java @@ -0,0 +1,76 @@ +package etr.android.reamp.mvp; + +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.app.Activity; +import android.app.AlertDialog; +import android.util.Log; + +import etr.android.reamp.R; + +/** + * A base Activity which is {@link ReampView}. + */ +public abstract class ReampAppActivity

, SM extends ReampStateModel> extends Activity implements ReampView { + + private MvpDelegate delegate = new MvpDelegate(this); + + @Override + protected void onCreate(Bundle savedInstanceState) { + delegate.onCreate(savedInstanceState); + super.onCreate(savedInstanceState); + } + + @Override + protected void onStart() { + super.onStart(); + delegate.connect(); + } + + @Override + protected void onStop() { + super.onStop(); + delegate.disconnect(); + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + delegate.onSaveInstanceState(outState); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + delegate.onResult(requestCode, resultCode, data); + } + + @Override + protected void onDestroy() { + delegate.onDestroy(); + super.onDestroy(); + } + + @Override + public Context getContext() { + return this; + } + + public P getPresenter() { + return delegate.getPresenter(); + } + + @Override + public void onError(Throwable throwable) { + new AlertDialog.Builder(this) + .setTitle(getString(R.string.reamp_common_error_title)) + .setMessage(Log.getStackTraceString(throwable)) + .show(); + + } + + public String getMvpId() { + return delegate.getId(); + } +}