List of usage examples for android.widget FrameLayout startAnimation
public void startAnimation(Animation animation)
From source file:com.launcher.silverfish.launcher.appdrawer.TabbedAppDrawerFragment.java
private void showUninstallIndicator() { // Get the layout FrameLayout uninstall_indicator; uninstall_indicator = (FrameLayout) rootView.findViewById(R.id.uninstall_indicator); // Make it visible uninstall_indicator.setVisibility(View.VISIBLE); // And start the animation AlphaAnimation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(500);/* w w w .j a v a2 s. co m*/ uninstall_indicator.startAnimation(animation); }
From source file:com.launcher.silverfish.HomeScreenFragment.java
@SuppressWarnings("deprecation") private void updateShortcuts() { int count = appsList.size(); int size = (int) Math.ceil(Math.sqrt(count)); shortcutLayout.removeAllViews();/* ww w. jav a 2 s . c o m*/ if (size == 0) { size = 1; } // Redraw the layout shortcutLayout.setSize(size); shortcutLayout.requestLayout(); shortcutLayout.invalidate(); for (int i = 0; i < appsList.size(); i++) { final AppDetail app = appsList.get(i); View convertView = getActivity().getLayoutInflater().inflate(R.layout.shortcut_item, null); // load the app icon in an async task ImageView im = (ImageView) convertView.findViewById(R.id.item_app_icon); Utils.loadAppIconAsync(mPacMan, app.name.toString(), im); TextView tv = (TextView) convertView.findViewById(R.id.item_app_label); tv.setText(app.label); shortcutLayout.addView(convertView); convertView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { switch (MotionEventCompat.getActionMasked(event)) { case MotionEvent.ACTION_DOWN: updateTouchDown(event); break; case MotionEvent.ACTION_MOVE: tryConsumeSwipe(event); break; case MotionEvent.ACTION_UP: // We only want to launch the activity if the touch was not consumed yet! if (!touchConsumed) { Intent i = mPacMan.getLaunchIntentForPackage(app.name.toString()); startActivity(i); } break; } return touchConsumed; } }); // start a drag when an app has been long clicked final long appId = app.id; final int appIndex = i; convertView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { String[] mime_types = { ClipDescription.MIMETYPE_TEXT_PLAIN }; ClipData data = new ClipData(Constants.DRAG_SHORTCUT_REMOVAL, mime_types, new ClipData.Item(Long.toString(appId))); data.addItem(new ClipData.Item(Integer.toString(appIndex))); View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder( view.findViewById(R.id.item_app_icon)); // "This method was deprecated in API level 24. Use startDragAndDrop() // for newer platform versions." if (Build.VERSION.SDK_INT < 24) { view.startDrag(data, shadowBuilder, view, 0); } else { view.startDragAndDrop(data, shadowBuilder, view, 0); } // Show removal indicator FrameLayout rem_ind = (FrameLayout) rootView.findViewById(R.id.remove_indicator); rem_ind.setVisibility(View.VISIBLE); AlphaAnimation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(500); rem_ind.startAnimation(animation); return true; } }); } }
From source file:com.launcher.silverfish.launcher.homescreen.HomeScreenFragment.java
@SuppressWarnings("deprecation") private void updateShortcuts() { int count = appsList.size(); int size = (int) Math.ceil(Math.sqrt(count)); shortcutLayout.removeAllViews();//from w w w . j av a 2 s . c o m if (size == 0) { size = 1; } // Redraw the layout shortcutLayout.setSize(size); shortcutLayout.requestLayout(); shortcutLayout.invalidate(); for (int i = 0; i < appsList.size(); i++) { final AppDetail app = appsList.get(i); View convertView = getActivity().getLayoutInflater().inflate(R.layout.shortcut_item, null); // load the app icon in an async task ImageView im = (ImageView) convertView.findViewById(R.id.item_app_icon); Utils.loadAppIconAsync(mPacMan, app.packageName.toString(), im); TextView tv = (TextView) convertView.findViewById(R.id.item_app_label); tv.setText(app.label); shortcutLayout.addView(convertView); convertView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { switch (MotionEventCompat.getActionMasked(event)) { case MotionEvent.ACTION_DOWN: updateTouchDown(event); break; case MotionEvent.ACTION_MOVE: tryConsumeSwipe(event); break; case MotionEvent.ACTION_UP: // We only want to launch the activity if the touch was not consumed yet! if (!touchConsumed) { Intent i = mPacMan.getLaunchIntentForPackage(app.packageName.toString()); if (i != null) { // Sanity check (application may have been uninstalled) // TODO Remove it from the database startActivity(i); } else { Toast.makeText(getContext(), R.string.application_not_installed, Toast.LENGTH_SHORT) .show(); } } break; } return touchConsumed; } }); // start a drag when an app has been long clicked final long appId = app.id; final int appIndex = i; convertView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { String[] mime_types = { ClipDescription.MIMETYPE_TEXT_PLAIN }; ClipData data = new ClipData(Constants.DRAG_SHORTCUT_REMOVAL, mime_types, new ClipData.Item(Long.toString(appId))); data.addItem(new ClipData.Item(Integer.toString(appIndex))); View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder( view.findViewById(R.id.item_app_icon)); // "This method was deprecated in API level 24. Use startDragAndDrop() // for newer platform versions." if (Build.VERSION.SDK_INT < 24) { view.startDrag(data, shadowBuilder, view, 0); } else { view.startDragAndDrop(data, shadowBuilder, view, 0); } // Show removal indicator FrameLayout rem_ind = (FrameLayout) rootView.findViewById(R.id.remove_indicator); rem_ind.setVisibility(View.VISIBLE); AlphaAnimation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(500); rem_ind.startAnimation(animation); return true; } }); } }
From source file:com.example.fragment.PrimitiveFragment.java
public void testAnimation(float destX, float destY) { this.mDestX = Factory.getAdjustedX(destX); this.mDestY = Factory.getAdjustedY(destY); // SELECT LAYER FrameLayout relate = (FrameLayout) mRootView.findViewById(R.id.FLBackLayer); // ScrollView relate = (ScrollView)mRootView.findViewById(R.id.content); // relate.setVisibility(View.VISIBLE); AnimationSet set = new AnimationSet(true); set.setAnimationListener(this); TranslateAnimation translate;// w ww . j a v a 2s. c o m float toX = this.mDestX; float fromX = this.mSrcX; float toY = this.mDestY; float fromY = this.mSrcY; translate = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, fromX, Animation.RELATIVE_TO_PARENT, toX, Animation.RELATIVE_TO_PARENT, fromY, Animation.RELATIVE_TO_PARENT, toY); translate.setDuration(Constants.Animation.IPF_START); translate.setInterpolator(new AccelerateInterpolator()); set.addAnimation(translate); set.setFillBefore(true); // set.setFillBefore(false); // set.setFillAfter(false); set.setFillAfter(true); relate.startAnimation(set); }
From source file:com.example.fragment.PrimitiveFragment.java
public void move(float destX, float destY) { if (!this.mIsAlive) return;/*w ww . j a va 2 s . com*/ if (this.mIsMoving) { return;// ADD Array } this.mDestX = Factory.getAdjustedX(destX - this.mPaddingW); this.mDestY = Factory.getAdjustedY(destY - this.mPaddingH); // SELECT LAYER FrameLayout relate = (FrameLayout) mRootView.findViewById(R.id.FLBackLayer); // ScrollView relate = (ScrollView)mRootView.findViewById(R.id.content); // relate.setVisibility(View.VISIBLE); AnimationSet set = new AnimationSet(true); set.setAnimationListener(this); TranslateAnimation translate; float toX = this.mDestX; float fromX = this.mSrcX; float toY = this.mDestY; float fromY = this.mSrcY; translate = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, fromX, Animation.RELATIVE_TO_PARENT, toX, Animation.RELATIVE_TO_PARENT, fromY, Animation.RELATIVE_TO_PARENT, toY); translate.setDuration(Constants.Animation.IPF); translate.setInterpolator(new AccelerateInterpolator()); set.addAnimation(translate); set.setFillBefore(true); // set.setFillBefore(false); // set.setFillAfter(false); set.setFillAfter(true); relate.startAnimation(set); this.mIsMoving = true; this.mIsMove = true; }
From source file:com.watasan.infospider.fragment.PrimitiveFragment.java
/** SCRIPT ACTION AREA --------------------------------------------------> */ public void testAnimation(float destX, float destY) { this.mDestX = Factory.getAdjustedX(destX); this.mDestY = Factory.getAdjustedY(destY); // SELECT LAYER FrameLayout relate = (FrameLayout) mRootView.findViewById(R.id.FLBackLayer); // ScrollView relate = (ScrollView)mRootView.findViewById(R.id.content); // relate.setVisibility(View.VISIBLE); AnimationSet set = new AnimationSet(true); set.setAnimationListener(this); TranslateAnimation translate;//from www . j a v a 2s .c o m float toX = this.mDestX; float fromX = this.mSrcX; float toY = this.mDestY; float fromY = this.mSrcY; translate = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, fromX, Animation.RELATIVE_TO_PARENT, toX, Animation.RELATIVE_TO_PARENT, fromY, Animation.RELATIVE_TO_PARENT, toY); translate.setDuration(Constants.Animation.IPF_START); translate.setInterpolator(new AccelerateInterpolator()); set.addAnimation(translate); set.setFillBefore(true); // set.setFillBefore(false); // set.setFillAfter(false); set.setFillAfter(true); relate.startAnimation(set); }
From source file:de.gebatzens.ggvertretungsplan.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { setTheme(GGApp.GG_APP.provider.getTheme()); super.onCreate(savedInstanceState); GGApp.GG_APP.activity = this; savedState = savedInstanceState;/*from w w w .java 2 s . co m*/ Intent intent = getIntent(); if (intent != null && intent.getStringExtra("fragment") != null) { GGApp.FragmentType type = GGApp.FragmentType.valueOf(intent.getStringExtra("fragment")); GGApp.GG_APP.setFragmentType(type); } mStrings = new String[] { getResources().getString(R.string.substitutionplan), getResources().getString(R.string.news), getResources().getString(R.string.cafeteria), getResources().getString(R.string.exams) }; NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.cancel(123); setContentView(getLayoutInflater().inflate(R.layout.activity_main, null)); removeAllFragments(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); mContent = createFragment(); transaction.replace(R.id.content_fragment, mContent, "gg_content_fragment"); transaction.commit(); if (GGApp.GG_APP.getDataForFragment(GGApp.GG_APP.getFragmentType()) == null) GGApp.GG_APP.refreshAsync(null, true, GGApp.GG_APP.getFragmentType()); mToolbar = (Toolbar) findViewById(R.id.toolbar); mToolbar.setBackgroundColor(GGApp.GG_APP.provider.getColor()); mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { if (menuItem.getItemId() == R.id.action_refresh) { ((SwipeRefreshLayout) mContent.getView().findViewById(R.id.refresh)).setRefreshing(true); GGApp.GG_APP.refreshAsync(new Runnable() { @Override public void run() { ((SwipeRefreshLayout) mContent.getView().findViewById(R.id.refresh)) .setRefreshing(false); } }, true, GGApp.GG_APP.getFragmentType()); } else if (menuItem.getItemId() == R.id.action_settings) { Intent i = new Intent(MainActivity.this, SettingsActivity.class); startActivityForResult(i, 1); } return false; } }); mToolbar.setTitle(GGApp.GG_APP.provider.getFullName()); mToolbar.setSubtitle( mStrings[Arrays.asList(GGApp.FragmentType.values()).indexOf(GGApp.GG_APP.getFragmentType())]); mToolbar.inflateMenu(R.menu.toolbar_menu); mToolbar.setTitleTextColor(Color.WHITE); mToolbar.setSubtitleTextColor(Color.WHITE); ((TextView) findViewById(R.id.drawer_image_text)).setText(GGApp.GG_APP.provider.getFullName()); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { GGApp.GG_APP.setStatusBarColorTransparent(getWindow()); mDrawerLayout.setStatusBarBackgroundColor(GGApp.GG_APP.provider.getDarkColor()); } mToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.drawer_open, R.string.drawer_close) { /** Called when a drawer has settled in a completely closed state. */ public void onDrawerClosed(View view) { super.onDrawerClosed(view); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } /** Called when a drawer has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; mNacvigationImage = (ImageView) findViewById(R.id.navigation_schoolpicture); mNacvigationImage.setImageResource(GGApp.GG_APP.provider.getImage()); mNavigationSchoolpictureLink = (View) findViewById(R.id.navigation_schoolpicture_link); mNavigationSchoolpictureLink.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View viewIn) { mDrawerLayout.closeDrawers(); Intent linkIntent = new Intent(Intent.ACTION_VIEW); linkIntent.setData(Uri.parse(GGApp.GG_APP.provider.getWebsite())); startActivity(linkIntent); } }); mDrawerLayout.setDrawerListener(mToggle); mDrawerList = (ListView) findViewById(R.id.left_drawer); //ArrayAdapter<String> aa = new ArrayAdapter<String>(this, R.layout.drawer_list_item, mStrings); NavigationListAdapter aa = new NavigationListAdapter(this, mStrings, mIcons); mDrawerList.setAdapter(aa); mDrawerList.setItemChecked( Arrays.asList(GGApp.FragmentType.values()).indexOf(GGApp.GG_APP.getFragmentType()), true); mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (GGApp.GG_APP.getFragmentType() != GGApp.FragmentType.values()[position]) { GGApp.GG_APP.setFragmentType(GGApp.FragmentType.values()[position]); mDrawerLayout.closeDrawers(); mToolbar.setSubtitle(mStrings[position]); mContent = createFragment(); Animation fadeOut = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_out); fadeOut.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { // Called when the Animation starts } @Override public void onAnimationEnd(Animation animation) { FrameLayout contentFrame = (FrameLayout) findViewById(R.id.content_fragment); contentFrame.setVisibility(View.INVISIBLE); if (GGApp.GG_APP.getDataForFragment(GGApp.GG_APP.getFragmentType()) == null) GGApp.GG_APP.refreshAsync(null, true, GGApp.GG_APP.getFragmentType()); removeAllFragments(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.content_fragment, mContent, "gg_content_fragment"); transaction.commit(); } @Override public void onAnimationRepeat(Animation animation) { // This is called each time the Animation repeats } }); FrameLayout contentFrame = (FrameLayout) findViewById(R.id.content_fragment); contentFrame.startAnimation(fadeOut); } else { mDrawerLayout.closeDrawers(); } } }); ListviewHelper.getListViewSize(mDrawerList); /*mDrawerFirstUse = (TextView) findViewById(R.id.left_drawer_firstuse); mDrawerFirstUse.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View viewIn) { mDrawerLayout.closeDrawers(); Intent i = new Intent(MainActivity.this, FirstUseActivity.class); startActivityForResult(i, 1); } });*/ mDrawerSettings = (TextView) findViewById(R.id.left_drawer_settings); mDrawerSettings.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View viewIn) { mDrawerLayout.closeDrawers(); Intent i = new Intent(MainActivity.this, SettingsActivity.class); startActivityForResult(i, 1); } }); //wait for vps new AsyncTask<Object, Void, Void>() { @Override protected Void doInBackground(Object... params) { boolean b = true; while (b) { switch (GGApp.GG_APP.getFragmentType()) { case PLAN: b = GGApp.GG_APP.plans == null; break; case NEWS: b = GGApp.GG_APP.news == null; break; case MENSA: b = GGApp.GG_APP.mensa == null; break; case EXAMS: b = GGApp.GG_APP.exams == null; break; } } return null; } }.execute(); }
From source file:de.gebatzens.sia.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { setTheme(SIAApp.SIA_APP.school.getTheme()); super.onCreate(savedInstanceState); Log.w("ggvp", "CREATE NEW MAINACTIVITY"); //Debug.startMethodTracing("sia3"); SIAApp.SIA_APP.activity = this; savedState = savedInstanceState;//from w w w. ja v a2 s . c o m final FragmentData.FragmentList fragments = SIAApp.SIA_APP.school.fragments; Intent intent = getIntent(); if (intent != null && intent.getStringExtra("fragment") != null) { FragmentData frag = fragments .getByType(FragmentData.FragmentType.valueOf(intent.getStringExtra("fragment"))).get(0); SIAApp.SIA_APP.setFragmentIndex(fragments.indexOf(frag)); } if (intent != null && intent.getBooleanExtra("reload", false)) { SIAApp.SIA_APP.refreshAsync(null, true, fragments.get(SIAApp.SIA_APP.getFragmentIndex())); intent.removeExtra("reload"); } setContentView(R.layout.activity_main); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); mContent = getFragment(); transaction.replace(R.id.content_fragment, mContent, "gg_content_fragment"); transaction.commit(); Log.d("ggvp", "DATA: " + fragments.get(SIAApp.SIA_APP.getFragmentIndex()).getData()); if (fragments.get(SIAApp.SIA_APP.getFragmentIndex()).getData() == null) SIAApp.SIA_APP.refreshAsync(null, true, fragments.get(SIAApp.SIA_APP.getFragmentIndex())); if ("Summer".equals(SIAApp.SIA_APP.getCurrentThemeName())) { ImageView summerNavigationPalm = (ImageView) findViewById(R.id.summer_navigation_palm); summerNavigationPalm.setImageResource(R.drawable.summer_palm); ImageView summerBackgroundImage = (ImageView) findViewById(R.id.summer_background_image); summerBackgroundImage.setImageResource(R.drawable.summer_background); } mToolBar = (Toolbar) findViewById(R.id.toolbar); mToolBar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.action_refresh: ((SwipeRefreshLayout) mContent.getView().findViewById(R.id.refresh)).setRefreshing(true); SIAApp.SIA_APP.refreshAsync(new Runnable() { @Override public void run() { ((SwipeRefreshLayout) mContent.getView().findViewById(R.id.refresh)) .setRefreshing(false); } }, true, fragments.get(SIAApp.SIA_APP.getFragmentIndex())); return true; case R.id.action_settings: Intent i = new Intent(MainActivity.this, SettingsActivity.class); startActivityForResult(i, 1); return true; case R.id.action_addToCalendar: showExamDialog(); return true; case R.id.action_help: AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setTitle(getApplication().getString(R.string.help)); builder.setMessage(getApplication().getString(R.string.exam_explain)); builder.setPositiveButton(getApplication().getString(R.string.close), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.create().show(); return true; } return false; } }); updateToolbar(SIAApp.SIA_APP.school.name, fragments.get(SIAApp.SIA_APP.getFragmentIndex()).name); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { SIAApp.SIA_APP.setStatusBarColorTransparent(getWindow()); // because of the navigation drawer } mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolBar, R.string.drawer_open, R.string.drawer_close) { /** Called when a drawer has settled in a completely closed state. */ public void onDrawerClosed(View view) { super.onDrawerClosed(view); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } /** Called when a drawer has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; mDrawerLayout.addDrawerListener(mDrawerToggle); navigationView = (NavigationView) findViewById(R.id.navigation_view); mNavigationHeader = navigationView.getHeaderView(0); mNavigationSchoolpictureText = (TextView) mNavigationHeader.findViewById(R.id.drawer_image_text); mNavigationSchoolpictureText.setText(SIAApp.SIA_APP.school.name); mNavigationSchoolpicture = (ImageView) mNavigationHeader.findViewById(R.id.navigation_schoolpicture); mNavigationSchoolpicture.setImageBitmap(SIAApp.SIA_APP.school.loadImage()); mNavigationSchoolpictureLink = mNavigationHeader.findViewById(R.id.navigation_schoolpicture_link); mNavigationSchoolpictureLink.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View viewIn) { mDrawerLayout.closeDrawers(); Intent linkIntent = new Intent(Intent.ACTION_VIEW); linkIntent.setData(Uri.parse(SIAApp.SIA_APP.school.website)); startActivity(linkIntent); } }); final Menu menu = navigationView.getMenu(); menu.clear(); for (int i = 0; i < fragments.size(); i++) { MenuItem item = menu.add(R.id.fragments, Menu.NONE, i, fragments.get(i).name); item.setIcon(fragments.get(i).getIconRes()); } menu.add(R.id.settings, R.id.settings_item, fragments.size(), R.string.settings); menu.setGroupCheckable(R.id.fragments, true, true); menu.setGroupCheckable(R.id.settings, false, false); final Menu navMenu = navigationView.getMenu(); selectedItem = SIAApp.SIA_APP.getFragmentIndex(); if (selectedItem != -1) navMenu.getItem(selectedItem).setChecked(true); navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { if (menuItem.getItemId() == R.id.settings_item) { mDrawerLayout.closeDrawers(); Intent i = new Intent(MainActivity.this, SettingsActivity.class); startActivityForResult(i, 1); } else { final int index = menuItem.getOrder(); if (SIAApp.SIA_APP.getFragmentIndex() != index) { SIAApp.SIA_APP.setFragmentIndex(index); menuItem.setChecked(true); updateToolbar(SIAApp.SIA_APP.school.name, menuItem.getTitle().toString()); mContent = getFragment(); Animation fadeOut = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_out); fadeOut.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { FrameLayout contentFrame = (FrameLayout) findViewById(R.id.content_fragment); contentFrame.setVisibility(View.INVISIBLE); if (fragments.get(index).getData() == null) SIAApp.SIA_APP.refreshAsync(null, true, fragments.get(index)); //removeAllFragments(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.content_fragment, mContent, "gg_content_fragment"); transaction.commit(); snowView.updateSnow(); } @Override public void onAnimationRepeat(Animation animation) { } }); FrameLayout contentFrame = (FrameLayout) findViewById(R.id.content_fragment); contentFrame.startAnimation(fadeOut); mDrawerLayout.closeDrawers(); } else { mDrawerLayout.closeDrawers(); } } return true; } }); if (Build.VERSION.SDK_INT >= 25) { ShortcutManager shortcutManager = getSystemService(ShortcutManager.class); shortcutManager.removeAllDynamicShortcuts(); for (int i = 0; i < fragments.size(); i++) { Drawable drawable = getDrawable(fragments.get(i).getIconRes()); Bitmap icon; if (drawable instanceof VectorDrawable) { icon = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(icon); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.draw(canvas); } else { icon = BitmapFactory.decodeResource(getResources(), fragments.get(i).getIconRes()); } Bitmap connectedIcon = Bitmap.createBitmap(icon.getWidth(), icon.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(connectedIcon); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(Color.parseColor("#f5f5f5")); canvas.drawCircle(icon.getWidth() / 2, icon.getHeight() / 2, icon.getWidth() / 2, paint); paint.setColorFilter( new PorterDuffColorFilter(SIAApp.SIA_APP.school.getColor(), PorterDuff.Mode.SRC_ATOP)); canvas.drawBitmap(icon, null, new RectF(icon.getHeight() / 4.0f, icon.getHeight() / 4.0f, icon.getHeight() - icon.getHeight() / 4.0f, icon.getHeight() - icon.getHeight() / 4.0f), paint); Intent newTaskIntent = new Intent(this, MainActivity.class); newTaskIntent.setAction(Intent.ACTION_MAIN); newTaskIntent.putExtra("fragment", fragments.get(i).type.toString()); ShortcutInfo shortcut = new ShortcutInfo.Builder(this, fragments.get(i).name) .setShortLabel(fragments.get(i).name).setLongLabel(fragments.get(i).name) .setIcon(Icon.createWithBitmap(connectedIcon)).setIntent(newTaskIntent).build(); shortcutManager.addDynamicShortcuts(Arrays.asList(shortcut)); } } if (SIAApp.SIA_APP.preferences.getBoolean("app_130_upgrade", true)) { if (!SIAApp.SIA_APP.preferences.getBoolean("first_use_filter", true)) { TextDialog.newInstance(R.string.upgrade1_3title, R.string.upgrade1_3) .show(getSupportFragmentManager(), "upgrade_dialog"); } SIAApp.SIA_APP.preferences.edit().putBoolean("app_130_upgrade", false).apply(); } snowView = (SnowView) findViewById(R.id.snow_view); shareToolbar = (Toolbar) findViewById(R.id.share_toolbar); shareToolbar.getMenu().clear(); shareToolbar.inflateMenu(R.menu.share_toolbar_menu); shareToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { toggleShareToolbar(false); for (Shareable s : MainActivity.this.shared) { s.setMarked(false); } MainActivity.this.shared.clear(); mContent.updateFragment(); } }); shareToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { toggleShareToolbar(false); HashMap<Date, ArrayList<Shareable>> dates = new HashMap<Date, ArrayList<Shareable>>(); for (Shareable s : MainActivity.this.shared) { ArrayList<Shareable> list = dates.get(s.getDate()); if (list == null) { list = new ArrayList<Shareable>(); dates.put(s.getDate(), list); } list.add(s); s.setMarked(false); } MainActivity.this.shared.clear(); List<Date> dateList = new ArrayList<Date>(dates.keySet()); Collections.sort(dateList); String content = ""; for (Date key : dateList) { content += SubstListAdapter.translateDay(key) + "\n\n"; Collections.sort(dates.get(key)); for (Shareable s : dates.get(key)) { content += s.getShareContent() + "\n"; } content += "\n"; } content = content.substring(0, content.length() - 1); mContent.updateFragment(); if (item.getItemId() == R.id.action_copy) { ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText(getString(R.string.entries), content); clipboard.setPrimaryClip(clip); } else if (item.getItemId() == R.id.action_share) { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, content); sendIntent.setType("text/plain"); startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to))); } return true; } }); if (shared.size() > 0) { shareToolbar.setVisibility(View.VISIBLE); updateShareToolbarText(); } // if a fragment is opened via a notification or a shortcut reset the shared entries // delete extra fragment because the same intent is used when the device gets rotated and the user could have opened a new fragment if (intent != null && intent.hasExtra("fragment")) { resetShareToolbar(); intent.removeExtra("fragment"); } }
From source file:org.numixproject.hermes.activity.ConversationActivity.java
private void showConversationLayout() { // get the final radius for the clipping circle int finalRadius = Math.max(roomsLayout.getWidth(), roomsLayout.getHeight()); final FrameLayout colorLayout = (FrameLayout) findViewById(R.id.colorLayout); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // create the animator for this view (the start radius is zero) Animator colorAnim;/*from w ww . j ava 2 s .co m*/ colorAnim = ViewAnimationUtils.createCircularReveal(colorLayout, (int) roomsLayout.getLeft(), (int) roomsLayout.getTop(), 0, finalRadius); final AlphaAnimation fadeAnim = new AlphaAnimation(1.0f, 0.0f); fadeAnim.setDuration(250); fadeAnim.setInterpolator(new AccelerateInterpolator()); fadeAnim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { conversationLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) { colorLayout.setVisibility(View.GONE); invalidateOptionsMenu(); } @Override public void onAnimationRepeat(Animation animation) { } }); colorAnim.setInterpolator(new AccelerateInterpolator()); colorAnim.addListener(new android.animation.Animator.AnimatorListener() { @Override public void onAnimationStart(android.animation.Animator animation) { } @Override public void onAnimationRepeat(android.animation.Animator animation) { } @Override public void onAnimationEnd(android.animation.Animator animation) { colorLayout.startAnimation(fadeAnim); } @Override public void onAnimationCancel(android.animation.Animator animation) { } }); colorLayout.setVisibility(View.VISIBLE); colorAnim.start(); } else { conversationLayout.setVisibility(View.VISIBLE); conversationLayout.setAlpha(0.f); conversationLayout.setScaleX(0.f); conversationLayout.setScaleY(0.f); conversationLayout.animate().alpha(1.f).scaleX(1.f).scaleY(1.f).setDuration(300).start(); } }
From source file:com.zoffcc.applications.zanavi.Navit.java
static void animate_bottom_bar_down() { final FrameLayout a = (FrameLayout) Global_Navit_Object.findViewById(R.id.bottom_bar_slide); // System.out.println("FRAG:animate_bottom_bar_down:014"); // set bottom end positon correctly?? bottom_y_margin_bottom_bar_touch = Navit.map_view_height + Navit.actionBarHeight + bottom_bar_px - Navit.bottom_bar_slider_shadow_px; final int move_by = (int) (bottom_y_margin_bottom_bar_touch - cur_y_margin_bottom_bar_touch); TranslateAnimation animation = new TranslateAnimation(0, 0, 0, move_by); // new TranslateAnimation(xFrom,xTo, yFrom,yTo) animation.setDuration(bottom_bar_snap_duration); // animation duration animation.setFillAfter(true);//from w w w .j a v a2 s.com animation.setFillEnabled(true); animation.setRepeatCount(0); // animation repeat count animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { // set bottom end positon correctly?? bottom_y_margin_bottom_bar_touch = Navit.map_view_height + Navit.actionBarHeight + bottom_bar_px - Navit.bottom_bar_slider_shadow_px; cur_y_margin_bottom_bar_touch = bottom_y_margin_bottom_bar_touch; RelativeLayout.LayoutParams relativeParams = (RelativeLayout.LayoutParams) a.getLayoutParams(); relativeParams.setMargins(0, (int) bottom_y_margin_bottom_bar_touch, 0, 0); // left, top, right, bottom a.setLayoutParams(relativeParams); a.requestLayout(); TranslateAnimation anim = new TranslateAnimation(0, 0, 0, 0); anim.setFillAfter(true); anim.setFillEnabled(true); anim.setDuration(1); a.startAnimation(anim); // remove roadbook fragment ----------- try { if (road_book != null) { FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); // System.out.println("FRAG:dettach:002"); fragmentTransaction.detach(road_book); fragmentTransaction.remove(road_book).commit(); road_book = null; } } catch (Exception ef) { } // remove roadbook fragment ----------- } }); a.startAnimation(animation); }