Android Open Source - android-mvc-framework Base Util






From Project

Back to project page android-mvc-framework.

License

The source code is released under:

Apache License

If you think the Android project android-mvc-framework listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.android_mvc.framework.common;
//from  www  . j  av a 2  s .  c  om
import com.android_mvc.framework.annotations.SuppressDebugLog;

import android.util.Log;

/**
 * ???????????
 * @author id:language_and_engineering
 *
 */
public class BaseUtil
{

    // ??????????????????????????????????
    private static final int DEBUG_STACK_INDEX = 5;


    // ??????????????????????????????????
    private static final int SUPPRESS_STACK_INDEX = 5;


    /**
     * ???????????????????????????????????????????????????
     */
    protected static String APP_TAG = "TODO:";


    /**
     * ??????????
     */
    protected static boolean DEBUGGING_FLAG;


    /**
     * ????????????????????????????
     */
    protected static boolean FORGET_PREFS_ON_DEBUG;


    /**
     * ?????????RDB????????????
     */
    protected static boolean FORGET_RDB_ON_DEBUG;



    // ----------------- ????


    /**
     * ?????????????
     */
    private static String getAppTag()
    {
        return APP_TAG;
    };
        // http://okwave.jp/qa/q3705267.html


    /**
     * ????????????
     */
    private static void setAppTag( String s )
    {
        APP_TAG = s;
    }


    /**
     * ???????????FW??????????????????????????????
     */
    public static void initAppTag( String s )
    {
        setAppTag( s );
    }


    // ----------------- ????


    /**
     *  Log.d??????
     */
    public static void d( String s )
    {
        // ????????????????????????????????????????????????????
        if( mustSuppressDebugLogByAnnotation() )
        {
            // ??
            return;
        }

        // TODO: ????????????????????????????????????????????????????????????????????


        // ?????????
        String output = "";

        // ???????????????????????????????????
        if( isDebuggingMode() )
        {
            // NOTE: ???????????????????????????????LogCat???????????????????????????????
            output += getCallerMethodInfoAsString() + " : \n  ";
        }

        output += s;
        Log.d( getAppTag(), output );
    }


    /**
     * ?????????????????????????????????
     */
    private static boolean mustSuppressDebugLogByAnnotation() {

        // ??????????
        Class<?> target_class = null;
        try {
            target_class = Class.forName( getTraceInfoByIndex( SUPPRESS_STACK_INDEX ).getClassName() );
        } catch (ClassNotFoundException e) {
            // ???????????
        }

        // ????????????????????????
        SuppressDebugLog ann = target_class.getAnnotation(SuppressDebugLog.class);
        if( ( ann != null ) && ann.value() ) // ???????????????true????????????????
        {
            return true;
        }
        else
        {
            return false;
        }
            // NOTE: ???????????????????????????????Android??????????????????????
            // @see http://d.hatena.ne.jp/Kazzz/20100110/p1
    }


    /**
     *  Log.w??????
     */
    public static void w( String s )
    {
        Log.w( getAppTag(), s );
    }


    /**
     *  Log.e??????
     */
    public static void e( String s )
    {
        Log.e( getAppTag(), s );
    }


    /**
     * ?????????????????????????????
     */
    private static String getCallerMethodInfoAsString()
    {
        StackTraceElement trace = getTraceInfoByIndex( DEBUG_STACK_INDEX );

        String class_name = trace.getClassName(); // FIXED:???????????????????????????????????
        String method_name = trace.getMethodName();
            // @see http://koteitan.seesaa.net/article/171393826.html
            // http://okwave.jp/qa/q6341313.html

        return class_name + "#" + method_name;
    }


    /**
     * ????????????????????????????
     */
    private static StackTraceElement getTraceInfoByIndex( int index )
    {
        return Thread.currentThread().getStackTrace()[ index ];
    }


    // ----------------- ???????


    /**
     * ????????????????????????????????
     */
    public static void initDebuggingMode( boolean b )
    {
        DEBUGGING_FLAG = b;
    }


    /**
     * ????????????????????????????????
     */
    public static boolean isDebuggingMode()
    {
        return DEBUGGING_FLAG;
    }


    /**
     * ????????????????????
     */
    public static void setForgetPrefOnDebug( boolean b )
    {
        FORGET_PREFS_ON_DEBUG = b;
    }


    /**
     * ?????????????????????
     */
    private static boolean mustForgetPrefIfDebug()
    {
        return FORGET_PREFS_ON_DEBUG;
    }


    /**
     * ??????????????????????????????????????????
     */
    public static boolean mustClearPrefsForDebug()
    {
        d("isDebuggingMode = " + isDebuggingMode() + ", mustForgetPrefIfDebug = " + mustForgetPrefIfDebug() );
        return isDebuggingMode() && mustForgetPrefIfDebug();
    }


    /**
     * ???RDB???????????
     */
    public static boolean mustForgetRdbIfDebug()
    {
        return FORGET_RDB_ON_DEBUG;
    }


    /**
     * ???RDB?????????
     */
    public static void setForgetRdbOnDebug( boolean b )
    {
        FORGET_RDB_ON_DEBUG = b;
    }


    /**
     * ???????????RDB????????????????????????
     */
    public static boolean mustClearRdbForDebug()
    {
        return isDebuggingMode() && mustForgetRdbIfDebug();
    }
}




Java Source Code List

