List of usage examples for android.widget TextView setAnimation
public void setAnimation(Animation animation)
From source file:org.gots.ui.TabSeedActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { String cameraFilename = savedInstanceState.getString("CAMERA_FILENAME"); if (cameraFilename != null) cameraPicture = new File(cameraFilename); }//from w w w. ja v a2s.co m gotsPurchase = new GotsPurchaseItem(this); GotsAnalytics.getInstance(getApplication()).incrementActivityCount(); GoogleAnalyticsTracker.getInstance().trackPageView(getClass().getSimpleName()); setContentView(R.layout.seed_tab); ActionBar bar = getSupportActionBar(); bar.setDisplayHomeAsUpEnabled(true); // bar.setDisplayShowTitleEnabled(false); getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // ********************** ********************** if (getIntent().getExtras() == null) { Log.e("SeedActivity", "You must provide a org.gots.seed.id as an Extra Int"); finish(); return; } if (getIntent().getExtras().getInt(GOTS_GROWINGSEED_ID) != 0) { int seedId = getIntent().getExtras().getInt(GOTS_GROWINGSEED_ID); mSeed = GotsGrowingSeedManager.getInstance().initIfNew(this).getGrowingSeedById(seedId); } else if (getIntent().getExtras().getInt(GOTS_VENDORSEED_ID) != 0) { int seedId = getIntent().getExtras().getInt(GOTS_VENDORSEED_ID); GotsSeedProvider helper = new LocalSeedProvider(getApplicationContext()); mSeed = (GrowingSeedInterface) helper.getSeedById(seedId); } else mSeed = new GrowingSeed(); // DEFAULT SEED // if (getIntent().getSerializableExtra(GOTS_TASKWORKFLOW_ID) != null) // taskWorkflow = (TaskInfo) getIntent().getSerializableExtra(GOTS_TASKWORKFLOW_ID); pictureGallery = (Gallery) findViewById(R.id.idPictureGallery); displayPictureGallery(); pictureGallery.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) { File f = (File) arg0.getItemAtPosition(position); File dest = new File(gotsPrefs.getGotsExternalFileDir(), f.getName()); try { FileUtilities.copy(f, dest); Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(dest), "image/*"); startActivity(intent); } catch (IOException e) { Log.w(TAG, e.getMessage()); } } }); bar.setTitle(mSeed.getSpecie()); SeedWidgetLong seedWidget = (SeedWidgetLong) findViewById(R.id.IdSeedWidgetLong); seedWidget.setSeed(mSeed); if (mSeed.getDateSowing() != null) { TextView textDateSowing = (TextView) findViewById(R.id.idTextSowingDate); textDateSowing.setText(new SimpleDateFormat().format(mSeed.getDateSowing())); TextView textDateHarvest = (TextView) findViewById(R.id.idTextHarvestDate); if (mSeed.getDateHarvest().getTime() > 0) textDateHarvest.setText(new SimpleDateFormat().format(mSeed.getDateHarvest())); else { Calendar plannedHarvest = Calendar.getInstance(); plannedHarvest.setTime(mSeed.getDateSowing()); plannedHarvest.add(Calendar.DAY_OF_YEAR, mSeed.getDurationMin()); textDateHarvest.setText(new SimpleDateFormat().format(plannedHarvest.getTime())); textDateHarvest.setAnimation(AnimationUtils.loadAnimation(getApplicationContext(), R.anim.tween)); } } else findViewById(R.id.idLayoutCulturePeriod).setVisibility(View.GONE); mViewPager = (ViewPager) findViewById(R.id.pager); TabsAdapter mTabsAdapter = new TabsAdapter(this, mViewPager); // ********************** Tab actions ********************** if (mSeed.getGrowingSeedId() > 0) { mTabsAdapter.addTab( bar.newTab().setTag("event_list").setText(getString(R.string.seed_description_tabmenu_actions)), ListActionActivity.class, null); } // // ********************** Tab description ********************** mTabsAdapter.addTab( bar.newTab().setTag("event_list").setText(getString(R.string.seed_description_tabmenu_detail)), SeedActivity.class, null); // ********************** Tab Wikipedia********************** ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); if (netInfo != null && netInfo.isConnectedOrConnecting()) { mTabsAdapter.addTab(bar.newTab().setTag("event_list") .setText(getString(R.string.seed_description_tabmenu_wikipedia)), WebViewActivity.class, null); urlDescription = "http://" + Locale.getDefault().getLanguage() + ".wikipedia.org/wiki/" + mSeed.getSpecie(); } if (!gotsPurchase.isPremium()) { GotsAdvertisement ads = new GotsAdvertisement(this); LinearLayout layout = (LinearLayout) findViewById(R.id.idAdsTop); layout.addView(ads.getAdsLayout()); } Fragment fragment = new WorkflowTaskFragment(); FragmentManager fragmentManager = getSupportFragmentManager(); fragmentManager.beginTransaction().replace(R.id.frame_workflow, fragment).commit(); }
From source file:com.giovanniterlingen.windesheim.view.Adapters.ScheduleAdapter.java
@Override public void onBindViewHolder(final ViewHolder holder, int position) { final TextView lessonName = holder.lessonName; final TextView lessonTime = holder.lessonTime; final TextView lessonRoom = holder.lessonRoom; final TextView lessonComponent = holder.lessonComponent; final RelativeLayout menuButton = holder.menuButton; final ImageView menuButtonImage = holder.menuButtonImage; final View scheduleIdentifier = holder.scheduleIdentifier; Lesson lesson = this.lessons[position]; long databaseDateStart = Long .parseLong(lesson.getDate().replaceAll("-", "") + lesson.getStartTime().replaceAll(":", "")); long databaseDateEnd = Long .parseLong(lesson.getDate().replaceAll("-", "") + lesson.getEndTime().replaceAll(":", "")); SimpleDateFormat yearMonthDayDateFormat = CalendarController.getInstance().getYearMonthDayDateTimeFormat(); long currentDate = Long.parseLong(yearMonthDayDateFormat.format(new Date())); lessonName.setText(lesson.getSubject()); lessonRoom.setText(lesson.getRoom()); lessonComponent.setText(lesson.getScheduleType() == 2 ? lesson.getClassName() : lesson.getTeacher()); lessonComponent.setSelected(true);//from w w w .j av a 2 s.c o m if (databaseDateStart <= currentDate && databaseDateEnd >= currentDate) { lessonTime.setTextColor(ContextCompat.getColor(activity, R.color.colorAccent)); lessonTime.setText( ApplicationLoader.applicationContext.getResources().getString(R.string.lesson_started)); holder.cardView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Lesson lesson = ScheduleAdapter.this.lessons[holder.getAdapterPosition()]; if (!lessonTime.getText().toString().equals(ApplicationLoader.applicationContext.getResources() .getString(R.string.lesson_started))) { TranslateAnimation 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); lessonTime.setAnimation(animation); lessonTime.setTextColor(ContextCompat.getColor(activity, R.color.colorAccent)); lessonTime.setText(ApplicationLoader.applicationContext.getResources() .getString(R.string.lesson_started)); } else { TranslateAnimation 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); lessonTime.setAnimation(animation); String lessonTimes = lesson.getStartTime() + " - " + lesson.getEndTime(); lessonTime.setTextColor(ContextCompat.getColor(activity, R.color.colorSecondaryText)); lessonTime.setText(lessonTimes); } } }); } else if (databaseDateEnd < currentDate) { lessonTime.setTextColor(ContextCompat.getColor(activity, R.color.colorAccent)); lessonTime.setText(ApplicationLoader.applicationContext.getResources().getString(R.string.finished)); holder.cardView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Lesson lesson = ScheduleAdapter.this.lessons[holder.getAdapterPosition()]; if (!lessonTime.getText().toString().equals( ApplicationLoader.applicationContext.getResources().getString(R.string.finished))) { TranslateAnimation 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); lessonTime.setAnimation(animation); lessonTime.setTextColor(ContextCompat.getColor(activity, R.color.colorAccent)); lessonTime.setText( ApplicationLoader.applicationContext.getResources().getString(R.string.finished)); } else { TranslateAnimation 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); lessonTime.setAnimation(animation); String lessonTimes = lesson.getStartTime() + " - " + lesson.getEndTime(); lessonTime.setTextColor(ContextCompat.getColor(activity, R.color.colorSecondaryText)); lessonTime.setText(lessonTimes); } } }); } else { String lessonTimes = lesson.getStartTime() + " - " + lesson.getEndTime(); lessonTime.setTextColor(ContextCompat.getColor(activity, R.color.colorSecondaryText)); lessonTime.setText(lessonTimes); holder.cardView.setOnClickListener(null); } menuButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { menuButtonImage.setImageDrawable( ResourcesCompat.getDrawable(activity.getResources(), R.drawable.overflow_open, null)); PopupMenu popupMenu = new PopupMenu(activity, menuButton); popupMenu.inflate(R.menu.menu_schedule); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { Lesson lesson = ScheduleAdapter.this.lessons[holder.getAdapterPosition()]; if (item.getItemId() == R.id.hide_lesson) { showPromptDialog(lesson.getSubject()); return true; } if (item.getItemId() == R.id.save_lesson) { showCalendarDialog(lesson.getRowId()); } return true; } }); popupMenu.setOnDismissListener(new PopupMenu.OnDismissListener() { @Override public void onDismiss(PopupMenu menu) { menuButtonImage.setImageDrawable(ResourcesCompat.getDrawable(activity.getResources(), R.drawable.overflow_normal, null)); } }); popupMenu.show(); } }); scheduleIdentifier.setBackgroundColor(ColorController.getInstance().getColorById(lesson.getScheduleId())); }
From source file:com.filemanager.free.activities.MainActivity.java
public void updatePath(@NonNull final String news, boolean results, int openmode, int folder_count, int file_count) { if (news.length() == 0) return;//from w w w .j a v a 2 s. com if (news == null) return; if (openmode == 1 && news.startsWith("smb:/")) newPath = mainActivityHelper.parseSmbPath(news); else if (openmode == 2) newPath = mainActivityHelper.getIntegralNames(news); else newPath = news; final TextView bapath = (TextView) pathbar.findViewById(R.id.fullpath); final TextView animPath = (TextView) pathbar.findViewById(R.id.fullpath_anim); TextView textView = (TextView) pathbar.findViewById(R.id.pathname); if (!results) { textView.setText(folder_count + " " + getResources().getString(R.string.folders) + "" + " " + file_count + " " + getResources().getString(R.string.files)); } else { bapath.setText(R.string.searchresults); textView.setText(R.string.empty); return; } final String oldPath = bapath.getText().toString(); if (null != oldPath && oldPath.equals(newPath)) return; // implement animation while setting text newPathBuilder = new StringBuffer().append(newPath); oldPathBuilder = new StringBuffer().append(oldPath); final Animation slideIn = AnimationUtils.loadAnimation(this, R.anim.slide_in); Animation slideOut = AnimationUtils.loadAnimation(this, R.anim.slide_out); if (newPath.length() > oldPath.length() && newPathBuilder.delete(oldPath.length(), newPath.length()).toString().equals(oldPath) && oldPath.length() != 0) { // navigate forward newPathBuilder.delete(0, newPathBuilder.length()); newPathBuilder.append(newPath); newPathBuilder.delete(0, oldPath.length()); animPath.setAnimation(slideIn); animPath.animate().setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); new Handler().postDelayed(new Runnable() { @Override public void run() { animPath.setVisibility(View.GONE); bapath.setText(newPath); } }, PATH_ANIM_END_DELAY); } @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); animPath.setVisibility(View.VISIBLE); animPath.setText(newPathBuilder.toString()); //bapath.setText(oldPath); scroll.post(new Runnable() { @Override public void run() { scroll1.fullScroll(View.FOCUS_RIGHT); } }); } @Override public void onAnimationCancel(Animator animation) { super.onAnimationCancel(animation); //onAnimationEnd(animation); } }).setStartDelay(PATH_ANIM_START_DELAY).start(); } else if (newPath.length() < oldPath.length() && oldPathBuilder.delete(newPath.length(), oldPath.length()).toString().equals(newPath)) { // navigate backwards oldPathBuilder.delete(0, oldPathBuilder.length()); oldPathBuilder.append(oldPath); oldPathBuilder.delete(0, newPath.length()); animPath.setAnimation(slideOut); animPath.animate().setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); animPath.setVisibility(View.GONE); bapath.setText(newPath); scroll.post(new Runnable() { @Override public void run() { scroll1.fullScroll(View.FOCUS_RIGHT); } }); } @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); animPath.setVisibility(View.VISIBLE); animPath.setText(oldPathBuilder.toString()); bapath.setText(newPath); scroll.post(new Runnable() { @Override public void run() { scroll1.fullScroll(View.FOCUS_LEFT); } }); } }).setStartDelay(PATH_ANIM_START_DELAY).start(); } else if (oldPath.isEmpty()) { // case when app starts // FIXME: COUNTER is incremented twice on app startup COUNTER++; if (COUNTER == 2) { animPath.setAnimation(slideIn); animPath.setText(newPath); animPath.animate().setListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); animPath.setVisibility(View.VISIBLE); bapath.setText(""); scroll.post(new Runnable() { @Override public void run() { scroll1.fullScroll(View.FOCUS_RIGHT); } }); } @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); new Handler().postDelayed(new Runnable() { @Override public void run() { animPath.setVisibility(View.GONE); bapath.setText(newPath); } }, PATH_ANIM_END_DELAY); } @Override public void onAnimationCancel(Animator animation) { super.onAnimationCancel(animation); //onAnimationEnd(animation); } }).setStartDelay(PATH_ANIM_START_DELAY).start(); } } else { // completely different path // first slide out of old path followed by slide in of new path animPath.setAnimation(slideOut); animPath.animate().setListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { super.onAnimationStart(animator); animPath.setVisibility(View.VISIBLE); animPath.setText(oldPath); bapath.setText(""); scroll.post(new Runnable() { @Override public void run() { scroll1.fullScroll(View.FOCUS_LEFT); } }); } @Override public void onAnimationEnd(Animator animator) { super.onAnimationEnd(animator); //animPath.setVisibility(View.GONE); animPath.setText(newPath); bapath.setText(""); animPath.setAnimation(slideIn); animPath.animate().setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); new Handler().postDelayed(new Runnable() { @Override public void run() { animPath.setVisibility(View.GONE); bapath.setText(newPath); } }, PATH_ANIM_END_DELAY); } @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); // we should not be having anything here in path bar animPath.setVisibility(View.VISIBLE); bapath.setText(""); scroll.post(new Runnable() { @Override public void run() { scroll1.fullScroll(View.FOCUS_RIGHT); } }); } }).start(); } @Override public void onAnimationCancel(Animator animation) { super.onAnimationCancel(animation); //onAnimationEnd(animation); } }).setStartDelay(PATH_ANIM_START_DELAY).start(); } }
From source file:com.amaze.filemanager.activities.MainActivity.java
public void updatePath(@NonNull final String news, boolean results, int openmode, int folder_count, int file_count) { if (news.length() == 0) return;//ww w . j a va 2s . c o m if (news == null) return; if (openmode == 1 && news.startsWith("smb:/")) newPath = mainActivityHelper.parseSmbPath(news); else if (openmode == 2) newPath = mainActivityHelper.getIntegralNames(news); else newPath = news; final TextView bapath = (TextView) pathbar.findViewById(R.id.fullpath); final TextView animPath = (TextView) pathbar.findViewById(R.id.fullpath_anim); TextView textView = (TextView) pathbar.findViewById(R.id.pathname); if (!results) { textView.setText(folder_count + " " + getResources().getString(R.string.folders) + "" + " " + file_count + " " + getResources().getString(R.string.files)); } else { bapath.setText(R.string.searchresults); textView.setText(R.string.empty); return; } final String oldPath = bapath.getText().toString(); if (oldPath != null && oldPath.equals(newPath)) return; // implement animation while setting text newPathBuilder = new StringBuffer().append(newPath); oldPathBuilder = new StringBuffer().append(oldPath); final Animation slideIn = AnimationUtils.loadAnimation(this, R.anim.slide_in); Animation slideOut = AnimationUtils.loadAnimation(this, R.anim.slide_out); if (newPath.length() > oldPath.length() && newPathBuilder.delete(oldPath.length(), newPath.length()).toString().equals(oldPath) && oldPath.length() != 0) { // navigate forward newPathBuilder.delete(0, newPathBuilder.length()); newPathBuilder.append(newPath); newPathBuilder.delete(0, oldPath.length()); animPath.setAnimation(slideIn); animPath.animate().setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); new Handler().postDelayed(new Runnable() { @Override public void run() { animPath.setVisibility(View.GONE); bapath.setText(newPath); } }, PATH_ANIM_END_DELAY); } @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); animPath.setVisibility(View.VISIBLE); animPath.setText(newPathBuilder.toString()); //bapath.setText(oldPath); scroll.post(new Runnable() { @Override public void run() { scroll1.fullScroll(View.FOCUS_RIGHT); } }); } @Override public void onAnimationCancel(Animator animation) { super.onAnimationCancel(animation); //onAnimationEnd(animation); } }).setStartDelay(PATH_ANIM_START_DELAY).start(); } else if (newPath.length() < oldPath.length() && oldPathBuilder.delete(newPath.length(), oldPath.length()).toString().equals(newPath)) { // navigate backwards oldPathBuilder.delete(0, oldPathBuilder.length()); oldPathBuilder.append(oldPath); oldPathBuilder.delete(0, newPath.length()); animPath.setAnimation(slideOut); animPath.animate().setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); animPath.setVisibility(View.GONE); bapath.setText(newPath); scroll.post(new Runnable() { @Override public void run() { scroll1.fullScroll(View.FOCUS_RIGHT); } }); } @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); animPath.setVisibility(View.VISIBLE); animPath.setText(oldPathBuilder.toString()); bapath.setText(newPath); scroll.post(new Runnable() { @Override public void run() { scroll1.fullScroll(View.FOCUS_LEFT); } }); } }).setStartDelay(PATH_ANIM_START_DELAY).start(); } else if (oldPath.isEmpty()) { // case when app starts // FIXME: COUNTER is incremented twice on app startup COUNTER++; if (COUNTER == 2) { animPath.setAnimation(slideIn); animPath.setText(newPath); animPath.animate().setListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); animPath.setVisibility(View.VISIBLE); bapath.setText(""); scroll.post(new Runnable() { @Override public void run() { scroll1.fullScroll(View.FOCUS_RIGHT); } }); } @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); new Handler().postDelayed(new Runnable() { @Override public void run() { animPath.setVisibility(View.GONE); bapath.setText(newPath); } }, PATH_ANIM_END_DELAY); } @Override public void onAnimationCancel(Animator animation) { super.onAnimationCancel(animation); //onAnimationEnd(animation); } }).setStartDelay(PATH_ANIM_START_DELAY).start(); } } else { // completely different path // first slide out of old path followed by slide in of new path animPath.setAnimation(slideOut); animPath.animate().setListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { super.onAnimationStart(animator); animPath.setVisibility(View.VISIBLE); animPath.setText(oldPath); bapath.setText(""); scroll.post(new Runnable() { @Override public void run() { scroll1.fullScroll(View.FOCUS_LEFT); } }); } @Override public void onAnimationEnd(Animator animator) { super.onAnimationEnd(animator); //animPath.setVisibility(View.GONE); animPath.setText(newPath); bapath.setText(""); animPath.setAnimation(slideIn); animPath.animate().setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); new Handler().postDelayed(new Runnable() { @Override public void run() { animPath.setVisibility(View.GONE); bapath.setText(newPath); } }, PATH_ANIM_END_DELAY); } @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); // we should not be having anything here in path bar animPath.setVisibility(View.VISIBLE); bapath.setText(""); scroll.post(new Runnable() { @Override public void run() { scroll1.fullScroll(View.FOCUS_RIGHT); } }); } }).start(); } @Override public void onAnimationCancel(Animator animation) { super.onAnimationCancel(animation); //onAnimationEnd(animation); } }).setStartDelay(PATH_ANIM_START_DELAY).start(); } }
From source file:com.amaze.carbonfilemanager.activities.MainActivity.java
public void updatePath(@NonNull final String news, boolean results, OpenMode openmode, int folder_count, int file_count) { if (news.length() == 0) return;// w ww. j a va 2s . c o m switch (openmode) { case SMB: newPath = mainActivityHelper.parseSmbPath(news); break; case OTG: newPath = mainActivityHelper.parseOTGPath(news); break; case CUSTOM: newPath = mainActivityHelper.getIntegralNames(news); break; case DROPBOX: case BOX: case ONEDRIVE: case GDRIVE: newPath = mainActivityHelper.parseCloudPath(openmode, news); break; default: newPath = news; } final TextView bapath = (TextView) pathbar.findViewById(R.id.fullpath); final TextView animPath = (TextView) pathbar.findViewById(R.id.fullpath_anim); TextView textView = (TextView) pathbar.findViewById(R.id.pathname); if (!results) { textView.setText(folder_count + " " + getResources().getString(R.string.folders) + "" + " " + file_count + " " + getResources().getString(R.string.files)); } else { bapath.setText(R.string.searchresults); textView.setText(R.string.empty); return; } final String oldPath = bapath.getText().toString(); if (oldPath.equals(newPath)) return; // implement animation while setting text newPathBuilder = new StringBuffer().append(newPath); oldPathBuilder = new StringBuffer().append(oldPath); final Animation slideIn = AnimationUtils.loadAnimation(this, R.anim.slide_in); Animation slideOut = AnimationUtils.loadAnimation(this, R.anim.slide_out); if (newPath.length() > oldPath.length() && newPathBuilder.delete(oldPath.length(), newPath.length()).toString().equals(oldPath) && oldPath.length() != 0) { // navigate forward newPathBuilder.delete(0, newPathBuilder.length()); newPathBuilder.append(newPath); newPathBuilder.delete(0, oldPath.length()); animPath.setAnimation(slideIn); animPath.animate().setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); new Handler().postDelayed(new Runnable() { @Override public void run() { animPath.setVisibility(View.GONE); bapath.setText(newPath); } }, PATH_ANIM_END_DELAY); } @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); animPath.setVisibility(View.VISIBLE); animPath.setText(newPathBuilder.toString()); //bapath.setText(oldPath); scroll.post(new Runnable() { @Override public void run() { scroll1.fullScroll(View.FOCUS_RIGHT); } }); } @Override public void onAnimationCancel(Animator animation) { super.onAnimationCancel(animation); //onAnimationEnd(animation); } }).setStartDelay(PATH_ANIM_START_DELAY).start(); } else if (newPath.length() < oldPath.length() && oldPathBuilder.delete(newPath.length(), oldPath.length()).toString().equals(newPath)) { // navigate backwards oldPathBuilder.delete(0, oldPathBuilder.length()); oldPathBuilder.append(oldPath); oldPathBuilder.delete(0, newPath.length()); animPath.setAnimation(slideOut); animPath.animate().setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); animPath.setVisibility(View.GONE); bapath.setText(newPath); scroll.post(new Runnable() { @Override public void run() { scroll1.fullScroll(View.FOCUS_RIGHT); } }); } @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); animPath.setVisibility(View.VISIBLE); animPath.setText(oldPathBuilder.toString()); bapath.setText(newPath); scroll.post(new Runnable() { @Override public void run() { scroll1.fullScroll(View.FOCUS_LEFT); } }); } }).setStartDelay(PATH_ANIM_START_DELAY).start(); } else if (oldPath.isEmpty()) { // case when app starts // FIXME: COUNTER is incremented twice on app startup COUNTER++; if (COUNTER == 2) { animPath.setAnimation(slideIn); animPath.setText(newPath); animPath.animate().setListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); animPath.setVisibility(View.VISIBLE); bapath.setText(""); scroll.post(new Runnable() { @Override public void run() { scroll1.fullScroll(View.FOCUS_RIGHT); } }); } @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); new Handler().postDelayed(new Runnable() { @Override public void run() { animPath.setVisibility(View.GONE); bapath.setText(newPath); } }, PATH_ANIM_END_DELAY); } @Override public void onAnimationCancel(Animator animation) { super.onAnimationCancel(animation); //onAnimationEnd(animation); } }).setStartDelay(PATH_ANIM_START_DELAY).start(); } } else { // completely different path // first slide out of old path followed by slide in of new path animPath.setAnimation(slideOut); animPath.animate().setListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { super.onAnimationStart(animator); animPath.setVisibility(View.VISIBLE); animPath.setText(oldPath); bapath.setText(""); scroll.post(new Runnable() { @Override public void run() { scroll1.fullScroll(View.FOCUS_LEFT); } }); } @Override public void onAnimationEnd(Animator animator) { super.onAnimationEnd(animator); //animPath.setVisibility(View.GONE); animPath.setText(newPath); bapath.setText(""); animPath.setAnimation(slideIn); animPath.animate().setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); new Handler().postDelayed(new Runnable() { @Override public void run() { animPath.setVisibility(View.GONE); bapath.setText(newPath); } }, PATH_ANIM_END_DELAY); } @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); // we should not be having anything here in path bar animPath.setVisibility(View.VISIBLE); bapath.setText(""); scroll.post(new Runnable() { @Override public void run() { scroll1.fullScroll(View.FOCUS_RIGHT); } }); } }).start(); } @Override public void onAnimationCancel(Animator animation) { super.onAnimationCancel(animation); //onAnimationEnd(animation); } }).setStartDelay(PATH_ANIM_START_DELAY).start(); } }