Example usage for android.view.animation AnimationUtils loadAnimation

List of usage examples for android.view.animation AnimationUtils loadAnimation

Introduction

In this page you can find the example usage for android.view.animation AnimationUtils loadAnimation.

Prototype

public static Animation loadAnimation(Context context, @AnimRes int id) throws NotFoundException 

Source Link

Document

Loads an Animation object from a resource

Usage

From source file:com.klinker.android.twitter.activities.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++;//from www .  j  av  a 2  s.  c o  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 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
    }

    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 || !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 = ((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:cn.zhangls.android.weibo.ui.weibo.WeiboFrameProvider.java

/**
 * ????//  w  ww. j  a va  2 s.co  m
 *
 * @param holder
 * @param status
 */
private void setupPopupBar(final FrameHolder holder, final Status status) {
    LayoutInflater layoutInflater = LayoutInflater
            .from(holder.binding.fgHomeWeiboPopupBar.getContext().getApplicationContext());
    // 
    final View popupView;
    if (status.isFavorited() && status.getUser().isFollowing()) {// ??
        popupView = layoutInflater.inflate(R.layout.popup_window_weibo_follow_save_post,
                holder.binding.flWeiboContainer, false);
    } else if (!status.isFavorited() && status.getUser().isFollowing()) {// ??
        popupView = layoutInflater.inflate(R.layout.popup_window_weibo_follow_unsave_post,
                holder.binding.flWeiboContainer, false);
    } else if (status.isFavorited() && !status.getUser().isFollowing()) {// ??
        popupView = layoutInflater.inflate(R.layout.popup_window_weibo_unfollow_save_post,
                holder.binding.flWeiboContainer, false);
    } else {// ??
        popupView = layoutInflater.inflate(R.layout.popup_window_weibo_unfollow_unsave_post,
                holder.binding.flWeiboContainer, false);
    }
    //  PopupWindow
    final PopupWindow popupWindow = new PopupWindow(popupView, LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    popupWindow.setTouchable(true);
    popupWindow.setFocusable(true);
    popupWindow.setOutsideTouchable(true);
    // popupWindow 
    popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            Animation animation = AnimationUtils.loadAnimation(
                    holder.binding.fgHomeWeiboPopupBar.getContext().getApplicationContext(),
                    R.anim.rotate_180_end);
            animation.setDuration(300);
            animation.setFillAfter(true);
            holder.binding.fgHomeWeiboPopupBar.startAnimation(animation);
        }
    });
    popupWindow.setAnimationStyle(R.style.PopupWindowAnimStyle);
    // popupWindow  Item ?
    if (status.isFavorited()) {// ??????
        popupWindow.getContentView().findViewById(R.id.menu_item_weibo_more_save_post)
                .setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        FavoritesAPI favoritesAPI = new FavoritesAPI(
                                mBinding.getRoot().getContext().getApplicationContext(),
                                AccessTokenKeeper.readAccessToken(
                                        mBinding.getRoot().getContext().getApplicationContext()));
                        BaseObserver<Favorite> observer = new BaseObserver<Favorite>(
                                mBinding.getRoot().getContext().getApplicationContext()) {
                            @Override
                            public void onNext(Favorite value) {
                            }

                            @Override
                            public void onError(Throwable e) {
                                super.onError(e);
                            }

                            @Override
                            public void onComplete() {

                            }
                        };

                        favoritesAPI.destroy(observer, status.getId());

                        popupWindow.dismiss();
                    }
                });
    } else {
        popupWindow.getContentView().findViewById(R.id.menu_item_weibo_more_unsave_post)
                .setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        FavoritesAPI favoritesAPI = new FavoritesAPI(
                                mBinding.getRoot().getContext().getApplicationContext(),
                                AccessTokenKeeper.readAccessToken(
                                        mBinding.getRoot().getContext().getApplicationContext()));
                        BaseObserver<Favorite> observer = new BaseObserver<Favorite>(
                                mBinding.getRoot().getContext().getApplicationContext()) {
                            @Override
                            public void onNext(Favorite value) {
                            }

                            @Override
                            public void onError(Throwable e) {
                                super.onError(e);
                            }

                            @Override
                            public void onComplete() {

                            }
                        };

                        favoritesAPI.create(observer, status.getId());

                        popupWindow.dismiss();
                    }
                });
    }
    if (status.getUser().isFollowing()) {// ????
        popupWindow.getContentView().findViewById(R.id.menu_item_weibo_more_follow)
                .setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        popupWindow.dismiss();
                    }
                });
    } else {
        popupWindow.getContentView().findViewById(R.id.menu_item_weibo_more_unfollow)
                .setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        popupWindow.dismiss();
                    }
                });
    }

    // ???
    holder.binding.fgHomeWeiboPopupBar.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (popupWindow != null && !popupWindow.isShowing()) {
                Animation animation = AnimationUtils.loadAnimation(
                        holder.binding.fgHomeWeiboPopupBar.getContext().getApplicationContext(),
                        R.anim.rotate_180_start);
                animation.setDuration(300);
                animation.setFillAfter(true);
                holder.binding.fgHomeWeiboPopupBar.startAnimation(animation);
                popupWindow.showAsDropDown(holder.binding.fgHomeWeiboPopupBar);
            }
        }
    });
}