com.android_mvc.framework.activities.CommonActivityUtil.java
com.android_mvc.framework.activities.IBaseActivity.java
com.android_mvc.framework.activities.base.BaseMapActivity.java
com.android_mvc.framework.activities.base.BaseNormalActivity.java
com.android_mvc.framework.activities.base.BaseTabHostActivity.java
com.android_mvc.framework.activities.installation.InstallAppFWBaseActivity.java
com.android_mvc.framework.annotations.SuppressDebugLog.java
com.android_mvc.framework.common.AbstractAppSettings.java
com.android_mvc.framework.common.BaseUtil.java
com.android_mvc.framework.common.FWUtil.java
com.android_mvc.framework.controller.BaseController.java
com.android_mvc.framework.controller.ControlFlowDetail.java
com.android_mvc.framework.controller.action.ActionResult.java
com.android_mvc.framework.controller.action.BLExecutor.java
com.android_mvc.framework.controller.action.BaseAction.java
com.android_mvc.framework.controller.routing.IntentPortable.java
com.android_mvc.framework.controller.routing.Router.java
com.android_mvc.framework.controller.routing.RoutingTable.java
com.android_mvc.framework.controller.routing.TabContentMapping.java
com.android_mvc.framework.controller.validation.ActivityParams.java
com.android_mvc.framework.controller.validation.BaseValidationsUtil.java
com.android_mvc.framework.controller.validation.NumberComparator.java
com.android_mvc.framework.controller.validation.ValidationExecutor.java
com.android_mvc.framework.controller.validation.ValidationResult.java
com.android_mvc.framework.db.DBHelper.java
com.android_mvc.framework.db.dao.BaseDAO.java
com.android_mvc.framework.db.dao.BaseDBDAO.java
com.android_mvc.framework.db.dao.BasePrefDAO.java
com.android_mvc.framework.db.dao.FWPrefDAO.java
com.android_mvc.framework.db.dao.Finder.java
com.android_mvc.framework.db.dao.IFWDAO.java
com.android_mvc.framework.db.entity.BaseLogicalEntity.java
com.android_mvc.framework.db.schema.AbstractSchemaDefinition.java
com.android_mvc.framework.db.schema.RDBColumn.java
com.android_mvc.framework.db.schema.RDBSchema.java
com.android_mvc.framework.db.schema.RDBTable.java
com.android_mvc.framework.db.transaction.todo.TxnListener.java
com.android_mvc.framework.db.transaction.todo.TxnScope.java
com.android_mvc.framework.net.HttpPostRequest.java
com.android_mvc.framework.net.HttpPostResponse.java
com.android_mvc.framework.net.old.HttpPostHandler.java
com.android_mvc.framework.net.old.HttpPostTask.java
com.android_mvc.framework.task.AsyncTasksRunner.java
com.android_mvc.framework.task.RunnerFollower.java
com.android_mvc.framework.task.SequentialAsyncTask.java
com.android_mvc.framework.ui.UIBuilder.java
com.android_mvc.framework.ui.UIUtil.java
com.android_mvc.framework.ui.menu.OptionMenuBuilder.java
com.android_mvc.framework.ui.menu.OptionMenuDescription.java
com.android_mvc.framework.ui.tab.TabDescription.java
com.android_mvc.framework.ui.tab.TabHostBuilder.java
com.android_mvc.framework.ui.view.IFWView.java
com.android_mvc.framework.ui.view.MButton.java
com.android_mvc.framework.ui.view.MCheckBox.java
com.android_mvc.framework.ui.view.MEditText.java
com.android_mvc.framework.ui.view.MLinearLayout.java
com.android_mvc.framework.ui.view.MTextView.java
com.android_mvc.sample_project.activities.func_db.DBEditActivity.java
com.android_mvc.sample_project.activities.func_db.DBListActivity.java
com.android_mvc.sample_project.activities.func_db.SampleTabHostActivity.java
com.android_mvc.sample_project.activities.func_net.HttpNetActivity.java
com.android_mvc.sample_project.activities.installation.InstallAppActivity.java
com.android_mvc.sample_project.activities.installation.InstallCompletedActivity.java
com.android_mvc.sample_project.activities.installation.lib.InstallAppUserBaseActivity.java
com.android_mvc.sample_project.activities.main.TopActivity.java
com.android_mvc.sample_project.common.AppSettings.java
com.android_mvc.sample_project.common.Util.java
com.android_mvc.sample_project.controller.FuncDBController.java
com.android_mvc.sample_project.controller.FuncDBValidation.java
com.android_mvc.sample_project.controller.FuncNetController.java
com.android_mvc.sample_project.controller.FuncNetValidation.java
com.android_mvc.sample_project.controller.MainController.java
com.android_mvc.sample_project.controller.util.ValidationsUtil.java
com.android_mvc.sample_project.db.dao.FriendDAO.java
com.android_mvc.sample_project.db.dao.PrefDAO.java
com.android_mvc.sample_project.db.dao.todo.HogeDAO.java
com.android_mvc.sample_project.db.entity.Friend.java
com.android_mvc.sample_project.db.entity.lib.LogicalEntity.java
com.android_mvc.sample_project.db.schema.SchemaDefinition.java
com.android_mvc.sample_project.domain.DBDeleteAction.java
com.android_mvc.sample_project.domain.DBEditAction.java
com.android_mvc.sample_project.domain.DBUpdateAction.java
com.android_mvc.sample_project.domain.HttpNetAction.java