-
Notifications
You must be signed in to change notification settings - Fork 444
Expand file tree
/
Copy pathMainActivity.java
More file actions
101 lines (82 loc) · 3.35 KB
/
MainActivity.java
File metadata and controls
101 lines (82 loc) · 3.35 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package ms.appcenter.sampleapp.android;
import android.os.Bundle;
import android.util.Log;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import com.microsoft.appcenter.AppCenter;
import com.microsoft.appcenter.analytics.Analytics;
import com.microsoft.appcenter.crashes.Crashes;
import com.microsoft.appcenter.distribute.Distribute;
public class MainActivity extends AppCompatActivity {
private SectionsPagerAdapter mSectionsPagerAdapter;
private ViewPager mViewPager;
private final Fragment[] views = {
new WelcomeActivity(),
new BuildActivity(),
new TestActivity(),
new DistributeActivity(),
new CrashesActivity(),
new AnalyticsActivity(),
new PushActivity()
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_root);
// Initialize SDK
if (!BuildConfig.APPCENTER_APP_SECRET.equals("")) {
// Use APPCENTER_APP_SECRET environment variable if it exists
AppCenter.start(getApplication(), BuildConfig.APPCENTER_APP_SECRET,
Analytics.class, Crashes.class, Distribute.class);
} else {
// Otherwise use the hardcoded string value here
AppCenter.start(getApplication(), "7e73572e-f646-4eb7-9503-7806f8056f2e",
Analytics.class, Crashes.class, Distribute.class);
}
if (BuildConfig.DEBUG) {
AppCenter.setLogLevel(Log.VERBOSE);
}
// UI Elements
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
mViewPager = findViewById(R.id.container);
mViewPager.setAdapter(mSectionsPagerAdapter);
}
public class SectionsPagerAdapter extends FragmentPagerAdapter {
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
@NonNull
@Override
public Fragment getItem(@IntRange(from = 0, to = 6) final int position) {
return views[position];
}
@Override
public int getCount() {
return views.length;
}
@Override
public CharSequence getPageTitle(@IntRange(from = 0, to = 6) final int position) {
if (views[position] instanceof WelcomeActivity) {
return "Welcome";
} else if (views[position] instanceof BuildActivity) {
return "Build";
} else if (views[position] instanceof TestActivity) {
return "Test";
} else if (views[position] instanceof DistributeActivity) {
return "Distribute";
} else if (views[position] instanceof CrashesActivity) {
return "Crashes";
} else if (views[position] instanceof AnalyticsActivity) {
return "Analytics";
} else if (views[position] instanceof PushActivity) {
return "Push";
}
return views[position].getClass().getSimpleName().trim().replace("Activity", "");
}
}
}