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:com.artur.softwareproject.BluetoothConnectionListAdapter.java

@Override
@NonNull/*from  www.  java 2  s .co  m*/
public View getView(final int position, View convertView, @NonNull ViewGroup parent) {
    ViewHolder mViewHolder;

    if (convertView == null) {
        mViewHolder = new ViewHolder();

        LayoutInflater ListInflater = LayoutInflater.from(getContext());

        convertView = ListInflater.inflate(R.layout.bluetooth_list_pattern, parent, false);

        mViewHolder.bluetoothConnectionName = (TextView) convertView
                .findViewById(R.id.bluetooth_connection_name);

        mViewHolder.bluetoothConnectionStatus = (TextView) convertView
                .findViewById(R.id.bluetooth_connection_status);

        convertView.setTag(mViewHolder);

        convertView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //What happens if you press on the list items at the bluetooth activity.
                Animation animation = new AlphaAnimation(0.3f, 1.0f);

                animation.setDuration(1000);

                v.startAnimation(animation);

                intent = new Intent(contextActivity, BluetoothService.class);
                intent.putExtra("device", bDevices.get(position));
                intent.putExtra("deviceList", bDevices);

                contextActivity.startService(intent);

                final ProgressDialog connectingDialog = new ProgressDialog(contextActivity);

                connectDialog = connectingDialog;

                connectingDialog.setMessage("Connecting...");
                connectingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                connectingDialog.setCancelable(false);
                connectingDialog.show();

                final ConnectionHandlerClass connectHandler = new ConnectionHandlerClass(bclaReference);

                connectThread = new Thread(new Runnable() {
                    @Override
                    public void run() {
                        int stop = 0;
                        int counter = 0;

                        //Timeout after 10 seconds.
                        while (stop == 0 && counter < 5) {
                            stop = getConnected();
                            counter++;
                            sleep(2000);
                        }

                        //Timeout occurred after 10s of waiting and stop is still 0.
                        if (stop == 0 && counter == 4) {
                            timeout = true;
                        }

                        connectHandler.sendEmptyMessage(0);
                    }
                });

                connectThread.start();
            }
        });
    } else {
        mViewHolder = (ViewHolder) convertView.getTag();
    }

    mViewHolder.bluetoothConnectionName.setText(bluetoothAddress.get(position));
    mViewHolder.bluetoothConnectionStatus.setText(bluetoothName.get(position));

    return convertView;
}

From source file:widgets.Graphical_Info.java

@SuppressLint("HandlerLeak")
public Graphical_Info(tracerengine Trac, Activity context, int id, int dev_id, String name,
        final String state_key, String url, final String usage, int update, int widgetSize, int session_type,
        final String parameters, int place_id, String place_type, SharedPreferences params) {
    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.wname = 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);

    mytag = "Graphical_Info (" + dev_id + ")";
    metrics = getResources().getDisplayMetrics();
    //Label Text size according to the screen size
    size10 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, metrics);
    size5 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, metrics);

    Tracer.e(mytag, "New instance for name = " + wname + " state_key = " + state_key);
    login = params.getString("http_auth_username", null);
    password = params.getString("http_auth_password", null);

    //state key/*from   w  w  w .j  a  va2s . c om*/
    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);

    if (with_graph) {

        //feature panel 2 which will contain graphic
        featurePan2 = new LinearLayout(context);
        featurePan2.setLayoutParams(
                new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
        featurePan2.setGravity(Gravity.CENTER_VERTICAL);
        featurePan2.setPadding(5, 10, 5, 10);
        //canvas
        canvas = new Graphical_Info_View(Tracer, context, params);
        canvas.dev_id = dev_id;
        canvas.state_key = state_key;
        canvas.url = url;
        canvas.update = update;

        LayoutInflater layoutInflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        featurePan2_buttons = layoutInflater.inflate(R.layout.graph_buttons, null);
        View v = null;

        v = featurePan2_buttons.findViewById(R.id.bt_prev);
        if (v != null)
            v.setOnClickListener(canvas);

        v = featurePan2_buttons.findViewById(R.id.bt_next);
        if (v != null)
            v.setOnClickListener(canvas);

        v = featurePan2_buttons.findViewById(R.id.bt_year);
        if (v != null)
            v.setOnClickListener(canvas);

        v = featurePan2_buttons.findViewById(R.id.bt_month);
        if (v != null)
            v.setOnClickListener(canvas);

        v = featurePan2_buttons.findViewById(R.id.bt_week);
        if (v != null)
            v.setOnClickListener(canvas);

        v = featurePan2_buttons.findViewById(R.id.bt_day);
        if (v != null)
            v.setOnClickListener(canvas);

        v = featurePan2_buttons.findViewById(R.id.period);
        if (v != null)
            canvas.dates = (TextView) v;

        //background_stats.addView(canvas);
        featurePan2.addView(canvas);
    }

    LL_featurePan.addView(value);
    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 !");
                    try {
                        Tracer.d(mytag, "Try to get value translate from R.STRING");
                        value.setText(
                                Graphics_Manager.getStringIdentifier(getContext(), loc_Value.toLowerCase()));
                    } catch (Exception e1) {
                        Tracer.d(mytag, "Nothing in R.STRING for " + loc_Value);
                        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....   

}

From source file:widgets.Graphical_Binary.java

public Graphical_Binary(tracerengine Trac, Activity context, String address, final String name, int id,
        int dev_id, String state_key, String url, String usage, String parameters, String model_id, int update,
        int widgetSize, int session_type, 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.address = address;
    this.url = url;
    this.state_key = state_key;
    this.usage = usage;
    this.update = update;
    this.myself = this;
    this.session_type = session_type;
    this.stateS = getResources().getText(R.string.State).toString();
    this.place_id = place_id;
    this.place_type = place_type;
    this.params = params;

    mytag = "Graphical_Binary(" + dev_id + ")";
    //get parameters      

    try {//from  ww w  . jav  a  2  s . c o m
        JSONObject jparam = new JSONObject(parameters.replaceAll("&quot;", "\""));
        value0 = jparam.getString("value0");
        value1 = jparam.getString("value1");
    } catch (Exception e) {
        value0 = "0";
        value1 = "1";
    }

    if (usage.equals("light")) {
        this.Value_0 = getResources().getText(R.string.light_stat_0).toString();
        this.Value_1 = getResources().getText(R.string.light_stat_1).toString();
    } else if (usage.equals("shutter")) {
        this.Value_0 = getResources().getText(R.string.shutter_stat_0).toString();
        this.Value_1 = getResources().getText(R.string.shutter_stat_1).toString();
    } else {
        this.Value_0 = value0;
        this.Value_1 = value1;
    }

    String[] model = model_id.split("\\.");
    type = model[0];
    Tracer.d(mytag,
            "model_id = <" + model_id + "> type = <" + type + "> value0 = " + value0 + "  value1 = " + value1);

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

    //first seekbar on/off
    seekBarOnOff = new SeekBar(context);
    seekBarOnOff.setProgress(0);
    seekBarOnOff.setMax(40);
    Bitmap bMap = BitmapFactory.decodeResource(getResources(), R.drawable.bgseekbaronoff);
    seekBarOnOff.setLayoutParams(new LayoutParams(bMap.getWidth(), bMap.getHeight()));
    seekBarOnOff.setProgressDrawable(getResources().getDrawable(R.drawable.bgseekbaronoff));
    seekBarOnOff.setThumb(getResources().getDrawable(R.drawable.buttonseekbar));
    seekBarOnOff.setThumbOffset(0);
    seekBarOnOff.setOnSeekBarChangeListener(this);
    seekBarOnOff.setTag("0");

    super.LL_infoPan.addView(state);
    super.LL_featurePan.addView(seekBarOnOff);

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

    handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            if (activate) {
                Tracer.d(mytag, "Handler receives a request to die ");
                if (realtime) {
                    Tracer.get_engine().unsubscribe(session);
                    session = null;
                    realtime = false;
                }
                //That seems to be a zombie
                //removeView(background);
                myself.setVisibility(GONE);
                if (container != null) {
                    container.removeView(myself);
                    container.recomputeViewAttributes(myself);
                }
                try {
                    finalize();
                } catch (Throwable t) {
                } //kill the handler thread itself
            } else {
                try {
                    Bundle b = msg.getData();
                    if ((b != null) && (b.getString("message") != null)) {
                        if (b.getString("message").equals(value0)) {
                            //state.setText(stateS+value0);
                            state.setText(stateS + Value_0);
                            new SBAnim(seekBarOnOff.getProgress(), 0).execute();
                        } else if (b.getString("message").equals(value1)) {
                            //state.setText(stateS+value1);
                            state.setText(stateS + Value_1);
                            new SBAnim(seekBarOnOff.getProgress(), 40).execute();
                        }
                        state.setAnimation(animation);
                    } else {
                        if (msg.what == 2) {
                            Toast.makeText(getContext(), "Command Failed", Toast.LENGTH_SHORT).show();
                        } else if (msg.what == 9999) {
                            //state_engine send us a signal to notify value changed
                            if (session == null)
                                return;
                            String new_val = session.getValue();
                            Tracer.d(mytag, "Handler receives a new value <" + new_val + ">");
                            if (new_val.equals(value0)) {
                                state.setText(stateS + Value_0);
                                new SBAnim(seekBarOnOff.getProgress(), 0).execute();
                            } else if (new_val.equals(value1)) {
                                state.setText(stateS + Value_1);
                                new SBAnim(seekBarOnOff.getProgress(), 40).execute();
                            } else {
                                state.setText(stateS + new_val);
                                new SBAnim(seekBarOnOff.getProgress(), 0).execute();
                            }
                        } 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(background);
                            myself.setVisibility(GONE);
                            if (container != null) {
                                container.removeView(myself);
                                container.recomputeViewAttributes(myself);
                            }
                            try {
                                finalize();
                            } catch (Throwable t) {
                            } //kill the handler thread itself
                        }
                    }

                } catch (Exception e) {
                    Tracer.e(mytag, "Handler error for device " + name);
                    e.printStackTrace();
                }
            }
        }
    };
    //================================================================================
    /*
     * 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....   

}

From source file:widgets.Graphical_List.java

@SuppressLint("HandlerLeak")
public Graphical_List(tracerengine Trac, Activity context, int id, int dev_id, String name, String type,
        String address, final String state_key, String url, final String usage, int period, int update,
        int widgetSize, int session_type, final String parameters, String model_id, int place_id,
        String place_type, SharedPreferences params) {
    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.address = address;
    //this.type = type;
    this.state_key = state_key;
    this.update = update;
    this.wname = name;
    this.url = url;
    String[] model = model_id.split("\\.");
    this.type = model[0];
    this.place_id = place_id;
    this.place_type = place_type;
    this.params = params;
    packageName = context.getPackageName();
    this.myself = this;
    this.session_type = session_type;
    this.parameters = parameters;
    setOnLongClickListener(this);
    setOnClickListener(this);

    mytag = "Graphical_List (" + dev_id + ")";
    login = params.getString("http_auth_username", null);
    password = params.getString("http_auth_password", null);

    //state key/*from  ww  w  . j ava  2s.  c om*/
    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);

    if (with_list) {
        //Exploit parameters
        JSONObject jparam = null;
        String command;
        JSONArray commandValues = null;
        try {
            jparam = new JSONObject(parameters.replaceAll("&quot;", "\""));
            command = jparam.getString("command");
            commandValues = jparam.getJSONArray("commandValues");
            Tracer.e(mytag, "Json command :" + commandValues);
        } catch (Exception e) {
            command = "";
            commandValues = null;
            Tracer.e(mytag, "Json command error " + e.toString());

        }
        if (commandValues != null) {
            if (commandValues.length() > 0) {
                if (known_values != null)
                    known_values = null;

                known_values = new String[commandValues.length()];
                for (int i = 0; i < commandValues.length(); i++) {
                    try {
                        known_values[i] = commandValues.getString(i);
                    } catch (Exception e) {
                        known_values[i] = "???";
                    }
                }
            }

        }
        //list of choices
        listeChoices = new ListView(context);

        listItem = new ArrayList<HashMap<String, String>>();
        list_usable_choices = new Vector<String>();
        for (int i = 0; i < known_values.length; i++) {
            list_usable_choices.add(getStringResourceByName(known_values[i]));
            HashMap<String, String> map = new HashMap<String, String>();
            map.put("choice", getStringResourceByName(known_values[i]));
            map.put("cmd_to_send", known_values[i]);
            listItem.add(map);

        }

        SimpleAdapter adapter_map = new SimpleAdapter(getContext(), listItem, R.layout.item_choice,
                new String[] { "choice", "cmd_to_send" }, new int[] { R.id.choice, R.id.cmd_to_send });
        listeChoices.setAdapter(adapter_map);
        listeChoices.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if ((position < listItem.size()) && (position > -1)) {
                    //process selected command
                    HashMap<String, String> map = new HashMap<String, String>();
                    map = listItem.get(position);
                    cmd_requested = map.get("cmd_to_send");
                    Tracer.d(mytag,
                            "command selected at Position = " + position + "  Commande = " + cmd_requested);
                    new CommandeThread().execute();
                }
            }
        });

        listeChoices.setScrollingCacheEnabled(false);
        //feature panel 2 which will contain list of selectable choices
        featurePan2 = new LinearLayout(context);
        featurePan2.setLayoutParams(
                new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
        featurePan2.setGravity(Gravity.CENTER_VERTICAL);
        featurePan2.setPadding(5, 10, 5, 10);
        featurePan2.addView(listeChoices);

    }

    LL_featurePan.addView(value);

    handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {

            if (msg.what == 2) {
                Toast.makeText(getContext(), "Command Failed", Toast.LENGTH_SHORT).show();

            } else if (msg.what == 9999) {

                //Message from cache engine
                //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 + ">");
                value.setText(getStringResourceByName(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, "cache 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
            }
        }

    }; //End of handler

    //================================================================================
    /*
     * 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 (tracerengine.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....   

}

From source file:com.javierarboleda.visualtilestogether.activities.SignInActivity.java

private void animateSignInButton(float fromAlpha, float toAlpha, final boolean invisible) {

    final View googleIconImageView = findViewById(R.id.ivGoogleIcon);
    final View signInTextView = findViewById(R.id.tvSignIn);
    final View buttonOutlineView = findViewById(R.id.viewButtonOutline);

    Animation animation = new AlphaAnimation(fromAlpha, toAlpha);
    if (invisible) {
        animation.setDuration(300);/*from   w ww .  j  av  a2s.  c o m*/
        mSignInButton.setIndeterminateProgressMode(true);
        mSignInButton.setProgress(50);
        mSignInButton.setClickable(false);
    } else {
        animation.setDuration(900);
        mSignInButton.setProgress(0);
        mSignInButton.setClickable(true);
    }

    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            if (invisible) {
                googleIconImageView.setVisibility(View.INVISIBLE);
                signInTextView.setVisibility(View.INVISIBLE);
                buttonOutlineView.setVisibility(View.INVISIBLE);
            } else {
                googleIconImageView.setVisibility(View.VISIBLE);
                signInTextView.setVisibility(View.VISIBLE);
                buttonOutlineView.setVisibility(View.VISIBLE);
            }

        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });
    googleIconImageView.startAnimation(animation);
    signInTextView.startAnimation(animation);
    buttonOutlineView.startAnimation(animation);
}

