Example usage for android.view.animation AlphaAnimation AlphaAnimation

List of usage examples for android.view.animation AlphaAnimation AlphaAnimation

Introduction

In this page you can find the example usage for android.view.animation AlphaAnimation AlphaAnimation.

Prototype

public AlphaAnimation(float fromAlpha, float toAlpha) 

Source Link

Document

Constructor to use when building an AlphaAnimation from code

Usage

From source file:hide.com.android.datetimepicker.date.DatePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d(TAG, "onCreateView: ");
    getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);

    View view = inflater.inflate(R.layout.date_picker_dialog, null);

    mDayOfWeekView = (TextView) view.findViewById(R.id.date_picker_header);

    mMonthAndDayView = (LinearLayout) view.findViewById(R.id.date_picker_month_and_day);
    mMonthAndDayView.setOnClickListener(this);
    mSelectedMonthTextView = (TextView) view.findViewById(R.id.date_picker_month);
    mSelectedDayTextView = (TextView) view.findViewById(R.id.date_picker_day);
    mYearView = (TextView) view.findViewById(R.id.date_picker_year);
    mYearView.setOnClickListener(this);

    int listPosition = -1;
    int listPositionOffset = 0;
    int currentView = MONTH_AND_DAY_VIEW;
    if (savedInstanceState != null) {
        mWeekStart = savedInstanceState.getInt(KEY_WEEK_START);
        mMinYear = savedInstanceState.getInt(KEY_YEAR_START);
        mMaxYear = savedInstanceState.getInt(KEY_YEAR_END);
        currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW);
        listPosition = savedInstanceState.getInt(KEY_LIST_POSITION);
        listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET);
    }//  w  w  w  .  ja  v  a2 s  .c o  m

    final Activity activity = getActivity();
    mDayPickerView = new DayPickerView(activity, this);
    mYearPickerView = new YearPickerView(activity, this);

    Resources res = getResources();
    mDayPickerDescription = res.getString(R.string.day_picker_description);
    mSelectDay = res.getString(R.string.select_day);
    mYearPickerDescription = res.getString(R.string.year_picker_description);
    mSelectYear = res.getString(R.string.select_year);

    mAnimator = (AccessibleDateAnimator) view.findViewById(R.id.animator);
    mAnimator.addView(mDayPickerView);
    mAnimator.addView(mYearPickerView);
    mAnimator.setDateMillis(mCalendar.getTimeInMillis());
    // TODO: Replace with animation decided upon by the design team.
    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(ANIMATION_DURATION);
    mAnimator.setInAnimation(animation);
    // TODO: Replace with animation decided upon by the design team.
    Animation animation2 = new AlphaAnimation(1.0f, 0.0f);
    animation2.setDuration(ANIMATION_DURATION);
    mAnimator.setOutAnimation(animation2);

    mDoneButton = (Button) view.findViewById(R.id.done);
    mDoneButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tryVibrate();
            if (mCallBack != null) {
                mCallBack.onDateSet(DatePickerDialog.this, mCalendar.get(Calendar.YEAR),
                        mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH));
            }
            dismiss();
        }
    });

    updateDisplay(false);
    setCurrentView(currentView);

    if (listPosition != -1) {
        if (currentView == MONTH_AND_DAY_VIEW) {
            mDayPickerView.postSetSelection(listPosition);
        } else if (currentView == YEAR_VIEW) {
            mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset);
        }
    }
    return view;
}

From source file:com.cicada.yuanxiaobao.common.BaseAdapterHelper.java

/**
 * Add an action to set the alpha of a view. Can be called multiple times.
 * Alpha between 0-1.// w  w  w.jav  a2s .com
 */
public BaseAdapterHelper setAlpha(int viewId, float value) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        retrieveView(viewId).setAlpha(value);
    } else {
        // Pre-honeycomb hack to set Alpha value
        AlphaAnimation alpha = new AlphaAnimation(value, value);
        alpha.setDuration(0);
        alpha.setFillAfter(true);
        retrieveView(viewId).startAnimation(alpha);
    }
    return this;
}

