mirror of
https://github.com/Nezumi-2711/Foodify.git
synced 2026-09-23 04:09:52 +00:00
Initial commit
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package com.capstone.foodify.Fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.capstone.foodify.R;
|
||||
|
||||
public class BasketFragment extends Fragment {
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_basket, container, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.capstone.foodify.Fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.capstone.foodify.R;
|
||||
|
||||
public class FavouriteFragment extends Fragment {
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_favourite, container, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.capstone.foodify.Fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.capstone.foodify.R;
|
||||
|
||||
public class HomeFragment extends Fragment {
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_home, container, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.capstone.foodify.Fragment;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
|
||||
import com.capstone.foodify.R;
|
||||
import com.capstone.foodify.SignInActivity;
|
||||
|
||||
public class ProfileFragment extends Fragment {
|
||||
|
||||
Button btnSignUp;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
View rootView = inflater.inflate(R.layout.fragment_profile, container, false);
|
||||
btnSignUp = (Button) rootView.findViewById(R.id.sign_up_button);
|
||||
btnSignUp.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent i =new Intent(getActivity(), SignInActivity.class);
|
||||
startActivity(i);
|
||||
((Activity) getActivity()).overridePendingTransition(0,0);
|
||||
}
|
||||
});
|
||||
return rootView;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.capstone.foodify.Fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.capstone.foodify.R;
|
||||
|
||||
public class SearchFragment extends Fragment {
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_search, container, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.capstone.foodify;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||
import com.google.android.material.navigation.NavigationBarView;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
ViewPager2 viewPager2;
|
||||
ViewPagerAdapter viewPagerAdapter;
|
||||
BottomNavigationView bottomNavigationView;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
bottomNavigationView = findViewById(R.id.bottom_nav);
|
||||
viewPager2 = findViewById(R.id.viewPager);
|
||||
viewPagerAdapter = new ViewPagerAdapter(this);
|
||||
viewPager2.setAdapter(viewPagerAdapter);
|
||||
bottomNavigationView.setOnItemSelectedListener(new NavigationBarView.OnItemSelectedListener() {
|
||||
@SuppressLint("NonConstantResourceId")
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
switch (id) {
|
||||
case R.id.activity_home:
|
||||
viewPager2.setCurrentItem(0);
|
||||
break;
|
||||
case R.id.activity_search:
|
||||
viewPager2.setCurrentItem(1);
|
||||
break;
|
||||
case R.id.activity_basket:
|
||||
viewPager2.setCurrentItem(2);
|
||||
break;
|
||||
case R.id.activity_favorite:
|
||||
viewPager2.setCurrentItem(3);
|
||||
break;
|
||||
case R.id.activity_profile:
|
||||
viewPager2.setCurrentItem(4);
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
viewPager2.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
switch (position){
|
||||
case 0:
|
||||
bottomNavigationView.getMenu().findItem(R.id.activity_home).setChecked(true);
|
||||
break;
|
||||
case 1:
|
||||
bottomNavigationView.getMenu().findItem(R.id.activity_search).setChecked(true);
|
||||
break;
|
||||
case 2:
|
||||
bottomNavigationView.getMenu().findItem(R.id.activity_basket).setChecked(true);
|
||||
break;
|
||||
case 3:
|
||||
bottomNavigationView.getMenu().findItem(R.id.activity_favorite).setChecked(true);
|
||||
break;
|
||||
case 4:
|
||||
bottomNavigationView.getMenu().findItem(R.id.activity_profile).setChecked(true);
|
||||
break;
|
||||
}
|
||||
super.onPageSelected(position);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
package com.capstone.foodify;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.app.DatePickerDialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.DatePicker;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class SignInActivity extends AppCompatActivity {
|
||||
|
||||
TextInputLayout textInput_email, textInput_password, textInput_phone,
|
||||
textInput_address, textInput_repeatPassword, textInput_firstName, textInput_lastName, textInput_birthDay;
|
||||
final Calendar myCalendar= Calendar.getInstance();
|
||||
EditText editText, edt_birthday;
|
||||
|
||||
Spinner wardSpinner, districtSpinner;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_sign_in);
|
||||
|
||||
setFontUI();
|
||||
|
||||
//Calendar date of birth
|
||||
editText=(EditText) findViewById(R.id.edt_birthDay);
|
||||
DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
|
||||
@Override
|
||||
public void onDateSet(DatePicker view, int year, int month, int day) {
|
||||
myCalendar.set(Calendar.YEAR, year);
|
||||
myCalendar.set(Calendar.MONTH,month);
|
||||
myCalendar.set(Calendar.DAY_OF_MONTH,day);
|
||||
updateLabel();
|
||||
}
|
||||
};
|
||||
editText.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
new DatePickerDialog(SignInActivity.this,date,myCalendar.get(Calendar.YEAR),myCalendar.get(Calendar.MONTH),myCalendar.get(Calendar.DAY_OF_MONTH)).show();
|
||||
}
|
||||
});
|
||||
|
||||
wardSpinner = (Spinner) findViewById(R.id.ward);
|
||||
districtSpinner = (Spinner) findViewById(R.id.district);
|
||||
|
||||
ArrayList<String> ward = new ArrayList<String>();
|
||||
ArrayList<String> district = new ArrayList<String>();
|
||||
|
||||
ward.add("---Phường");
|
||||
ward.add("Hoà Hiệp Bắc");
|
||||
ward.add("Hòa Khánh Bắc");
|
||||
ward.add("Hòa Minh");
|
||||
ward.add("Hòa Hiệp Nam");
|
||||
ward.add("Hòa Khánh Nam");
|
||||
|
||||
district.add("---Quận");
|
||||
district.add("Liên Chiểu");
|
||||
district.add("Ngũ Hành Sơn");
|
||||
|
||||
MySpinnerAdapter adapterWard = new MySpinnerAdapter(getApplicationContext(), android.R.layout.simple_spinner_item, ward);
|
||||
MySpinnerAdapter adapterDistrict = new MySpinnerAdapter(getApplicationContext(), android.R.layout.simple_spinner_item, district);
|
||||
wardSpinner.setAdapter(adapterWard); // this will set list of values to spinner
|
||||
districtSpinner.setAdapter(adapterDistrict); // this will set list of values to spinner
|
||||
|
||||
wardSpinner.setSelection(ward.indexOf("---Phường"));//set selected value in spinner
|
||||
districtSpinner.setSelection(district.indexOf("---Quận"));
|
||||
}
|
||||
|
||||
private static class MySpinnerAdapter extends ArrayAdapter<String> {
|
||||
// Initialise custom font, for example:
|
||||
Typeface font = Typeface.createFromAsset(getContext().getAssets(),
|
||||
"font/bebas.ttf");
|
||||
|
||||
// (In reality I used a manager which caches the Typeface objects)
|
||||
// Typeface font = FontManager.getInstance().getFont(getContext(), BLAMBOT);
|
||||
|
||||
private MySpinnerAdapter(Context context, int resource, List<String> items) {
|
||||
super(context, resource, items);
|
||||
}
|
||||
|
||||
// Affects default (closed) state of the spinner
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
TextView view = (TextView) super.getView(position, convertView, parent);
|
||||
view.setTypeface(font);
|
||||
return view;
|
||||
}
|
||||
|
||||
// Affects opened state of the spinner
|
||||
@Override
|
||||
public View getDropDownView(int position, View convertView, ViewGroup parent) {
|
||||
TextView view = (TextView) super.getDropDownView(position, convertView, parent);
|
||||
view.setTypeface(font);
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateLabel(){
|
||||
String myFormat="MM/dd/yy";
|
||||
SimpleDateFormat dateFormat=new SimpleDateFormat(myFormat, Locale.US);
|
||||
editText.setText(dateFormat.format(myCalendar.getTime()));
|
||||
}
|
||||
|
||||
private void setFontUI() {
|
||||
Typeface bebas= Typeface.createFromAsset(getAssets(), "font/bebas.ttf");
|
||||
|
||||
//Find view ID
|
||||
textInput_email= (TextInputLayout) findViewById(R.id.textInput_email);
|
||||
textInput_password = (TextInputLayout) findViewById(R.id.textInput_password);
|
||||
textInput_phone = (TextInputLayout) findViewById(R.id.textInput_phone);
|
||||
textInput_address = (TextInputLayout) findViewById(R.id.textInput_address);
|
||||
textInput_repeatPassword = (TextInputLayout) findViewById(R.id.textInput_confirmPassword);
|
||||
textInput_firstName = (TextInputLayout) findViewById(R.id.textInput_firstName);
|
||||
textInput_lastName = (TextInputLayout) findViewById(R.id.textInput_lastName);
|
||||
textInput_birthDay = (TextInputLayout) findViewById(R.id.textInput_birthDay);
|
||||
|
||||
edt_birthday = (EditText) findViewById(R.id.edt_birthDay);
|
||||
|
||||
//Set Type face
|
||||
textInput_email.setTypeface(bebas);
|
||||
textInput_password.setTypeface(bebas);
|
||||
textInput_phone.setTypeface(bebas);
|
||||
textInput_address.setTypeface(bebas);
|
||||
textInput_repeatPassword.setTypeface(bebas);
|
||||
textInput_firstName.setTypeface(bebas);
|
||||
textInput_lastName.setTypeface(bebas);
|
||||
textInput_birthDay.setTypeface(bebas);
|
||||
|
||||
edt_birthday.setTypeface(bebas);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.capstone.foodify;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
|
||||
public class SplashScreenActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_splash_screen);
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
startActivity(new Intent(SplashScreenActivity.this, MainActivity.class));
|
||||
finish();
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.capstone.foodify;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
|
||||
import com.capstone.foodify.Fragment.BasketFragment;
|
||||
import com.capstone.foodify.Fragment.FavouriteFragment;
|
||||
import com.capstone.foodify.Fragment.HomeFragment;
|
||||
import com.capstone.foodify.Fragment.ProfileFragment;
|
||||
import com.capstone.foodify.Fragment.SearchFragment;
|
||||
|
||||
public class ViewPagerAdapter extends FragmentStateAdapter {
|
||||
|
||||
public ViewPagerAdapter(@NonNull FragmentActivity fragmentActivity) {
|
||||
super(fragmentActivity);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
switch(position) {
|
||||
case 1: return new SearchFragment();
|
||||
case 2: return new BasketFragment();
|
||||
case 3: return new FavouriteFragment();
|
||||
case 4: return new ProfileFragment();
|
||||
default: return new HomeFragment();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user