From source file:quickbeer.android.next.activities.base.SearchBarActivity.java

private void setupSearch() {
    adapter = new SearchAdapter(this, getInitialQueriesObservable(), getQueryObservable());
    searchViewOverlay = findViewById(R.id.search_view_overlay);
    searchViewOverlay.setOnTouchListener((view, event) -> {
        if (event.getAction() == MotionEvent.ACTION_UP && searchView.isSearchOpen()) {
            searchView.closeSearch();//from   w  w  w  . ja v a  2s .c  o  m
        }
        return true;
    });

    searchView = (MaterialSearchView) findViewById(R.id.search_view);
    searchView.setHint(getSearchHint());
    searchView.setOnQueryTextListener(new MaterialSearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            Log.d(TAG, "onQueryTextSubmit(" + query + ")");
            if (updateQueryText(query)) {
                searchView.closeSearch();
            }
            return true;
        }

        @Override
        public boolean onQueryTextChange(String query) {
            Log.v(TAG, "onQueryTextChange(" + query + ")");
            if (liveFilteringEnabled()) {
                updateQueryText(query);
            }
            return true;
        }

        private boolean updateQueryText(String query) {
            if (query.length() > minimumSearchLength()) {
                querySubject.onNext(query);
                return true;
            } else {
                showTooShortSearchError();
                return false;
            }
        }
    });

    searchView.setOnSearchViewListener(new MaterialSearchView.SearchViewListener() {
        @Override
        public void onSearchViewAboutToClose() {
        }

        @Override
        public void onSearchViewAboutToShow() {
            Log.d(TAG, "onSearchViewAboutToShow");

            // TODO better subscription handling
            activitySubscription
                    .add(getQueryObservable().first().subscribe(query -> searchView.setQuery(query, false)));

            if (contentOverlayEnabled()) {
                Animation fadeIn = new AlphaAnimation(0.0f, 0.5f);
                fadeIn.setDuration(AnimationUtil.ANIMATION_DURATION_MEDIUM);
                fadeIn.setFillAfter(true);

                searchViewOverlay.setVisibility(View.VISIBLE);
                searchViewOverlay.startAnimation(fadeIn);
            }
        }

        @Override
        public void onSearchViewShown() {
            Log.d(TAG, "onSearchViewShown");

            searchView.setAdapter(adapter);
        }

        @Override
        public void onSearchViewClosed() {
            Log.d(TAG, "onSearchViewClosed");

            searchView.setAdapter(null);
            searchViewOverlay.clearAnimation();
            searchViewOverlay.setVisibility(View.GONE);
        }
    });

    searchView.setOnItemClickListener((parent, view, position, id) -> {
        searchView.closeSearch();
        querySubject.onNext(adapter.getItem(position));
    });
}

