List of usage examples for android.view.animation AlphaAnimation AlphaAnimation
public AlphaAnimation(float fromAlpha, float toAlpha)
From source file:com.irccloud.android.activity.MainActivity.java
@Override public void onBufferSelected(int bid) { launchBid = -1;//from www .j ava 2s . c o m launchURI = null; cidToOpen = -1; bufferToOpen = null; setIntent(new Intent(this, MainActivity.class)); if (suggestionsTimerTask != null) suggestionsTimerTask.cancel(); sortedChannels = null; sortedUsers = null; if (drawerLayout != null) { drawerLayout.closeDrawers(); } if (bid != -1 && conn != null && conn.getUserInfo() != null) { conn.getUserInfo().last_selected_bid = bid; } for (int i = 0; i < backStack.size(); i++) { if (buffer != null && backStack.get(i) == buffer.bid) backStack.remove(i); } if (buffer != null && buffer.bid >= 0 && bid != buffer.bid) { backStack.add(0, buffer.bid); buffer.draft = messageTxt.getText().toString(); } if (buffer == null || buffer.bid == -1 || buffer.cid == -1 || buffer.bid == bid) shouldFadeIn = false; else shouldFadeIn = true; buffer = BuffersDataSource.getInstance().getBuffer(bid); if (buffer != null) { Crashlytics.log(Log.DEBUG, "IRCCloud", "Buffer selected: cid" + buffer.cid + " bid" + bid + " shouldFadeIn: " + shouldFadeIn); server = ServersDataSource.getInstance().getServer(buffer.cid); try { TreeMap<Long, EventsDataSource.Event> events = EventsDataSource.getInstance() .getEventsForBuffer(buffer.bid); if (events != null) { events = (TreeMap<Long, EventsDataSource.Event>) events.clone(); for (EventsDataSource.Event e : events.values()) { if (e != null && e.highlight && e.from != null) { UsersDataSource.User u = UsersDataSource.getInstance().getUser(buffer.bid, e.from); if (u != null && u.last_mention < e.eid) u.last_mention = e.eid; } } } } catch (Exception e) { Crashlytics.logException(e); } try { if (Build.VERSION.SDK_INT >= 16 && buffer != null && server != null) { NfcAdapter nfc = NfcAdapter.getDefaultAdapter(this); if (nfc != null) { String uri = "irc"; if (server.ssl > 0) uri += "s"; uri += "://" + server.hostname + ":" + server.port; if (buffer.type.equals("channel")) { uri += "/" + URLEncoder.encode(buffer.name, "UTF-8"); ChannelsDataSource.Channel c = ChannelsDataSource.getInstance() .getChannelForBuffer(buffer.bid); if (c != null && c.hasMode("k")) uri += "," + c.paramForMode("k"); } nfc.setNdefPushMessage(new NdefMessage(NdefRecord.createUri(uri)), this); } } } catch (Exception e) { } } else { Crashlytics.log(Log.DEBUG, "IRCCloud", "Buffer selected but not found: bid" + bid + " shouldFadeIn: " + shouldFadeIn); server = null; } update_subtitle(); final Bundle b = new Bundle(); if (buffer != null) b.putInt("cid", buffer.cid); b.putInt("bid", bid); b.putBoolean("fade", shouldFadeIn); BuffersListFragment blf = (BuffersListFragment) getSupportFragmentManager() .findFragmentById(R.id.BuffersList); final MessageViewFragment mvf = (MessageViewFragment) getSupportFragmentManager() .findFragmentById(R.id.messageViewFragment); UsersListFragment ulf = (UsersListFragment) getSupportFragmentManager() .findFragmentById(R.id.usersListFragment); UsersListFragment ulf2 = (UsersListFragment) getSupportFragmentManager() .findFragmentById(R.id.usersListFragment2); if (mvf != null) mvf.ready = false; if (blf != null) blf.setSelectedBid(bid); if (ulf != null) ulf.setArguments(b); if (ulf2 != null) ulf2.setArguments(b); if (shouldFadeIn) { Crashlytics.log(Log.DEBUG, "IRCCloud", "Fade Out"); if (Build.VERSION.SDK_INT < 16) { AlphaAnimation anim = new AlphaAnimation(1, 0); anim.setDuration(150); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { if (mvf != null) mvf.setArguments(b); messageTxt.setText(""); if (buffer != null && buffer.draft != null) messageTxt.append(buffer.draft); } @Override public void onAnimationRepeat(Animation animation) { } }); try { mvf.getListView().startAnimation(anim); ulf.getListView().startAnimation(anim); } catch (Exception e) { } } else { mvf.getListView().animate().alpha(0).withEndAction(new Runnable() { @Override public void run() { if (mvf != null) mvf.setArguments(b); messageTxt.setText(""); if (buffer != null && buffer.draft != null) messageTxt.append(buffer.draft); } }); ulf.getListView().animate().alpha(0); } mvf.showSpinner(true); } else { if (mvf != null) mvf.setArguments(b); messageTxt.setText(""); if (buffer != null && buffer.draft != null) messageTxt.append(buffer.draft); } updateUsersListFragmentVisibility(); supportInvalidateOptionsMenu(); if (excludeBIDTask != null) excludeBIDTask.cancel(true); excludeBIDTask = new ExcludeBIDTask(); excludeBIDTask.execute(bid); if (drawerLayout != null) new RefreshUpIndicatorTask().execute((Void) null); if (buffer != null && buffer.cid != -1) { if (drawerLayout != null) { drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.LEFT); getSupportActionBar().setHomeButtonEnabled(true); } } update_suggestions(false); }
From source file:com.irccloud.android.activity.MainActivity.java
@Override public void onMessageViewReady() { if (shouldFadeIn) { Crashlytics.log(Log.DEBUG, "IRCCloud", "Fade In"); MessageViewFragment mvf = (MessageViewFragment) getSupportFragmentManager() .findFragmentById(R.id.messageViewFragment); UsersListFragment ulf = (UsersListFragment) getSupportFragmentManager() .findFragmentById(R.id.usersListFragment); if (Build.VERSION.SDK_INT < 16) { AlphaAnimation anim = new AlphaAnimation(0, 1); anim.setDuration(150);/*from w w w . j ava2 s . c o m*/ anim.setFillAfter(true); if (mvf != null && mvf.getListView() != null) mvf.getListView().startAnimation(anim); if (ulf != null && ulf.getListView() != null) ulf.getListView().startAnimation(anim); } else { if (mvf != null && mvf.getListView() != null) mvf.getListView().animate().alpha(1); if (ulf != null && ulf.getListView() != null) ulf.getListView().animate().alpha(1); } if (mvf != null && mvf.getListView() != null) { if (mvf.buffer != buffer && buffer != null && BuffersDataSource.getInstance().getBuffer(buffer.bid) != null) { Bundle b = new Bundle(); b.putInt("cid", buffer.cid); b.putInt("bid", buffer.bid); b.putBoolean("fade", false); mvf.setArguments(b); } mvf.showSpinner(false); } shouldFadeIn = false; } }
From source file:com.xmobileapp.rockplayer.RockPlayer.java
/******************************** * /* www . j ava2 s. co m*/ * switch between different UI modes * ********************************/ public void setNormalView() { if (VIEW_STATE == NORMAL_VIEW) { } else if (VIEW_STATE == LIST_EXPANDED_VIEW) { /* * Animate fading of the current playing layout */ /* * Put album navigator full screen (this will happen in the end of the animation) */ RelativeLayout.LayoutParams params = (LayoutParams) albumNavigatorLayoutOuter.getLayoutParams(); params.addRule(RelativeLayout.RIGHT_OF, R.id.songfest_current_playing_container); albumNavigatorLayoutOuter.setLayoutParams(params); /* * Animate growth of the album navigator */ int slideAmount = currentPlayingLayout.getWidth(); albumNavigatorLayoutOuter.bringToFront(); TranslateAnimation slideRight = new TranslateAnimation(-slideAmount, 0, 0, 0); slideRight.setFillAfter(true); slideRight.setDuration(250); slideRight.setAnimationListener(slideRightAnimationListener); albumNavigatorLayoutOuter.startAnimation(slideRight); } else if (VIEW_STATE == FULLSCREEN_VIEW) { setBackground(); AlphaAnimation fadeOut = new AlphaAnimation(1.0f, 0.0f); fadeOut.setFillAfter(true); fadeOut.setDuration(300); this.mainUIContainer.startAnimation(fadeOut); showFullScreenHandler.sendEmptyMessageDelayed(VIEW_STATE, 300); VIEW_STATE = FULLSCREEN_VIEW; } VIEW_STATE = NORMAL_VIEW; return; }
From source file:com.xmobileapp.rockplayer.RockPlayer.java
public void setFullScreenView() { Log.i("GOGO", "FULL SCREEN"); hideBackground();//from w w w. ja va 2 s. c o m AlphaAnimation fadeOut = new AlphaAnimation(1.0f, 0.0f); fadeOut.setFillAfter(true); fadeOut.setDuration(300); this.mainUIContainer.startAnimation(fadeOut); showFullScreenHandler.sendEmptyMessageDelayed(NORMAL_VIEW, 300); VIEW_STATE = FULLSCREEN_VIEW; if (true) return; /* * Animate fading of the album navigator */ Rotate3dAnimation perspectiveFullLeft = new Rotate3dAnimation(0, 0, // X-axis rotation 90, 90, // Y-axis rotation 0, 0, // Z-axis rotation 100, 100, // rotation center 0.0f, // Z-depth false); //reverse movement perspectiveFullLeft.setFillAfter(true); perspectiveFullLeft.setDuration(1); albumNavigatorList.startAnimation(perspectiveFullLeft); // currentPlayingLayout.startAnimation(perspectiveFullLeft); /* * Put album navigator full screen */ RelativeLayout.LayoutParams params = (LayoutParams) currentPlayingLayout.getLayoutParams(); params.width = RelativeLayout.LayoutParams.FILL_PARENT; currentPlayingLayout.setLayoutParams(params); /* * Animate growth of the current playing layout */ // int fullWidth = display.getWidth(); //// int slideAmount = display.getWidth() - albumNavigatorList.getWidth(); //// TranslateAnimation slideLeft= new TranslateAnimation(slideAmount, 0, 0, 0); // ScaleAnimation scaleAnim = new ScaleAnimation(0.66f, 1.0f, 1.0f, 1.0f); // scaleAnim.setFillAfter(true); // scaleAnim.setDuration(400); // currentPlayingLayout.startAnimation(scaleAnim); //albumNavigatorLayout.setBackgroundColor(Color.WHITE); // // LayoutParams paramsList = (LayoutParams) albumNavigatorList.getLayoutParams(); // paramsList.width = display.getWidth(); // albumNavigatorList.setLayoutParams(paramsList); // currentPlayingLayout.setVisibility(View.GONE); // if(VIEW_STATE == NORMAL_VIEW){ // // // // } else if(VIEW_STATE == LIST_EXPANDED_VIEW) { // // } else if(VIEW_STATE == FULLSCREEN_VIEW){ // // } VIEW_STATE = FULLSCREEN_VIEW; }