mirror of
https://github.com/Nezumi-2711/Foodify.git
synced 2026-09-22 13:38:41 +00:00
Change ip api url
This commit is contained in:
@@ -41,7 +41,7 @@ public interface FoodApiToken {
|
|||||||
|
|
||||||
FoodApiToken apiService = new Retrofit.Builder()
|
FoodApiToken apiService = new Retrofit.Builder()
|
||||||
.client(client)
|
.client(client)
|
||||||
.baseUrl("http://10.0.2.2:8080/api/").addConverterFactory(GsonConverterFactory.create(gson))
|
.baseUrl("http://192.168.1.183:8080/api/").addConverterFactory(GsonConverterFactory.create(gson))
|
||||||
.build()
|
.build()
|
||||||
.create(FoodApiToken.class);
|
.create(FoodApiToken.class);
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
// Check if user is signed in (non-null) and update UI accordingly.
|
// Check if user is signed in (non-null) and update UI accordingly.
|
||||||
user = mAuth.getCurrentUser();
|
user = mAuth.getCurrentUser();
|
||||||
if(user != null){
|
if(user != null && Common.CURRENT_USER == null){
|
||||||
user.getIdToken(true)
|
user.getIdToken(true)
|
||||||
.addOnCompleteListener(new OnCompleteListener<GetTokenResult>() {
|
.addOnCompleteListener(new OnCompleteListener<GetTokenResult>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -96,10 +96,12 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
bottomNavigation();
|
bottomNavigation();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initComponent() {
|
private void initComponent() {
|
||||||
bottomNavigationView = findViewById(R.id.bottom_nav);
|
bottomNavigationView = findViewById(R.id.bottom_nav);
|
||||||
viewPager2 = findViewById(R.id.viewPager);
|
viewPager2 = findViewById(R.id.viewPager);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bottomNavigation() {
|
private void bottomNavigation() {
|
||||||
viewPagerAdapter = new ViewPagerAdapter(this);
|
viewPagerAdapter = new ViewPagerAdapter(this);
|
||||||
viewPager2.setAdapter(viewPagerAdapter);
|
viewPager2.setAdapter(viewPagerAdapter);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
|
|
||||||
import com.capstone.foodify.API.FoodApi;
|
import com.capstone.foodify.API.FoodApi;
|
||||||
|
import com.capstone.foodify.API.FoodApiToken;
|
||||||
import com.capstone.foodify.Common;
|
import com.capstone.foodify.Common;
|
||||||
import com.capstone.foodify.Model.User;
|
import com.capstone.foodify.Model.User;
|
||||||
import com.capstone.foodify.R;
|
import com.capstone.foodify.R;
|
||||||
@@ -168,6 +169,23 @@ public class SignInActivity extends AppCompatActivity {
|
|||||||
if(task.isSuccessful()){
|
if(task.isSuccessful()){
|
||||||
Common.TOKEN = task.getResult().getToken();
|
Common.TOKEN = task.getResult().getToken();
|
||||||
|
|
||||||
|
//Get user from database
|
||||||
|
FoodApiToken.apiService.getUserFromEmail(user.getEmail()).enqueue(new Callback<User>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call<User> call, Response<User> response) {
|
||||||
|
User userData = response.body();
|
||||||
|
if(userData != null){
|
||||||
|
Common.CURRENT_USER = userData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call<User> call, Throwable t) {
|
||||||
|
System.out.println("ERROR: " + t);
|
||||||
|
Common.showErrorServerNotification(SignInActivity.this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
//Dismiss progress bar
|
//Dismiss progress bar
|
||||||
progressLayout.setVisibility(View.GONE);
|
progressLayout.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public class HomeFragment extends Fragment {
|
|||||||
menuAdapter = new MenuAdapter(getContext());
|
menuAdapter = new MenuAdapter(getContext());
|
||||||
recyclerView_restaurant = view.findViewById(R.id.recycler_view_restaurant);
|
recyclerView_restaurant = view.findViewById(R.id.recycler_view_restaurant);
|
||||||
shopAdapter = new ShopAdapter(getContext());
|
shopAdapter = new ShopAdapter(getContext());
|
||||||
progressLayout = view.findViewById(R.id.progress_layout);
|
progressLayout = getActivity().findViewById(R.id.progress_layout);
|
||||||
|
|
||||||
|
|
||||||
if(listFood.isEmpty() || recentFood.isEmpty()){
|
if(listFood.isEmpty() || recentFood.isEmpty()){
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
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"
|
||||||
@@ -8,17 +8,57 @@
|
|||||||
tools:context=".Activity.MainActivity"
|
tools:context=".Activity.MainActivity"
|
||||||
>
|
>
|
||||||
|
|
||||||
<androidx.viewpager2.widget.ViewPager2
|
<LinearLayout
|
||||||
android:id="@+id/viewPager"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
android:clickable="false"
|
||||||
|
android:orientation="vertical"
|
||||||
|
>
|
||||||
|
|
||||||
|
<androidx.viewpager2.widget.ViewPager2
|
||||||
|
android:id="@+id/viewPager"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
|
android:id="@+id/bottom_nav"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:menu="@menu/menu_bottom_nav" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1"
|
android:background="#80000000"
|
||||||
/>
|
android:id="@+id/progress_layout"
|
||||||
|
android:clickable="true"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
>
|
||||||
|
|
||||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
<ProgressBar
|
||||||
android:id="@+id/bottom_nav"
|
android:id="@+id/progressBarLoadData"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:menu="@menu/menu_bottom_nav" />
|
android:indeterminateTint="@color/primaryColor"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
/>
|
||||||
|
|
||||||
</LinearLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -123,29 +123,5 @@
|
|||||||
|
|
||||||
</androidx.core.widget.NestedScrollView>
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:background="#80000000"
|
|
||||||
android:id="@+id/progress_layout"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
>
|
|
||||||
|
|
||||||
<ProgressBar
|
|
||||||
android:id="@+id/progressBarLoadData"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:indeterminateTint="@color/primaryColor"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
/>
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
Reference in New Issue
Block a user