Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ru.mephi.testapplication;
- import android.content.Intent;
- import android.os.Bundle;
- import android.support.design.widget.FloatingActionButton;
- import android.support.v7.app.AppCompatActivity;
- import android.support.v7.widget.Toolbar;
- import android.util.Log;
- import android.view.View;
- import android.widget.EditText;
- import java.util.Random;
- /**
- * Created by hpc on 2/12/16.
- */
- public abstract class BaseActivity extends AppCompatActivity {
- private Random random = new Random();
- private StringBuilder result = new StringBuilder();
- private Class mIntentActivity;
- private String TAG;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_first);
- Log.i(TAG, "onCreate");
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
- FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
- fab.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Intent intent = new Intent(BaseActivity.this, mIntentActivity);
- startActivity(intent);
- }
- });
- }
- public void setIntentActivity(Class clazz){
- mIntentActivity = clazz;
- }
- public void setTag(String tag){
- this.TAG = tag;
- }
- public void randomizeAndSet(){
- if (result.toString().equals("")) result.append(random.nextInt(20000) + 1);
- ((EditText) findViewById(R.id.myedittext)).setText(result.toString());
- }
- @Override
- protected void onStart() {
- super.onStart();
- Log.i(TAG, "onStart");
- }
- @Override
- protected void onResume(){
- Log.i(TAG, "onResume");
- randomizeAndSet();
- super.onResume();
- }
- @Override
- protected void onPause(){
- super.onPause();
- Log.i(TAG, "onPause");
- }
- @Override
- protected void onStop(){
- super.onStop();
- Log.i(TAG, "onStop");
- }
- @Override
- protected void onDestroy(){
- super.onDestroy();
- Log.i(TAG, "onDestroy");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement