bottom navi with frags and activities
This commit is contained in:
parent
d60a3c413c
commit
5dab4eaf4b
@ -29,7 +29,7 @@
|
||||
</value>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8 (1)" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.uam.wmi.findmytutor.activity;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.support.annotation.NonNull;
|
||||
@ -39,6 +41,7 @@ public abstract class BaseActivity
|
||||
private ListView listView;
|
||||
private ArrayList<String> stringArrayList;
|
||||
private ListViewAdapter adapter;
|
||||
private SharingFragment sharingFragment;
|
||||
|
||||
|
||||
@Override
|
||||
@ -48,6 +51,8 @@ public abstract class BaseActivity
|
||||
|
||||
navigationView = findViewById(R.id.navigation);
|
||||
navigationView.setOnNavigationItemSelectedListener(this);
|
||||
sharingFragment = new SharingFragment();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -161,36 +166,37 @@ public abstract class BaseActivity
|
||||
overridePendingTransition(0,0);
|
||||
}
|
||||
|
||||
private void setFragment(Fragment fragment) {
|
||||
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
||||
fragmentTransaction.replace(R.id.activity_content, fragment);
|
||||
fragmentTransaction.commit();
|
||||
}
|
||||
|
||||
private void removeFragment(Fragment fragment) {
|
||||
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
||||
fragmentTransaction.remove(fragment);
|
||||
fragmentTransaction.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
||||
|
||||
navigationView.postDelayed(() -> {
|
||||
int itemId = item.getItemId();
|
||||
if (itemId == R.id.nav_map) {
|
||||
startActivity(new Intent(this, MapActivity.class));
|
||||
removeFragment(sharingFragment);
|
||||
// startActivity(new Intent(this, MapActivity.class));
|
||||
} else if (itemId == R.id.nav_profile) {
|
||||
startActivity(new Intent(this, ProfileActivity.class));
|
||||
// startActivity(new Intent(this, ProfileActivity.class));
|
||||
setFragment(sharingFragment);
|
||||
|
||||
} else if (itemId == R.id.nav_notif) {
|
||||
startActivity(new Intent(this, NotificationsActivity.class));
|
||||
}
|
||||
finish();
|
||||
}, 300);
|
||||
return true;
|
||||
|
||||
// navigationView.postDelayed(() -> {
|
||||
// int itemId = item.getItemId();
|
||||
// switch (itemId) {
|
||||
// case R.id.nav_profile:
|
||||
// startActivity(new Intent(this, ProfileActivity.class));
|
||||
// case R.id.nav_map:
|
||||
// startActivity(new Intent(this, MapActivity.class));
|
||||
// case R.id.nav_notif:
|
||||
// startActivity(new Intent(this, NotificationsActivity.class));
|
||||
// }
|
||||
//
|
||||
//finish();
|
||||
// }, 300);
|
||||
// return true;
|
||||
}, 300);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void updateNavigationBarState() {
|
||||
|
@ -36,7 +36,7 @@ public class SharingActivity extends AppCompatPreferenceActivity {
|
||||
@Override
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.pref_sharing);
|
||||
addPreferencesFromResource(R.layout.pref_sharing);
|
||||
|
||||
Preference manualStatus = findPreference("key_manual_status");
|
||||
manualStatus.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
|
@ -24,7 +24,7 @@ public class SharingFragment extends PreferenceFragment {
|
||||
@Override
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.pref_sharing);
|
||||
addPreferencesFromResource(R.layout.pref_sharing);
|
||||
Preference manualStatus = findPreference("key_manual_status");
|
||||
manualStatus.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
ListPreference lp = (ListPreference) findPreference("key_status_value");
|
||||
|
@ -15,7 +15,7 @@ public class StartupActivity extends AppCompatActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
if (PrefUtils.isLoggedIn(getApplicationContext())){
|
||||
Intent startupIntent = new Intent(this, MainActivity.class);
|
||||
Intent startupIntent = new Intent(this, MapActivity.class);
|
||||
startupIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(startupIntent);
|
||||
finish();
|
||||
@ -31,7 +31,7 @@ public class StartupActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == AUTHENTICATION_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
|
||||
Intent startupIntent = new Intent(this, MainActivity.class);
|
||||
Intent startupIntent = new Intent(this, MapActivity.class);
|
||||
startupIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(startupIntent);
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
<com.mapbox.mapboxsdk.maps.MapView
|
||||
android:id="@+id/mapView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="visible"
|
||||
mapbox:mapbox_cameraTargetLat="52.466799"
|
||||
mapbox:mapbox_cameraTargetLng="16.927002"
|
||||
@ -19,13 +19,4 @@
|
||||
|
||||
</com.mapbox.mapboxsdk.maps.MapView>
|
||||
|
||||
<include
|
||||
android:id="@+id/navigation"
|
||||
layout="@layout/element_bottom_navigation"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
@ -5,30 +5,45 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
android:id="@+id/cl_root_coordinator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:id="@+id/app_bar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?actionBarSize"
|
||||
android:layout_height="?actionBarSize" />
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="?actionBarSize">
|
||||
|
||||
/>
|
||||
<FrameLayout
|
||||
android:id="@+id/activity_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@+id/navigation"/>
|
||||
|
||||
<include
|
||||
android:id="@id/navigation"
|
||||
layout="@layout/element_bottom_navigation"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
||||
</LinearLayout>
|
||||
<!--<android.support.design.widget.NavigationView-->
|
||||
<!--android:id="@+id/navigation"-->
|
||||
<!--android:layout_width="wrap_content"-->
|
||||
<!--android:layout_height="match_parent"-->
|
||||
<!--android:layout_gravity="start"-->
|
||||
<!--/>-->
|
||||
<android.support.design.widget.NavigationView
|
||||
android:id="@+id/nav_view"
|
||||
android:layout_width="wrap_content"
|
||||
@ -37,5 +52,6 @@
|
||||
app:headerLayout="@layout/nav_header_main"
|
||||
app:menu="@menu/activity_main_drawer">
|
||||
|
||||
|
||||
</android.support.design.widget.NavigationView>
|
||||
</android.support.v4.widget.DrawerLayout>
|
@ -1,7 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
tools:ignore="MissingDefaultResource">
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
tools:ignore="MissingDefaultResource"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<PreferenceCategory android:title="@string/settings_category_location">
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
@ -56,6 +59,7 @@
|
||||
android:title="@string/title_manual_location"
|
||||
/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user