|
|
@@ -7,11 +7,15 @@ import android.arch.lifecycle.ViewModelProviders;
|
|
|
import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
import android.support.annotation.CallSuper;
|
|
|
+import android.support.annotation.IntDef;
|
|
|
import android.support.v7.app.AppCompatActivity;
|
|
|
import android.util.Log;
|
|
|
|
|
|
import com.bumptech.glide.Glide;
|
|
|
|
|
|
+import java.lang.annotation.Retention;
|
|
|
+import java.lang.annotation.RetentionPolicy;
|
|
|
+
|
|
|
import kr.co.zumo.app.R;
|
|
|
import kr.co.zumo.app.lifeplus.application.App;
|
|
|
import kr.co.zumo.app.lifeplus.helper.ActionBarHelper;
|
|
|
@@ -39,6 +43,19 @@ import kr.co.zumo.app.lifeplus.view.screen.factory.FragmentFactory;
|
|
|
*/
|
|
|
public abstract class ActivityBase extends AppCompatActivity {
|
|
|
|
|
|
+ private final String SLIDE_TYPE = "slide_type";
|
|
|
+
|
|
|
+ public static final int SLIDE_TYPE_ACTIVITY = 0;
|
|
|
+ public static final int SLIDE_TYPE_DIALOG = 1;
|
|
|
+
|
|
|
+ @Retention(RetentionPolicy.SOURCE)
|
|
|
+ @IntDef({
|
|
|
+ SLIDE_TYPE_ACTIVITY, SLIDE_TYPE_DIALOG
|
|
|
+ })
|
|
|
+ public @interface SlideType {}
|
|
|
+
|
|
|
+ protected int slideType;
|
|
|
+
|
|
|
/***********************************
|
|
|
* Activity
|
|
|
***********************************/
|
|
|
@@ -47,6 +64,8 @@ public abstract class ActivityBase extends AppCompatActivity {
|
|
|
protected final void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
+ slideType = getIntent().getIntExtra(SLIDE_TYPE, SLIDE_TYPE_ACTIVITY);
|
|
|
+
|
|
|
if (allowCountActivity()) {
|
|
|
App.getInstance().addActivityCount();
|
|
|
}
|
|
|
@@ -152,7 +171,6 @@ public abstract class ActivityBase extends AppCompatActivity {
|
|
|
protected final void onDestroy() {
|
|
|
Log.w("APP# ActivityBase | onDestroy", "| <<-- " + this.getClass().getSimpleName() + " HC: " + this.hashCode());
|
|
|
|
|
|
-
|
|
|
Glide.get(this).clearMemory();
|
|
|
|
|
|
onBeforeDestroy();
|
|
|
@@ -167,6 +185,42 @@ public abstract class ActivityBase extends AppCompatActivity {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void startActivity(Intent intent, @SlideType int type) {
|
|
|
+ intent.putExtra(SLIDE_TYPE, type);
|
|
|
+ super.startActivity(intent);
|
|
|
+ switch (type) {
|
|
|
+ case SLIDE_TYPE_DIALOG:
|
|
|
+ overridePendingTransition(R.anim.activity_transition_slide_up, R.anim.none);
|
|
|
+ break;
|
|
|
+ case SLIDE_TYPE_ACTIVITY:
|
|
|
+ /* falls through */
|
|
|
+ default:
|
|
|
+ overridePendingTransition(R.anim.activity_slide_in_enter, R.anim.activity_slide_out_exit);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public final void startActivity(Intent intent) {
|
|
|
+ startActivity(intent, SLIDE_TYPE_ACTIVITY);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void finish() {
|
|
|
+ super.finish();
|
|
|
+
|
|
|
+ switch (slideType) {
|
|
|
+ case SLIDE_TYPE_DIALOG:
|
|
|
+ overridePendingTransition(R.anim.none, R.anim.activity_slide_down);
|
|
|
+ break;
|
|
|
+ case SLIDE_TYPE_ACTIVITY:
|
|
|
+ /* falls through */
|
|
|
+ default:
|
|
|
+ overridePendingTransition(R.anim.activity_slide_in_back_enter, R.anim.activity_slide_out_back_exit);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private boolean exitToBack() {
|
|
|
// fragment 가 있다면.
|
|
|
final FragmentBase fragment = (FragmentBase) getSupportFragmentManager().findFragmentById(R.id.container_main);
|