code clean up, removed unnecessary .xml elements, rebuild MainActivity structure, chop onCreate to particular functions
This commit is contained in:
parent
ad58983d32
commit
9ca1617e29
@ -19,7 +19,7 @@
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
|
||||
|
||||
<activity android:name=".activity.StartupActivity"
|
||||
android:label="@string/title_activity_startup"
|
||||
|
@ -41,28 +41,26 @@ public class MainActivity extends AppCompatActivity {
|
||||
private DrawerLayout drawerLayout;
|
||||
private ActionBarDrawerToggle actionBarDrawerToggle;
|
||||
|
||||
|
||||
|
||||
private MapView mapView;
|
||||
|
||||
public List<Coordinate> coordinates;
|
||||
public List<Coordinate> getCoordinates() {
|
||||
return this.coordinates;
|
||||
}
|
||||
|
||||
public void setCoordinates(List<Coordinate> coordinates) {
|
||||
this.coordinates = coordinates;
|
||||
}
|
||||
|
||||
public List<Coordinate> coordinates;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Mapbox.getInstance(this, getString(R.string.access_token));
|
||||
setContentView(R.layout.activity_main);
|
||||
Mapbox.getInstance(this, getString(R.string.access_token));
|
||||
|
||||
/* Side nav start*/
|
||||
configureconfigureNavigationDrawer();
|
||||
configureBottomNavigationView();
|
||||
configureLogoutButton();
|
||||
}
|
||||
|
||||
private void configureconfigureNavigationDrawer() {
|
||||
Toolbar toolbar = findViewById(R.id.toolbar_main);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
@ -72,17 +70,26 @@ public class MainActivity extends AppCompatActivity {
|
||||
drawerLayout.addDrawerListener(actionBarDrawerToggle);
|
||||
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
actionBar.setDisplayShowTitleEnabled(false);
|
||||
|
||||
if (actionBar != null) {
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
actionBar.setHomeButtonEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
/* Side nav end*/
|
||||
private void setFragment(Fragment fragment) {
|
||||
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
||||
fragmentTransaction.replace(R.id.main_frame, fragment);
|
||||
fragmentTransaction.commit();
|
||||
}
|
||||
|
||||
private void configureBottomNavigationView(){
|
||||
|
||||
Bundle extras = getIntent().getExtras();
|
||||
mMainFrame = (FrameLayout) findViewById(R.id.main_frame);
|
||||
mMainNav = (BottomNavigationView) findViewById(R.id.main_nav);
|
||||
|
||||
Bundle extras = getIntent().getExtras();
|
||||
isTutor = (boolean) extras.get("is_tutor");
|
||||
if (!isTutor){
|
||||
mMainNav.findViewById(R.id.nav_profile).setVisibility(View.GONE);
|
||||
@ -96,7 +103,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
setFragment(mapFragment);
|
||||
mMainNav.setSelectedItemId(R.id.nav_map);
|
||||
|
||||
/* code below is resposible for changing colours of tabs in main tab menu */
|
||||
/* code below is resposible for changing colours of tabs in main tab menu */
|
||||
mMainNav.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
||||
@ -116,7 +123,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void configureLogoutButton(){
|
||||
// Logout button
|
||||
final FloatingActionButton button = findViewById(R.id.logoutButton);
|
||||
button.setOnClickListener(new View.OnClickListener(){
|
||||
@ -133,17 +142,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
// CoordinateService service = ApiClient.getClient(getApplicationContext())
|
||||
// .create(CoordinateService.class);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void setFragment(Fragment fragment) {
|
||||
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
||||
fragmentTransaction.replace(R.id.main_frame, fragment);
|
||||
fragmentTransaction.commit();
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
tools:context=".activity.LoginActivity">
|
||||
|
||||
<!-- Login progress -->
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/login_progress"
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
|
@ -13,8 +13,7 @@
|
||||
<include
|
||||
layout="@layout/app_bar_main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<android.support.design.widget.NavigationView
|
||||
android:id="@+id/nav_view"
|
||||
@ -22,11 +21,11 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
app:headerLayout="@layout/nav_header_main"
|
||||
app:menu="@menu/activity_main_drawer" />
|
||||
app:menu="@menu/activity_main_drawer" >
|
||||
|
||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
</android.support.design.widget.NavigationView>
|
||||
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".activity.MainActivity">
|
||||
@ -39,21 +38,13 @@
|
||||
android:id="@+id/logoutButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginTop="77dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginRight="@dimen/fab_margin"
|
||||
android:layout_marginTop="77dp"
|
||||
app:backgroundTint="@android:color/holo_red_dark"
|
||||
app:srcCompat="@android:drawable/ic_lock_power_off" />
|
||||
|
||||
<include layout="@layout/content_main" />
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<include
|
||||
android:id="@+id/include"
|
||||
|
@ -7,11 +7,12 @@
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".activity.MainActivity">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fitsSystemWindows="true"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
<!--<android.support.design.widget.AppBarLayout-->
|
||||
<!--android:layout_width="match_parent"-->
|
||||
<!--android:layout_height="wrap_content"-->
|
||||
<!--android:fitsSystemWindows="true"-->
|
||||
<!--android:theme="@style/AppTheme.NoActionBar">-->
|
||||
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar_main"
|
||||
@ -19,7 +20,18 @@
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:layout_scrollFlags="scroll|enterAlways"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||
android:elevation="40dp"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
|
||||
app:popupTheme="@style/AppTheme" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:inputType="textPersonName"
|
||||
android:text="ToolBar Title" />
|
||||
|
||||
<!--</android.support.design.widget.AppBarLayout>-->
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
</android.support.design.widget.CoordinatorLayout>
|
@ -1,18 +1,16 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
<item name="windowActionBar">true</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
<item name="windowNoTitle">false</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||
|
Loading…
Reference in New Issue
Block a user