Custom Navigation Drawer

STEP 1: Main.java

(Drawer Layout XML)

 

<?xml version="1.0" encoding="utf-8"?>

<androidx.drawerlayout.widget.DrawerLayout 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:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:background="@color/colorPrimary"
android:layout_height="match_parent"
tools:context=".Activity.MainActivity">


<androidx.constraintlayout.widget.ConstraintLayout
android:background="@color/colorPrimary"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/main_toolBar"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:background="@color/colorPrimary"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<ImageView
android:id="@+id/iv_menu"
android:layout_width="26dp"
android:layout_height="26dp"
android:layout_gravity="center"
android:layout_margin="15dp"
android:layout_weight="5"
android:clickable="true"
android:contentDescription="@string/todo"
android:focusable="true"
android:foreground="@drawable/ripple_round"
android:src="@drawable/ic_menu"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/main_title"
app:tint="@color/white"
tools:ignore="UnusedAttribute" />


<TextView
android:id="@+id/main_title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="3"
android:gravity="center"
android:text="@string/app_name"
android:textColor="@color/white"
android:textSize="20sp"
android:textStyle="bold"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp" />

<ImageView
android:id="@+id/main_share"
android:layout_width="26dp"
android:layout_height="26dp"
android:layout_gravity="center"
android:layout_margin="11dp"
android:layout_weight="5"
android:clickable="true"
android:contentDescription="@string/todo"
android:focusable="true"
android:foreground="@drawable/ripple_round"
android:src="@drawable/ic_share"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/main_title"
app:layout_constraintTop_toTopOf="@+id/main_title"
app:tint="@color/white"
tools:ignore="UnusedAttribute" />

</androidx.constraintlayout.widget.ConstraintLayout>

<View
android:id="@+id/view2"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/main_toolBar" />


<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/adArea"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/view2" />


<RelativeLayout
android:id="@+id/adArea"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dp"
android:background="@drawable/border_ads"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">

<com.google.android.gms.ads.AdView
android:id="@+id/banner1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:adSize="BANNER"
app:adUnitId="@string/BANNER_AdMob" />

<LinearLayout
android:id="@+id/fb_banner_container"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="vertical" />

</RelativeLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

<FrameLayout
android:id="@+id/navigationMenu"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/white">

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbarAlwaysDrawHorizontalTrack="true"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbars="none"
tools:ignore="UselessParent">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical">

<LinearLayout
android:id="@+id/ll_header"
android:layout_width="match_parent"
android:layout_height="170dp"
android:gravity="center"
android:orientation="vertical"
tools:ignore="UseCompoundDrawables">

<ImageView
android:background="@drawable/border"
android:padding="6dp"
android:layout_gravity="center"
android:id="@+id/drawer_img"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_margin="16dp"
android:contentDescription="@string/todo"
android:src="@drawable/logo" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/app_name"
android:textColor="@color/colorPrimary"
android:textSize="18sp"
android:textStyle="bold" />

</LinearLayout>

<View
android:id="@+id/mView"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@id/ll_header"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:background="@color/silver" />


<LinearLayout
android:id="@+id/ll_drawer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/mView"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<LinearLayout
android:id="@+id/drawer_home"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:foreground="@drawable/ripple1"
android:orientation="horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp"
tools:ignore="UnusedAttribute">     

<ImageView
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_weight="3"
android:contentDescription="@string/todo"
android:src="@drawable/ic_laptop"
app:tint="@color/colorPrimary" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="@string/home"
android:textColor="@color/colorPrimary" />
</LinearLayout>

<LinearLayout
android:id="@+id/drawer_pp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:foreground="@drawable/ripple1"
android:orientation="horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp"
tools:ignore="UnusedAttribute">

<ImageView
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_weight="3"
android:contentDescription="@string/todo"
android:src="@drawable/ic_lock"
app:tint="@color/colorPrimary" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="@string/privacy_policy"
android:textColor="@color/colorPrimary" />
</LinearLayout>

<LinearLayout
android:id="@+id/drawer_rateApp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:foreground="@drawable/ripple1"
android:orientation="horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp"
tools:ignore="UnusedAttribute">

