List of usage examples for android.widget TextView getText
@ViewDebug.CapturedViewProperty
public CharSequence getText()
From source file:com.zen.androidhtmleditor.AHEActivity.java
@SuppressLint("NewApi") @Override// w w w. ja v a 2 s . co m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); setContentView(R.layout.main); SystemBarTintManager tintManager = new SystemBarTintManager(this); // enable status bar tint tintManager.setStatusBarTintEnabled(true); tintManager.setTintColor(Color.parseColor("#4acab4")); SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); Settings.init(settings); //Uncomment this for non Market installs. This will allow version checking. //new Version(this,getVersionName(this,DeveloperToolsActivity.class),"http://androidhtmleditor.com/version.php").execute(); deviceId = Secure.getString(this.getContentResolver(), Secure.ANDROID_ID); getOverflowMenu(); getActionBar().setIcon(R.drawable.icon_white); tabactivity = (TabActivity) this; tabHost = tabactivity.getTabHost(); hsv = (HorizontalScrollView) tabactivity.findViewById(R.id.topmenu); mLicenseCheckerCallback = new MyLicenseCheckerCallback(); mChecker = new LicenseChecker(this, new ServerManagedPolicy(this, new AESObfuscator(SALT, getPackageName(), deviceId)), BASE64_PUBLIC_KEY // Your public licensing key. ); mHandler = new Handler(); // doCheck(); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (LinearLayout) findViewById(R.id.l1); // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description for accessibility */ R.string.drawer_close /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { getActionBar().setTitle("File(s)"); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } public void onDrawerOpened(View drawerView) { getActionBar().setTitle("Server"); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; mDrawerLayout.setDrawerListener(mDrawerToggle); Button button1 = (Button) findViewById(R.id.button1); button1.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { onButtonClickEvent(v); } }); Button disconnect_button = (Button) findViewById(R.id.disconnect_button); disconnect_button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { disconnect(); } }); /* Button button2 = (Button)findViewById(R.id.button2); button2.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { hsv.setVisibility(View.GONE); v.setVisibility(View.GONE); RelativeLayout rl = (RelativeLayout)v.getParent(); Button button1 = (Button)findViewById(R.id.button1); button1.setVisibility(View.VISIBLE); Button button3 = (Button)findViewById(R.id.button3); button3.setVisibility(View.VISIBLE); ImageView logo = (ImageView)findViewById(R.id.logo); logo.setVisibility(View.VISIBLE); TextView slogan = (TextView)findViewById(R.id.appSlogan); slogan.setVisibility(View.VISIBLE); ScrollView frontLayout = (ScrollView)findViewById(R.id.front); frontLayout.setVisibility(View.VISIBLE); TextView appTitle = (TextView)findViewById(R.id.appTitle); appTitle.setVisibility(View.VISIBLE); Button backButton = (Button)rl.findViewById(R.id.backButton); backButton.setVisibility(View.GONE); arrayAdapter.clear(); arrayAdapter.notifyDataSetChanged(); TextView pathInfo = (TextView)rl.findViewById(R.id.path); pathInfo.setText(""); folderPath = ""; //new MyFetchTask("zenstudio.com.au", "zenstudi", ".-x$%Wmd5b#C","folder",folderPath).execute(); connectedTo = -1; Toast.makeText(AHEActivity.this, "Disconnected", Toast.LENGTH_SHORT).show(); } });*/ Button button3 = (Button) findViewById(R.id.button3); button3.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent SettingsIntent = new Intent(AHEActivity.this, Settings.class); startActivity(SettingsIntent); } }); /*Button backButton = (Button)findViewById(R.id.backButton); backButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String[] pathBits = folderPath.split("/"); folderPath = ""; for(int i=0;i<pathBits.length-1;i++){ folderPath += pathBits[i]+"/"; } arrayAdapter.clear(); //connectedTo SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); String currentServers = settings.getString("Accounts", ""); if(currentServers.equals("")){}else{ Gson gson = new Gson(); SearchResponse response = gson.fromJson(currentServers, SearchResponse.class); List<Result> results = response.data; Result l = results.get(connectedTo); if(l.serverName!="" && l.userName!="" && l.port.trim()!=""){ if(l.sftp.equals("0") || l.sftp.equals("1") || l.sftp.equals("2")){ new MyFetchTask(l.serverName, l.userName, l.passWord,"folder",folderPath,l.sftp,l.port).execute(); }else if(l.sftp.equals("3")){ new FetchSSLTask(l.serverName, l.userName, l.passWord,"folder",folderPath,l.sftp,l.port).execute(); } } } } });*/ TextView pathInfo = (TextView) findViewById(R.id.path); pathInfo.setText(folderPath); lstTest = (ListView) findViewById(R.id.list); // lstTest.setDividerHeight(10); lstTest.setPadding(0, 5, 0, 5); alrts = new ArrayList<String[]>(); arrayAdapter = new FetchAdapter(AHEActivity.this, R.layout.listitems, alrts); lstTest.setAdapter(arrayAdapter); lstTest.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> av, View v, int pos, long id) { final View d = v; final CharSequence[] items = { "Delete", "Rename", "Chmod", "Download" }; TextView t = (TextView) v.findViewById(R.id.fileFolderName); final String oldName = t.getText().toString(); final int position = pos; AlertDialog.Builder builder = new AlertDialog.Builder(AHEActivity.this); builder.setTitle("Choose Action"); builder.setItems(items, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { if (item == 0) { AlertDialog.Builder dbuilder = new AlertDialog.Builder(AHEActivity.this); dbuilder.setMessage("Delete this file?").setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { deleteFile(d); dialog.cancel(); } }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog dalert = dbuilder.create(); dalert.show(); } else if (item == 1) { final Dialog renameDialog = new Dialog(AHEActivity.this); renameDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); renameDialog.setContentView(R.layout.renamediag); renameDialog.setCancelable(true); Button closeServer = (Button) renameDialog.findViewById(R.id.closeServer); closeServer.setOnClickListener(new OnClickListener() { public void onClick(View v) { renameDialog.cancel(); } }); Button saveServer = (Button) renameDialog.findViewById(R.id.saveServer); saveServer.setOnClickListener(new OnClickListener() { public void onClick(View v) { EditText themeUrl = (EditText) renameDialog.findViewById(R.id.themeLink); String newName = themeUrl.getText().toString(); //connectedTo SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); String currentServers = settings.getString("Accounts", ""); if (currentServers.equals("")) { } else { Gson gson = new Gson(); SearchResponse response = gson.fromJson(currentServers, SearchResponse.class); List<Result> results = response.data; Result l = results.get(connectedTo); if (l.serverName != "" && l.userName != "" && l.port.trim() != "") { new RenameTask(l.serverName, l.userName, l.passWord, oldName, newName, folderPath, l.sftp, l.port, position).execute(); renameDialog.cancel(); } } } }); renameDialog.show(); } else if (item == 2) { final Dialog chmodDialog = new Dialog(AHEActivity.this); chmodDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); chmodDialog.setContentView(R.layout.chmoddiag); chmodDialog.setCancelable(true); Button closeServer = (Button) chmodDialog.findViewById(R.id.closeServer); closeServer.setOnClickListener(new OnClickListener() { public void onClick(View v) { chmodDialog.cancel(); } }); Button saveServer = (Button) chmodDialog.findViewById(R.id.saveServer); saveServer.setOnClickListener(new OnClickListener() { public void onClick(View v) { EditText themeUrl = (EditText) chmodDialog.findViewById(R.id.themeLink); String perms = themeUrl.getText().toString(); //connectedTo SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); String currentServers = settings.getString("Accounts", ""); if (currentServers.equals("")) { } else { Gson gson = new Gson(); SearchResponse response = gson.fromJson(currentServers, SearchResponse.class); List<Result> results = response.data; Result l = results.get(connectedTo); if (l.serverName != "" && l.userName != "" && l.port.trim() != "") { if (l.sftp.equals("0") || l.sftp.equals("1") || l.sftp.equals("2")) { new ChmodTask(l.serverName, l.userName, l.passWord, oldName, perms, folderPath, l.sftp, l.port, position).execute(); } else { Toast.makeText(AHEActivity.this, "CHMOD could not be performed on your server via sftp", Toast.LENGTH_SHORT).show(); } chmodDialog.cancel(); } } } }); chmodDialog.show(); } else if (item == 3) { //Make new class to download a file SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); String currentServers = settings.getString("Accounts", ""); if (currentServers.equals("")) { } else { Gson gson = new Gson(); SearchResponse response = gson.fromJson(currentServers, SearchResponse.class); List<Result> results = response.data; Result l = results.get(connectedTo); if (l.serverName != "" && l.userName != "" && l.port.trim() != "") { if (l.sftp.equals("0") || l.sftp.equals("1") || l.sftp.equals("2")) { new DlTask(l.serverName, l.userName, l.passWord, oldName, l.sftp, l.port) .execute(); } } } } //Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show(); } }); AlertDialog alert = builder.create(); alert.show(); return true; } }); lstTest.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> av, View v, int pos, long id) { loadFileFolder(v); } }); }
From source file:de.vanita5.twittnuker.util.Utils.java
public static int getTextCount(final TextView view) { if (view == null) return 0; final String string = ParseUtils.parseString(view.getText()); return getTextCount(string); }
From source file:com.mobicage.rogerthat.registration.RegistrationActivity2.java
@Override protected void onServiceBound() { T.UI();/*from ww w. ja v a 2 s . c o m*/ if (mNotYetProcessedIntent != null) { processIntent(mNotYetProcessedIntent); mNotYetProcessedIntent = null; } setContentView(R.layout.registration2); //Apply Fonts TextUtils.overrideFonts(this, findViewById(android.R.id.content)); final Typeface faTypeFace = Typeface.createFromAsset(getAssets(), "FontAwesome.ttf"); final int[] visibleLogos; final int[] goneLogos; if (AppConstants.FULL_WIDTH_HEADERS) { visibleLogos = FULL_WIDTH_ROGERTHAT_LOGOS; goneLogos = NORMAL_WIDTH_ROGERTHAT_LOGOS; View viewFlipper = findViewById(R.id.registration_viewFlipper); FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) viewFlipper.getLayoutParams(); params.setMargins(0, 0, 0, 0); } else { visibleLogos = NORMAL_WIDTH_ROGERTHAT_LOGOS; goneLogos = FULL_WIDTH_ROGERTHAT_LOGOS; } for (int id : visibleLogos) findViewById(id).setVisibility(View.VISIBLE); for (int id : goneLogos) findViewById(id).setVisibility(View.GONE); handleScreenOrientation(getResources().getConfiguration().orientation); ScrollView rc = (ScrollView) findViewById(R.id.registration_container); Resources resources = getResources(); if (CloudConstants.isRogerthatApp()) { rc.setBackgroundColor(resources.getColor(R.color.mc_page_dark)); } else { rc.setBackgroundColor(resources.getColor(R.color.mc_homescreen_background)); } TextView rogerthatWelcomeTextView = (TextView) findViewById(R.id.rogerthat_welcome); TextView tosTextView = (TextView) findViewById(R.id.registration_tos); Typeface FONT_THIN_ITALIC = Typeface.createFromAsset(getAssets(), "fonts/lato_light_italic.ttf"); tosTextView.setTypeface(FONT_THIN_ITALIC); tosTextView.setTextColor(ContextCompat.getColor(RegistrationActivity2.this, R.color.mc_words_color)); Button agreeBtn = (Button) findViewById(R.id.registration_agree_tos); TextView tvRegistration = (TextView) findViewById(R.id.registration); tvRegistration.setText(getString(R.string.registration_city_app_sign_up, getString(R.string.app_name))); mEnterEmailAutoCompleteTextView = (AutoCompleteTextView) findViewById(R.id.registration_enter_email); if (CloudConstants.isEnterpriseApp()) { rogerthatWelcomeTextView .setText(getString(R.string.rogerthat_welcome_enterprise, getString(R.string.app_name))); tosTextView.setVisibility(View.GONE); agreeBtn.setText(R.string.start_registration); mEnterEmailAutoCompleteTextView.setHint(R.string.registration_enter_email_hint_enterprise); } else { rogerthatWelcomeTextView .setText(getString(R.string.registration_welcome_text, getString(R.string.app_name))); tosTextView.setText(Html.fromHtml( "<a href=\"" + CloudConstants.TERMS_OF_SERVICE_URL + "\">" + tosTextView.getText() + "</a>")); tosTextView.setMovementMethod(LinkMovementMethod.getInstance()); agreeBtn.setText(R.string.registration_btn_agree_tos); mEnterEmailAutoCompleteTextView.setHint(R.string.registration_enter_email_hint); } agreeBtn.getBackground().setColorFilter(Message.GREEN_BUTTON_COLOR, PorterDuff.Mode.MULTIPLY); agreeBtn.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { sendRegistrationStep(RegistrationWizard2.REGISTRATION_STEP_AGREED_TOS); mWiz.proceedToNextPage(); } }); initLocationUsageStep(faTypeFace); View.OnClickListener emailLoginListener = new View.OnClickListener() { @Override public void onClick(View v) { sendRegistrationStep(RegistrationWizard2.REGISTRATION_STEP_EMAIL_LOGIN); mWiz.proceedToNextPage(); } }; findViewById(R.id.login_via_email).setOnClickListener(emailLoginListener); Button facebookButton = (Button) findViewById(R.id.login_via_fb); View.OnClickListener facebookLoginListener = new View.OnClickListener() { @Override public void onClick(View v) { // Check network connectivity if (!mService.getNetworkConnectivityManager().isConnected()) { UIUtils.showNoNetworkDialog(RegistrationActivity2.this); return; } sendRegistrationStep(RegistrationWizard2.REGISTRATION_STEP_FACEBOOK_LOGIN); FacebookUtils.ensureOpenSession(RegistrationActivity2.this, AppConstants.PROFILE_SHOW_GENDER_AND_BIRTHDATE ? Arrays.asList("email", "user_friends", "user_birthday") : Arrays.asList("email", "user_friends"), PermissionType.READ, new Session.StatusCallback() { @Override public void call(Session session, SessionState state, Exception exception) { if (session != Session.getActiveSession()) { session.removeCallback(this); return; } if (exception != null) { session.removeCallback(this); if (!(exception instanceof FacebookOperationCanceledException)) { L.bug("Facebook SDK error during registration", exception); AlertDialog.Builder builder = new AlertDialog.Builder( RegistrationActivity2.this); builder.setMessage(R.string.error_please_try_again); builder.setPositiveButton(R.string.rogerthat, null); AlertDialog dialog = builder.create(); dialog.show(); } } else if (session.isOpened()) { session.removeCallback(this); if (session.getPermissions().contains("email")) { registerWithAccessToken(session.getAccessToken()); } else { AlertDialog.Builder builder = new AlertDialog.Builder( RegistrationActivity2.this); builder.setMessage(R.string.facebook_registration_email_missing); builder.setPositiveButton(R.string.rogerthat, null); AlertDialog dialog = builder.create(); dialog.show(); } } } }, false); } ; }; facebookButton.setOnClickListener(facebookLoginListener); final Button getAccountsButton = (Button) findViewById(R.id.get_accounts); if (configureEmailAutoComplete()) { // GET_ACCOUNTS permission is granted getAccountsButton.setVisibility(View.GONE); } else { getAccountsButton.setTypeface(faTypeFace); getAccountsButton.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { ActivityCompat.requestPermissions(RegistrationActivity2.this, new String[] { Manifest.permission.GET_ACCOUNTS }, PERMISSION_REQUEST_GET_ACCOUNTS); } }); } mEnterPinEditText = (EditText) findViewById(R.id.registration_enter_pin); mEnterPinEditText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { if (s.length() == PIN_LENGTH) onPinEntered(); } }); Button requestNewPinButton = (Button) findViewById(R.id.registration_request_new_pin); requestNewPinButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mWiz.setEmail(null); hideNotification(); mWiz.reInit(); mWiz.goBackToPrevious(); mEnterEmailAutoCompleteTextView.setText(""); } }); mWiz = RegistrationWizard2.getWizard(mService); mWiz.setFlipper((ViewFlipper) findViewById(R.id.registration_viewFlipper)); setFinishHandler(); addAgreeTOSHandler(); addIBeaconUsageHandler(); addChooseLoginMethodHandler(); addEnterPinHandler(); mWiz.run(); mWiz.setDeviceId(Installation.id(this)); handleEnterEmail(); if (mWiz.getBeaconRegions() != null && mBeaconManager == null) { bindBeaconManager(); } if (CloudConstants.USE_GCM_KICK_CHANNEL && GoogleServicesUtils.checkPlayServices(this, true)) { GoogleServicesUtils.registerGCMRegistrationId(mService, new GCMRegistrationIdFoundCallback() { @Override public void idFound(String registrationId) { mGCMRegistrationId = registrationId; } }); } }
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 www .j a v a2s . co 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 (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.hichinaschool.flashcards.anki.DeckPicker.java
/** Called when the activity is first created. */ @Override//www. j a v a 2s . com protected void onCreate(Bundle savedInstanceState) throws SQLException { // Log.i(AnkiDroidApp.TAG, "DeckPicker - onCreate"); Intent intent = getIntent(); if (!isTaskRoot()) { // Log.i(AnkiDroidApp.TAG, "DeckPicker - onCreate: Detected multiple instance of this activity, closing it and return to root activity"); Intent reloadIntent = new Intent(DeckPicker.this, DeckPicker.class); reloadIntent.setAction(Intent.ACTION_MAIN); if (intent != null && intent.getExtras() != null) { reloadIntent.putExtras(intent.getExtras()); } if (intent != null && intent.getData() != null) { reloadIntent.setData(intent.getData()); } reloadIntent.addCategory(Intent.CATEGORY_LAUNCHER); reloadIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); finish(); startActivityIfNeeded(reloadIntent, 0); } if (intent.getData() != null) { mImportPath = getIntent().getData().getEncodedPath(); } // need to start this here in order to avoid showing deckpicker before splashscreen if (AnkiDroidApp.colIsOpen()) { setTitle(getResources().getString(R.string.app_name)); } else { setTitle(""); mOpenCollectionHandler.onPreExecute(); } Themes.applyTheme(this); super.onCreate(savedInstanceState); // mStartedByBigWidget = intent.getIntExtra(EXTRA_START, EXTRA_START_NOTHING); SharedPreferences preferences = restorePreferences(); // activate broadcast messages if first start of a day if (mLastTimeOpened < UIUtils.getDayStart()) { preferences.edit().putBoolean("showBroadcastMessageToday", true).commit(); } preferences.edit().putLong("lastTimeOpened", System.currentTimeMillis()).commit(); // if (intent != null && intent.hasExtra(EXTRA_DECK_ID)) { // openStudyOptions(intent.getLongExtra(EXTRA_DECK_ID, 1)); // } // BroadcastMessages.checkForNewMessages(this); View mainView = getLayoutInflater().inflate(R.layout.deck_picker, null); setContentView(mainView); // check, if tablet layout View studyoptionsFrame = findViewById(R.id.studyoptions_fragment); mFragmented = studyoptionsFrame != null && studyoptionsFrame.getVisibility() == View.VISIBLE; Themes.setContentStyle(mFragmented ? mainView : mainView.findViewById(R.id.deckpicker_view), Themes.CALLER_DECKPICKER); registerExternalStorageListener(); if (!mFragmented) { // mAddButton = (ImageButton) findViewById(R.id.deckpicker_add); // mAddButton.setOnClickListener(new OnClickListener() { // @Override // public void onClick(View v) { // addNote(); // } // }); // // mCardsButton = (ImageButton) findViewById(R.id.deckpicker_card_browser); // mCardsButton.setOnClickListener(new OnClickListener() { // @Override // public void onClick(View v) { // openCardBrowser(); // } // }); // // mStatsButton = (ImageButton) findViewById(R.id.statistics_all_button); // mStatsButton.setOnClickListener(new OnClickListener() { // @Override // public void onClick(View v) { // showDialog(DIALOG_SELECT_STATISTICS_TYPE); // } // }); // // mSyncButton = (ImageButton) findViewById(R.id.sync_all_button); // mSyncButton.setOnClickListener(new OnClickListener() { // @Override // public void onClick(View v) { // sync(); // } // }); } mInvalidateMenu = false; mDeckList = new ArrayList<HashMap<String, String>>(); mDeckListView = (ListView) findViewById(R.id.files); // mDeckListAdapter = new SimpleAdapter(this, mDeckList, R.layout.deck_item, new String[] { "name", "new", "lrn", // "rev", // "complMat", "complAll", // "sep", "dyn" }, new int[] { R.id.DeckPickerName, R.id.deckpicker_new, R.id.deckpicker_lrn, // R.id.deckpicker_rev, // R.id.deckpicker_bar_mat, R.id.deckpicker_bar_all, // R.id.deckpicker_deck, R.id.DeckPickerName }); mDeckListAdapter = new SimpleAdapter(this, mDeckList, R.layout.deck_item, new String[] { "name", "new", "lrn", "rev", "sep", "dyn", "url" }, new int[] { R.id.DeckPickerName, R.id.deckpicker_new, R.id.deckpicker_lrn, R.id.deckpicker_rev, R.id.deckpicker_deck, R.id.DeckPickerName, R.id.deckpicker_url }); mDeckListAdapter.setViewBinder(new SimpleAdapter.ViewBinder() { @Override public boolean setViewValue(final View view, final Object data, String text) { if (view.getId() == R.id.deckpicker_url) { // If "url" field has text, it means the deck must be downloaded // so we put the downloadButton visible and add its listener if (!text.equals("")) { final View parentView = (View) view.getParent(); Button downloadButton = (Button) parentView.findViewById(R.id.deckpicker_button); downloadButton.setVisibility(View.VISIBLE); parentView.findViewById(R.id.deckpicker_new).setVisibility(View.GONE); parentView.findViewById(R.id.deckpicker_rev).setVisibility(View.GONE); parentView.findViewById(R.id.deckpicker_lrn).setVisibility(View.GONE); downloadButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // ListView lv = (ListView) parentView.getParent().getParent(); // int i; // for (i = 0; i < mDeckList.size(); i++) { // if (mDeckListView.getItemAtPosition(i).equals(view)){ // mDeckLastItemSelected = i; // } // } // Gets url from the selected deck and download it TextView txt = (TextView) ((View) view.getParent()) .findViewById(R.id.deckpicker_url); String url = txt.getText().toString(); Connection.downloadSharedDeck(mDownloadDeckListener, new Connection.Payload(new Object[] { url })); } }); } else { Button downloadButton = (Button) ((View) view.getParent()) .findViewById(R.id.deckpicker_button); downloadButton.setVisibility(View.GONE); ((View) view.getParent()).findViewById(R.id.deckpicker_new).setVisibility(View.VISIBLE); ((View) view.getParent()).findViewById(R.id.deckpicker_rev).setVisibility(View.VISIBLE); ((View) view.getParent()).findViewById(R.id.deckpicker_lrn).setVisibility(View.VISIBLE); } } if (view.getId() == R.id.deckpicker_deck) { if (text.equals("top")) { view.setBackgroundResource(R.drawable.white_deckpicker_top); return true; } else if (text.equals("bot")) { view.setBackgroundResource(R.drawable.white_deckpicker_bottom); return true; } else if (text.equals("ful")) { view.setBackgroundResource(R.drawable.white_deckpicker_full); return true; } else if (text.equals("cen")) { view.setBackgroundResource(R.drawable.white_deckpicker_center); return true; } } else if (view.getId() == R.id.DeckPickerName) { if (text.equals("d0")) { ((TextView) view).setTextColor(getResources().getColor(R.color.non_dyn_deck)); return true; } else if (text.equals("d1")) { ((TextView) view).setTextColor(getResources().getColor(R.color.dyn_deck)); return true; } } // } else if (view.getId() == R.id.deckpicker_bar_mat || view.getId() == R.id.deckpicker_bar_all) { // if (text.length() > 0 && !text.equals("-1.0")) { // View parent = (View)view.getParent().getParent(); // if (text.equals("-2")) { // parent.setVisibility(View.GONE); // } else { // Utils.updateProgressBars(view, (int) UIUtils.getDensityAdjustedValue(DeckPicker.this, 3.4f), // (int) (Double.parseDouble(text) * ((View)view.getParent().getParent().getParent()).getHeight())); // if (parent.getVisibility() == View.INVISIBLE) { // parent.setVisibility(View.VISIBLE); // parent.setAnimation(ViewAnimation.fade(ViewAnimation.FADE_IN, 500, 0)); // } // } // } // return true; // } else if (view.getVisibility() == View.INVISIBLE) { // if (!text.equals("-1")) { // view.setVisibility(View.VISIBLE); // view.setAnimation(ViewAnimation.fade(ViewAnimation.FADE_IN, 500, 0)); // return false; // } // } else if (text.equals("-1")){ // view.setVisibility(View.INVISIBLE); // return false; return false; } }); mDeckListView.setOnItemClickListener(mDeckSelHandler); mDeckListView.setAdapter(mDeckListAdapter); if (mFragmented) { mDeckListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); } registerForContextMenu(mDeckListView); showStartupScreensAndDialogs(preferences, 0); if (mSwipeEnabled) { gestureDetector = new GestureDetector(new MyGestureDetector()); mDeckListView.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { if (gestureDetector.onTouchEvent(event)) { return true; } return false; } }); } }
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 .ja va2 s. 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:github.popeen.dsub.fragments.SelectDirectoryFragment.java
private void setupTextDisplay(final View header) { final TextView titleView = (TextView) header.findViewById(R.id.select_album_title); if (playlistName != null) { titleView.setText(playlistName); } else if (podcastName != null) { Collections.reverse(entries); titleView.setText(podcastName);/*from w w w . j a v a 2 s .co m*/ titleView.setPadding(0, 6, 4, 8); } else if (name != null) { titleView.setText(name); if (artistInfo != null) { titleView.setPadding(0, 6, 4, 8); } } else if (share != null) { titleView.setVisibility(View.GONE); } int songCount = 0; Set<String> artists = new HashSet<String>(); Set<Integer> years = new HashSet<Integer>(); totalDuration = 0; for (Entry entry : entries) { if (!entry.isDirectory()) { songCount++; if (entry.getArtist() != null) { artists.add(entry.getArtist()); } if (entry.getYear() != null) { years.add(entry.getYear()); } Integer duration = entry.getDuration(); if (duration != null) { totalDuration += duration; } } } String artistName = ""; bookDescription = "Could not collect any info about the book at this time"; try { artistName = artists.iterator().next(); String endpoint = "getBookDirectory"; if (Util.isTagBrowsing(context)) { endpoint = "getBook"; } SharedPreferences prefs = Util.getPreferences(context); String url = Util.getRestUrl(context, endpoint) + "&id=" + directory.getId() + "&f=json"; Log.w("GetInfo", url); String artist, title; int year = 0; artist = title = ""; try { artist = artists.iterator().next(); } catch (Exception e) { Log.w("GetInfoArtist", e.toString()); } try { title = titleView.getText().toString(); } catch (Exception e) { Log.w("GetInfoTitle", e.toString()); } try { year = years.iterator().next(); } catch (Exception e) { Log.w("GetInfoYear", e.toString()); } BookInfoAPIParams params = new BookInfoAPIParams(url, artist, title, year); bookInfo = new BookInfoAPI(context).execute(params).get(); bookDescription = bookInfo[0]; bookReader = bookInfo[1]; } catch (Exception e) { Log.w("GetInfoError", e.toString()); } if (bookDescription.equals("noInfo")) { bookDescription = "The server has no description for this book"; } final TextView artistView = (TextView) header.findViewById(R.id.select_album_artist); if (podcastDescription != null || artistInfo != null || bookDescription != null) { artistView.setVisibility(View.VISIBLE); String text = ""; if (bookDescription != null) { text = bookDescription; } if (podcastDescription != null) { text = podcastDescription; } if (artistInfo != null) { text = artistInfo.getBiography(); } Spanned spanned = null; if (text != null) { String newText = ""; try { if (!artistName.equals("")) { newText += "<b>" + context.getResources().getString(R.string.main_artist) + "</b>: " + artistName + "<br/>"; } } catch (Exception e) { } try { if (totalDuration > 0) { newText += "<b>" + context.getResources().getString(R.string.album_book_reader) + "</b>: " + bookReader + "<br/>"; } } catch (Exception e) { } try { if (totalDuration > 0) { newText += "<b>" + context.getResources().getString(R.string.album_book_length) + "</b>: " + Util.formatDuration(totalDuration) + "<br/>"; } } catch (Exception e) { } try { newText += text + "<br/>"; } catch (Exception e) { } spanned = Html.fromHtml(newText); } artistView.setText(spanned); artistView.setSingleLine(false); final int minLines = context.getResources().getInteger(R.integer.TextDescriptionLength); artistView.setLines(minLines); artistView.setTextAppearance(context, android.R.style.TextAppearance_Small); final Spanned spannedText = spanned; artistView.setOnClickListener(new View.OnClickListener() { @TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override public void onClick(View v) { if (artistView.getMaxLines() == minLines) { // Use LeadingMarginSpan2 to try to make text flow around image Display display = context.getWindowManager().getDefaultDisplay(); ImageView coverArtView = (ImageView) header.findViewById(R.id.select_album_art); coverArtView.measure(display.getWidth(), display.getHeight()); int height, width; ViewGroup.MarginLayoutParams vlp = (ViewGroup.MarginLayoutParams) coverArtView .getLayoutParams(); if (coverArtView.getDrawable() != null) { height = coverArtView.getMeasuredHeight() + coverArtView.getPaddingBottom(); width = coverArtView.getWidth() + coverArtView.getPaddingRight(); } else { height = coverArtView.getHeight(); width = coverArtView.getWidth() + coverArtView.getPaddingRight(); } float textLineHeight = artistView.getPaint().getTextSize(); int lines = (int) Math.ceil(height / textLineHeight) + 1; SpannableString ss = new SpannableString(spannedText); ss.setSpan(new MyLeadingMarginSpan2(lines, width), 0, ss.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); View linearLayout = header.findViewById(R.id.select_album_text_layout); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) linearLayout .getLayoutParams(); int[] rules = params.getRules(); rules[RelativeLayout.RIGHT_OF] = 0; params.leftMargin = vlp.rightMargin; artistView.setText(ss); artistView.setMaxLines(100); vlp = (ViewGroup.MarginLayoutParams) titleView.getLayoutParams(); vlp.leftMargin = width; } else { artistView.setMaxLines(minLines); } } }); artistView.setMovementMethod(LinkMovementMethod.getInstance()); } else if (topTracks) { artistView.setText(R.string.menu_top_tracks); artistView.setVisibility(View.VISIBLE); } else if (showAll) { artistView.setText(R.string.menu_show_all); artistView.setVisibility(View.VISIBLE); } else if (artists.size() == 1) { String artistText = artists.iterator().next(); if (years.size() == 1) { artistText += " - " + years.iterator().next(); } artistView.setText(artistText); artistView.setVisibility(View.VISIBLE); } else { artistView.setVisibility(View.GONE); } TextView songCountView = (TextView) header.findViewById(R.id.select_album_song_count); TextView songLengthView = (TextView) header.findViewById(R.id.select_album_song_length); if (podcastDescription != null || artistInfo != null) { songCountView.setVisibility(View.GONE); songLengthView.setVisibility(View.GONE); } else { String s = context.getResources().getQuantityString(R.plurals.select_album_n_songs, songCount, songCount); songCountView.setVisibility(View.GONE); songLengthView.setVisibility(View.GONE); } }
From source file:cl.gisred.android.InspActivity.java
private void setTextViewReq(View view, int idRequerido, boolean bool) { if (bool) {//ww w . j av a 2s .c o m TextView oText = (TextView) getLayoutContenedor(view).findViewById(idRequerido); if (oText.getText() != null && oText.getText().toString().contains("*")) { oText.setText(oText.getText().toString().replace("*", "")); } } else { TextView oText = (TextView) getLayoutContenedor(view).findViewById(idRequerido); if (oText.getText() != null && !oText.getText().toString().contains("*")) { oText.setText(oText.getText().toString().concat("*")); } } }
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;/*from w w w. 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(); } }
From source file:com.skytree.epubtest.BookViewActivity.java
public void setLabelLength(TextView label, int maxLength) { String text = (String) label.getText(); if (text.length() > maxLength) { text = text.substring(0, maxLength); text = text + ".."; }//from w ww . j av a2s. com label.setText(text); }