From source file:com.codetroopers.betterpickers.calendardatepicker.CalendarDatePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d(TAG, "onCreateView: ");
    if (getShowsDialog()) {
        getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    }//from  w w w  .j a  v  a 2  s. c om

    View view = inflater.inflate(R.layout.calendar_date_picker_dialog, null);

    mDayOfWeekView = (TextView) view.findViewById(R.id.date_picker_header);
    mMonthAndDayView = (LinearLayout) view.findViewById(R.id.date_picker_month_and_day);
    mMonthAndDayView.setOnClickListener(this);
    mSelectedMonthTextView = (TextView) view.findViewById(R.id.date_picker_month);
    mSelectedDayTextView = (TextView) view.findViewById(R.id.date_picker_day);
    mYearView = (TextView) view.findViewById(R.id.date_picker_year);
    mYearView.setOnClickListener(this);

    int listPosition = -1;
    int listPositionOffset = 0;
    int currentView = MONTH_AND_DAY_VIEW;
    if (savedInstanceState != null) {
        mWeekStart = savedInstanceState.getInt(KEY_WEEK_START);
        mMinYear = savedInstanceState.getInt(KEY_YEAR_START);
        mMaxYear = savedInstanceState.getInt(KEY_YEAR_END);
        currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW);
        listPosition = savedInstanceState.getInt(KEY_LIST_POSITION);
        listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET);
    }

    final Activity activity = getActivity();
    mDayPickerView = new SimpleDayPickerView(activity, this);
    mYearPickerView = new YearPickerView(activity, this);

    Resources res = getResources();
    mDayPickerDescription = res.getString(R.string.day_picker_description);
    mSelectDay = res.getString(R.string.select_day);
    mYearPickerDescription = res.getString(R.string.year_picker_description);
    mSelectYear = res.getString(R.string.select_year);

    mAnimator = (AccessibleDateAnimator) view.findViewById(R.id.animator);
    mAnimator.addView(mDayPickerView);
    mAnimator.addView(mYearPickerView);
    mAnimator.setDateMillis(mCalendar.getTimeInMillis());
    // TODO: Replace with animation decided upon by the design team.
    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(ANIMATION_DURATION);
    mAnimator.setInAnimation(animation);
    // TODO: Replace with animation decided upon by the design team.
    Animation animation2 = new AlphaAnimation(1.0f, 0.0f);
    animation2.setDuration(ANIMATION_DURATION);
    mAnimator.setOutAnimation(animation2);

    mDoneButton = (Button) view.findViewById(R.id.done);
    mDoneButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tryVibrate();
            if (mCallBack != null) {
                mCallBack.onDateSet(CalendarDatePickerDialog.this, mCalendar.get(Calendar.YEAR),
                        mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH));
            }
            dismiss();
        }
    });

    updateDisplay(false);
    setCurrentView(currentView);

    if (listPosition != -1) {
        if (currentView == MONTH_AND_DAY_VIEW) {
            mDayPickerView.postSetSelection(listPosition);
        } else if (currentView == YEAR_VIEW) {
            mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset);
        }
    }

    mHapticFeedbackController = new HapticFeedbackController(activity);
    return view;
}

From source file:com.wii.sean.wiimmfiitus.adapters.CustomWiiCyclerViewAdapter.java

private Animation getBlinkAnimation() {
    Animation animation = new AlphaAnimation(1, 0);
    animation.setDuration(500);//  w ww  .j  a v  a 2  s  . c  o  m
    animation.setInterpolator(new LinearInterpolator());
    animation.setRepeatCount(Animation.INFINITE);
    animation.setRepeatMode(Animation.REVERSE);

    return animation;
}

From source file:org.digitalcampus.oppia.activity.CourseIndexActivity.java

private void initializeCourseIndex(boolean animate) {

    final ListView listView = (ListView) findViewById(R.id.section_list);
    if (listView == null)
        return;/*from w  w w .j a v a2s. com*/
    ViewCompat.setNestedScrollingEnabled(listView, true);
    sla = new SectionListAdapter(CourseIndexActivity.this, course, sections,
            new SectionListAdapter.CourseClickListener() {
                @Override
                public void onActivityClicked(String activityDigest) {
                    startCourseActivityByDigest(activityDigest);
                }
            });

    if (animate) {
        AlphaAnimation fadeOutAnimation = new AlphaAnimation(1f, 0f);
        fadeOutAnimation.setDuration(700);
        fadeOutAnimation.setFillAfter(true);

        listView.setAlpha(0f);
        ValueAnimator animator = ValueAnimator.ofFloat(1f, 0f);
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                listView.setTranslationX((Float) valueAnimator.getAnimatedValue() * 80);
                listView.setAlpha(1f - (Float) valueAnimator.getAnimatedValue());
            }
        });
        animator.setDuration(700);
        animator.start();
        loadingCourseView.startAnimation(fadeOutAnimation);

    } else {
        loadingCourseView.setVisibility(View.GONE);
        listView.setVisibility(View.VISIBLE);
    }

    listView.setAdapter(sla);
}

From source file:com.appassit.common.Utils.java

/**
 * ??//from   ww  w  . ja va 2 s .com
 * 
 * @return
 */
public static LayoutAnimationController getLayoutAnimation() {
    AnimationSet set = new AnimationSet(true);

    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(50);
    set.addAnimation(animation);

    animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
            Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
    animation.setDuration(100);
    set.addAnimation(animation);

    LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f);
    return controller;
}

From source file:io.github.data4all.activity.CameraActivity.java

private AlphaAnimation createAnimation(final View v) {
    AlphaAnimation anim = new AlphaAnimation(1.0f, 0.0f);
    anim.setDuration(3000);/*  w  ww  .  j av  a  2 s .  c  o  m*/
    anim.setStartOffset(3000);
    anim.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
            v.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            v.setVisibility(View.INVISIBLE);
            v.setClickable(false);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });
    return anim;
}

From source file:org.nla.tarotdroid.lib.ui.GameReadFragment.java

/**
 * Displays game index in game set and then smoothly removes the text.
 *///from   ww  w  .ja v a 2  s  .  co  m
private void smoothlyHideText() {
    final TextView onTop = (TextView) this.frameLayout.findViewById(R.id.txtOnTop);
    onTop.setText(this.game.getIndex() + "/" + this.game.getHighestGameIndex());

    Animation animation1 = new AlphaAnimation(1.0f, 0.0f);
    animation1.setDuration(1500);

    //animation1 AnimationListener
    animation1.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationEnd(Animation arg0) {
            // start animation2 when animation1 ends (continue)
            onTop.setVisibility(View.GONE);
        }

        @Override
        public void onAnimationRepeat(Animation arg0) {
        }

        @Override
        public void onAnimationStart(Animation arg0) {
        }
    });

    onTop.startAnimation(animation1);
}

From source file:mirko.android.datetimepicker.date.DatePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d(TAG, "onCreateView: ");
    getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);

    View view = inflater.inflate(R.layout.date_picker_dialog, null);

    if (view == null) {
        Log.e(TAG, "view null");
    }/*from   w  ww .j  a v a 2s  . c  om*/

    Log.e(TAG, "full path R");
    mDayOfWeekView = (TextView) view.findViewById(mirko.android.datetimepicker.R.id.date_picker_header);
    if (mDayOfWeekView == null) {
        Log.e(TAG, "mDayOfWeekView null");
    }
    mMonthAndDayView = (AccessibleLinearLayout) view.findViewById(R.id.date_picker_month_and_day);
    if (mMonthAndDayView == null) {
        Log.e(TAG, "mMonthAndDayView null");
    }
    mMonthAndDayView.setOnClickListener(this);
    mSelectedMonthTextView = (TextView) view.findViewById(R.id.date_picker_month);
    if (mSelectedMonthTextView == null) {
        Log.i(TAG, "mSelectedMonthTextView is null onCreateView");
    }
    mSelectedDayTextView = (TextView) view.findViewById(R.id.date_picker_day);
    mYearView = (TextView) view.findViewById(R.id.date_picker_year);
    mYearView.setOnClickListener(this);

    int listPosition = -1;
    int listPositionOffset = 0;
    int currentView = MONTH_AND_DAY_VIEW;
    if (savedInstanceState != null) {
        mWeekStart = savedInstanceState.getInt(KEY_WEEK_START);
        mMinYear = savedInstanceState.getInt(KEY_YEAR_START);
        mMaxYear = savedInstanceState.getInt(KEY_YEAR_END);
        currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW);
        listPosition = savedInstanceState.getInt(KEY_LIST_POSITION);
        listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET);
    }

    final Activity activity = getActivity();
    mDayPickerView = new DayPickerView(activity, this);
    mYearPickerView = new YearPickerView(activity, this);

    Resources res = getResources();
    mDayPickerDescription = res.getString(R.string.day_picker_description);
    mSelectDay = res.getString(R.string.select_day);
    mYearPickerDescription = res.getString(R.string.year_picker_description);
    mSelectYear = res.getString(R.string.select_year);

    mAnimator = (AccessibleDateAnimator) view.findViewById(R.id.animator);
    mAnimator.addView(mDayPickerView);
    mAnimator.addView(mYearPickerView);
    mAnimator.setDateMillis(mCalendar.getTimeInMillis());
    // TODO: Replace with animation decided upon by the design team.
    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(ANIMATION_DURATION);
    mAnimator.setInAnimation(animation);
    // TODO: Replace with animation decided upon by the design team.
    Animation animation2 = new AlphaAnimation(1.0f, 0.0f);
    animation2.setDuration(ANIMATION_DURATION);
    mAnimator.setOutAnimation(animation2);

    mDoneButton = (Button) view.findViewById(R.id.done);
    mDoneButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tryVibrate();
            if (mCallBack != null) {
                mCallBack.onDateSet(DatePickerDialog.this, mCalendar.get(Calendar.YEAR),
                        mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH));
            }
            dismiss();
        }
    });

    updateDisplay(false);
    setCurrentView(currentView);

    if (listPosition != -1) {
        if (currentView == MONTH_AND_DAY_VIEW) {
            mDayPickerView.postSetSelection(listPosition);
        } else if (currentView == YEAR_VIEW) {
            mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset);
        }
    }
    return view;
}

