-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseActivity.java
More file actions
55 lines (43 loc) · 1.42 KB
/
BaseActivity.java
File metadata and controls
55 lines (43 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import android.app.ActivityOptions;
import android.content.Intent;
import android.os.Build;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Pair;
import android.view.View;
import com.umeng.analytics.MobclickAgent;
public class BaseActivity extends AppCompatActivity {
@Override
protected void onResume() {
super.onResume();
MobclickAgent.onResume(this);
}
@Override
protected void onPause() {
super.onPause();
MobclickAgent.onPause(this);
}
public void startActivityTrans(Intent intent, @Nullable Pair<View, String>... sharedElements) {
if (sharedElements != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
ActivityOptions options = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
options = ActivityOptions
.makeSceneTransitionAnimation(this, sharedElements);
}
if (options == null) {
startActivity(intent);
} else {
startActivity(intent, options.toBundle());
}
} else {
startActivity(intent);
}
}
public void finishThis() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
finishAfterTransition();
} else {
finish();
}
}
}