Skip to content

Commit

Permalink
Arreglado login con nuevo usuario
Browse files Browse the repository at this point in the history
Close #53
  • Loading branch information
martinlaizg committed Jun 17, 2019
1 parent b0f2897 commit e485a4b
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,11 @@ protected void onCreate(Bundle savedInstanceState) {

public void setDrawerHeader(String username, String name, String image) {
View headerView = navigationView.getHeaderView(0);
if(username == null || name == null) {
((TextView) headerView.findViewById(R.id.drawer_header_name))
.setText(getString(R.string.your_account));
((TextView) headerView.findViewById(R.id.drawer_header_username))
.setText(getString(R.string.configure));
return;
if(name == null) {
name = getString(R.string.your_account);
}
if(username == null) {
username = getString(R.string.configure);
}
((TextView) headerView.findViewById(R.id.drawer_header_name)).setText(name);
((TextView) headerView.findViewById(R.id.drawer_header_username)).setText(username);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.martinlaizg.geofind.views.fragment.list;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
Expand All @@ -12,14 +13,18 @@
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProviders;
import androidx.navigation.Navigation;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;

import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.martinlaizg.geofind.R;
import com.martinlaizg.geofind.config.Preferences;
import com.martinlaizg.geofind.data.access.api.error.ErrorType;
import com.martinlaizg.geofind.data.access.api.service.exceptions.APIException;
import com.martinlaizg.geofind.data.access.database.entities.User;
import com.martinlaizg.geofind.data.enums.UserType;
import com.martinlaizg.geofind.views.adapter.TourListAdapter;
import com.martinlaizg.geofind.views.viewmodel.TourListViewModel;

Expand Down Expand Up @@ -61,8 +66,16 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
viewModel = ViewModelProviders.of(this).get(TourListViewModel.class);
swipe_refresh.setRefreshing(true);
refreshTours();
create_tour_button
.setOnClickListener(Navigation.createNavigateOnClickListener(R.id.toCreator));
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(requireContext());
User u = Preferences.getLoggedUser(sp);
if(u.getUser_type() != null && u.getUser_type() != UserType.USER) {
create_tour_button
.setOnClickListener(Navigation.createNavigateOnClickListener(R.id.toCreator));
} else {
create_tour_button.setOnClickListener(v -> Toast
.makeText(requireContext(), getString(R.string.no_permissions),
Toast.LENGTH_SHORT).show());
}
swipe_refresh.setOnRefreshListener(this::refreshTours);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ private void login(Login login) {
password_input.setError(getString(R.string.wrong_password));
break;
case SECURE:
Toast.makeText(requireContext(), getString(R.string.wrong_login),
Toast.LENGTH_SHORT).show();
break;
default:
Toast.makeText(requireContext(), getString(R.string.other_error),
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-en/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,5 @@
<string name="wrong_answer">Wrong answer</string>
<string name="ok">Ok</string>
<string name="at_least_one_place">At least one place</string>
<string name="no_permissions">No has permission</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,5 @@
<string name="ok">Vale</string>
<string name="wrong_answer">Respuesta incorrecta</string>
<string name="wrong_tour">Tour incorrecto</string>
<string name="no_permissions">No tienes permisos</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,5 @@
<string name="wrong_answer">Wrong answer</string>
<string name="ok">Ok</string>
<string name="at_least_one_place">At least one place</string>
<string name="no_permissions">No has permission</string>
</resources>

0 comments on commit e485a4b

Please sign in to comment.