From source file:widgets.Graphical_Info_with_achartengine.java

@SuppressLint("HandlerLeak")
public Graphical_Info_with_achartengine(tracerengine Trac, Activity context, int id, int dev_id, String name,
        final String state_key, String url, final String usage, int period, int update, int widgetSize,
        int session_type, final String parameters, int place_id, String place_type, SharedPreferences params)
        throws JSONException {
    super(context, Trac, id, name, "", usage, widgetSize, session_type, place_id, place_type, mytag, container);
    this.Tracer = Trac;
    this.context = context;
    this.dev_id = dev_id;
    this.id = id;
    this.usage = usage;
    this.state_key = state_key;
    this.update = update;
    this.name = name;
    this.url = url;
    this.myself = this;
    this.session_type = session_type;
    this.parameters = parameters;
    this.place_id = place_id;
    this.place_type = place_type;
    this.params = params;
    setOnClickListener(this);

    metrics = getResources().getDisplayMetrics();
    //Label Text size according to the screen size
    size12 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 12, metrics);
    size10 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 10, metrics);
    size5 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 5, metrics);
    size2 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 2, metrics);

    //Design the graph
    //Creating a XYMultipleSeriesRenderer to customize the whole chart
    multiRenderer = new XYMultipleSeriesRenderer();
    //Creating XYSeriesRenderer to customize incomeSeries
    incomeRenderer = new XYSeriesRenderer();
    emptyRenderer = new XYSeriesRenderer();
    //Creating a dataset to hold each series
    dataset = new XYMultipleSeriesDataset();
    //Creating an  XYSeries for Income
    nameSeries = new XYSeries(name);
    //TODO translate
    EmptySeries = new XYSeries("NO VALUE");
    incomeRenderer.setColor(0xff0B909A);
    emptyRenderer.setColor(0xffff0000);//from  ww w . java  2  s .co  m
    incomeRenderer.setPointStyle(PointStyle.CIRCLE);
    //emptyRenderer.setPointStyle(PointStyle.CIRCLE);
    incomeRenderer.setFillPoints(true);
    emptyRenderer.setFillPoints(true);
    incomeRenderer.setLineWidth(4);
    emptyRenderer.setLineWidth(4);
    incomeRenderer.setDisplayChartValues(true);
    emptyRenderer.setDisplayChartValues(false);
    incomeRenderer.setChartValuesTextSize(size12);

    //Change the type of line between point
    //incomeRenderer.setStroke(BasicStroke.DASHED);
    //Remove default X axis label
    multiRenderer.setXLabels(0);
    //Remove default Y axis label
    multiRenderer.setYLabels(0);
    //Set X label text color
    multiRenderer.setXLabelsColor(Color.BLACK);
    //Set Y label text color
    multiRenderer.setYLabelsColor(0, Color.BLACK);
    //Set X label text size 
    multiRenderer.setLabelsTextSize(size12);
    //Set X label text angle 
    multiRenderer.setXLabelsAngle(-45);
    //Set Y label text angle 
    //multiRenderer.setYLabelsAngle(-45);
    //Set X label text alignement
    multiRenderer.setXLabelsAlign(Align.LEFT);
    //Set to make value of y axis left aligned
    multiRenderer.setYLabelsAlign(Align.LEFT);
    //Disable zoom button
    multiRenderer.setZoomButtonsVisible(false);
    //get background transparent
    multiRenderer.setMarginsColor(Color.argb(0x00, 0xff, 0x00, 0x00));
    //Disable Zoom in Y axis
    multiRenderer.setZoomEnabled(true, false);
    //Disable Pan in Y axis
    multiRenderer.setPanEnabled(true, false);
    //Limits pan mouvement
    //[panMinimumX, panMaximumX, panMinimumY, panMaximumY] 
    double[] panLimits = { -5, 26, 0, 0 };
    multiRenderer.setPanLimits(panLimits);
    //Sets the selectable radius value around clickable points. 
    multiRenderer.setSelectableBuffer(10);
    //Add grid
    multiRenderer.setShowGrid(true);
    //Set color for grid
    multiRenderer.setGridColor(Color.BLACK, 0);

    login = params.getString("http_auth_username", null);
    password = params.getString("http_auth_password", null);

    mytag = "Graphical_Info_with_achartengine (" + dev_id + ")";
    Tracer.e(mytag, "New instance for name = " + name + " state_key = " + state_key);

    //state key
    state_key_view = new TextView(context);
    state_key_view.setText(state_key);
    state_key_view.setTextColor(Color.parseColor("#333333"));

    //value
    value = new TextView(context);
    value.setTextSize(28);
    value.setTextColor(Color.BLACK);
    animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(1000);

    super.LL_featurePan.addView(value);
    super.LL_infoPan.addView(state_key_view);

    handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            if (msg.what == 9999) {
                //Message from widgetupdate
                //state_engine send us a signal to notify value changed
                if (session == null)
                    return;

                String loc_Value = session.getValue();
                Tracer.d(mytag, "Handler receives a new value <" + loc_Value + ">");
                try {
                    float formatedValue = 0;
                    if (loc_Value != null)
                        formatedValue = Round(Float.parseFloat(loc_Value), 2);
                    try {
                        //Basilic add, number feature has a unit parameter
                        JSONObject jparam = new JSONObject(parameters.replaceAll("&quot;", "\""));
                        String test_unite = jparam.getString("unit");
                        value.setText(formatedValue + " " + test_unite);
                    } catch (JSONException e) {
                        if (state_key.equalsIgnoreCase("temperature") == true)
                            value.setText(formatedValue + " C");
                        else if (state_key.equalsIgnoreCase("pressure") == true)
                            value.setText(formatedValue + " hPa");
                        else if (state_key.equalsIgnoreCase("humidity") == true)
                            value.setText(formatedValue + " %");
                        else if (state_key.equalsIgnoreCase("percent") == true)
                            value.setText(formatedValue + " %");
                        else if (state_key.equalsIgnoreCase("visibility") == true)
                            value.setText(formatedValue + " km");
                        else if (state_key.equalsIgnoreCase("chill") == true)
                            value.setText(formatedValue + " C");
                        else if (state_key.equalsIgnoreCase("speed") == true)
                            value.setText(formatedValue + " km/h");
                        else if (state_key.equalsIgnoreCase("drewpoint") == true)
                            value.setText(formatedValue + " C");
                        else if (state_key.equalsIgnoreCase("condition-code") == true)
                            //Add try catch to avoid other case that make #1794
                            try {

                                value.setText(Graphics_Manager.Names_conditioncodes(getContext(),
                                        (int) formatedValue));
                            } catch (Exception e1) {
                                value.setText(loc_Value);
                            }
                        else
                            value.setText(loc_Value);
                    }
                    value.setAnimation(animation);
                } catch (Exception e) {
                    // It's probably a String that could'nt be converted to a float
                    Tracer.d(mytag, "Handler exception : new value <" + loc_Value + "> not numeric !");
                    value.setText(loc_Value);
                }
                //To have the icon colored as it has no state
                IV_img.setBackgroundResource(Graphics_Manager.Icones_Agent(usage, 2));

            } else if (msg.what == 9998) {
                // state_engine send us a signal to notify it'll die !
                Tracer.d(mytag, "state engine disappeared ===> Harakiri !");
                session = null;
                realtime = false;
                removeView(LL_background);
                myself.setVisibility(GONE);
                if (container != null) {
                    container.removeView(myself);
                    container.recomputeViewAttributes(myself);
                }
                try {
                    finalize();
                } catch (Throwable t) {
                } //kill the handler thread itself
            }
        }

    };

    //================================================================================
    /*
     * New mechanism to be notified by widgetupdate engine when our value is changed
     * 
     */
    WidgetUpdate cache_engine = WidgetUpdate.getInstance();
    if (cache_engine != null) {
        session = new Entity_client(dev_id, state_key, mytag, handler, session_type);
        if (Tracer.get_engine().subscribe(session)) {
            realtime = true; //we're connected to engine
            //each time our value change, the engine will call handler
            handler.sendEmptyMessage(9999); //Force to consider current value in session
        }

    }
    //================================================================================
    //updateTimer();   //Don't use anymore cyclic refresh....   

}