From source file:com.ibuildapp.romanblack.FanWallPlugin.FanWallPlugin.java

private void initializeBackend() {
    // parse input xml data
    res = getResources();//from www.  ja va  2  s . c o  m
    density = res.getDisplayMetrics().density;

    showProgress = AnimationUtils.loadAnimation(FanWallPlugin.this, R.anim.show_progress_anim);
    hideProgress = AnimationUtils.loadAnimation(FanWallPlugin.this, R.anim.hide_progress_anim);

    currentIntent = getIntent();
    widget = (Widget) currentIntent.getSerializableExtra("Widget");
    String tempCachePath = widget.getCachePath();

    EntityParser parser = new EntityParser();
    try {
        if (TextUtils.isEmpty(widget.getPluginXmlData())) {
            if (TextUtils.isEmpty(currentIntent.getStringExtra("WidgetFile"))) {
                handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 3000);
                return;
            }
        }

        if (!TextUtils.isEmpty(widget.getPluginXmlData())) {
            parser.parse(widget.getPluginXmlData());
        } else {
            String xmlData = readXmlFromFile(currentIntent.getStringExtra("WidgetFile"));
            parser.parse(xmlData);
        }
    } catch (Exception e) {
        handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 3000);
        return;
    }

    Statics.hasAd = widget.isHaveAdvertisement();
    Statics.appName = widget.getAppName();
    Statics.near = parser.getNear();
    Statics.MODULE_ID = parser.getModuleId();
    Statics.canEdit = parser.getCanEdit();
    Statics.APP_ID = parser.getAppId();

    Statics.color1 = parser.getColor1();
    Statics.color2 = parser.getColor2();
    Statics.color3 = parser.getColor3();
    Statics.color4 = parser.getColor4();
    Statics.color5 = parser.getColor5();
    if (Statics.BackColorToFontColor(Statics.color1) == Color.WHITE)
        Statics.isSchemaDark = true;
    else
        Statics.isSchemaDark = false;

    // init cache path
    if (!TextUtils.isEmpty(tempCachePath))
        Statics.cachePath = tempCachePath + "/fanwall-" + widget.getOrder();

    Statics.onAuthListeners.add(this);

    // register separate LocationManager.GPS_PROVIDER for register status change events
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    Statics.currentLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 0, new LocationListener() {
        @Override
        public void onLocationChanged(Location location) {
            Statics.currentLocation = location;
        }

        @Override
        public void onStatusChanged(String s, int i, Bundle bundle) {
        }

        @Override
        public void onProviderEnabled(String s) {
            Prefs.with(FanWallPlugin.this).save(Prefs.KEY_GPS, true);
            enableGpsCheckbox.setChecked(true);
        }

        @Override
        public void onProviderDisabled(String s) {
            Prefs.with(FanWallPlugin.this).save(Prefs.KEY_GPS, false);
            enableGpsCheckbox.setChecked(false);
        }
    });
}

From source file:com.hamsik2046.password.view.SingleInputFormActivity.java

private void setupInput() {
    mInputSwitcher.setInAnimation(AnimationUtils.loadAnimation(activity, R.anim.alpha_in));
    mInputSwitcher.setOutAnimation(AnimationUtils.loadAnimation(activity, R.anim.alpha_out));

    mInputSwitcher.removeAllViews();/*  w w w  . java  2 s .  c  o m*/
    for (int i = 0; i < stepsSize(); i++) {
        mInputSwitcher.addView(getStep(i).getView());
    }
}

From source file:com.smartx.bill.mepad.mestore.uimgloader.AbsListViewBaseActivity.java

protected void setDialog() {
    dialog = new ProgressDialog(this, R.style.welcome_dialog);
    dialog.setCancelable(false);//from  w w w. j a v a 2  s.c  om
    dialog.show();
    LayoutInflater inflater = LayoutInflater.from(this);
    View v = inflater.inflate(R.layout.wlecome_dialog, null);// view
    LinearLayout layout = (LinearLayout) v.findViewById(R.id.dialog_view);// 
    // main.xmlImageView
    ImageView spaceshipImage = (ImageView) v.findViewById(R.id.img);
    TextView tipTextView = (TextView) v.findViewById(R.id.tipTextView);// ??
    // 
    Animation hyperspaceJumpAnimation = AnimationUtils.loadAnimation(this, R.anim.loading_animation);
    // ImageView
    spaceshipImage.startAnimation(hyperspaceJumpAnimation);
    // tipTextView.setText(msg);// ?
    dialog.setContentView(layout);
}

From source file:com.cypress.cysmart.BLEServiceFragments.HeartRateService.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.hrm_measurement, container, false);
    mDataField_HRM = (TextView) rootView.findViewById(R.id.hrm_heartrate);
    mDataField_HREE = (TextView) rootView.findViewById(R.id.heart_rate_ee);
    mDataField_HRRR = (TextView) rootView.findViewById(R.id.heart_rate_rr);
    mDataField_BSL = (TextView) rootView.findViewById(R.id.hrm_sensor_data);
    mProgressDialog = new ProgressDialog(getActivity());
    mHeartView = (ImageView) rootView.findViewById(R.id.heart_icon);
    setHasOptionsMenu(true);/*w  w w . j  a va  2  s. com*/
    Animation pulse = AnimationUtils.loadAnimation(getActivity(), R.anim.pulse);
    mHeartView.startAnimation(pulse);
    // Setting up chart
    setupChart(rootView);
    return rootView;
}

From source file:fr.simon.marquis.preferencesmanager.ui.PreferencesActivity.java

private void updateFindFiles(ArrayList<String> tmp) {
    files = tmp;//from ww w .  j  a  v a 2 s . c  om
    SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager(), files);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    Animation fadeIn = AnimationUtils.loadAnimation(this, android.R.anim.fade_in);
    Animation fadeOut = AnimationUtils.loadAnimation(this, android.R.anim.fade_out);

    if (files == null || files.size() == 0) {
        if (fadeIn != null) {
            mEmptyView.startAnimation(fadeIn);
        }
        mEmptyView.setVisibility(View.VISIBLE);
        if (fadeOut != null) {
            mLoadingView.startAnimation(fadeOut);
        }
        mLoadingView.setVisibility(View.GONE);
    } else {
        mEmptyView.setVisibility(View.GONE);
        mLoadingView.setVisibility(View.GONE);
        if (fadeIn != null) {
            mViewPager.startAnimation(fadeIn);
        }
        mViewPager.setVisibility(View.VISIBLE);
    }
}

