Adds top level navigation and placeholder fragments.
This commit is contained in:
		| @@ -31,7 +31,10 @@ public class MainActivity extends AppCompatActivity { | |||||||
|         // Passing each menu ID as a set of Ids because each |         // Passing each menu ID as a set of Ids because each | ||||||
|         // menu should be considered as top level destinations. |         // menu should be considered as top level destinations. | ||||||
|         AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder( |         AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder( | ||||||
|                 R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications) |                 R.id.navigation_search, | ||||||
|  |                 R.id.navigation_dashboard, | ||||||
|  |                 R.id.navigation_collections, | ||||||
|  |                 R.id.navigation_library) | ||||||
|                 .build(); |                 .build(); | ||||||
|         NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment); |         NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment); | ||||||
|         NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration); |         NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration); | ||||||
|   | |||||||
| @@ -7,21 +7,29 @@ import android.view.ViewGroup; | |||||||
| import android.widget.TextView; | import android.widget.TextView; | ||||||
|  |  | ||||||
| import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||||
| import androidx.lifecycle.ViewModelProvider; | import androidx.annotation.Nullable; | ||||||
|  | import androidx.fragment.app.Fragment; | ||||||
|  | import androidx.lifecycle.Observer; | ||||||
|  | import androidx.lifecycle.ViewModelProviders; | ||||||
|  |  | ||||||
| import com.majinnaibu.monstercards.R; | import com.majinnaibu.monstercards.R; | ||||||
| import com.majinnaibu.monstercards.ui.shared.MCFragment; |  | ||||||
|  |  | ||||||
| public class CollectionsFragment extends MCFragment { | public class CollectionsFragment extends Fragment { | ||||||
|  |  | ||||||
|     private CollectionsViewModel collectionsViewModel; |     private CollectionsViewModel collectionsViewModel; | ||||||
|  |  | ||||||
|     public View onCreateView(@NonNull LayoutInflater inflater, |     public View onCreateView(@NonNull LayoutInflater inflater, | ||||||
|                              ViewGroup container, Bundle savedInstanceState) { |                              ViewGroup container, Bundle savedInstanceState) { | ||||||
|         collectionsViewModel = new ViewModelProvider(this).get(CollectionsViewModel.class); |         collectionsViewModel = | ||||||
|  |                 ViewModelProviders.of(this).get(CollectionsViewModel.class); | ||||||
|         View root = inflater.inflate(R.layout.fragment_collections, container, false); |         View root = inflater.inflate(R.layout.fragment_collections, container, false); | ||||||
|         final TextView textView = root.findViewById(R.id.text_collections); |         final TextView textView = root.findViewById(R.id.text_collections); | ||||||
|         collectionsViewModel.getText().observe(getViewLifecycleOwner(), textView::setText); |         collectionsViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() { | ||||||
|  |             @Override | ||||||
|  |             public void onChanged(@Nullable String s) { | ||||||
|  |                 textView.setText(s); | ||||||
|  |             } | ||||||
|  |         }); | ||||||
|         return root; |         return root; | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @@ -6,7 +6,7 @@ import androidx.lifecycle.ViewModel; | |||||||
|  |  | ||||||
| public class CollectionsViewModel extends ViewModel { | public class CollectionsViewModel extends ViewModel { | ||||||
|  |  | ||||||
|     private final MutableLiveData<String> mText; |     private MutableLiveData<String> mText; | ||||||
|  |  | ||||||
|     public CollectionsViewModel() { |     public CollectionsViewModel() { | ||||||
|         mText = new MutableLiveData<>(); |         mText = new MutableLiveData<>(); | ||||||
|   | |||||||
| @@ -1,35 +0,0 @@ | |||||||
| package com.majinnaibu.monstercards.ui.home; |  | ||||||
|  |  | ||||||
| import android.os.Bundle; |  | ||||||
| import android.view.LayoutInflater; |  | ||||||
| import android.view.View; |  | ||||||
| import android.view.ViewGroup; |  | ||||||
| import android.widget.TextView; |  | ||||||
|  |  | ||||||
| import androidx.annotation.NonNull; |  | ||||||
| import androidx.annotation.Nullable; |  | ||||||
| import androidx.fragment.app.Fragment; |  | ||||||
| import androidx.lifecycle.Observer; |  | ||||||
| import androidx.lifecycle.ViewModelProviders; |  | ||||||
|  |  | ||||||
| import com.majinnaibu.monstercards.R; |  | ||||||
|  |  | ||||||
| public class HomeFragment extends Fragment { |  | ||||||
|  |  | ||||||
|     private HomeViewModel homeViewModel; |  | ||||||
|  |  | ||||||
|     public View onCreateView(@NonNull LayoutInflater inflater, |  | ||||||
|                              ViewGroup container, Bundle savedInstanceState) { |  | ||||||
|         homeViewModel = |  | ||||||
|                 ViewModelProviders.of(this).get(HomeViewModel.class); |  | ||||||
|         View root = inflater.inflate(R.layout.fragment_home, container, false); |  | ||||||
|         final TextView textView = root.findViewById(R.id.text_home); |  | ||||||
|         homeViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() { |  | ||||||
|             @Override |  | ||||||
|             public void onChanged(@Nullable String s) { |  | ||||||
|                 textView.setText(s); |  | ||||||
|             } |  | ||||||
|         }); |  | ||||||
|         return root; |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -1,121 +1,35 @@ | |||||||
| package com.majinnaibu.monstercards.ui.library; | package com.majinnaibu.monstercards.ui.library; | ||||||
|  |  | ||||||
| import android.content.Context; |  | ||||||
| import android.os.Bundle; | import android.os.Bundle; | ||||||
| import android.view.LayoutInflater; | import android.view.LayoutInflater; | ||||||
| import android.view.View; | import android.view.View; | ||||||
| import android.view.ViewGroup; | import android.view.ViewGroup; | ||||||
|  | import android.widget.TextView; | ||||||
|  |  | ||||||
| import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||||
| import androidx.navigation.NavDirections; | import androidx.annotation.Nullable; | ||||||
| import androidx.navigation.Navigation; | import androidx.fragment.app.Fragment; | ||||||
| import androidx.recyclerview.widget.DividerItemDecoration; | import androidx.lifecycle.Observer; | ||||||
| import androidx.recyclerview.widget.ItemTouchHelper; | import androidx.lifecycle.ViewModelProviders; | ||||||
| import androidx.recyclerview.widget.LinearLayoutManager; |  | ||||||
| import androidx.recyclerview.widget.RecyclerView; |  | ||||||
|  |  | ||||||
| import com.google.android.material.floatingactionbutton.FloatingActionButton; |  | ||||||
| import com.google.android.material.snackbar.Snackbar; |  | ||||||
| import com.majinnaibu.monstercards.R; | import com.majinnaibu.monstercards.R; | ||||||
| import com.majinnaibu.monstercards.data.MonsterRepository; |  | ||||||
| import com.majinnaibu.monstercards.models.Monster; |  | ||||||
| import com.majinnaibu.monstercards.ui.shared.MCFragment; |  | ||||||
| import com.majinnaibu.monstercards.ui.shared.SwipeToDeleteCallback; |  | ||||||
| import com.majinnaibu.monstercards.utils.Logger; |  | ||||||
|  |  | ||||||
| import java.util.UUID; | public class LibraryFragment extends Fragment { | ||||||
|  |  | ||||||
| import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; |     private LibraryViewModel libraryViewModel; | ||||||
| import io.reactivex.rxjava3.observers.DisposableCompletableObserver; |  | ||||||
| import io.reactivex.rxjava3.schedulers.Schedulers; |  | ||||||
|  |  | ||||||
| public class LibraryFragment extends MCFragment { |  | ||||||
|  |  | ||||||
|     public View onCreateView(@NonNull LayoutInflater inflater, |     public View onCreateView(@NonNull LayoutInflater inflater, | ||||||
|                              ViewGroup container, Bundle savedInstanceState) { |                              ViewGroup container, Bundle savedInstanceState) { | ||||||
|  |         libraryViewModel = | ||||||
|  |                 ViewModelProviders.of(this).get(LibraryViewModel.class); | ||||||
|         View root = inflater.inflate(R.layout.fragment_library, container, false); |         View root = inflater.inflate(R.layout.fragment_library, container, false); | ||||||
|  |         final TextView textView = root.findViewById(R.id.text_library); | ||||||
|         FloatingActionButton fab = root.findViewById(R.id.fab); |         libraryViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() { | ||||||
|         assert fab != null; |             @Override | ||||||
|         setupAddMonsterButton(fab); |             public void onChanged(@Nullable String s) { | ||||||
|  |                 textView.setText(s); | ||||||
|         final RecyclerView recyclerView = root.findViewById(R.id.monster_list); |             } | ||||||
|         assert recyclerView != null; |         }); | ||||||
|         setupRecyclerView(recyclerView); |  | ||||||
|  |  | ||||||
|         return root; |         return root; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void setupRecyclerView(@NonNull RecyclerView recyclerView) { |  | ||||||
|         Context context = requireContext(); |  | ||||||
|         MonsterRepository repository = this.getMonsterRepository(); |  | ||||||
|  |  | ||||||
|         LibraryRecyclerViewAdapter adapter = new LibraryRecyclerViewAdapter( |  | ||||||
|                 context, |  | ||||||
|                 repository.getMonsters(), |  | ||||||
|                 (monster) -> navigateToMonsterDetail(monster.id), |  | ||||||
|                 (monster) -> repository |  | ||||||
|                         .deleteMonster(monster) |  | ||||||
|                         .subscribeOn(Schedulers.io()) |  | ||||||
|                         .observeOn(AndroidSchedulers.mainThread()) |  | ||||||
|                         .subscribe(new DisposableCompletableObserver() { |  | ||||||
|                             @Override |  | ||||||
|                             public void onComplete() { |  | ||||||
|                             } |  | ||||||
|  |  | ||||||
|                             @Override |  | ||||||
|                             public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) { |  | ||||||
|                                 Logger.logError(e); |  | ||||||
|                             } |  | ||||||
|                         })); |  | ||||||
|         recyclerView.setAdapter(adapter); |  | ||||||
|  |  | ||||||
|         LinearLayoutManager layoutManager = new LinearLayoutManager(context); |  | ||||||
|         recyclerView.setLayoutManager(layoutManager); |  | ||||||
|  |  | ||||||
|         DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(context, layoutManager.getOrientation()); |  | ||||||
|         recyclerView.addItemDecoration(dividerItemDecoration); |  | ||||||
|  |  | ||||||
|         ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new SwipeToDeleteCallback(requireContext(), (position, direction) -> adapter.deleteItem(position), null)); |  | ||||||
|         itemTouchHelper.attachToRecyclerView(recyclerView); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     private void setupAddMonsterButton(@NonNull FloatingActionButton fab) { |  | ||||||
|         fab.setOnClickListener(view -> { |  | ||||||
|             Monster monster = new Monster(); |  | ||||||
|             monster.name = getString(R.string.default_monster_name); |  | ||||||
|             MonsterRepository repository = this.getMonsterRepository(); |  | ||||||
|             repository.addMonster(monster) |  | ||||||
|                     .subscribeOn(Schedulers.io()) |  | ||||||
|                     .observeOn(AndroidSchedulers.mainThread()) |  | ||||||
|                     .subscribe( |  | ||||||
|                             new DisposableCompletableObserver() { |  | ||||||
|                                 @Override |  | ||||||
|                                 public void onComplete() { |  | ||||||
|                                     View view = getView(); |  | ||||||
|                                     assert view != null; |  | ||||||
|                                     Snackbar.make( |  | ||||||
|                                             view, |  | ||||||
|                                             getString(R.string.snackbar_monster_created, monster.name), |  | ||||||
|                                             Snackbar.LENGTH_LONG) |  | ||||||
|                                             .setAction("Action", (_view) -> navigateToMonsterDetail(monster.id)) |  | ||||||
|                                             .show(); |  | ||||||
|                                 } |  | ||||||
|  |  | ||||||
|                                 @Override |  | ||||||
|                                 public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) { |  | ||||||
|                                     Logger.logError("Error creating monster", e); |  | ||||||
|                                     View view = getView(); |  | ||||||
|                                     assert view != null; |  | ||||||
|                                     Snackbar.make(view, getString(R.string.snackbar_failed_to_create_monster), Snackbar.LENGTH_LONG) |  | ||||||
|                                             .setAction("Action", null).show(); |  | ||||||
|                                 } |  | ||||||
|                             }); |  | ||||||
|         }); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     protected void navigateToMonsterDetail(@NonNull UUID monsterId) { |  | ||||||
|         NavDirections action = LibraryFragmentDirections.actionNavigationLibraryToNavigationMonster(monsterId.toString()); |  | ||||||
|         Navigation.findNavController(requireView()).navigate(action); |  | ||||||
|     } |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,19 +1,19 @@ | |||||||
| package com.majinnaibu.monstercards.ui.notifications; | package com.majinnaibu.monstercards.ui.library; | ||||||
| 
 | 
 | ||||||
| import androidx.lifecycle.LiveData; | import androidx.lifecycle.LiveData; | ||||||
| import androidx.lifecycle.MutableLiveData; | import androidx.lifecycle.MutableLiveData; | ||||||
| import androidx.lifecycle.ViewModel; | import androidx.lifecycle.ViewModel; | ||||||
| 
 | 
 | ||||||
| public class NotificationsViewModel extends ViewModel { | public class LibraryViewModel extends ViewModel { | ||||||
| 
 | 
 | ||||||
|     private MutableLiveData<String> mText; |     private MutableLiveData<String> mText; | ||||||
| 
 | 
 | ||||||
|     public NotificationsViewModel() { |     public LibraryViewModel() { | ||||||
|         mText = new MutableLiveData<>(); |         mText = new MutableLiveData<>(); | ||||||
|         mText.setValue("This is notifications fragment"); |         mText.setValue("This is library fragment"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public LiveData<String> getText() { |     public LiveData<String> getText() { | ||||||
|         return mText; |         return mText; | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @@ -1,35 +0,0 @@ | |||||||
| package com.majinnaibu.monstercards.ui.notifications; |  | ||||||
|  |  | ||||||
| import android.os.Bundle; |  | ||||||
| import android.view.LayoutInflater; |  | ||||||
| import android.view.View; |  | ||||||
| import android.view.ViewGroup; |  | ||||||
| import android.widget.TextView; |  | ||||||
|  |  | ||||||
| import androidx.annotation.NonNull; |  | ||||||
| import androidx.annotation.Nullable; |  | ||||||
| import androidx.fragment.app.Fragment; |  | ||||||
| import androidx.lifecycle.Observer; |  | ||||||
| import androidx.lifecycle.ViewModelProviders; |  | ||||||
|  |  | ||||||
| import com.majinnaibu.monstercards.R; |  | ||||||
|  |  | ||||||
| public class NotificationsFragment extends Fragment { |  | ||||||
|  |  | ||||||
|     private NotificationsViewModel notificationsViewModel; |  | ||||||
|  |  | ||||||
|     public View onCreateView(@NonNull LayoutInflater inflater, |  | ||||||
|                              ViewGroup container, Bundle savedInstanceState) { |  | ||||||
|         notificationsViewModel = |  | ||||||
|                 ViewModelProviders.of(this).get(NotificationsViewModel.class); |  | ||||||
|         View root = inflater.inflate(R.layout.fragment_notifications, container, false); |  | ||||||
|         final TextView textView = root.findViewById(R.id.text_notifications); |  | ||||||
|         notificationsViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() { |  | ||||||
|             @Override |  | ||||||
|             public void onChanged(@Nullable String s) { |  | ||||||
|                 textView.setText(s); |  | ||||||
|             } |  | ||||||
|         }); |  | ||||||
|         return root; |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -1,53 +1,35 @@ | |||||||
| package com.majinnaibu.monstercards.ui.search; | package com.majinnaibu.monstercards.ui.search; | ||||||
|  |  | ||||||
| import android.os.Bundle; | import android.os.Bundle; | ||||||
| import android.text.Editable; |  | ||||||
| import android.text.TextWatcher; |  | ||||||
| import android.view.LayoutInflater; | import android.view.LayoutInflater; | ||||||
| import android.view.View; | import android.view.View; | ||||||
| import android.view.ViewGroup; | import android.view.ViewGroup; | ||||||
| import android.widget.TextView; | import android.widget.TextView; | ||||||
|  |  | ||||||
| import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||||
| import androidx.recyclerview.widget.LinearLayoutManager; | import androidx.annotation.Nullable; | ||||||
| import androidx.recyclerview.widget.RecyclerView; | import androidx.fragment.app.Fragment; | ||||||
|  | import androidx.lifecycle.Observer; | ||||||
|  | import androidx.lifecycle.ViewModelProviders; | ||||||
|  |  | ||||||
| import com.majinnaibu.monstercards.R; | import com.majinnaibu.monstercards.R; | ||||||
| import com.majinnaibu.monstercards.data.MonsterRepository; |  | ||||||
| import com.majinnaibu.monstercards.ui.shared.MCFragment; |  | ||||||
|  |  | ||||||
| public class SearchFragment extends MCFragment { | public class SearchFragment extends Fragment { | ||||||
|  |  | ||||||
|  |     private SearchViewModel searchViewModel; | ||||||
|  |  | ||||||
|     public View onCreateView(@NonNull LayoutInflater inflater, |     public View onCreateView(@NonNull LayoutInflater inflater, | ||||||
|                              ViewGroup container, Bundle savedInstanceState) { |                              ViewGroup container, Bundle savedInstanceState) { | ||||||
|  |         searchViewModel = | ||||||
|  |                 ViewModelProviders.of(this).get(SearchViewModel.class); | ||||||
|         View root = inflater.inflate(R.layout.fragment_search, container, false); |         View root = inflater.inflate(R.layout.fragment_search, container, false); | ||||||
|         MonsterRepository repository = this.getMonsterRepository(); |         final TextView textView = root.findViewById(R.id.text_search); | ||||||
|         SearchResultsRecyclerViewAdapter adapter = new SearchResultsRecyclerViewAdapter(repository, null); |         searchViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() { | ||||||
|         final RecyclerView recyclerView = root.findViewById(R.id.monster_list); |  | ||||||
|         assert recyclerView != null; |  | ||||||
|         setupRecyclerView(recyclerView, adapter); |  | ||||||
|  |  | ||||||
|         final TextView textView = root.findViewById(R.id.search_query); |  | ||||||
|         textView.addTextChangedListener(new TextWatcher() { |  | ||||||
|             @Override |             @Override | ||||||
|             public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { |             public void onChanged(@Nullable String s) { | ||||||
|             } |                 textView.setText(s); | ||||||
|  |  | ||||||
|             @Override |  | ||||||
|             public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             @Override |  | ||||||
|             public void afterTextChanged(Editable editable) { |  | ||||||
|                 adapter.doSearch(textView.getText().toString()); |  | ||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
|         return root; |         return root; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void setupRecyclerView(@NonNull RecyclerView recyclerView, @NonNull SearchResultsRecyclerViewAdapter adapter) { |  | ||||||
|         recyclerView.setAdapter(adapter); |  | ||||||
|         recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); |  | ||||||
|     } |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,16 +1,16 @@ | |||||||
| package com.majinnaibu.monstercards.ui.home; | package com.majinnaibu.monstercards.ui.search; | ||||||
| 
 | 
 | ||||||
| import androidx.lifecycle.LiveData; | import androidx.lifecycle.LiveData; | ||||||
| import androidx.lifecycle.MutableLiveData; | import androidx.lifecycle.MutableLiveData; | ||||||
| import androidx.lifecycle.ViewModel; | import androidx.lifecycle.ViewModel; | ||||||
| 
 | 
 | ||||||
| public class HomeViewModel extends ViewModel { | public class SearchViewModel extends ViewModel { | ||||||
| 
 | 
 | ||||||
|     private MutableLiveData<String> mText; |     private MutableLiveData<String> mText; | ||||||
| 
 | 
 | ||||||
|     public HomeViewModel() { |     public SearchViewModel() { | ||||||
|         mText = new MutableLiveData<>(); |         mText = new MutableLiveData<>(); | ||||||
|         mText.setValue("This is home fragment"); |         mText.setValue("This is search fragment"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public LiveData<String> getText() { |     public LiveData<String> getText() { | ||||||
| @@ -1,9 +0,0 @@ | |||||||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" |  | ||||||
|     android:width="24dp" |  | ||||||
|     android:height="24dp" |  | ||||||
|     android:viewportWidth="24.0" |  | ||||||
|     android:viewportHeight="24.0"> |  | ||||||
|     <path |  | ||||||
|         android:fillColor="#FF000000" |  | ||||||
|         android:pathData="M10,20v-6h4v6h5v-8h3L12,3 2,12h3v8z" /> |  | ||||||
| </vector> |  | ||||||
| @@ -1,9 +0,0 @@ | |||||||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" |  | ||||||
|     android:width="24dp" |  | ||||||
|     android:height="24dp" |  | ||||||
|     android:viewportWidth="24.0" |  | ||||||
|     android:viewportHeight="24.0"> |  | ||||||
|     <path |  | ||||||
|         android:fillColor="#FF000000" |  | ||||||
|         android:pathData="M12,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.89,2 2,2zM18,16v-5c0,-3.07 -1.64,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68C7.63,5.36 6,7.92 6,11v5l-2,2v1h16v-1l-2,-2z" /> |  | ||||||
| </vector> |  | ||||||
| @@ -3,8 +3,7 @@ | |||||||
|     xmlns:app="http://schemas.android.com/apk/res-auto" |     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||||
|     android:id="@+id/container" |     android:id="@+id/container" | ||||||
|     android:layout_width="match_parent" |     android:layout_width="match_parent" | ||||||
|     android:layout_height="match_parent" |     android:layout_height="match_parent"> | ||||||
|     android:paddingTop="?attr/actionBarSize"> |  | ||||||
|  |  | ||||||
|     <com.google.android.material.bottomnavigation.BottomNavigationView |     <com.google.android.material.bottomnavigation.BottomNavigationView | ||||||
|         android:id="@+id/nav_view" |         android:id="@+id/nav_view" | ||||||
| @@ -20,14 +19,17 @@ | |||||||
|  |  | ||||||
|     <fragment |     <fragment | ||||||
|         android:id="@+id/nav_host_fragment" |         android:id="@+id/nav_host_fragment" | ||||||
|  |  | ||||||
|         android:name="androidx.navigation.fragment.NavHostFragment" |         android:name="androidx.navigation.fragment.NavHostFragment" | ||||||
|         android:layout_width="match_parent" |         android:layout_width="0dp" | ||||||
|         android:layout_height="match_parent" |         android:layout_height="0dp" | ||||||
|         app:defaultNavHost="true" |         app:defaultNavHost="true" | ||||||
|         app:layout_constraintBottom_toTopOf="@id/nav_view" |         app:layout_constraintBottom_toTopOf="@id/nav_view" | ||||||
|  |         app:layout_constraintHorizontal_bias="0.0" | ||||||
|         app:layout_constraintLeft_toLeftOf="parent" |         app:layout_constraintLeft_toLeftOf="parent" | ||||||
|         app:layout_constraintRight_toRightOf="parent" |         app:layout_constraintRight_toRightOf="parent" | ||||||
|         app:layout_constraintTop_toTopOf="parent" |         app:layout_constraintTop_toTopOf="parent" | ||||||
|  |         app:layout_constraintVertical_bias="0.0" | ||||||
|         app:navGraph="@navigation/mobile_navigation" /> |         app:navGraph="@navigation/mobile_navigation" /> | ||||||
|  |  | ||||||
| </androidx.constraintlayout.widget.ConstraintLayout> | </androidx.constraintlayout.widget.ConstraintLayout> | ||||||
| @@ -1,22 +0,0 @@ | |||||||
| <?xml version="1.0" encoding="utf-8"?> |  | ||||||
| <androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent" |  | ||||||
|     android:layout_height="match_parent" |  | ||||||
|     tools:context=".ui.home.HomeFragment"> |  | ||||||
|  |  | ||||||
|     <TextView |  | ||||||
|         android:id="@+id/text_home" |  | ||||||
|         android:layout_width="match_parent" |  | ||||||
|         android:layout_height="wrap_content" |  | ||||||
|         android:layout_marginStart="8dp" |  | ||||||
|         android:layout_marginTop="8dp" |  | ||||||
|         android:layout_marginEnd="8dp" |  | ||||||
|         android:textAlignment="center" |  | ||||||
|         android:textSize="20sp" |  | ||||||
|         app:layout_constraintBottom_toBottomOf="parent" |  | ||||||
|         app:layout_constraintEnd_toEndOf="parent" |  | ||||||
|         app:layout_constraintStart_toStartOf="parent" |  | ||||||
|         app:layout_constraintTop_toTopOf="parent" /> |  | ||||||
| </androidx.constraintlayout.widget.ConstraintLayout> |  | ||||||
| @@ -6,28 +6,17 @@ | |||||||
|     android:layout_height="match_parent" |     android:layout_height="match_parent" | ||||||
|     tools:context=".ui.library.LibraryFragment"> |     tools:context=".ui.library.LibraryFragment"> | ||||||
|  |  | ||||||
|  |     <TextView | ||||||
|     <androidx.recyclerview.widget.RecyclerView |         android:id="@+id/text_library" | ||||||
|         android:id="@+id/monster_list" |  | ||||||
|         android:layout_width="match_parent" |         android:layout_width="match_parent" | ||||||
|         android:layout_height="match_parent" |         android:layout_height="wrap_content" | ||||||
|         app:layoutManager="LinearLayoutManager" |         android:layout_marginStart="8dp" | ||||||
|  |         android:layout_marginTop="8dp" | ||||||
|  |         android:layout_marginEnd="8dp" | ||||||
|  |         android:textAlignment="center" | ||||||
|  |         android:textSize="20sp" | ||||||
|         app:layout_constraintBottom_toBottomOf="parent" |         app:layout_constraintBottom_toBottomOf="parent" | ||||||
|         app:layout_constraintEnd_toEndOf="parent" |         app:layout_constraintEnd_toEndOf="parent" | ||||||
|         app:layout_constraintStart_toStartOf="parent" |         app:layout_constraintStart_toStartOf="parent" | ||||||
|         app:layout_constraintTop_toTopOf="parent" |         app:layout_constraintTop_toTopOf="parent" /> | ||||||
|         tools:context=".MonsterListFragment" | </androidx.constraintlayout.widget.ConstraintLayout> | ||||||
|         tools:listitem="@layout/monster_list_content" /> |  | ||||||
|  |  | ||||||
|     <com.google.android.material.floatingactionbutton.FloatingActionButton |  | ||||||
|         android:id="@+id/fab" |  | ||||||
|         android:layout_width="wrap_content" |  | ||||||
|         android:layout_height="wrap_content" |  | ||||||
|         android:layout_gravity="bottom|end" |  | ||||||
|         android:layout_margin="@dimen/fab_margin" |  | ||||||
|         android:contentDescription="@string/action_add_monster" |  | ||||||
|         app:layout_constraintBottom_toBottomOf="parent" |  | ||||||
|         app:layout_constraintEnd_toEndOf="parent" |  | ||||||
|         app:srcCompat="@android:drawable/ic_input_add" |  | ||||||
|         app:tint="@android:color/white" /> |  | ||||||
| </androidx.constraintlayout.widget.ConstraintLayout> |  | ||||||
| @@ -1,22 +0,0 @@ | |||||||
| <?xml version="1.0" encoding="utf-8"?> |  | ||||||
| <androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent" |  | ||||||
|     android:layout_height="match_parent" |  | ||||||
|     tools:context=".ui.notifications.NotificationsFragment"> |  | ||||||
|  |  | ||||||
|     <TextView |  | ||||||
|         android:id="@+id/text_notifications" |  | ||||||
|         android:layout_width="match_parent" |  | ||||||
|         android:layout_height="wrap_content" |  | ||||||
|         android:layout_marginStart="8dp" |  | ||||||
|         android:layout_marginTop="8dp" |  | ||||||
|         android:layout_marginEnd="8dp" |  | ||||||
|         android:textAlignment="center" |  | ||||||
|         android:textSize="20sp" |  | ||||||
|         app:layout_constraintBottom_toBottomOf="parent" |  | ||||||
|         app:layout_constraintEnd_toEndOf="parent" |  | ||||||
|         app:layout_constraintStart_toStartOf="parent" |  | ||||||
|         app:layout_constraintTop_toTopOf="parent" /> |  | ||||||
| </androidx.constraintlayout.widget.ConstraintLayout> |  | ||||||
| @@ -4,37 +4,20 @@ | |||||||
|     xmlns:tools="http://schemas.android.com/tools" |     xmlns:tools="http://schemas.android.com/tools" | ||||||
|     android:layout_width="match_parent" |     android:layout_width="match_parent" | ||||||
|     android:layout_height="match_parent" |     android:layout_height="match_parent" | ||||||
|     tools:context=".ui.search.SearchFragment" |     tools:context=".ui.search.SearchFragment"> | ||||||
|     tools:targetApi="o"> |  | ||||||
|  |  | ||||||
|     <EditText |     <TextView | ||||||
|         android:id="@+id/search_query" |         android:id="@+id/text_search" | ||||||
|         android:layout_width="0dp" |         android:layout_width="match_parent" | ||||||
|         android:layout_height="wrap_content" |         android:layout_height="wrap_content" | ||||||
|         android:layout_marginStart="8dp" |         android:layout_marginStart="8dp" | ||||||
|         android:layout_marginTop="8dp" |         android:layout_marginTop="8dp" | ||||||
|         android:layout_marginEnd="8dp" |         android:layout_marginEnd="8dp" | ||||||
|         android:ems="10" |         android:textAlignment="center" | ||||||
|         android:hint="@string/label_search_query" |         android:textSize="20sp" | ||||||
|         android:importantForAutofill="no" |         app:layout_constraintBottom_toBottomOf="parent" | ||||||
|         android:inputType="textPersonName" |  | ||||||
|         app:layout_constraintEnd_toEndOf="parent" |         app:layout_constraintEnd_toEndOf="parent" | ||||||
|         app:layout_constraintStart_toStartOf="parent" |         app:layout_constraintStart_toStartOf="parent" | ||||||
|         app:layout_constraintTop_toTopOf="parent" /> |         app:layout_constraintTop_toTopOf="parent" /> | ||||||
|  |  | ||||||
|     <androidx.recyclerview.widget.RecyclerView | </androidx.constraintlayout.widget.ConstraintLayout> | ||||||
|         android:id="@+id/monster_list" |  | ||||||
|         android:layout_width="0dp" |  | ||||||
|         android:layout_height="0dp" |  | ||||||
|         android:layout_marginLeft="16dp" |  | ||||||
|         android:layout_marginRight="16dp" |  | ||||||
|         app:layoutManager="LinearLayoutManager" |  | ||||||
|         app:layout_constraintBottom_toBottomOf="parent" |  | ||||||
|         app:layout_constraintEnd_toEndOf="parent" |  | ||||||
|         app:layout_constraintStart_toStartOf="parent" |  | ||||||
|         app:layout_constraintTop_toBottomOf="@+id/search_query" |  | ||||||
|         tools:context=".SearchResultsFragment" |  | ||||||
|         tools:listitem="@layout/monster_list_content" /> |  | ||||||
|  |  | ||||||
|  |  | ||||||
| </androidx.constraintlayout.widget.ConstraintLayout> |  | ||||||
| @@ -2,9 +2,9 @@ | |||||||
| <menu xmlns:android="http://schemas.android.com/apk/res/android"> | <menu xmlns:android="http://schemas.android.com/apk/res/android"> | ||||||
|  |  | ||||||
|     <item |     <item | ||||||
|         android:id="@+id/navigation_home" |         android:id="@+id/navigation_search" | ||||||
|         android:icon="@drawable/ic_home_black_24dp" |         android:icon="@drawable/ic_search_black_24dp" | ||||||
|         android:title="@string/title_home" /> |         android:title="@string/title_search" /> | ||||||
|  |  | ||||||
|     <item |     <item | ||||||
|         android:id="@+id/navigation_dashboard" |         android:id="@+id/navigation_dashboard" | ||||||
| @@ -12,8 +12,13 @@ | |||||||
|         android:title="@string/title_dashboard" /> |         android:title="@string/title_dashboard" /> | ||||||
|  |  | ||||||
|     <item |     <item | ||||||
|         android:id="@+id/navigation_notifications" |         android:id="@+id/navigation_collections" | ||||||
|         android:icon="@drawable/ic_notifications_black_24dp" |         android:icon="@drawable/ic_collections_black_24dp" | ||||||
|         android:title="@string/title_notifications" /> |         android:title="@string/title_collections" /> | ||||||
|  |  | ||||||
|  |     <item | ||||||
|  |         android:id="@+id/navigation_library" | ||||||
|  |         android:icon="@drawable/ic_library_black_24dp" | ||||||
|  |         android:title="@string/title_library" /> | ||||||
|  |  | ||||||
| </menu> | </menu> | ||||||
| @@ -3,23 +3,52 @@ | |||||||
|     xmlns:app="http://schemas.android.com/apk/res-auto" |     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||||
|     xmlns:tools="http://schemas.android.com/tools" |     xmlns:tools="http://schemas.android.com/tools" | ||||||
|     android:id="@+id/mobile_navigation" |     android:id="@+id/mobile_navigation" | ||||||
|     app:startDestination="@+id/navigation_home"> |     app:startDestination="@+id/navigation_dashboard"> | ||||||
|  |  | ||||||
|     <fragment |     <fragment | ||||||
|         android:id="@+id/navigation_home" |         android:id="@+id/navigation_search" | ||||||
|         android:name="com.majinnaibu.monstercards.ui.home.HomeFragment" |         android:name="com.majinnaibu.monstercards.ui.search.SearchFragment" | ||||||
|         android:label="@string/title_home" |         android:label="@string/title_search" | ||||||
|         tools:layout="@layout/fragment_home" /> |         tools:layout="@layout/fragment_search" > | ||||||
|  |         <action | ||||||
|  |             android:id="@+id/action_navigation_search_to_navigation_monster" | ||||||
|  |             app:destination="@id/navigation_monster" /> | ||||||
|  |     </fragment> | ||||||
|  |  | ||||||
|     <fragment |     <fragment | ||||||
|         android:id="@+id/navigation_dashboard" |         android:id="@+id/navigation_dashboard" | ||||||
|         android:name="com.majinnaibu.monstercards.ui.dashboard.DashboardFragment" |         android:name="com.majinnaibu.monstercards.ui.dashboard.DashboardFragment" | ||||||
|         android:label="@string/title_dashboard" |         android:label="@string/title_dashboard" | ||||||
|         tools:layout="@layout/fragment_dashboard" /> |         tools:layout="@layout/fragment_dashboard" > | ||||||
|  |         <action | ||||||
|  |             android:id="@+id/action_navigation_dashboard_to_navigation_monster" | ||||||
|  |             app:destination="@id/navigation_monster" /> | ||||||
|  |     </fragment> | ||||||
|  |  | ||||||
|     <fragment |     <fragment | ||||||
|         android:id="@+id/navigation_notifications" |         android:id="@+id/navigation_collections" | ||||||
|         android:name="com.majinnaibu.monstercards.ui.notifications.NotificationsFragment" |         android:name="com.majinnaibu.monstercards.ui.collections.CollectionsFragment" | ||||||
|         android:label="@string/title_notifications" |         android:label="@string/title_collections" | ||||||
|         tools:layout="@layout/fragment_notifications" /> |         tools:layout="@layout/fragment_collections" > | ||||||
| </navigation> |         <action | ||||||
|  |             android:id="@+id/action_navigation_collections_to_navigation_monster" | ||||||
|  |             app:destination="@id/navigation_monster" /> | ||||||
|  |     </fragment> | ||||||
|  |  | ||||||
|  |     <fragment | ||||||
|  |         android:id="@+id/navigation_library" | ||||||
|  |         android:name="com.majinnaibu.monstercards.ui.library.LibraryFragment" | ||||||
|  |         android:label="@string/title_library" | ||||||
|  |         tools:layout="@layout/fragment_library" > | ||||||
|  |         <action | ||||||
|  |             android:id="@+id/action_navigation_library_to_navigation_monster" | ||||||
|  |             app:destination="@id/navigation_monster" /> | ||||||
|  |     </fragment> | ||||||
|  |  | ||||||
|  |     <fragment | ||||||
|  |         android:id="@+id/navigation_monster" | ||||||
|  |         android:name="com.majinnaibu.monstercards.ui.monster.MonsterFragment" | ||||||
|  |         android:label="Monster" | ||||||
|  |         tools:layout="@layout/fragment_monster" /> | ||||||
|  |  | ||||||
|  | </navigation> | ||||||
| @@ -1,6 +1,7 @@ | |||||||
| <resources> | <resources> | ||||||
|     <string name="app_name">MonsterCards</string> |     <string name="app_name">MonsterCards</string> | ||||||
|     <string name="title_home">Home</string> |  | ||||||
|     <string name="title_dashboard">Dashboard</string> |     <string name="title_dashboard">Dashboard</string> | ||||||
|     <string name="title_notifications">Notifications</string> |     <string name="title_search">Search</string> | ||||||
| </resources> |     <string name="title_collections">Collections</string> | ||||||
|  |     <string name="title_library">Library</string> | ||||||
|  | </resources> | ||||||
		Reference in New Issue
	
	Block a user
	 Tom Hicks
						Tom Hicks