导航菜单

页面标题

页面副标题

St.John's v1.0.9 - DesignMateContentActivity.java 源代码

正在查看: St.John's v1.0.9 应用的 DesignMateContentActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.mcb.stjohnsemschool.activity;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment;
import com.google.android.material.navigation.NavigationView;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.mcb.stjohnsemschool.fragment.DesignMateCoursePacksFragment;
import com.mcb.stjohnsemschool.fragment.DesignMatePaymentsFragment;
import com.mcb.stjohnsemschool.fragment.DesignMateSubscribedCoursePacksFragment;
import com.mcb.stjohnsemschool.utils.RoundedTransformation;
import com.squareup.picasso.Picasso;

public class DesignMateContentActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
    Context context;
    SharedPreferences mSharedPref;
    NavigationView navigationView;
    Typeface tf;

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_designmate_content);
        Toolbar findViewById = findViewById(R.id.toolbar);
        setSupportActionBar(findViewById);
        Context applicationContext = getApplicationContext();
        this.context = applicationContext;
        this.mSharedPref = applicationContext.getSharedPreferences("", 0);
        this.tf = Typeface.createFromAsset(this.context.getAssets(), "Roboto-Regular.ttf");
        DrawerLayout findViewById2 = findViewById(R.id.drawer_layout);
        ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(this, findViewById2, findViewById, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        findViewById2.addDrawerListener(actionBarDrawerToggle);
        actionBarDrawerToggle.syncState();
        NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
        this.navigationView = navigationView;
        navigationView.setNavigationItemSelectedListener(this);
        getHeadLayout();
        if (getIntent().getExtras().getString("To", "All").equalsIgnoreCase("All")) {
            replaceFragment(new DesignMateCoursePacksFragment(), getResources().getString(R.string.nav_course_packs));
        } else {
            replaceFragment(new DesignMateSubscribedCoursePacksFragment(), getResources().getString(R.string.nav_subscribed_course_packs));
        }
    }

    private void getHeadLayout() {
        View inflateHeaderView = this.navigationView.inflateHeaderView(R.layout.nav_designmate_content_navigation);
        ImageView imageView = (ImageView) inflateHeaderView.findViewById(2131362622);
        TextView textView = (TextView) inflateHeaderView.findViewById(2131363809);
        TextView textView2 = (TextView) inflateHeaderView.findViewById(R.id.enrollmentid);
        TextView textView3 = (TextView) inflateHeaderView.findViewById(R.id.classname);
        ((LinearLayout) inflateHeaderView.findViewById(R.id.nav_header_rl)).setBackground(getDrawable(R.drawable.tool_bar_bg));
        String string = this.mSharedPref.getString("ProfilePicPath", "");
        String string2 = this.mSharedPref.getString("Name", "");
        String string3 = this.mSharedPref.getString("Class", "");
        this.mSharedPref.getString("schoolNameURLkey", "");
        String string4 = this.mSharedPref.getString("EnrollmentCode", "");
        if (string.length() > 0) {
            Picasso.get().load(string).error(R.drawable.nopicture).transform(new RoundedTransformation(100, 2)).resize(100, 100).centerCrop().into(imageView);
        }
        textView.setTypeface(this.tf);
        textView2.setTypeface(this.tf);
        textView3.setTypeface(this.tf);
        textView.setText(string2);
        textView2.setText(string4);
        textView3.setText(string3);
    }

    public void onBackPressed() {
        DrawerLayout findViewById = findViewById(R.id.drawer_layout);
        if (findViewById.isDrawerOpen(8388611)) {
            findViewById.closeDrawer(8388611);
            return;
        }
        if (NavigationActivity.mActivityObj == null) {
            startActivity(new Intent(this.context, (Class<?>) NavigationActivity.class));
        }
        super.onBackPressed();
    }

    @Override
    public boolean onNavigationItemSelected(MenuItem menuItem) {
        DesignMateSubscribedCoursePacksFragment designMatePaymentsFragment;
        int itemId = menuItem.getItemId();
        if (itemId == 2131363132) {
            finish();
            return true;
        }
        if (itemId == 2131363135) {
            designMatePaymentsFragment = new DesignMateSubscribedCoursePacksFragment();
        } else if (itemId == 2131363127) {
            designMatePaymentsFragment = new DesignMateCoursePacksFragment();
        } else {
            designMatePaymentsFragment = itemId == 2131363133 ? new DesignMatePaymentsFragment() : null;
        }
        replaceFragment(designMatePaymentsFragment, menuItem.getTitle().toString());
        return true;
    }

    private void replaceFragment(Fragment fragment, String str) {
        if (fragment != null) {
            setTitle(str);
            getSupportFragmentManager().beginTransaction().replace(R.id.design_mate_content_navigation, fragment).commit();
            findViewById(R.id.drawer_layout).closeDrawer(8388611);
        }
    }

    protected void onResume() {
        super.onResume();
        String string = this.mSharedPref.getString("usernamekey", "");
        Bundle bundle = new Bundle();
        bundle.putString("user_name", string);
        FirebaseAnalytics.getInstance(this).logEvent("PAGE_DESIGNMATE_CONTENT", bundle);
    }
}