Q:

Navigation Drawer hangs while opening/closing on some devices

While working with my android app, I found out that navigation drawer hangs while opening as well as closing. It hangs for 2-3 seconds. On most devices, it's fine (mostly with Stock Android) but on some devices, it hangs (Mostly Samsung).
Home.java (activity in which drawer is implemented):
public class Home extends AppCompatActivity
        implements NavigationView.OnNavigationItemSelectedListener{

    Fragment fragment;

    public void MsgBox(String title, String msg,int id){
        new LovelyInfoDialog(this)
                .setTopColorRes(R.color.primary)
                .setIcon(R.drawable.ic_info_white_24dp)
                //This will add Don't show again checkbox to the dialog. You can pass any ID as argument
                .setNotShowAgainOptionEnabled(id)
                .setTitle(title)
                .setMessage(msg)
                .show();
    }

    public boolean showAds() {
        SharedPreferences getPrefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
        boolean showAd = getPrefs.getBoolean("showAd", true);
        return showAd;
    }

    public static boolean hasPermissions(Context context, String... permissions) {
        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && context != null && permissions != null) {
            for (String permission : permissions) {
                if (ActivityCompat.checkSelfPermission(context, permission) != PackageManager.PERMISSION_GRANTED) {
                    return false;
                }
            }
        }
        return true;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        hasPermissions(this,Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.GET_ACCOUNTS);
        int PERMISSION_ALL = 1;
        String[] PERMISSIONS = {Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.GET_ACCOUNTS};
        if(!hasPermissions(this, PERMISSIONS)){
            ActivityCompat.requestPermissions(this, PERMISSIONS, PERMISSION_ALL);
        }
        AppRate.with(this)
                .setInstallDays(5) // default 10, 0 means install day.
                .setLaunchTimes(10) // default 10
                .setRemindInterval(2) // default 1
                .setShowLaterButton(true) // default true
                .setDebug(false) // default false
                .monitor();

        AppRate.showRateDialogIfMeetsConditions(this);

        final NavigationView navigationView = (NavigationView) findViewById(nav_view);
        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                navigationView.getMenu().getItem(1).setChecked(true);
                onNavigationItemSelected(navigationView.getMenu().getItem(1));
            }
        });

        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.addDrawerListener(toggle);
        toggle.syncState();
        navigationView.setNavigationItemSelectedListener(this);
        fragment=new QuestionPap();
        if (fragment != null) {
            FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
            ft.replace(R.id.content_frame, fragment, "Home");
            ft.commit();
        }
    }

    boolean doubleBackToExitPressedOnce = false;
    boolean drawe=false;
    void Back(){
        if (doubleBackToExitPressedOnce) {
            super.onBackPressed();
            return;
        }

        this.doubleBackToExitPressedOnce = true;
        this.drawe=true;
        Toast.makeText(this, "Please click BACK again to exit", Toast.LENGTH_SHORT).show();

        new Handler().postDelayed(new Runnable() {

            @Override
            public void run() {
                doubleBackToExitPressedOnce=false;
                drawe=true;
            }
        }, 2000);
    }
    @Override
    public void onBackPressed() {
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        if (!drawe) {
            if (drawer.isDrawerOpen(GravityCompat.START)) {
                drawer.closeDrawer(GravityCompat.START);
            } else {
                if (fragment == getSupportFragmentManager().findFragmentByTag("Home")) {
                    super.onBackPressed();
                } else {
                    drawer.openDrawer(GravityCompat.START);
                    Back();
                }
            }
        }else{
            super.onBackPressed();
        }
    }

    @Override
    protected void onDestroy(){
        super.onDestroy();
        Intent i = new Intent(this,DownloadService.class);
        stopService(i);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
   if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

    @SuppressWarnings("StatementWithEmptyBody")
    @Override
    public boolean onNavigationItemSelected(MenuItem item) {
        try {
            int id = item.getItemId();
          //  fragment = null;
            String TAG=null;
            AppBarLayout appbar = (AppBarLayout)findViewById(R.id.appbar);
            FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);

            if (id == R.id.home && fragment!=getSupportFragmentManager().findFragmentByTag("Home")) {
                TAG="Home";
                fragment = new QuestionPap();
                fab.setVisibility(View.VISIBLE);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ) {
                    appbar.setTranslationZ(0);
                }
            } else if (id == R.id.offline && fragment!=getSupportFragmentManager().findFragmentByTag("Offline")) {
                TAG="Offline";
                MsgBox("Save Files Offline","Tap and hold any file to delete it.",2);
                fragment = new offline();
                fab.setVisibility(View.GONE);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ) {
                    appbar.setTranslationZ(6*2);
                }
            } else if (id == R.id.syll && fragment!=getSupportFragmentManager().findFragmentByTag("Syllabus")) {
                TAG="Syllabus";
                fragment = new Syllabus();
                fab.setVisibility(View.GONE);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ) {
                    appbar.setTranslationZ(0);
                }
            } else if (id == R.id.Tools && fragment!=getSupportFragmentManager().findFragmentByTag("Tools")) {
                TAG="Tools";
                fragment = new Tools();
                fab.setVisibility(View.GONE);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ) {
                    appbar.setTranslationZ(6*2);
                }
            } else if (id == R.id.contribute && fragment!=getSupportFragmentManager().findFragmentByTag("Contribute")) {
                TAG="Contribute";
                fragment = new contribute();
                fab.setVisibility(View.GONE);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ) {
                    appbar.setTranslationZ(6*2);
                }
            } else if (id == R.id.about && fragment!=getSupportFragmentManager().findFragmentByTag("About")) {
                TAG="About";
                fragment = new about();
                fab.setVisibility(View.GONE);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ) {
                    appbar.setTranslationZ(6*2);
                }
            } else if (id==R.id.notices && fragment!=getSupportFragmentManager().findFragmentByTag("Notices")) {
                TAG="Notices";
                fragment = new notices();
                fab.setVisibility(View.GONE);
                MsgBox("Get Latest News", "Don't miss out on any department news.",3);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ) {
                    appbar.setTranslationZ(6*2);
                }
            } else if (id==R.id.donate && fragment!=getSupportFragmentManager().findFragmentByTag("Donate")) {
                TAG="Donate";
                fragment = new donate();
                fab.setVisibility(View.GONE);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                    appbar.setTranslationZ(6 * 2);
                }
            }  else if (id==R.id.assig && fragment!=getSupportFragmentManager().findFragmentByTag("Assignments")) {
                TAG = "Assignments";
                fragment = new assignments();
                fab.setVisibility(View.GONE);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                    appbar.setTranslationZ(6 * 2);
                }
            }
            getWindow().getDecorView().setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
            if (fragment != null ) {
                FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
                ft.replace(R.id.content_frame, fragment,TAG);
                ft.commit();
            }
            DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
            drawer.closeDrawer(GravityCompat.START);
        }
        catch (Exception ex){

        }
            return true;
    }
}

I don't know what's the reason behind it. Whenever I try to open it, it hangs. Whenever I open a fragment by clicking an option, it hangs (I don't think it has something to do with loading of fragment because drawer hangs while it opens when no fragment loading is done). If any other code is required, I'm ready to show it.

A:

I solved the problem by decreasing the image resolution of Navigation Drawer header image. It was 1600*1200 and I changed the resolution to 400*300. After doing this, the drawer opens smoothly on affected phones.
It wasn't my coding fault but it might be a problem with customized ROMs how they handle the images with high resolution because the drawer was already opening smoothly on Stock Android.

