Java tutorial
/* * Copyright 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.mobizi.passwordmanager; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.FragmentTransaction; import android.support.v7.app.ActionBarActivity; import android.view.View; import com.mobizi.passwordmanager.fragments.BaseAccountFragment; import com.mobizi.passwordmanager.fragments.CreateWebsiteFragment; import com.mobizi.passwordmanager.models.Account; import com.mobizi.passwordmanager.utils.AccountFragmentFactory; import com.mobizi.passwordmanager.utils.AccountType; public class AccountActivity extends ActionBarActivity implements PasswordGeneratorDialog.PasswordDialogListener { private BaseAccountFragment displayFrag; public void onBackPressed() { super.onBackPressed(); overridePendingTransition(R.anim.fade_in, R.anim.fade_out_scale); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.account_activity); Intent i = getIntent(); Account account = (Account) i.getParcelableExtra("ACCOUNT"); AccountType type = account == null ? (AccountType) i.getSerializableExtra("TYPE") : account.getAccountType(); if (savedInstanceState == null) { displayFrag = AccountFragmentFactory.getAccountFragment(type); displayFrag.setAccount(account); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.id.content_frame, displayFrag, type.toString()); ft.commit(); } } @Override public void onDialogPositiveClick(String password) { // TODO Auto-generated method stub displayFrag.setPasswordText(password); } @Override public void onDialogNegativeClick() { // TODO Auto-generated method stub } public void onGen(View v) { displayFrag.onGen(v); } public void onCopy(View v) { displayFrag.onCopy(v); } public void onView(View v) { displayFrag.onView(v); } }