<ImageView
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_weight="3"
android:contentDescription="@string/todo"
android:src="@drawable/ic_star"
app:tint="@color/colorPrimary" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="@string/rate_app"
android:textColor="@color/colorPrimary" />
</LinearLayout>


<LinearLayout
android:id="@+id/drawer_share"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:foreground="@drawable/ripple1"
android:orientation="horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp"
tools:ignore="UnusedAttribute">

<ImageView
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_weight="3"
android:contentDescription="@string/todo"
android:src="@drawable/ic_pin"
app:tint="@color/colorPrimary" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="@string/share"
android:textColor="@color/colorPrimary" />

</LinearLayout>

<LinearLayout
android:id="@+id/drawer_more_apps"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:foreground="@drawable/ripple1"
android:orientation="horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp"
tools:ignore="UnusedAttribute">

<ImageView
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_weight="3"
android:contentDescription="@string/todo"
android:src="@drawable/ic_more_apps"
app:tint="@color/colorPrimary" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="@string/more_apps"
android:textColor="@color/colorPrimary" />

</LinearLayout>
<LinearLayout
android:id="@+id/drawer_exit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:foreground="@drawable/ripple1"
android:orientation="horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp"
tools:ignore="UnusedAttribute">

<ImageView
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_weight="3"
android:contentDescription="@string/todo"
android:src="@drawable/ic_exit"
app:tint="@color/colorPrimary" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="@string/tv_exit"
android:textColor="@color/colorPrimary" />
</LinearLayout>

</LinearLayout>


<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:background="@color/silver" />


<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<LinearLayout
android:id="@+id/drawer_dev_contact"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:foreground="@drawable/ripple1"
android:orientation="horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp"
tools:ignore="UnusedAttribute">

<ImageView
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_weight="3"
android:contentDescription="@string/todo"
android:src="@drawable/ic_dev_contact"
app:tint="@color/colorPrimary" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="@string/developer_contact"
android:textColor="@color/colorPrimary" />
</LinearLayout>
<LinearLayout
android:id="@+id/drawer_feedback"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:foreground="@drawable/ripple1"
android:orientation="horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp"
tools:ignore="UnusedAttribute">

<ImageView
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_weight="3"
android:contentDescription="@string/todo"
android:src="@drawable/ic_feedback"
app:tint="@color/colorPrimary" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="@string/feedback"
android:textColor="@color/colorPrimary" />

</LinearLayout>
<LinearLayout
android:id="@+id/drawer_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:foreground="@drawable/ripple1"
android:orientation="horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp"
tools:ignore="UnusedAttribute">

<ImageView
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_weight="3"
android:contentDescription="@string/todo"
android:src="@drawable/ic_infoo"
app:tint="@color/colorPrimary" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="@string/info"
android:textColor="@color/colorPrimary" />

</LinearLayout>

</LinearLayout>

<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:background="@color/silver" />


</LinearLayout>

<TextView
android:id="@+id/version_code"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/ll_drawer"
android:layout_alignParentBottom="true"
android:gravity="center"
android:padding="16dp"
android:textColor="@color/silver"
android:textStyle="bold" />

</RelativeLayout>
</ScrollView>
</FrameLayout>

</androidx.drawerlayout.widget.DrawerLayout>



STEP 2: Main Java (Drawer)


package com.developerbrothers.dailynews.Activity;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;

import android.Manifest;
import android.annotation.SuppressLint;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.net.ConnectivityManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.developerbrothers.dailynews.BuildConfig;
import com.developerbrothers.dailynews.Fragment.BottomSheetFragment;
import com.developerbrothers.dailynews.Fragment.FM_Home;
import com.developerbrothers.dailynews.PrivacyPolicyFragment;
import com.developerbrothers.dailynews.R;
import com.facebook.ads.AudienceNetworkAds;
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.InterstitialAd;
import com.google.android.gms.ads.LoadAdError;
import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.initialization.InitializationStatus;
import com.google.android.gms.ads.initialization.OnInitializationCompleteListener;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

private String mPackageName = "com.developerbrothers.dailynews";
private boolean SetFlagHome = true;
public static MainActivity fa;
private DrawerLayout drawerLayout;
private ConstraintLayout main_toolBar;
private ImageView iv_menu, main_share;
private LinearLayout drawer_Home, drawer_pp, drawer_rateApp, drawer_share, drawer_dev_contact, drawer_more_apps, drawer_feedback, drawer_exit, drawer_info;
public static TextView main_title, version_code;

private AdView banner1;
private AdView mAdView;
private LinearLayout fb_banner_container;
private com.facebook.ads.AdView adView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

//Facebook Ads...
AudienceNetworkAds.initialize(this);

if (!isNetworkConnected()) {
Toast.makeText(MainActivity.this, "Check your internet connection!", Toast.LENGTH_SHORT).show();
}

//initialize google ads...
MobileAds.initialize(this, new OnInitializationCompleteListener() {
@Override
public void onInitializationComplete(InitializationStatus initializationStatus) {
}
});


//implement banner...
banner1 = findViewById(R.id.banner1);
mAdView = new AdView(this);
mAdView.setAdSize(AdSize.BANNER);
mAdView.setAdUnitId(getString(R.string.BANNER_AdMob));
AdRequest adRequest = new AdRequest.Builder().build();
banner1.loadAd(adRequest);
googleBanner();

fa = this;

if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.fragment_container, new FM_Home()).commit();
}

drawerLayout = findViewById(R.id.drawerLayout);
main_toolBar = findViewById(R.id.main_toolBar);
iv_menu = findViewById(R.id.iv_menu);
main_share = findViewById(R.id.main_share);
main_title = findViewById(R.id.main_title);
version_code = findViewById(R.id.version_code);

drawer_Home = findViewById(R.id.drawer_home);
drawer_pp = findViewById(R.id.drawer_pp);
drawer_rateApp = findViewById(R.id.drawer_rateApp);
drawer_share = findViewById(R.id.drawer_share);
drawer_dev_contact = findViewById(R.id.drawer_dev_contact);
drawer_more_apps = findViewById(R.id.drawer_more_apps);
drawer_feedback = findViewById(R.id.drawer_feedback);
drawer_exit = findViewById(R.id.drawer_exit);
drawer_info = findViewById(R.id.drawer_info);


drawer_Home.setOnClickListener(this);
drawer_pp.setOnClickListener(this);
drawer_rateApp.setOnClickListener(this);
drawer_share.setOnClickListener(this);
drawer_dev_contact.setOnClickListener(this);
drawer_more_apps.setOnClickListener(this);
drawer_feedback.setOnClickListener(this);
drawer_exit.setOnClickListener(this);
drawer_info.setOnClickListener(this);

version_code.setText("version : " + BuildConfig.VERSION_NAME);


iv_menu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
drawerLayout.openDrawer(GravityCompat.START);
}
});

main_share.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
shareApp();
}
});
}


@SuppressLint("NonConstantResourceId")
@Override
public void onClick(View v) {

Fragment fragment = null;

switch (v.getId()) {

case R.id.drawer_home:
drawerLayout.closeDrawer(GravityCompat.START);
fragment = new FM_Home();
replaceFragment(fragment);
break;

case R.id.drawer_pp:
drawerLayout.closeDrawer(GravityCompat.START);
fragment = new PrivacyPolicyFragment();
replaceFragment(fragment);
break;

case R.id.drawer_rateApp:
drawerLayout.closeDrawer(GravityCompat.START);
setDilogRateUs();
break;

case R.id.drawer_share:
drawerLayout.closeDrawer(GravityCompat.START);
shareApp();
break;

// case R.id.drawer_dev_contact:
// drawerLayout.closeDrawer(GravityCompat.START);
// openDevContact();
// break;

case R.id.drawer_more_apps:
drawerLayout.closeDrawer(GravityCompat.START);
// openMoreApps();
startActivity(new Intent(MainActivity.this, Info.class));
break;

// case R.id.drawer_feedback:
// drawerLayout.closeDrawer(GravityCompat.START);
// openFeedBack();
// break;

case R.id.drawer_exit:
drawerLayout.closeDrawer(GravityCompat.START);
showExitDialog();
break;

// case R.id.drawer_info:
// drawerLayout.closeDrawer(GravityCompat.START);
// startActivity(new Intent(MainActivity.this, Info.class));
// break;


}
}

