com.android.fastlibrary.ui.activity.CoreActivity.java Source code

Java tutorial

Introduction

Here is the source code for com.android.fastlibrary.ui.activity.CoreActivity.java

Source

/*
 * Copyright (C) 2014 loQua.Xee <loquaciouser@gmail.com>
 *
 * 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.android.fastlibrary.ui.activity;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

import com.android.fastlibrary.AppManager;

import butterknife.ButterKnife;

/**
 * Do one thing at a time, and do well!
 *
 * @Prject: FastAndroid
 * @Location: com.androd.fastibrary.ui.activity.BaseActivity
 * @Description: TODO Acitivity?....?
 * @author: loQua.Xee    loquaciouser@gmail.com
 * @date: 2014/8/16 14:00
 * @version: V1.0
 */

public abstract class CoreActivity extends FragmentActivity {
    private static final String TAG = "Fugao-CoreActivity";

    @Override
    protected void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        /**
         * ?activity
         */
        AppManager.getInstance().addActivity(this);
        setRootView();
        ButterKnife.inject(this);
        initialize();
    }

    private void initialize() {
        initWidget();
        new Thread(new Runnable() {
            @Override
            public void run() {
                initAsyncData();
            }
        }).start();
        initData();
        registerBroadcast();
        initListener();
    }

    /**
     * ??
     */
    protected abstract void setRootView();

    /**
     * ?
     */
    protected void initWidget() {
    }

    /**
     * ??,?
     */
    protected void initAsyncData() {
    }

    /**
     * ???
     */
    protected void initData() {
    }

    /**
     * ??
     */
    protected void initListener() {
    }

    /**
     * 
     */
    protected void registerBroadcast() {
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        /**
         * ?,?ativity?
         */
        unRegisterBroadcast();
        AppManager.getInstance().finishActivity(this);
    }

    protected void unRegisterBroadcast() {
    }
}