导航菜单

页面标题

页面副标题

BestFriend v2.0.20 - AddMedicineActivity.java 源代码

正在查看: BestFriend v2.0.20 应用的 AddMedicineActivity.java JAVA 源代码文件

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


package com.projectx.addmedicine;

import android.os.Bundle;
import android.os.PersistableBundle;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import com.projectx.R;
import com.projectx.utils.ActivityUtils;

public class AddMedicineActivity extends AppCompatActivity {
    public static final String EXTRA_TASK_ID = "task_extra_id";
    public static final String EXTRA_TASK_NAME = "task_extra_name";
    public static final int REQUEST_ADD_TASK = 1;
    public static final String SHOULD_LOAD_DATA_FROM_REPO_KEY = "SHOULD_LOAD_DATA_FROM_REPO_KEY";
    private ActionBar mActionBar;
    private AddMedicinePresenter mAddMedicinePresenter;

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_add_medicine);
        setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
        ActionBar supportActionBar = getSupportActionBar();
        this.mActionBar = supportActionBar;
        supportActionBar.setDisplayHomeAsUpEnabled(true);
        this.mActionBar.setDisplayShowHomeEnabled(true);
        AddMedicineFragment addMedicineFragment = (AddMedicineFragment) getSupportFragmentManager().findFragmentById(R.id.contentFrame);
        int intExtra = getIntent().getIntExtra(AddMedicineFragment.ARGUMENT_EDIT_MEDICINE_ID, 0);
        setToolbarTitle(getIntent().getStringExtra(AddMedicineFragment.ARGUMENT_EDIT_MEDICINE_NAME));
        if (addMedicineFragment == null) {
            AddMedicineFragment newInstance = AddMedicineFragment.newInstance();
            if (getIntent().hasExtra(AddMedicineFragment.ARGUMENT_EDIT_MEDICINE_ID)) {
                Bundle bundle2 = new Bundle();
                bundle2.putInt(AddMedicineFragment.ARGUMENT_EDIT_MEDICINE_ID, intExtra);
                newInstance.setArguments(bundle2);
            }
            ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), newInstance, R.id.contentFrame);
        }
        if (bundle != null) {
            bundle.getBoolean(SHOULD_LOAD_DATA_FROM_REPO_KEY);
        }
    }

    public void setToolbarTitle(String str) {
        if (str == null) {
            this.mActionBar.setTitle(getString(R.string.new_medicine));
        } else {
            this.mActionBar.setTitle(str);
        }
    }

    public void onSaveInstanceState(Bundle bundle, PersistableBundle persistableBundle) {
        bundle.putBoolean(SHOULD_LOAD_DATA_FROM_REPO_KEY, this.mAddMedicinePresenter.isDataMissing());
        super.onSaveInstanceState(bundle, persistableBundle);
    }

    public boolean onSupportNavigateUp() {
        onBackPressed();
        return true;
    }
}