code clean up, removed unnecessary .xml elements, rebuild MainActivity structure, chop onCreate to particular functions

This commit is contained in:
Domagalski 2018-09-20 22:51:19 +02:00
parent ad58983d32
commit 9ca1617e29
6 changed files with 51 additions and 51 deletions

View File

@ -19,7 +19,7 @@
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<activity android:name=".activity.StartupActivity" <activity android:name=".activity.StartupActivity"
android:label="@string/title_activity_startup" android:label="@string/title_activity_startup"

View File

@ -41,28 +41,26 @@ public class MainActivity extends AppCompatActivity {
private DrawerLayout drawerLayout; private DrawerLayout drawerLayout;
private ActionBarDrawerToggle actionBarDrawerToggle; private ActionBarDrawerToggle actionBarDrawerToggle;
public List<Coordinate> coordinates;
private MapView mapView;
public List<Coordinate> getCoordinates() { public List<Coordinate> getCoordinates() {
return this.coordinates; return this.coordinates;
} }
public void setCoordinates(List<Coordinate> coordinates) { public void setCoordinates(List<Coordinate> coordinates) {
this.coordinates = coordinates; this.coordinates = coordinates;
} }
public List<Coordinate> coordinates;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
Mapbox.getInstance(this, getString(R.string.access_token));
setContentView(R.layout.activity_main); 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); Toolbar toolbar = findViewById(R.id.toolbar_main);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
@ -72,17 +70,26 @@ public class MainActivity extends AppCompatActivity {
drawerLayout.addDrawerListener(actionBarDrawerToggle); drawerLayout.addDrawerListener(actionBarDrawerToggle);
ActionBar actionBar = getSupportActionBar(); ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowTitleEnabled(false);
if (actionBar != null) { if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(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); mMainFrame = (FrameLayout) findViewById(R.id.main_frame);
mMainNav = (BottomNavigationView) findViewById(R.id.main_nav); mMainNav = (BottomNavigationView) findViewById(R.id.main_nav);
Bundle extras = getIntent().getExtras();
isTutor = (boolean) extras.get("is_tutor"); isTutor = (boolean) extras.get("is_tutor");
if (!isTutor){ if (!isTutor){
mMainNav.findViewById(R.id.nav_profile).setVisibility(View.GONE); mMainNav.findViewById(R.id.nav_profile).setVisibility(View.GONE);
@ -116,7 +123,9 @@ public class MainActivity extends AppCompatActivity {
} }
} }
}); });
}
private void configureLogoutButton(){
// Logout button // Logout button
final FloatingActionButton button = findViewById(R.id.logoutButton); final FloatingActionButton button = findViewById(R.id.logoutButton);
button.setOnClickListener(new View.OnClickListener(){ button.setOnClickListener(new View.OnClickListener(){
@ -133,17 +142,6 @@ public class MainActivity extends AppCompatActivity {
finish(); 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();
} }

View File

@ -12,6 +12,7 @@
tools:context=".activity.LoginActivity"> tools:context=".activity.LoginActivity">
<!-- Login progress --> <!-- Login progress -->
<ProgressBar <ProgressBar
android:id="@+id/login_progress" android:id="@+id/login_progress"
style="?android:attr/progressBarStyleLarge" style="?android:attr/progressBarStyleLarge"

View File

@ -13,8 +13,7 @@
<include <include
layout="@layout/app_bar_main" layout="@layout/app_bar_main"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content" />
/>
<android.support.design.widget.NavigationView <android.support.design.widget.NavigationView
android:id="@+id/nav_view" android:id="@+id/nav_view"
@ -22,11 +21,11 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="start" android:layout_gravity="start"
app:headerLayout="@layout/nav_header_main" 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" </android.support.design.widget.NavigationView>
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" <android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".activity.MainActivity"> tools:context=".activity.MainActivity">
@ -39,21 +38,13 @@
android:id="@+id/logoutButton" android:id="@+id/logoutButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_marginTop="77dp" android:layout_alignParentTop="true"
android:layout_marginRight="@dimen/fab_margin" android:layout_marginRight="@dimen/fab_margin"
android:layout_marginTop="77dp"
app:backgroundTint="@android:color/holo_red_dark" app:backgroundTint="@android:color/holo_red_dark"
app:srcCompat="@android:drawable/ic_lock_power_off" /> 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 <include
android:id="@+id/include" android:id="@+id/include"

View File

@ -7,11 +7,12 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".activity.MainActivity"> tools:context=".activity.MainActivity">
<android.support.design.widget.AppBarLayout <!--<android.support.design.widget.AppBarLayout-->
android:layout_width="match_parent" <!--android:layout_width="match_parent"-->
android:layout_height="wrap_content" <!--android:layout_height="wrap_content"-->
android:fitsSystemWindows="true" <!--android:fitsSystemWindows="true"-->
android:theme="@style/AppTheme.AppBarOverlay"> <!--android:theme="@style/AppTheme.NoActionBar">-->
<android.support.v7.widget.Toolbar <android.support.v7.widget.Toolbar
android:id="@+id/toolbar_main" android:id="@+id/toolbar_main"
@ -19,7 +20,18 @@
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary" android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways" 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> </android.support.design.widget.CoordinatorLayout>

View File

@ -1,18 +1,16 @@
<resources> <resources>
<!-- Base application theme. --> <!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. --> <!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item> <item name="colorAccent">@color/colorAccent</item>
<item name="windowActionBar">true</item>
<item name="windowNoTitle">true</item>
</style> </style>
<style name="AppTheme.NoActionBar"> <style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item> <item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item> <item name="windowNoTitle">false</item>
</style> </style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />