Login Activity Implementation Code
Login Activity Implementation Code
5.1 Log In :
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link].R;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_login);
userMail = findViewById([Link].login_mail);
userPassword = findViewById([Link].login_password);
btnLogin = findViewById([Link].login_btn);
loginProgress = findViewById([Link].login_progress);
mAuth = [Link]();
HomeActivity = new Intent(this, [Link]);
login_photo = findViewById([Link].login_photo);
login_photo.setOnClickListener(new [Link]() {
@Override
public void onClick(View v) {
}
});
[Link]([Link]);
[Link](new [Link]() {
@Override
public void onClick(View v) {
[Link]([Link]);
[Link]([Link]);
if ([Link]() || [Link]()) {
}
else
{
signIn(mail,password);
}
}
});
[Link](mail,password).addOnCompleteListener(new
OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if ([Link]()) {
[Link]([Link]);
[Link]([Link]);
updateUI();
} else{
showMessage([Link]().getMessage());
[Link]([Link]);
[Link]([Link]);
}
});
startActivity(HomeActivity);
finish();
}
[Link](getApplicationContext(),text,Toast.LENGTH_LONG).show();
@Override
protected void onStart() {
[Link]();
FirebaseUser user = [Link]();
if(user !=null) {
updateUI();
}
}
}
-------------------- ------------------------------------------- ---------------------------------------------------
Activity_login.xml
<ImageView
android:id="@+id/login_photo"
android:layout_width="265dp"
android:layout_height="100dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/userphoto" />
<[Link]
android:id="@+id/guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.5" />
<EditText
android:hint="Email"
android:background="@drawable/reg_edittext_style"
android:id="@+id/login_mail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="4dp"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintBottom_toTopOf="@+id/guideline2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/login_photo" />
<EditText
android:hint="password"
android:background="@drawable/reg_edittext_style"
android:id="@+id/login_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="136dp"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintBottom_toTopOf="@+id/login_btn"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/login_mail" />
<Button
android:textColor="#fff"
android:id="@+id/login_btn"
android:layout_width="145dp"
android:layout_height="50dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/reg_btn_style"
android:text="LogIn"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/login_password" />
<ProgressBar
android:id="@+id/login_progress"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@+id/login_btn"
app:layout_constraintEnd_toEndOf="@+id/login_btn"
app:layout_constraintStart_toStartOf="@+id/login_btn"
app:layout_constraintTop_toTopOf="@+id/login_btn" />
</[Link]>
--------------------------------------------------------------------------------------
5.2 Register :
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link].R;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
ImageView ImgUserPhoto;
static int PReqCode = 1;
static int REQUESCODE = 1;
Uri pickedImgUri ;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_register);
//inu Views
userEmail = findViewById([Link]);
userPassword = findViewById([Link]);
userPassword2 = findViewById([Link].regPassword2);
userName = findViewById([Link]);
loadingProgress = findViewById([Link]);
regbtn = findViewById([Link]);
[Link]([Link]);
mAuth = [Link]();
[Link](new [Link]() {
@Override
public void onClick(View v) {
[Link]([Link]);
[Link]([Link]);
final String email = [Link]().toString();
final String password = [Link]().toString();
final String password2 = [Link]().toString();
final String name = [Link]().toString();
}
else {
CreateUserAccount(email,name,password);
}
}
});
ImgUserPhoto = findViewById([Link]) ;
[Link](new [Link]() {
@Override
public void onClick(View view) {
if([Link].SDK_INT>=22){
checkAndRequestForPermission();
}
else{
openGallery();
}
}
});
}
[Link](email,password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if([Link]()) {
showMessage("Account Created");
updateUserInfo(name, pickedImgUri, [Link]());
}
else {
showMessage("Account Creation Failed" +
[Link]().getMessage());
[Link]([Link]);
[Link]([Link]);
}
}
});
[Link]().addOnSuccessListener(new
OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
[Link](profileUpdate)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if([Link]()) {
showMessage("Register Complete");
updateUI();
}
}
});
}
});
}
});
[Link](getApplicationContext(),message,Toast.LENGTH_LONG).show();
}
else{
[Link]([Link],
new
String[]{[Link].READ_EXTERNAL_STORAGE},
PReqCode);
}
}
else
openGallery();
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
[Link](requestCode, resultCode, data);
if (resultCode == RESULT_OK && requestCode == REQUESCODE && data !=null ) {
}
}
--------------------------------------------------------------------------------------------------------------------
Activity_Register.xml
<ImageView
android:id="@+id/regUserPhoto"
android:layout_width="265dp"
android:layout_height="100dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:src="@drawable/userphoto"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<[Link]
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.47" />
<EditText
android:background="@drawable/reg_edittext_style"
android:hint="Enter Name"
android:id="@+id/regName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="28dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintBottom_toTopOf="@+id/regMail"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/regUserPhoto"
/>
<EditText
android:background="@drawable/reg_edittext_style"
android:hint="Enter Email"
android:id="@+id/regMail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintBottom_toTopOf="@+id/regPassword"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/regName" />
<EditText
android:id="@+id/regPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/reg_edittext_style"
android:ems="10"
android:hint="Enter Password"
android:inputType="textPassword"
app:layout_constraintBottom_toTopOf="@+id/regPassword2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/regMail" />
<EditText
android:id="@+id/regPassword2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="148dp"
android:background="@drawable/reg_edittext_style"
android:ems="10"
android:hint="Confirm Password"
android:inputType="textPassword"
app:layout_constraintBottom_toTopOf="@+id/regBtn"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/regPassword" />
<Button
android:id="@+id/regBtn"
android:layout_width="132dp"
android:layout_height="46dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="50dp"
android:background="@drawable/reg_btn_style"
android:text="SignUp"
android:textColor="#ffffff"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/regPassword2" />
<ProgressBar
android:id="@+id/regProgressBar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@+id/regBtn"
app:layout_constraintEnd_toEndOf="@+id/regBtn"
app:layout_constraintStart_toStartOf="@+id/regBtn"
app:layout_constraintTop_toTopOf="@+id/regBtn" />
</[Link]>
---------------------------------------------------------------------------------------------------------------------
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link].R;
import [Link];
import [Link];
FirebaseAuth mAuth;
FirebaseUser currentUser;
Dialog popAddPost ;
ImageView popUserImage,popupPostImage,popupAddBtn;
TextView popupTitle,popupDescription;
ProgressBar popupClickProgress;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_home2);
Toolbar toolbar = findViewById([Link]);
setSupportActionBar(toolbar);
mAuth = [Link]();
currentUser = [Link]();
//popup
inipopup();
updateNavHeader();
}
[Link]([Link].popup_add_post);
[Link]().setBackgroundDrawable(new
ColorDrawable([Link]));
[Link]().setLayout([Link].MATCH_PARENT,[Link]
utParams.WRAP_CONTENT);
[Link]().getAttributes().gravity = [Link];
//popup widgets
popupPostImage = [Link]([Link].popup_user_image);
popupTitle = [Link]([Link].popup_title);
popupDescription = [Link]([Link].popup_description);
popupAddBtn = [Link]([Link].popup_app);
popupClickProgress = [Link]([Link].popup_progressBar);
}
});
@Override
public void onBackPressed() {
DrawerLayout drawer = findViewById([Link].drawer_layout);
if ([Link]([Link])) {
[Link]([Link]);
} else {
[Link]();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate([Link], menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in [Link].
int id = [Link]();
//noinspection SimplifiableIfStatement
if (id == [Link].action_settings) {
return true;
}
return [Link](item);
}
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = [Link]();
if (id == [Link].nav_home) {
getSupportActionBar().setTitle("Post And Comment");
getSupportFragmentManager().beginTransaction().replace([Link],new
HomeFragment()).commit();
getSupportFragmentManager().beginTransaction().replace([Link],new
ProfileFragment()).commit();
getSupportFragmentManager().beginTransaction().replace([Link],new
SettingsFragment()).commit();
[Link]().signOut();
Intent loginActivity = new Intent(getApplicationContext(),[Link]);
startActivity(loginActivity);
finish();
}
[Link]([Link]());
[Link]([Link]());
[Link](this).load([Link]()).into(navUserPhoto);
}
activity_home.xml
</[Link]>
---------------------------------------------------------------------------------------------------------------------
activity_home2.xml
<include
layout="@layout/app_bar_home"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<[Link]
android:background="#fff"
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_home"
app:menu="@menu/activity_home2_drawer" />
</[Link]>
---------------------------------------------------------------------------------------------------------------------
app_bar_home.xml
<[Link]
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/[Link]">
<[Link]
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/[Link]" />
</[Link]>
<[Link]
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:src="@drawable/ic_edit_black_24dp" />
</[Link]>
--------------------------------------------------------------------------------------------------------------------
content_home.xml
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"></FrameLayout>
</[Link]>
--------------------------------------------------------------------------------------------------------------------
nav_header_home.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="[Link]
xmlns:app="[Link]
android:layout_width="match_parent"
android:layout_height="@dimen/nav_header_height"
android:gravity="bottom"
android:orientation="vertical"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:theme="@style/[Link]"
android:background="#ffffff">
<ImageView
android:scaleType="centerCrop"
android:id="@+id/nav_user_photo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/nav_header_desc"
android:paddingTop="@dimen/nav_header_vertical_spacing"
app:srcCompat="@mipmap/ic_launcher_round" />
<TextView
android:id="@+id/nav_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/nav_header_vertical_spacing"
android:textColor="#000000"
android:text="@string/nav_header_title"
android:textAppearance="@style/[Link].Body1" />
<TextView
android:id="@+id/nav_user_mail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/nav_header_subtitle"
android:textColor="#000000"/>
</LinearLayout>
--------------------------------------------------------------------------------------------------------------------
popup_add_post.xml
<?xml version="1.0" encoding="utf-8"?>
<[Link]
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout_editor_absoluteY="81dp">
<ImageView
android:background="#ffffff"
android:id="@+id/popup_user_image"
android:layout_width="48dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/popup_description"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/popup_title"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@tools:sample/avatars" />
<EditText
android:id="@+id/popup_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@drawable/popup_edittext_style"
android:ems="10"
android:hint="Title"
android:inputType="textPersonName"
app:layout_constraintEnd_toStartOf="@+id/popup_user_image"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/popup_description"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:background="@drawable/popup_edittext_style"
android:ems="10"
android:hint="Description"
android:inputType="textPersonName"
app:layout_constraintEnd_toEndOf="@+id/popup_user_image"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/popup_title" />
<ImageView
android:id="@+id/popup_app"
android:layout_width="160dp"
android:layout_height="44dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/circle_bg"
android:padding="12dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/popup_description"
app:layout_constraintVertical_bias="0.0"
app:srcCompat="@drawable/ic_edit_black_24dp" />
<ProgressBar
android:padding="4dp"
android:background="@drawable/circle_bg"
android:visibility="invisible"
android:id="@+id/popup_progressBar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
app:layout_constraintBottom_toBottomOf="@+id/popup_app"
app:layout_constraintEnd_toEndOf="@+id/popup_app"
app:layout_constraintStart_toStartOf="@+id/popup_app"
app:layout_constraintTop_toTopOf="@+id/popup_app" />
</[Link]>
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link].R;
/**
* A simple {@link Fragment} subclass.
* Activities that contain this fragment must implement the
* {@link [Link]} interface
* to handle interaction events.
* Use the {@link HomeFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class HomeFragment extends Fragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
public HomeFragment() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment HomeFragment.
*/
// TODO: Rename and change types and number of parameters
public static HomeFragment newInstance(String param1, String param2) {
HomeFragment fragment = new HomeFragment();
Bundle args = new Bundle();
[Link](ARG_PARAM1, param1);
[Link](ARG_PARAM2, param2);
[Link](args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return [Link]([Link].fragment_home, container, false);
}
// TODO: Rename method, update argument and hook method into UI event
public void onButtonPressed(Uri uri) {
if (mListener != null) {
[Link](uri);
}
}
@Override
public void onAttach(Context context) {
[Link](context);
}
@Override
public void onDetach() {
[Link]();
mListener = null;
}
/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
* <p>
* See the Android Training lesson <a href=
* "[Link]
* >Communicating with Other Fragments</a> for more information.
*/
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
void onFragmentInteraction(Uri uri);
}
}
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link].R;
/**
* A simple {@link Fragment} subclass.
* Activities that contain this fragment must implement the
* {@link [Link]} interface
* to handle interaction events.
* Use the {@link ProfileFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class ProfileFragment extends Fragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
public ProfileFragment() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment ProfileFragment.
*/
// TODO: Rename and change types and number of parameters
public static ProfileFragment newInstance(String param1, String param2) {
ProfileFragment fragment = new ProfileFragment();
Bundle args = new Bundle();
[Link](ARG_PARAM1, param1);
[Link](ARG_PARAM2, param2);
[Link](args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return [Link]([Link].fragment_profile, container, false);
}
// TODO: Rename method, update argument and hook method into UI event
public void onButtonPressed(Uri uri) {
if (mListener != null) {
[Link](uri);
}
}
@Override
public void onAttach(Context context) {
[Link](context);
}
@Override
public void onDetach() {
[Link]();
mListener = null;
}
/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
* <p>
* See the Android Training lesson <a href=
* "[Link]
* >Communicating with Other Fragments</a> for more information.
*/
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
void onFragmentInteraction(Uri uri);
}
}
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link].R;
/**
* A simple {@link Fragment} subclass.
* Activities that contain this fragment must implement the
* {@link [Link]} interface
* to handle interaction events.
* Use the {@link SettingsFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class SettingsFragment extends Fragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
public SettingsFragment() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment SettingsFragment.
*/
// TODO: Rename and change types and number of parameters
public static SettingsFragment newInstance(String param1, String param2) {
SettingsFragment fragment = new SettingsFragment();
Bundle args = new Bundle();
[Link](ARG_PARAM1, param1);
[Link](ARG_PARAM2, param2);
[Link](args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return [Link]([Link].fragment_settings, container, false);
}
// TODO: Rename method, update argument and hook method into UI event
public void onButtonPressed(Uri uri) {
if (mListener != null) {
[Link](uri);
}
}
@Override
public void onAttach(Context context) {
[Link](context);
}
@Override
public void onDetach() {
[Link]();
mListener = null;
}
/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
* <p>
* See the Android Training lesson <a href=
* "[Link]
* >Communicating with Other Fragments</a> for more information.
*/
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
void onFragmentInteraction(Uri uri);
}
}
Fragment_Home.xml
</FrameLayout>
Fragment_Profile.xml
</FrameLayout>
Fragment_Settings.xml
</FrameLayout>
---------------------------------------------------------------------------------------------------------------------
C:\Users\KEERTHIPATIVINAY\AndroidStudioProjects\BlogApp\app\src\main\res\values\color
[Link]
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#008577</color>
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B60</color>
</resources>
C:\Users\KEERTHIPATIVINAY\AndroidStudioProjects\BlogApp\app\src\main\res\values\dime
[Link]
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="nav_header_vertical_spacing">8dp</dimen>
<dimen name="nav_header_height">176dp</dimen>
<dimen name="fab_margin">16dp</dimen>
</resources>
C:\Users\KEERTHIPATIVINAY\AndroidStudioProjects\BlogApp\app\src\main\res\values\draw
[Link]
<resources xmlns:android="[Link]
<item name="ic_menu_camera"
type="drawable">@android:drawable/ic_menu_camera</item>
<item name="ic_menu_gallery"
type="drawable">@android:drawable/ic_menu_gallery</item>
<item name="ic_menu_slideshow"
type="drawable">@android:drawable/ic_menu_slideshow</item>
<item name="ic_menu_manage"
type="drawable">@android:drawable/ic_menu_manage</item>
<item name="ic_menu_share"
type="drawable">@android:drawable/ic_menu_share</item>
<item name="ic_menu_send"
type="drawable">@android:drawable/ic_menu_send</item>
</resources>
C:\Users\KEERTHIPATIVINAY\AndroidStudioProjects\BlogApp\app\src\main\res\values\strin
[Link]
<resources>
<string name="app_name">BlogApp</string>
<string name="title_activity_home">Home</string>
<string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_open1">Open navigation drawer1</string>
<string name="navigation_drawer_close">Close navigation drawer</string>
<string name="navigation_drawer_close2">Close navigation drawer2</string>
<string name="nav_header_title">Android Studio</string>
<string name="nav_header_subtitle">[Link]@[Link]</string>
<string name="nav_header_desc">Navigation header</string>
<string name="action_settings">Settings</string>
<string name="home">Home</string>
<string name="profile">Profile</string>
<string name="settings">Settings</string>
<string name="signout">Sign Out</string>
<string name="menu_share">Share</string>
<string name="menu_send">Send</string>