private void openPrivacyPolicy() {
Uri uri = Uri.parse("https://dailynewsformorning.blogspot.com/2020/12/daily-breaking-news-daily-hunt-latest.html");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}

private void shareApp() {
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "\n*BREAKING NEWS*\n\nClick this link - To Watch and Read Daily News, Live News & Read Many Languages Newspapers.\nDownload Now!\n\nhttp://bit.ly/dailybreakingnewsapp");
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getString(R.string.shareSub));
startActivity(Intent.createChooser(sharingIntent, getString(R.string.shareKey)));
}

private void openMoreApps() {
Uri uri = Uri.parse("https://play.google.com/store/apps/developer?id=Developer+Brother%27s");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}

private void setDilogRateUs() {
try {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(MainActivity.this);
LayoutInflater inflater = MainActivity.this.getLayoutInflater();
View dialogView = inflater.inflate(R.layout.dialog_rate_us, null);
dialogBuilder.setView(dialogView);
dialogBuilder.setCancelable(false);
final AlertDialog dialog = dialogBuilder.create();
dialog.getWindow().getAttributes().windowAnimations = R.style.MyDialogTheme;
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.show();


Button btnLater = (Button) dialog.findViewById(R.id.btnLater);
Button btnRateNow = (Button) dialog.findViewById(R.id.btnRateNow);
btnLater.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

if (SetFlagHome == true) {

dialog.dismiss();
// MainActivity.this.onBackPressed();
} else {
Intent intent = new Intent(MainActivity.this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
}
}
});

btnRateNow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

dialog.dismiss();

Intent rateIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + mPackageName));
startActivity(rateIntent);
}
});


} catch (Exception e) {
e.printStackTrace();
}

}

private void openFeedBack() {
String mailto = "mailto:dailynewsformorning@gmail.com";

Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
emailIntent.setData(Uri.parse(mailto));

try {
startActivity(emailIntent);
} catch (ActivityNotFoundException e) {
Toast.makeText(MainActivity.this, "Please install E-mail Application!", Toast.LENGTH_SHORT).show();
}
}

private void openDevContact() {
String mailto = "mailto:dailynewsformorning@gmail.com";

Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
emailIntent.setData(Uri.parse(mailto));

try {
startActivity(emailIntent);
} catch (ActivityNotFoundException e) {
Toast.makeText(MainActivity.this, "Please install E-mail Application!", Toast.LENGTH_SHORT).show();
}
}

public void onBackPressed() {
if (drawerLayout.isDrawerOpen(GravityCompat.START)) {
drawerLayout.closeDrawer(GravityCompat.START);
} else {
showExitDialog();
}
}

public void replaceFragment(Fragment fragment) {

FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment);
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
}

private void showExitDialog() {
BottomSheetFragment bottomSheetDialog = BottomSheetFragment.newInstance();
bottomSheetDialog.show(getSupportFragmentManager(), "Exit Dialog");
}


private boolean isNetworkConnected() {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
return cm.getActiveNetworkInfo() != null && cm.getActiveNetworkInfo().isConnected();
}

private void googleBanner() {
banner1.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
// Code to be executed when an ad finishes loading.
}

@Override
public void onAdFailedToLoad(LoadAdError adError) {
// Code to be executed when an ad request fails.

//TODO: Facebook Ads here... + ON DESTROYED(); method calling...
loadFacebookBanner();
}

@Override
public void onAdOpened() {
// Code to be executed when an ad opens an overlay that
// covers the screen.

}

@Override
public void onAdClicked() {
// Code to be executed when the user clicks on an ad.

}

@Override
public void onAdLeftApplication() {
// Code to be executed when the user has left the app.
}

@Override
public void onAdClosed() {
// Code to be executed when the user is about to return
// to the app after tapping on an ad.

}
});
}

private void loadFacebookBanner() {
adView = new com.facebook.ads.AdView(MainActivity.this, getResources().getString(R.string.FB_Banner), com.facebook.ads.AdSize.BANNER_HEIGHT_50);
fb_banner_container = (LinearLayout) findViewById(R.id.fb_banner_container);
fb_banner_container.addView(adView);
adView.loadAd();
}
}