Android Open Source - twawm2 Twawm Utils






From Project

Back to project page twawm2.

License

The source code is released under:

Copyright (c) 2014, afnf All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistr...

If you think the Android project twawm2 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.appspot.afnf4199ga.twawm;
//ww  w.ja  va  2  s .co  m
import java.util.EnumSet;
import java.util.Iterator;

import net.afnf.and.twawm2.R;
import android.content.Context;

import com.appspot.afnf4199ga.utils.MyStringUtlis;

public class TwawmUtils {

    // ????????
    public static enum BT_RESUME_TYPE {
        FAST, NORMAL_FORCE, BT_RESTART, NORMAL;

        public static BT_RESUME_TYPE ordinalOf(int ordinal) {
            Iterator<BT_RESUME_TYPE> ite = EnumSet.allOf(BT_RESUME_TYPE.class).iterator();
            while (ite.hasNext()) {
                BT_RESUME_TYPE e = ite.next();
                if (e.ordinal() == ordinal)
                    return e;
            }
            return null;
        }
    }

    public static int getBtRetryCount(BT_RESUME_TYPE btResumeType) {
        int retry = 1; // BT_RESUME_TYPE.FAST

        if (btResumeType == BT_RESUME_TYPE.NORMAL) {
            retry = 2;
        }
        else if (btResumeType == BT_RESUME_TYPE.NORMAL_FORCE) {
            retry = 3;
        }
        else if (btResumeType == BT_RESUME_TYPE.BT_RESTART) {
            retry = 3;
        }
        return retry;
    }

    public static int getValue2ColorIndex(Context context, String color_value) {

        if (MyStringUtlis.isEmpty(color_value) == false) {
            if (color_value.equals(context.getString(R.string.color_black_value))) {
                return R.color.black;
            }
            else if (color_value.equals(context.getString(R.string.color_gray_value))) {
                return R.color.gray;
            }
            else if (color_value.equals(context.getString(R.string.color_white_value))) {
                return R.color.white;
            }
            else if (color_value.equals(context.getString(R.string.color_red_value))) {
                return R.color.red;
            }
            else if (color_value.equals(context.getString(R.string.color_green_value))) {
                return R.color.green;
            }
            else if (color_value.equals(context.getString(R.string.color_blue_value))) {
                return R.color.blue;
            }
            else if (color_value.equals(context.getString(R.string.color_none_value))) {
                return R.color.full_transparent;
            }
        }

        return R.color.red;
    }

    static int[] R_BLACK = { R.drawable.backbround_black, R.drawable.backbround_white };
    static int[] R_BLACK_TRANS = { R.drawable.backbround_black_trans, R.drawable.backbround_white_trans };
    static int[] R_WHITE = { R.drawable.backbround_white, R.drawable.backbround_black };
    static int[] R_WHITE_TRANS = { R.drawable.backbround_white_trans, R.drawable.backbround_black_trans };
    static int[] R_NONE = { 0, R.drawable.backbround_white_trans };

    public static int[] getValue2ResourceIndex(Context context, String color_value) {

        if (MyStringUtlis.isEmpty(color_value) == false) {
            if (color_value.equals(context.getString(R.string.color_black_value))) {
                return R_BLACK;
            }
            else if (color_value.equals(context.getString(R.string.color_black_trans_value))) {
                return R_BLACK_TRANS;
            }
            else if (color_value.equals(context.getString(R.string.color_white_value))) {
                return R_WHITE;
            }
            else if (color_value.equals(context.getString(R.string.color_white_trans_value))) {
                return R_WHITE_TRANS;
            }
            else if (color_value.equals(context.getString(R.string.color_none_value))) {
                return R_NONE; // ?0 to remove the background?????????
            }
        }

        return R_BLACK_TRANS;
    }
}




Java Source Code List