From source file:com.capricorn.ArcMenu.java

private static Animation createItemDisapperAnimation(final long duration, final boolean isClicked) {
    AnimationSet animationSet = new AnimationSet(true);
    animationSet.addAnimation(new ScaleAnimation(1.0f, isClicked ? 2.0f : 0.0f, 1.0f, isClicked ? 2.0f : 0.0f,
            Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f));
    animationSet.addAnimation(new AlphaAnimation(1.0f, 0.0f));

    animationSet.setDuration(duration);/*from   www  .ja va2  s  .c o  m*/
    animationSet.setInterpolator(new DecelerateInterpolator());
    animationSet.setFillAfter(true);

    return animationSet;
}

From source file:com.app.jdy.ui.LoginActivity.java

/**
 * //from   w  w w  .  j  av  a 2s. c  o  m
 * @author Owater
 * @createtime 2015-1-13 ?6:05:11
 * @Decription ??
 * 
 */
public void intiAnimation() {
    // 
    // Animation translateAnimation = AnimationUtils.loadAnimation(this,
    // R.anim.translate_username);
    Animation translateAnimation1 = new TranslateAnimation(0, 0, 3000, 0);
    translateAnimation1.setDuration(1200);// ?
    // username_message.startAnimation(translateAnimation1);

    Animation translateAnimation2 = new TranslateAnimation(0, 0, 3000, 0);
    translateAnimation2.setDuration(1400);// ?
    // password_message.startAnimation(translateAnimation2);

    Animation translateAnimation3 = new TranslateAnimation(0, 0, 3000, 0);
    translateAnimation3.setDuration(1600);// ?
    sumbitLogin.startAnimation(translateAnimation3);
    loginOther.startAnimation(translateAnimation3);
    loginWeixin.startAnimation(translateAnimation3);

    Animation translateAnimation4 = new TranslateAnimation(0, 0, 3000, 0);
    translateAnimation4.setDuration(1800);// ?
    find_password.startAnimation(translateAnimation4);
    regirster.startAnimation(translateAnimation4);

    // ??
    // Animation animation =AnimationUtils.loadAnimation(this,
    // R.anim.animation_image_logo);
    Animation animation = new AlphaAnimation(0F, 1.0F);
    animation.setDuration(5000);
    // logoImage.startAnimation(animation);
    animation.startNow();

    /*
     * Animation scaleAnimation = new ScaleAnimation(1.0f, 1.0f, 4.0f, 1.0f,
     * Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 1.0f);
     * scaleAnimation.setDuration(2000);
     * logoImage.startAnimation(scaleAnimation); scaleAnimation.startNow();
     */
}

