List of usage examples for android.view.animation AnimationUtils loadAnimation
public static Animation loadAnimation(Context context, @AnimRes int id) throws NotFoundException
From source file:br.unb.mobileMedia.core.view.ExpandableListFragment.java
/** * Control whether the list is being displayed. You can make it not * displayed if you are waiting for the initial data to show in it. During * this time an indeterminant progress indicator will be shown instead. * @param shown If true, the list view is shown; if false, the progress * indicator. The initial value is true. * @param animate If true, an animation will be used to transition to the * new state./*from w w w . ja va 2s . c o m*/ */ private void setListShown(boolean shown, boolean animate) { ensureList(); if (mListShown == shown) { return; } mListShown = shown; if (mListContainer != null) { if (shown) { if (animate) { mListContainer .startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in)); } mListContainer.setVisibility(View.VISIBLE); } else { if (animate) { mListContainer .startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out)); } mListContainer.setVisibility(View.GONE); } } }
From source file:com.daiv.android.twitter.ui.drawer_activities.DrawerActivity.java
public void setUpDrawer(int number, final String actName) { int currentAccount = sharedPrefs.getInt("current_account", 1); for (int i = 0; i < TimelinePagerAdapter.MAX_EXTRA_PAGES; i++) { String pageIdentifier = "account_" + currentAccount + "_page_" + (i + 1); int type = sharedPrefs.getInt(pageIdentifier, AppSettings.PAGE_TYPE_NONE); if (type != AppSettings.PAGE_TYPE_NONE) { number++;/* w w w. j a v a 2 s. co m*/ } } try { ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception ex) { // Ignore } actionBar = getActionBar(); adapter = new MainDrawerArrayAdapter(context); MainDrawerArrayAdapter.setCurrent(context, number); TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.drawerIcon }); int resource = a.getResourceId(0, 0); a.recycle(); a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.read_button }); openMailResource = a.getResourceId(0, 0); a.recycle(); a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.unread_button }); closedMailResource = a.getResourceId(0, 0); a.recycle(); mDrawerLayout = (NotificationDrawerLayout) findViewById(R.id.drawer_layout); mDrawer = (LinearLayout) findViewById(R.id.left_drawer); HoloTextView name = (HoloTextView) mDrawer.findViewById(R.id.name); HoloTextView screenName = (HoloTextView) mDrawer.findViewById(R.id.screen_name); backgroundPic = (NetworkedCacheableImageView) mDrawer.findViewById(R.id.background_image); profilePic = (NetworkedCacheableImageView) mDrawer.findViewById(R.id.profile_pic_contact); final ImageButton showMoreDrawer = (ImageButton) mDrawer.findViewById(R.id.options); final LinearLayout logoutLayout = (LinearLayout) mDrawer.findViewById(R.id.logoutLayout); final Button logoutDrawer = (Button) mDrawer.findViewById(R.id.logoutButton); drawerList = (ListView) mDrawer.findViewById(R.id.drawer_list); notificationList = (EnhancedListView) findViewById(R.id.notificationList); try { mDrawerLayout = (NotificationDrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow_rev, Gravity.END); mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ resource, /* nav drawer icon to replace 'Up' caret */ R.string.app_name, /* "open drawer" description */ R.string.app_name /* "close drawer" description */ ) { public void onDrawerClosed(View view) { actionBar.setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent))); if (logoutVisible) { Animation ranim = AnimationUtils.loadAnimation(context, R.anim.drawer_rotate_back); ranim.setFillAfter(true); showMoreDrawer.startAnimation(ranim); logoutLayout.setVisibility(View.GONE); drawerList.setVisibility(View.VISIBLE); logoutVisible = false; } if (MainDrawerArrayAdapter.current > adapter.pageTypes.size()) { actionBar.setTitle(actName); } else { int position = mViewPager.getCurrentItem(); String title = ""; try { title = "" + mSectionsPagerAdapter.getPageTitle(position); } catch (NullPointerException e) { title = ""; } actionBar.setTitle(title); } try { if (oldInteractions.getText().toString() .equals(getResources().getString(R.string.new_interactions))) { oldInteractions.setText(getResources().getString(R.string.old_interactions)); readButton.setImageResource(openMailResource); notificationList.enableSwipeToDismiss(); notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource .getInstance(context).getUnreadCursor(DrawerActivity.settings.currentAccount)); notificationList.setAdapter(notificationAdapter); } } catch (Exception e) { // don't have Test pull on } invalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { actionBar.setTitle(getResources().getString(R.string.app_name)); actionBar.setIcon(R.mipmap.ic_launcher); try { notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource .getInstance(context).getUnreadCursor(settings.currentAccount)); notificationList.setAdapter(notificationAdapter); notificationList.enableSwipeToDismiss(); oldInteractions.setText(getResources().getString(R.string.old_interactions)); readButton.setImageResource(openMailResource); sharedPrefs.edit().putBoolean("new_notification", false).commit(); } catch (Exception e) { // don't have Test pull on } invalidateOptionsMenu(); } public void onDrawerSlide(View drawerView, float slideOffset) { super.onDrawerSlide(drawerView, slideOffset); if (!actionBar.isShowing()) { actionBar.show(); } if (translucent) { statusBar.setVisibility(View.VISIBLE); } } }; mDrawerLayout.setDrawerListener(mDrawerToggle); } catch (Exception e) { // landscape mode } actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); showMoreDrawer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (logoutLayout.getVisibility() == View.GONE) { Animation ranim = AnimationUtils.loadAnimation(context, R.anim.drawer_rotate); ranim.setFillAfter(true); showMoreDrawer.startAnimation(ranim); Animation anim = AnimationUtils.loadAnimation(context, R.anim.fade_out); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { drawerList.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) { } }); anim.setDuration(300); drawerList.startAnimation(anim); Animation anim2 = AnimationUtils.loadAnimation(context, R.anim.fade_in); anim2.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { logoutLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); anim2.setDuration(300); logoutLayout.startAnimation(anim2); logoutVisible = true; } else { Animation ranim = AnimationUtils.loadAnimation(context, R.anim.drawer_rotate_back); ranim.setFillAfter(true); showMoreDrawer.startAnimation(ranim); Animation anim = AnimationUtils.loadAnimation(context, R.anim.fade_in); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { drawerList.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); anim.setDuration(300); drawerList.startAnimation(anim); Animation anim2 = AnimationUtils.loadAnimation(context, R.anim.fade_out); anim2.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { logoutLayout.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) { } }); anim2.setDuration(300); logoutLayout.startAnimation(anim2); logoutVisible = false; } } }); logoutDrawer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { logoutFromTwitter(); } }); final String sName = settings.myName; final String sScreenName = settings.myScreenName; final String backgroundUrl = settings.myBackgroundUrl; final String profilePicUrl = settings.myProfilePicUrl; final BitmapLruCache mCache = App.getInstance(context).getProfileCache(); if (!backgroundUrl.equals("")) { backgroundPic.loadImage(backgroundUrl, false, null); //ImageUtils.loadImage(context, backgroundPic, backgroundUrl, mCache); } else { backgroundPic.setImageDrawable(getResources().getDrawable(R.drawable.default_header_background)); } backgroundPic.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { mDrawerLayout.closeDrawer(Gravity.START); } catch (Exception e) { } new Handler().postDelayed(new Runnable() { @Override public void run() { } }, 400); } }); backgroundPic.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { try { mDrawerLayout.closeDrawer(Gravity.START); } catch (Exception e) { } return false; } }); try { name.setText(sName); screenName.setText("@" + sScreenName); name.setTextSize(15); screenName.setTextSize(15); } catch (Exception e) { // 7 inch tablet in portrait } try { if (settings.roundContactImages) { //profilePic.loadImage(profilePicUrl, false, null, NetworkedCacheableImageView.CIRCLE); ImageUtils.loadCircleImage(context, profilePic, profilePicUrl, mCache); } else { profilePic.loadImage(profilePicUrl, false, null); ImageUtils.loadImage(context, profilePic, profilePicUrl, mCache); } } catch (Exception e) { // empty path again } drawerList.setAdapter(adapter); drawerList.setOnItemClickListener(new MainDrawerClickListener(context, mDrawerLayout, mViewPager)); // set up for the second account int count = 0; // number of accounts logged in if (sharedPrefs.getBoolean("is_logged_in_1", false)) { count++; } if (sharedPrefs.getBoolean("is_logged_in_2", false)) { count++; } RelativeLayout secondAccount = (RelativeLayout) findViewById(R.id.second_profile); HoloTextView name2 = (HoloTextView) findViewById(R.id.name_2); HoloTextView screenname2 = (HoloTextView) findViewById(R.id.screen_name_2); NetworkedCacheableImageView proPic2 = (NetworkedCacheableImageView) findViewById(R.id.profile_pic_2); name2.setTextSize(15); screenname2.setTextSize(15); final int current = sharedPrefs.getInt("current_account", 1); // make a second account if (count == 1) { name2.setText(getResources().getString(R.string.new_account)); screenname2.setText(getResources().getString(R.string.tap_to_setup)); secondAccount.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (canSwitch) { if (current == 1) { sharedPrefs.edit().putInt("current_account", 2).commit(); } else { sharedPrefs.edit().putInt("current_account", 1).commit(); } context.sendBroadcast(new Intent("com.daiv.android.twitter.STOP_PUSH_SERVICE")); context.sendBroadcast(new Intent("com.daiv.android.twitter.MARK_POSITION")); Intent login = new Intent(context, LoginActivity.class); AppSettings.invalidate(); finish(); startActivity(login); } } }); } else { // switch accounts if (current == 1) { name2.setText(sharedPrefs.getString("twitter_users_name_2", "")); screenname2.setText("@" + sharedPrefs.getString("twitter_screen_name_2", "")); try { if (settings.roundContactImages) { //proPic2.loadImage(sharedPrefs.getString("profile_pic_url_2", ""), true, null, NetworkedCacheableImageView.CIRCLE); ImageUtils.loadCircleImage(context, proPic2, sharedPrefs.getString("profile_pic_url_2", ""), mCache); } else { //proPic2.loadImage(sharedPrefs.getString("profile_pic_url_2", ""), true, null); ImageUtils.loadImage(context, proPic2, sharedPrefs.getString("profile_pic_url_2", ""), mCache); } } catch (Exception e) { } secondAccount.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (canSwitch) { context.sendBroadcast(new Intent("com.daiv.android.twitter.STOP_PUSH_SERVICE")); context.sendBroadcast(new Intent("com.daiv.android.twitter.MARK_POSITION") .putExtra("current_account", current)); Toast.makeText(context, "Preparing to switch", Toast.LENGTH_SHORT).show(); // we want to wait a second so that the mark position broadcast will work new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(1000); } catch (Exception e) { } sharedPrefs.edit().putInt("current_account", 2).commit(); sharedPrefs.edit().remove("new_notifications").remove("new_retweets") .remove("new_favorites").remove("new_follows").commit(); AppSettings.invalidate(); finish(); Intent next = new Intent(context, MainActivity.class); startActivity(next); } }).start(); } } }); } else { name2.setText(sharedPrefs.getString("twitter_users_name_1", "")); screenname2.setText("@" + sharedPrefs.getString("twitter_screen_name_1", "")); try { if (settings.roundContactImages) { //proPic2.loadImage(sharedPrefs.getString("profile_pic_url_1", ""), true, null, NetworkedCacheableImageView.CIRCLE); ImageUtils.loadCircleImage(context, proPic2, sharedPrefs.getString("profile_pic_url_1", ""), mCache); } else { //proPic2.loadImage(sharedPrefs.getString("profile_pic_url_1", ""), true, null); ImageUtils.loadImage(context, proPic2, sharedPrefs.getString("profile_pic_url_1", ""), mCache); } } catch (Exception e) { } secondAccount.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (canSwitch) { context.sendBroadcast(new Intent("com.daiv.android.twitter.STOP_PUSH_SERVICE")); context.sendBroadcast(new Intent("com.daiv.android.twitter.MARK_POSITION") .putExtra("current_account", current)); Toast.makeText(context, "Preparing to switch", Toast.LENGTH_SHORT).show(); new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(1000); } catch (Exception e) { } sharedPrefs.edit().putInt("current_account", 1).commit(); sharedPrefs.edit().remove("new_notifications").remove("new_retweets") .remove("new_favorites").remove("new_follows").commit(); AppSettings.invalidate(); finish(); Intent next = new Intent(context, MainActivity.class); startActivity(next); } }).start(); } } }); } } statusBar = findViewById(R.id.activity_status_bar); statusBarHeight = Utils.getStatusBarHeight(context); navBarHeight = Utils.getNavBarHeight(context); try { RelativeLayout.LayoutParams statusParams = (RelativeLayout.LayoutParams) statusBar.getLayoutParams(); statusParams.height = statusBarHeight; statusBar.setLayoutParams(statusParams); } catch (Exception e) { try { LinearLayout.LayoutParams statusParams = (LinearLayout.LayoutParams) statusBar.getLayoutParams(); statusParams.height = statusBarHeight; statusBar.setLayoutParams(statusParams); } catch (Exception x) { // in the trends } } View navBarSeperater = findViewById(R.id.nav_bar_seperator); if (translucent && Utils.hasNavBar(context)) { try { RelativeLayout.LayoutParams navParams = (RelativeLayout.LayoutParams) navBarSeperater .getLayoutParams(); navParams.height = navBarHeight; navBarSeperater.setLayoutParams(navParams); } catch (Exception e) { try { LinearLayout.LayoutParams navParams = (LinearLayout.LayoutParams) navBarSeperater .getLayoutParams(); navParams.height = navBarHeight; navBarSeperater.setLayoutParams(navParams); } catch (Exception x) { // in the trends } } } if (translucent) { if (Utils.hasNavBar(context)) { View footer = new View(context); footer.setOnClickListener(null); footer.setOnLongClickListener(null); ListView.LayoutParams params = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, Utils.getNavBarHeight(context)); footer.setLayoutParams(params); drawerList.addFooterView(footer); drawerList.setFooterDividersEnabled(false); } View drawerStatusBar = findViewById(R.id.drawer_status_bar); LinearLayout.LayoutParams status2Params = (LinearLayout.LayoutParams) drawerStatusBar.getLayoutParams(); status2Params.height = statusBarHeight; drawerStatusBar.setLayoutParams(status2Params); drawerStatusBar.setVisibility(View.VISIBLE); statusBar.setVisibility(View.VISIBLE); drawerStatusBar = findViewById(R.id.drawer_status_bar_2); status2Params = (LinearLayout.LayoutParams) drawerStatusBar.getLayoutParams(); status2Params.height = statusBarHeight; drawerStatusBar.setLayoutParams(status2Params); drawerStatusBar.setVisibility(View.VISIBLE); } if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE || getResources().getBoolean(R.bool.isTablet)) { actionBar.setDisplayHomeAsUpEnabled(false); } if (!settings.pushNotifications || !settings.useInteractionDrawer) { try { mDrawerLayout.setDrawerLockMode(NotificationDrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.END); } catch (Exception e) { // no drawer? } } else { mDrawerLayout.setDrawerRightEdgeSize(this, .1f); try { if (Build.VERSION.SDK_INT < 18 && DrawerActivity.settings.uiExtras) { View viewHeader2 = context.getLayoutInflater().inflate(R.layout.ab_header, null); notificationList.addHeaderView(viewHeader2, null, false); notificationList.setHeaderDividersEnabled(false); } } catch (Exception e) { // i don't know why it does this to be honest... } notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource.getInstance(context) .getUnreadCursor(DrawerActivity.settings.currentAccount)); try { notificationList.setAdapter(notificationAdapter); } catch (Exception e) { } View viewHeader = context.getLayoutInflater().inflate(R.layout.interactions_footer_1, null); notificationList.addFooterView(viewHeader, null, false); oldInteractions = (HoloTextView) findViewById(R.id.old_interactions_text); readButton = (ImageView) findViewById(R.id.read_button); LinearLayout footer = (LinearLayout) viewHeader.findViewById(R.id.footer); footer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (oldInteractions.getText().toString() .equals(getResources().getString(R.string.old_interactions))) { oldInteractions.setText(getResources().getString(R.string.new_interactions)); readButton.setImageResource(closedMailResource); notificationList.disableSwipeToDismiss(); notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource .getInstance(context).getCursor(DrawerActivity.settings.currentAccount)); } else { oldInteractions.setText(getResources().getString(R.string.old_interactions)); readButton.setImageResource(openMailResource); notificationList.enableSwipeToDismiss(); notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource .getInstance(context).getUnreadCursor(DrawerActivity.settings.currentAccount)); } notificationList.setAdapter(notificationAdapter); } }); if (DrawerActivity.translucent) { if (Utils.hasNavBar(context)) { View nav = new View(context); nav.setOnClickListener(null); nav.setOnLongClickListener(null); ListView.LayoutParams params = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, Utils.getNavBarHeight(context)); nav.setLayoutParams(params); notificationList.addFooterView(nav); notificationList.setFooterDividersEnabled(false); } } notificationList.setDismissCallback(new EnhancedListView.OnDismissCallback() { @Override public EnhancedListView.Undoable onDismiss(EnhancedListView listView, int position) { Log.v("Test_interactions_delete", "position to delete: " + position); InteractionsDataSource data = InteractionsDataSource.getInstance(context); data.markRead(settings.currentAccount, position); notificationAdapter = new InteractionsCursorAdapter(context, data.getUnreadCursor(DrawerActivity.settings.currentAccount)); notificationList.setAdapter(notificationAdapter); oldInteractions.setText(getResources().getString(R.string.old_interactions)); readButton.setImageResource(openMailResource); if (notificationAdapter.getCount() == 0) { setNotificationFilled(false); } return null; } }); notificationList.enableSwipeToDismiss(); notificationList.setSwipeDirection(EnhancedListView.SwipeDirection.START); notificationList .setOnItemClickListener(new InteractionClickListener(context, mDrawerLayout, mViewPager)); } }
From source file:com.andrada.sitracker.ui.fragment.AuthorsFragment.java
private void toggleUpdatingState() { mIsUpdating = !mIsUpdating;//from ww w . java 2 s . co m ActionBar bar = ((ActionBarActivity) getActivity()).getSupportActionBar(); bar.setDisplayShowHomeEnabled(!mIsUpdating); bar.setDisplayShowTitleEnabled(!mIsUpdating); bar.setDisplayShowCustomEnabled(mIsUpdating); EventBus.getDefault().post(new ProgressBarToggleEvent(mIsUpdating)); if (mIsUpdating) { View mLogoView = LayoutInflater.from(getActivity()).inflate(R.layout.updating_actionbar_layout, null); bar.setCustomView(mLogoView, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mLogoView.clearAnimation(); mLogoView.startAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.ab_custom_view_anim)); } getActivity().supportInvalidateOptionsMenu(); }
From source file:com.rnd.snapsplit.view.OcrCaptureFragment.java
/** * Initializes the UI and creates the detector pipeline. *//*from w ww . ja v a2 s.c o m*/ // @Override // public void onActivityResult(int requestCode, int resultCode, Intent data) { // super.onActivityResult(requestCode, resultCode, data); // // if (requestCode == TAKE_PHOTO_CODE && resultCode == RESULT_OK) { // Toast.makeText(getContext(), "pic saved", Toast.LENGTH_LONG).show(); // Log.d("CameraDemo", "Pic saved"); // } // } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.view_ocr_capture, container, false); final Activity activity = getActivity(); final Context context = getContext(); ((Toolbar) activity.findViewById(R.id.tool_bar_hamburger)) .setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent)); final String dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + "/picFolder/"; File newdir = new File(dir); newdir.mkdirs(); mPreview = (CameraSourcePreview) view.findViewById(R.id.preview); mGraphicOverlay = (GraphicOverlay<OcrGraphic>) view.findViewById(R.id.graphicOverlay); StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder(); StrictMode.setVmPolicy(builder.build()); // Set good defaults for capturing text. boolean autoFocus = true; boolean useFlash = false; // createNewThread(); // t.start(); final ImageView upArrow = (ImageView) view.findViewById(R.id.arrow_up); upArrow.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (rotationAngle == 0) { // arrow up //mCameraSource.takePicture(null, mPicture); //mGraphicOverlay.clear(); // mGraphicOverlay.clear(); // mGraphicOverlay.amountItem = null; onPause(); //shouldContinue = false; //mCamera.takePicture(null, null, mPicture); File pictureFile = getOutputMediaFile(); if (pictureFile == null) { return; } try { FileOutputStream fos = new FileOutputStream(pictureFile); Bitmap receiptBitmap = byteStreamToBitmap(mCameraSource.mostRecentBitmap); receiptBitmap.compress(Bitmap.CompressFormat.JPEG, 80, fos); picPath = pictureFile.getAbsolutePath(); //fos.write(mCameraSource.mostRecentBitmap); fos.close(); } catch (FileNotFoundException e) { } catch (IOException e) { } upArrow.animate().rotation(180).setDuration(500).start(); TextView amount = (TextView) view.findViewById(R.id.text_amount_value); if (mGraphicOverlay.amountItem == null) { amount.setText("0.00"); } else { amount.setText(String.format("%.2f", mGraphicOverlay.amountItemAfterFormat)); } TextView desc = (TextView) view.findViewById(R.id.text_name_value); desc.setText(mGraphicOverlay.description); RelativeLayout box = (RelativeLayout) view.findViewById(R.id.recognition_box); box.setVisibility(View.VISIBLE); Animation slide_up = AnimationUtils.loadAnimation(activity.getApplicationContext(), R.anim.slide_up); box.startAnimation(slide_up); rotationAngle = 180; } else { // t.interrupt(); // t = null; RelativeLayout box = (RelativeLayout) view.findViewById(R.id.recognition_box); Animation slide_down = AnimationUtils.loadAnimation(activity.getApplicationContext(), R.anim.slide_down); upArrow.animate().rotation(0).setDuration(500).start(); box.startAnimation(slide_down); box.setVisibility(View.INVISIBLE); //shouldContinue = true; mGraphicOverlay.amountItem = null; mGraphicOverlay.amountItemAfterFormat = 0f; mGraphicOverlay.description = ""; onResume(); // createNewThread(); // t.start(); rotationAngle = 0; } } }); ImageView addButton = (ImageView) view.findViewById(R.id.add_icon); addButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // takePicture(); EditText description = (EditText) view.findViewById(R.id.text_name_value); EditText amount = (EditText) view.findViewById(R.id.text_amount_value); float floatAmount = Float.parseFloat(amount.getText().toString()); Summary t = new Summary(description.getText().toString(), floatAmount); Bundle bundle = new Bundle(); bundle.putSerializable("splitTransaction", t); // ByteArrayOutputStream stream = new ByteArrayOutputStream(); // mCameraSource.mostRecentBitmap.compress(Bitmap.CompressFormat.PNG, 80, stream); // byte[] byteArray = stream.toByteArray(); //Bitmap receiptBitmap = byteStreamToBitmap(mCameraSource.mostRecentBitmap); //bundle.putParcelable("receiptPicture",receiptBitmap); bundle.putString("receiptPicture", picPath); FriendsSelectionFragment fragment = new FriendsSelectionFragment(); fragment.setArguments(bundle); ((Toolbar) activity.findViewById(R.id.tool_bar_hamburger)).setVisibility(View.INVISIBLE); getActivity().getSupportFragmentManager().beginTransaction() .add(R.id.fragment_holder, fragment, "FriendsSelectionFragment").addToBackStack(null) .commit(); } }); // Check for the camera permission before accessing the camera. If the // permission is not granted yet, request permission. int rc = ActivityCompat.checkSelfPermission(context, Manifest.permission.CAMERA); if (rc == PackageManager.PERMISSION_GRANTED) { createCameraSource(autoFocus, useFlash); } else { requestCameraPermission(); } gestureDetector = new GestureDetector(context, new CaptureGestureListener()); scaleGestureDetector = new ScaleGestureDetector(context, new ScaleListener()); // Snackbar.make(mGraphicOverlay, "Tap to Speak. Pinch/Stretch to zoom", // Snackbar.LENGTH_LONG) // .show(); // Set up the Text To Speech engine. TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() { @Override public void onInit(final int status) { if (status == TextToSpeech.SUCCESS) { Log.d("OnInitListener", "Text to speech engine started successfully."); tts.setLanguage(Locale.US); } else { Log.d("OnInitListener", "Error starting the text to speech engine."); } } }; tts = new TextToSpeech(activity.getApplicationContext(), listener); return view; }
From source file:com.github.pockethub.android.ui.ItemListFragment.java
private ItemListFragment<E> fadeIn(final View view, final boolean animate) { if (view != null) { if (animate) { view.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in)); } else {//w ww . ja va 2 s. c o m view.clearAnimation(); } } return this; }
From source file:com.contralabs.inmap.activities.MainActivity.java
private void showStoreList() { isShowingStoreList = true;// w w w.j a v a2s . c o m mLayoutStoreList.setVisibility(View.VISIBLE); mLayoutCategoryList.startAnimation(AnimationUtils.loadAnimation(this, R.anim.to_up_100)); mLayoutStoreList.startAnimation(AnimationUtils.loadAnimation(this, R.anim.to_up_from_100)); }
From source file:com.skubit.comics.activities.ComicViewerActivity.java
@Override public void toggleView() { if (mIsFullView) { toolbar.setVisibility(View.VISIBLE); toolbar.animate().translationY(0); mMainView.setBackgroundColor(getResources().getColor(android.R.color.background_light)); mIsFullView = false;/* w w w .j a v a2 s . c om*/ mSlider.setVisibility(View.VISIBLE); mSlider.animate().translationY(0); mSlider.setValue(mPager.getCurrentItem()); final Animation anim = AnimationUtils.loadAnimation(this, R.anim.scale_in); anim.setFillEnabled(true); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation arg0) { mPager.setDrawingCacheEnabled(true); } @Override public void onAnimationRepeat(Animation arg0) { } @Override public void onAnimationEnd(Animation arg0) { mPager.setScaleX(.83f); mPager.setScaleY(.83f); mPager.clearAnimation(); } }); mPager.setAnimation(anim); mPager.startAnimation(anim); } else { toolbar.animate().translationY(-toolbar.getHeight()); toolbar.setLayoutAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { toolbar.setVisibility(View.INVISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); mMainView.setBackgroundColor(getResources().getColor(android.R.color.background_dark)); mIsFullView = true; mSlider.animate().translationY(mMainView.getHeight() + mSlider.getHeight()); mSlider.setLayoutAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { mSlider.setVisibility(View.INVISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); final Animation anim = AnimationUtils.loadAnimation(this, R.anim.scale_out); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation arg0) { mPager.setScaleX(1f); mPager.setScaleY(1f); } @Override public void onAnimationRepeat(Animation arg0) { } @Override public void onAnimationEnd(Animation arg0) { mPager.clearAnimation(); } }); mPager.setAnimation(anim); mPager.startAnimation(anim); } }
From source file:com.klinker.android.twitter.ui.drawer_activities.DrawerActivity.java
public void setUpDrawer(int number, final String actName) { try {/* w w w .j av a2s.c om*/ ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception ex) { // Ignore } actionBar = getActionBar(); MainDrawerArrayAdapter.current = number; TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.drawerIcon }); int resource = a.getResourceId(0, 0); a.recycle(); a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.read_button }); openMailResource = a.getResourceId(0, 0); a.recycle(); a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.unread_button }); closedMailResource = a.getResourceId(0, 0); a.recycle(); mDrawerLayout = (NotificationDrawerLayout) findViewById(R.id.drawer_layout); mDrawer = (LinearLayout) findViewById(R.id.left_drawer); HoloTextView name = (HoloTextView) mDrawer.findViewById(R.id.name); HoloTextView screenName = (HoloTextView) mDrawer.findViewById(R.id.screen_name); backgroundPic = (NetworkedCacheableImageView) mDrawer.findViewById(R.id.background_image); profilePic = (NetworkedCacheableImageView) mDrawer.findViewById(R.id.profile_pic_contact); final ImageButton showMoreDrawer = (ImageButton) mDrawer.findViewById(R.id.options); final LinearLayout logoutLayout = (LinearLayout) mDrawer.findViewById(R.id.logoutLayout); final Button logoutDrawer = (Button) mDrawer.findViewById(R.id.logoutButton); drawerList = (ListView) mDrawer.findViewById(R.id.drawer_list); notificationList = (EnhancedListView) findViewById(R.id.notificationList); try { mDrawerLayout = (NotificationDrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow_rev, Gravity.END); mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ resource, /* nav drawer icon to replace 'Up' caret */ R.string.app_name, /* "open drawer" description */ R.string.app_name /* "close drawer" description */ ) { public void onDrawerClosed(View view) { actionBar.setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent))); if (logoutVisible) { Animation ranim = AnimationUtils.loadAnimation(context, R.anim.drawer_rotate_back); ranim.setFillAfter(true); showMoreDrawer.startAnimation(ranim); logoutLayout.setVisibility(View.GONE); drawerList.setVisibility(View.VISIBLE); logoutVisible = false; } if (MainDrawerArrayAdapter.current > 2) { actionBar.setTitle(actName); } else { int position = mViewPager.getCurrentItem(); String title = ""; try { title = "" + mSectionsPagerAdapter.getPageTitle(position); } catch (NullPointerException e) { title = ""; } actionBar.setTitle(title); } try { if (oldInteractions.getText().toString() .equals(getResources().getString(R.string.new_interactions))) { oldInteractions.setText(getResources().getString(R.string.old_interactions)); readButton.setImageResource(openMailResource); notificationList.enableSwipeToDismiss(); notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource .getInstance(context).getUnreadCursor(DrawerActivity.settings.currentAccount)); notificationList.setAdapter(notificationAdapter); } } catch (Exception e) { // don't have talon pull on } invalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { actionBar.setTitle(getResources().getString(R.string.app_name)); actionBar.setIcon(R.mipmap.ic_launcher); try { notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource .getInstance(context).getUnreadCursor(settings.currentAccount)); notificationList.setAdapter(notificationAdapter); notificationList.enableSwipeToDismiss(); oldInteractions.setText(getResources().getString(R.string.old_interactions)); readButton.setImageResource(openMailResource); sharedPrefs.edit().putBoolean("new_notification", false).commit(); } catch (Exception e) { // don't have talon pull on } invalidateOptionsMenu(); } public void onDrawerSlide(View drawerView, float slideOffset) { super.onDrawerSlide(drawerView, slideOffset); if (!actionBar.isShowing()) { actionBar.show(); } if (translucent) { statusBar.setVisibility(View.VISIBLE); } } }; mDrawerLayout.setDrawerListener(mDrawerToggle); } catch (Exception e) { // landscape mode } actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); showMoreDrawer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (logoutLayout.getVisibility() == View.GONE) { Animation ranim = AnimationUtils.loadAnimation(context, R.anim.drawer_rotate); ranim.setFillAfter(true); showMoreDrawer.startAnimation(ranim); Animation anim = AnimationUtils.loadAnimation(context, R.anim.fade_out); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { drawerList.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) { } }); anim.setDuration(300); drawerList.startAnimation(anim); Animation anim2 = AnimationUtils.loadAnimation(context, R.anim.fade_in); anim2.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { logoutLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); anim2.setDuration(300); logoutLayout.startAnimation(anim2); logoutVisible = true; } else { Animation ranim = AnimationUtils.loadAnimation(context, R.anim.drawer_rotate_back); ranim.setFillAfter(true); showMoreDrawer.startAnimation(ranim); Animation anim = AnimationUtils.loadAnimation(context, R.anim.fade_in); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { drawerList.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); anim.setDuration(300); drawerList.startAnimation(anim); Animation anim2 = AnimationUtils.loadAnimation(context, R.anim.fade_out); anim2.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { logoutLayout.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) { } }); anim2.setDuration(300); logoutLayout.startAnimation(anim2); logoutVisible = false; } } }); logoutDrawer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { logoutFromTwitter(); } }); final String sName = settings.myName; final String sScreenName = settings.myScreenName; final String backgroundUrl = settings.myBackgroundUrl; final String profilePicUrl = settings.myProfilePicUrl; final BitmapLruCache mCache = App.getInstance(context).getProfileCache(); if (!backgroundUrl.equals("")) { backgroundPic.loadImage(backgroundUrl, false, null); //ImageUtils.loadImage(context, backgroundPic, backgroundUrl, mCache); } else { backgroundPic.setImageDrawable(getResources().getDrawable(R.drawable.default_header_background)); } backgroundPic.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { mDrawerLayout.closeDrawer(Gravity.START); } catch (Exception e) { } new Handler().postDelayed(new Runnable() { @Override public void run() { Intent viewProfile = new Intent(context, ProfilePager.class); viewProfile.putExtra("name", sName); viewProfile.putExtra("screenname", sScreenName); viewProfile.putExtra("proPic", profilePicUrl); viewProfile.putExtra("tweetid", 0); viewProfile.putExtra("retweet", false); viewProfile.putExtra("long_click", false); context.startActivity(viewProfile); } }, 400); } }); backgroundPic.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { try { mDrawerLayout.closeDrawer(Gravity.START); } catch (Exception e) { } new Handler().postDelayed(new Runnable() { @Override public void run() { Intent viewProfile = new Intent(context, ProfilePager.class); viewProfile.putExtra("name", sName); viewProfile.putExtra("screenname", sScreenName); viewProfile.putExtra("proPic", profilePicUrl); viewProfile.putExtra("tweetid", 0); viewProfile.putExtra("retweet", false); viewProfile.putExtra("long_click", true); context.startActivity(viewProfile); } }, 400); return false; } }); try { name.setText(sName); screenName.setText("@" + sScreenName); name.setTextSize(15); screenName.setTextSize(15); } catch (Exception e) { // 7 inch tablet in portrait } try { if (settings.roundContactImages) { //profilePic.loadImage(profilePicUrl, false, null, NetworkedCacheableImageView.CIRCLE); ImageUtils.loadCircleImage(context, profilePic, profilePicUrl, mCache); } else { profilePic.loadImage(profilePicUrl, false, null); ImageUtils.loadImage(context, profilePic, profilePicUrl, mCache); } } catch (Exception e) { // empty path again } MainDrawerArrayAdapter adapter = new MainDrawerArrayAdapter(context, new ArrayList<String>(Arrays.asList(MainDrawerArrayAdapter.getItems(context)))); drawerList.setAdapter(adapter); drawerList.setOnItemClickListener(new MainDrawerClickListener(context, mDrawerLayout, mViewPager)); // set up for the second account int count = 0; // number of accounts logged in if (sharedPrefs.getBoolean("is_logged_in_1", false)) { count++; } if (sharedPrefs.getBoolean("is_logged_in_2", false)) { count++; } RelativeLayout secondAccount = (RelativeLayout) findViewById(R.id.second_profile); HoloTextView name2 = (HoloTextView) findViewById(R.id.name_2); HoloTextView screenname2 = (HoloTextView) findViewById(R.id.screen_name_2); NetworkedCacheableImageView proPic2 = (NetworkedCacheableImageView) findViewById(R.id.profile_pic_2); name2.setTextSize(15); screenname2.setTextSize(15); final int current = sharedPrefs.getInt("current_account", 1); // make a second account if (count == 1) { name2.setText(getResources().getString(R.string.new_account)); screenname2.setText(getResources().getString(R.string.tap_to_setup)); secondAccount.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (canSwitch) { if (current == 1) { sharedPrefs.edit().putInt("current_account", 2).commit(); } else { sharedPrefs.edit().putInt("current_account", 1).commit(); } context.sendBroadcast(new Intent("com.klinker.android.twitter.STOP_PUSH_SERVICE")); context.sendBroadcast(new Intent("com.klinker.android.twitter.MARK_POSITION")); Intent login = new Intent(context, LoginActivity.class); AppSettings.invalidate(); finish(); startActivity(login); } } }); } else { // switch accounts if (current == 1) { name2.setText(sharedPrefs.getString("twitter_users_name_2", "")); screenname2.setText("@" + sharedPrefs.getString("twitter_screen_name_2", "")); try { if (settings.roundContactImages) { //proPic2.loadImage(sharedPrefs.getString("profile_pic_url_2", ""), true, null, NetworkedCacheableImageView.CIRCLE); ImageUtils.loadCircleImage(context, proPic2, sharedPrefs.getString("profile_pic_url_2", ""), mCache); } else { //proPic2.loadImage(sharedPrefs.getString("profile_pic_url_2", ""), true, null); ImageUtils.loadImage(context, proPic2, sharedPrefs.getString("profile_pic_url_2", ""), mCache); } } catch (Exception e) { } secondAccount.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (canSwitch) { context.sendBroadcast(new Intent("com.klinker.android.twitter.STOP_PUSH_SERVICE")); context.sendBroadcast(new Intent("com.klinker.android.twitter.MARK_POSITION") .putExtra("current_account", current)); Toast.makeText(context, "Preparing to switch", Toast.LENGTH_SHORT).show(); // we want to wait a second so that the mark position broadcast will work new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(1000); } catch (Exception e) { } sharedPrefs.edit().putInt("current_account", 2).commit(); sharedPrefs.edit().remove("new_notifications").remove("new_retweets") .remove("new_favorites").remove("new_follows").commit(); AppSettings.invalidate(); finish(); Intent next = new Intent(context, MainActivity.class); startActivity(next); } }).start(); } } }); } else { name2.setText(sharedPrefs.getString("twitter_users_name_1", "")); screenname2.setText("@" + sharedPrefs.getString("twitter_screen_name_1", "")); try { if (settings.roundContactImages) { //proPic2.loadImage(sharedPrefs.getString("profile_pic_url_1", ""), true, null, NetworkedCacheableImageView.CIRCLE); ImageUtils.loadCircleImage(context, proPic2, sharedPrefs.getString("profile_pic_url_1", ""), mCache); } else { //proPic2.loadImage(sharedPrefs.getString("profile_pic_url_1", ""), true, null); ImageUtils.loadImage(context, proPic2, sharedPrefs.getString("profile_pic_url_1", ""), mCache); } } catch (Exception e) { } secondAccount.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (canSwitch) { context.sendBroadcast(new Intent("com.klinker.android.twitter.STOP_PUSH_SERVICE")); context.sendBroadcast(new Intent("com.klinker.android.twitter.MARK_POSITION") .putExtra("current_account", current)); Toast.makeText(context, "Preparing to switch", Toast.LENGTH_SHORT).show(); new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(1000); } catch (Exception e) { } sharedPrefs.edit().putInt("current_account", 1).commit(); sharedPrefs.edit().remove("new_notifications").remove("new_retweets") .remove("new_favorites").remove("new_follows").commit(); AppSettings.invalidate(); finish(); Intent next = new Intent(context, MainActivity.class); startActivity(next); } }).start(); } } }); } } statusBar = findViewById(R.id.activity_status_bar); statusBarHeight = Utils.getStatusBarHeight(context); navBarHeight = Utils.getNavBarHeight(context); try { RelativeLayout.LayoutParams statusParams = (RelativeLayout.LayoutParams) statusBar.getLayoutParams(); statusParams.height = statusBarHeight; statusBar.setLayoutParams(statusParams); } catch (Exception e) { try { LinearLayout.LayoutParams statusParams = (LinearLayout.LayoutParams) statusBar.getLayoutParams(); statusParams.height = statusBarHeight; statusBar.setLayoutParams(statusParams); } catch (Exception x) { // in the trends } } View navBarSeperater = findViewById(R.id.nav_bar_seperator); if (translucent && Utils.hasNavBar(context)) { try { RelativeLayout.LayoutParams navParams = (RelativeLayout.LayoutParams) navBarSeperater .getLayoutParams(); navParams.height = navBarHeight; navBarSeperater.setLayoutParams(navParams); } catch (Exception e) { try { LinearLayout.LayoutParams navParams = (LinearLayout.LayoutParams) navBarSeperater .getLayoutParams(); navParams.height = navBarHeight; navBarSeperater.setLayoutParams(navParams); } catch (Exception x) { // in the trends } } } if (translucent) { if (Utils.hasNavBar(context)) { View footer = new View(context); footer.setOnClickListener(null); footer.setOnLongClickListener(null); ListView.LayoutParams params = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, Utils.getNavBarHeight(context)); footer.setLayoutParams(params); drawerList.addFooterView(footer); drawerList.setFooterDividersEnabled(false); } View drawerStatusBar = findViewById(R.id.drawer_status_bar); LinearLayout.LayoutParams status2Params = (LinearLayout.LayoutParams) drawerStatusBar.getLayoutParams(); status2Params.height = statusBarHeight; drawerStatusBar.setLayoutParams(status2Params); drawerStatusBar.setVisibility(View.VISIBLE); statusBar.setVisibility(View.VISIBLE); drawerStatusBar = findViewById(R.id.drawer_status_bar_2); status2Params = (LinearLayout.LayoutParams) drawerStatusBar.getLayoutParams(); status2Params.height = statusBarHeight; drawerStatusBar.setLayoutParams(status2Params); drawerStatusBar.setVisibility(View.VISIBLE); } if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE || getResources().getBoolean(R.bool.isTablet)) { actionBar.setDisplayHomeAsUpEnabled(false); } if (!settings.pushNotifications) { try { mDrawerLayout.setDrawerLockMode(NotificationDrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.END); } catch (Exception e) { // no drawer? } } else { try { if (Build.VERSION.SDK_INT < 18 && DrawerActivity.settings.uiExtras) { View viewHeader2 = ((Activity) context).getLayoutInflater().inflate(R.layout.ab_header, null); notificationList.addHeaderView(viewHeader2, null, false); notificationList.setHeaderDividersEnabled(false); } } catch (Exception e) { // i don't know why it does this to be honest... } notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource.getInstance(context) .getUnreadCursor(DrawerActivity.settings.currentAccount)); try { notificationList.setAdapter(notificationAdapter); } catch (Exception e) { } View viewHeader = ((Activity) context).getLayoutInflater().inflate(R.layout.interactions_footer_1, null); notificationList.addFooterView(viewHeader, null, false); oldInteractions = (HoloTextView) findViewById(R.id.old_interactions_text); readButton = (ImageView) findViewById(R.id.read_button); LinearLayout footer = (LinearLayout) viewHeader.findViewById(R.id.footer); footer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (oldInteractions.getText().toString() .equals(getResources().getString(R.string.old_interactions))) { oldInteractions.setText(getResources().getString(R.string.new_interactions)); readButton.setImageResource(closedMailResource); notificationList.disableSwipeToDismiss(); notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource .getInstance(context).getCursor(DrawerActivity.settings.currentAccount)); } else { oldInteractions.setText(getResources().getString(R.string.old_interactions)); readButton.setImageResource(openMailResource); notificationList.enableSwipeToDismiss(); notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource .getInstance(context).getUnreadCursor(DrawerActivity.settings.currentAccount)); } notificationList.setAdapter(notificationAdapter); } }); if (DrawerActivity.translucent) { if (Utils.hasNavBar(context)) { View nav = new View(context); nav.setOnClickListener(null); nav.setOnLongClickListener(null); ListView.LayoutParams params = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, Utils.getNavBarHeight(context)); nav.setLayoutParams(params); notificationList.addFooterView(nav); notificationList.setFooterDividersEnabled(false); } } notificationList.setDismissCallback(new EnhancedListView.OnDismissCallback() { @Override public EnhancedListView.Undoable onDismiss(EnhancedListView listView, int position) { Log.v("talon_interactions_delete", "position to delete: " + position); InteractionsDataSource data = InteractionsDataSource.getInstance(context); data.markRead(settings.currentAccount, position); notificationAdapter = new InteractionsCursorAdapter(context, data.getUnreadCursor(DrawerActivity.settings.currentAccount)); notificationList.setAdapter(notificationAdapter); oldInteractions.setText(getResources().getString(R.string.old_interactions)); readButton.setImageResource(openMailResource); if (notificationAdapter.getCount() == 0) { setNotificationFilled(false); } return null; } }); notificationList.enableSwipeToDismiss(); notificationList.setSwipeDirection(EnhancedListView.SwipeDirection.START); notificationList .setOnItemClickListener(new InteractionClickListener(context, mDrawerLayout, mViewPager)); } }
From source file:com.osama.cryptofm.filemanager.ui.TabsFragmentOne.java
private void forwardAnimation(final int mode) { Animation animation = AnimationUtils.loadAnimation(mContext, R.anim.enter_from_left); if (mode == 0) { animation = AnimationUtils.loadAnimation(mContext, R.anim.enter_from_right); }/*from ww w . j a va2 s . c o m*/ mRecyclerView.setAnimation(animation); mRecyclerView.animate(); }
From source file:com.filemanager.free.adapters.Recycleradapter.java
void animate(Recycleradapter.ViewHolder holder) { holder.rl.clearAnimation();/*www. j av a 2 s . c o m*/ localAnimation = AnimationUtils.loadAnimation(context, anim); localAnimation.setStartOffset(this.offset); holder.rl.startAnimation(localAnimation); this.offset += 30; }