From source file:samples.piggate.com.piggateCompleteExample.Activity_Logged.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    _piggate = new Piggate(this, null); //Initialize the Piggate object
    setContentView(R.layout.activity_logged);
    getSupportActionBar().setTitle(PiggateUser.getEmail());

    startService(new Intent(getApplicationContext(), Service_Notify.class)); //Start the service

    //Initialize and set all the left navigation drawer fields
    mDrawer = new Drawer().withActivity(this).withTranslucentStatusBar(false).withHeader(R.layout.drawerheader)
            .addDrawerItems( /* Add drawer items with this method */)
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override//from w w w . ja  va2  s  .c o  m
                public void onItemClick(AdapterView<?> parent, View view, int position, long id,
                        IDrawerItem drawerItem) {
                    // Open the exchange activity for the selected item
                    Intent slideactivity = new Intent(Activity_Logged.this, Activity_Exchange.class);
                    slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);

                    //Send the current offer information to the exchange activity
                    slideactivity.putExtra("offerName", exchangeOfferList.get(position).getName().toString());
                    slideactivity.putExtra("offerDescription",
                            exchangeOfferList.get(position).getDescription().toString());
                    slideactivity.putExtra("offerImgURL",
                            exchangeOfferList.get(position).getImgURL().toString());
                    slideactivity.putExtra("exchangeID",
                            exchangeOfferList.get(position).getExchangeID().toString());

                    Bundle bndlanimation = ActivityOptions.makeCustomAnimation(Activity_Logged.this,
                            R.anim.slidefromright, R.anim.slidetoleft).toBundle();
                    startActivity(slideactivity, bndlanimation);
                }
            }).withSliderBackgroundColor(Color.parseColor("#FFFFFF")).withSelectedItem(-1).build();

    //Initialize recycler view
    mRecyclerView = (RecyclerView) findViewById(R.id.my_recycler_view);
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(Activity_Logged.this));
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    newBeaconsLayout = (LinearLayout) findViewById(R.id.newBeaconsLayout);

    //Initialize swipe layout
    mSwipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container);
    mSwipeLayout.setOnRefreshListener(this);

    errorDialog = new AlertDialog.Builder(this).create();
    errorDialog.setTitle("Logout error");
    errorDialog.setMessage("There is an error with the logout");
    errorDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    successPaymentDialog = new AlertDialog.Builder(this).create();
    successPaymentDialog.setTitle("Successful payment");
    successPaymentDialog.setMessage("Now you can exchange your purchased product");
    successPaymentDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    errorBuyDialog = new AlertDialog.Builder(this).create();
    errorBuyDialog.setTitle("Payment failed");
    errorBuyDialog.setMessage("There is an error with your payment");
    errorBuyDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    successExchangeDialog = new AlertDialog.Builder(this).create();
    successExchangeDialog.setTitle("Offer successfully exchanged");
    successExchangeDialog.setMessage("The offer has been purchased and exchanged");
    successExchangeDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    errorExchangeDialog = new AlertDialog.Builder(this).create();
    errorExchangeDialog.setTitle("Exchange error");
    errorExchangeDialog.setMessage("There is an error with the exchange");
    errorExchangeDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    networkErrorDialog = new AlertDialog.Builder(this).create();
    networkErrorDialog.setTitle("Network error");
    networkErrorDialog.setMessage("There is an error with the network connection");
    networkErrorDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    fadeIn = AnimationUtils.loadAnimation(Activity_Logged.this, R.anim.fadein);
    fadeOut = AnimationUtils.loadAnimation(Activity_Logged.this, R.anim.fadeout);

    //Check if the bluetooth is switched on
    BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    if (!mBluetoothAdapter.isEnabled()) {
        Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
        startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
    }

    if (getIntent().hasExtra("payment")) {
        if (getIntent().getExtras().getBoolean("payment") == true) {
            successPaymentDialog.show(); //Show success payment dialog
            mDrawer.openDrawer(); //Open the left panel
        } else {
            errorBuyDialog.show(); //Show payment error dialog
        }
    } else if (getIntent().hasExtra("exchanged")) {
        if (getIntent().getExtras().getBoolean("exchanged") == true) {
            successExchangeDialog.show(); //Show exchange success dialog
        } else {
            errorExchangeDialog.show(); //Show exchange error dialog
        }
    }
}

From source file:com.android2ee.tileprovider.activity.MainActivity.java

/**
 * Display information in the banner and run animation on banner in
 * @param info//from   www .  j  a va 2 s.  c  o  m
 */
private void displayInfo(String info) {
    if (textView != null) {
        textView.setText(info);
        Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.in);
        textView.setAnimation(animation);
        textView.setVisibility(View.VISIBLE);

        if (handler == null) {
            handler = new Handler();
        } else {
            handler.removeCallbacks(myRunnable);
        }
        // thus 4s remove banner
        handler.postDelayed(myRunnable, 4000);
    }
}

From source file:com.binu.LogarithmicGraph.DrawGraphAsyncTask.java

@Override
protected void onPreExecute() {
    popIn = AnimationUtils.loadAnimation(mContext, R.anim.pop_in);
}