From source file:de.grobox.liberario.ui.LocationGpsView.java

public void activateGPS() {
    if (searching)
        return;/*from www .  j  av  a 2 s.c  o  m*/

    // check permissions
    if (ContextCompat.checkSelfPermission(getContext(),
            Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        // Should we show an explanation?
        if (ActivityCompat.shouldShowRequestPermissionRationale(activity,
                Manifest.permission.ACCESS_FINE_LOCATION)) {
            Toast.makeText(getContext(), R.string.permission_denied_gps, Toast.LENGTH_LONG).show();
        } else {
            // No explanation needed, we can request the permission
            ActivityCompat.requestPermissions(activity,
                    new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, caller);
        }

        return;
    }

    searching = true;

    List<String> providers = locationManager.getProviders(true);

    for (String provider : providers) {
        // Register the listener with the Location Manager to receive location updates
        locationManager.requestSingleUpdate(provider, this, null);

        Log.d(getClass().getSimpleName(), "Register provider for location updates: " + provider);
    }

    // check if there is a non-passive provider available
    if (providers.size() == 0
            || (providers.size() == 1 && providers.get(0).equals(LocationManager.PASSIVE_PROVIDER))) {
        locationManager.removeUpdates(this);
        Toast.makeText(getContext(), getContext().getString(R.string.error_no_location_provider),
                Toast.LENGTH_LONG).show();

        return;
    }

    // clear input
    setLocation(null, TransportrUtils.getTintedDrawable(getContext(), R.drawable.ic_gps));
    ui.clear.setVisibility(View.VISIBLE);

    // clear current GPS location, because we are looking to find a new one
    gps_location = null;

    // show GPS button blinking
    final Animation animation = new AlphaAnimation(1, 0);
    animation.setDuration(500);
    animation.setInterpolator(new LinearInterpolator());
    animation.setRepeatCount(Animation.INFINITE);
    animation.setRepeatMode(Animation.REVERSE);
    ui.status.startAnimation(animation);

    ui.location.setHint(R.string.stations_searching_position);
    ui.location.clearFocus();

    if (gpsListener != null)
        gpsListener.activateGPS();
}

From source file:org.akvo.caddisfly.sensor.colorimetry.strip.camera.CameraSharedFragmentBase.java

private void hideProgressBar() {
    AlphaAnimation animation = new AlphaAnimation(1f, 0);
    animation.setDuration(PROGRESS_FADE_DURATION_MILLIS);
    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override//from   w  w  w  . ja v  a 2 s  . co  m
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            clearProgress();
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });
    progressBar.startAnimation(animation);
}