com.appspot.afnf4199ga.twawm.BluetoothHelper.java
com.appspot.afnf4199ga.twawm.Const.java
com.appspot.afnf4199ga.twawm.Const.java
com.appspot.afnf4199ga.twawm.HostnameListTest.java
com.appspot.afnf4199ga.twawm.HostnameList.java
com.appspot.afnf4199ga.twawm.IconSelectorTest.java
com.appspot.afnf4199ga.twawm.IconSelector.java
com.appspot.afnf4199ga.twawm.OnlineChecker.java
com.appspot.afnf4199ga.twawm.StateMachineTest.java
com.appspot.afnf4199ga.twawm.StateMachine.java
com.appspot.afnf4199ga.twawm.TwawmUtils.java
com.appspot.afnf4199ga.twawm.app.BackgroundServiceTest.java
com.appspot.afnf4199ga.twawm.app.BackgroundService.java
com.appspot.afnf4199ga.twawm.app.DefaultWidgetProvider.java
com.appspot.afnf4199ga.twawm.app.InfoActivity.java
com.appspot.afnf4199ga.twawm.app.InitialConfigurationWizardActivity.java
com.appspot.afnf4199ga.twawm.app.LogSendActivity.java
com.appspot.afnf4199ga.twawm.app.MainActivity.java
com.appspot.afnf4199ga.twawm.app.MainApp.java
com.appspot.afnf4199ga.twawm.app.MyPreferenceActivity.java
com.appspot.afnf4199ga.twawm.app.NetworkSwitcher.java
com.appspot.afnf4199ga.twawm.app.StaticIntentListener.java
com.appspot.afnf4199ga.twawm.app.UIAct.java
com.appspot.afnf4199ga.twawm.ctl.CustomizeActionsActivityTest.java
com.appspot.afnf4199ga.twawm.ctl.CustomizeActionsActivity.java
com.appspot.afnf4199ga.twawm.ctl.CwacTouchListView.java
com.appspot.afnf4199ga.twawm.ctl.ListItem.java
com.appspot.afnf4199ga.twawm.router.EcoModeControlTest.java
com.appspot.afnf4199ga.twawm.router.EcoModeControl.java
com.appspot.afnf4199ga.twawm.router.InetLookupWrappter.java
com.appspot.afnf4199ga.twawm.router.InetLookupWrappter.java
com.appspot.afnf4199ga.twawm.router.MyHttpClientTest.java
com.appspot.afnf4199ga.twawm.router.MyHttpClient.java
com.appspot.afnf4199ga.twawm.router.MyHttpClient.java
com.appspot.afnf4199ga.twawm.router.RouterControlByHttpTest.java
com.appspot.afnf4199ga.twawm.router.RouterControlByHttp.java
com.appspot.afnf4199ga.twawm.router.RouterControlByHttp.java
com.appspot.afnf4199ga.twawm.router.RouterControl.java
com.appspot.afnf4199ga.twawm.router.RouterControl.java
com.appspot.afnf4199ga.twawm.router.RouterInfo.java
com.appspot.afnf4199ga.twawm.router.RouterInfo.java
com.appspot.afnf4199ga.utils.AndroidUtilsTest.java
com.appspot.afnf4199ga.utils.AndroidUtils.java
com.appspot.afnf4199ga.utils.AndroidUtils.java
com.appspot.afnf4199ga.utils.Logger.java
com.appspot.afnf4199ga.utils.Logger.java
com.appspot.afnf4199ga.utils.MyStringUtlisTest.java
com.appspot.afnf4199ga.utils.MyStringUtlis.java
com.appspot.afnf4199ga.utils.MyStringUtlis.java
com.appspot.afnf4199ga.utils.MyTestUtils.java
com.appspot.afnf4199ga.utils.MyUncaughtExceptionHandler.java
com.appspot.afnf4199ga.utils.MyUncaughtExceptionHandler.java
com.appspot.afnf4199ga.wmgraph.app.FetchThread.java
com.appspot.afnf4199ga.wmgraph.app.InetLookupThread.java
com.appspot.afnf4199ga.wmgraph.app.InfoActivity.java
com.appspot.afnf4199ga.wmgraph.app.MainActivity.java
com.appspot.afnf4199ga.wmgraph.app.MyPreferenceActivity.java
com.appspot.afnf4199ga.wmgraph.app.UIAct.java
net.afnf.and.twawm2.DexmakerInstrumentationTestCase.java
net.afnf.and.twawm2.MyInstrumentationTestRunner.java