本文整理匯總了Java中android.support.annotation.AnimRes類的典型用法代碼示例。如果您正苦於以下問題:Java AnimRes類的具體用法?Java AnimRes怎麽用?Java AnimRes使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
AnimRes類屬於android.support.annotation包,在下文中一共展示了AnimRes類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: startWithText
import android.support.annotation.AnimRes; //導入依賴的package包/類
/**
* 根據字符串,啟動翻頁公告
*
* @param notice 字符串
* @param inAnimResId 進入動畫的resID
* @param outAnimResID 離開動畫的resID
*/
@SuppressWarnings("deprecation")
public void startWithText(final String notice, final @AnimRes int inAnimResId, final @AnimRes int outAnimResID) {
if (TextUtils.isEmpty(notice)) return;
getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else {
getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
startWithFixedWidth(notice, inAnimResId, outAnimResID);
}
});
}
示例2: startWithFixedWidth
import android.support.annotation.AnimRes; //導入依賴的package包/類
/**
* 根據字符串和寬度,啟動翻頁公告
*
* @param notice 字符串
*/
private void startWithFixedWidth(String notice, @AnimRes int inAnimResId, @AnimRes int outAnimResID) {
int noticeLength = notice.length();
int width = Utils.px2dip(getContext(), getWidth());
if (width == 0) {
throw new RuntimeException("Please set the width of MarqueeView !");
}
int limit = width / textSize;
List list = new ArrayList();
if (noticeLength <= limit) {
list.add(notice);
} else {
int size = noticeLength / limit + (noticeLength % limit != 0 ? 1 : 0);
for (int i = 0; i < size; i++) {
int startIndex = i * limit;
int endIndex = ((i + 1) * limit >= noticeLength ? noticeLength : (i + 1) * limit);
list.add(notice.substring(startIndex, endIndex));
}
}
if (notices == null) notices = new ArrayList<>();
notices.clear();
notices.addAll(list);
start(inAnimResId, outAnimResID);
}
示例3: finishToActivity
import android.support.annotation.AnimRes; //導入依賴的package包/類
/**
* 結束到指定 Activity
*
* @param activity activity
* @param isIncludeSelf 是否結束該 activity 自己
* @param enterAnim 入場動畫
* @param exitAnim 出場動畫
*/
public static boolean finishToActivity(@NonNull final Activity activity,
final boolean isIncludeSelf,
@AnimRes final int enterAnim,
@AnimRes final int exitAnim) {
List<Activity> activities = Utils.sActivityList;
for (int i = activities.size() - 1; i >= 0; --i) {
Activity aActivity = activities.get(i);
if (aActivity.equals(activity)) {
if (isIncludeSelf) {
finishActivity(aActivity, enterAnim, exitAnim);
}
return true;
}
finishActivity(aActivity, enterAnim, exitAnim);
}
return false;
}
示例4: finishOtherActivities
import android.support.annotation.AnimRes; //導入依賴的package包/類
/**
* 結束所有其他類型的 Activity
*
* @param clz Activity 類
* @param enterAnim 入場動畫
* @param exitAnim 出場動畫
*/
public static void finishOtherActivities(@NonNull final Class<?> clz,
@AnimRes final int enterAnim,
@AnimRes final int exitAnim) {
List<Activity> activities = Utils.sActivityList;
boolean flag = false;
for (int i = activities.size() - 1; i >= 0; i--) {
Activity activity = activities.get(i);
if (activity.getClass().equals(clz)) {
if (flag) {
finishActivity(activity, enterAnim, exitAnim);
} else {
flag = true;
}
} else {
finishActivity(activity, enterAnim, exitAnim);
}
}
}
示例5: setInAndOutAnimation
import android.support.annotation.AnimRes; //導入依賴的package包/類
/**
* 設置進入動畫和離開動畫
*
* @param inAnimResId 進入動畫的resID
* @param outAnimResID 離開動畫的resID
*/
private void setInAndOutAnimation(@AnimRes int inAnimResId, @AnimRes int outAnimResID) {
Animation inAnim = AnimationUtils.loadAnimation(getContext(), inAnimResId);
if (hasSetAnimDuration) inAnim.setDuration(animDuration);
setInAnimation(inAnim);
Animation outAnim = AnimationUtils.loadAnimation(getContext(), outAnimResID);
if (hasSetAnimDuration) outAnim.setDuration(animDuration);
setOutAnimation(outAnim);
}
示例6: startActivity
import android.support.annotation.AnimRes; //導入依賴的package包/類
/**
* 啟動Activity
*
* @param cls activity類
* @param enterAnim 入場動畫
* @param exitAnim 出場動畫
*/
public static void startActivity(@NonNull final Class<?> cls,
@AnimRes final int enterAnim,
@AnimRes final int exitAnim) {
Context context = getActivityOrApp();
startActivity(context, null, context.getPackageName(), cls.getName(),
getOptionsBundle(context, enterAnim, exitAnim));
}
示例7: startActivities
import android.support.annotation.AnimRes; //導入依賴的package包/類
/**
* 啟動Activity
*
* @param activity activity
* @param intents 意圖
* @param enterAnim 入場動畫
* @param exitAnim 出場動畫
*/
public static void startActivities(@NonNull final Activity activity,
@NonNull final Intent[] intents,
@AnimRes final int enterAnim,
@AnimRes final int exitAnim) {
startActivities(intents, activity, getOptionsBundle(activity, enterAnim, exitAnim));
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
activity.overridePendingTransition(enterAnim, exitAnim);
}
}
示例8: getAnimation
import android.support.annotation.AnimRes; //導入依賴的package包/類
@Override
public XmlResourceParser getAnimation(@AnimRes int id) throws NotFoundException {
int realId = getCorrespondResIdStrictly(id);
if (realId > 0) {
return mSkinResources.getAnimation(realId);
}
return super.getAnimation(id);
}
示例9: runLayoutAnimation
import android.support.annotation.AnimRes; //導入依賴的package包/類
public static void runLayoutAnimation(final RecyclerView recyclerView, @AnimRes int res) {
final Context context = recyclerView.getContext();
final LayoutAnimationController controller = AnimationUtils.loadLayoutAnimation(context, res);
recyclerView.setLayoutAnimation(controller);
recyclerView.getAdapter().notifyDataSetChanged();
recyclerView.scheduleLayoutAnimation();
}
示例10: setCustomAnimations
import android.support.annotation.AnimRes; //導入依賴的package包/類
@Override
public ExtraTransaction setCustomAnimations(@AnimRes int targetFragmentEnter
, @AnimRes int currentFragmentPopExit) {
mRecord.targetFragmentEnter = targetFragmentEnter;
mRecord.currentFragmentPopExit = currentFragmentPopExit;
mRecord.currentFragmentPopEnter = 0;
mRecord.targetFragmentExit = 0;
return this;
}
示例11: setExitAnimations
import android.support.annotation.AnimRes; //導入依賴的package包/類
/**
* Sets the exit animations.
*
* @param context Application context.
* @param enterResId Resource ID of the "enter" animation for the application.
* @param exitResId Resource ID of the "exit" animation for the browser.
*/
public Builder setExitAnimations(
@NonNull Context context, @AnimRes int enterResId, @AnimRes int exitResId) {
Bundle bundle = ActivityOptionsCompat.makeCustomAnimation(
context, enterResId, exitResId).toBundle();
mIntent.putExtra(EXTRA_EXIT_ANIMATION_BUNDLE, bundle);
return this;
}
示例12: setCustomAnimations
import android.support.annotation.AnimRes; //導入依賴的package包/類
/**
* Set a Custom Animation to a Fragment transaction
*
* @param transaction The transaction that will
* @param enterAnim The animation resource to be used when the next fragment enters.
* @param exitAnim The animation resource to be used when the current fragment exits.
* @param popEnterAnim The animation resource to be used when the previous fragment enters on back pressed.
* @param popExitAnim The animation resource to be used when the current fragment exits on back pressed..
*/
private void setCustomAnimations(FragmentTransaction transaction, @AnimRes int enterAnim,
@AnimRes int exitAnim, @AnimRes int popEnterAnim, @AnimRes int popExitAnim) {
transaction.setCustomAnimations(
enterAnim,
exitAnim,
popEnterAnim,
popExitAnim
);
}
示例13: setCustomTransactionAnimation
import android.support.annotation.AnimRes; //導入依賴的package包/類
/**
* Set a Custom Animation to a Fragment transaction.
*
* @param enterAnim The animation resource to be used when the next fragment enters.
* @param exitAnim The animation resource to be used when the current fragment exits.
* @param popEnterAnim The animation resource to be used when the previous fragment enters on back pressed.
* @param popExitAnim The animation resource to be used when the current fragment exits on back pressed..
*/
public Builder setCustomTransactionAnimation(@AnimRes int enterAnim, @AnimRes int exitAnim,
@AnimRes int popEnterAnim, @AnimRes int popExitAnim) {
data.setEnterAnim(enterAnim);
data.setExitAnim(exitAnim);
data.setPopEnterAnim(popEnterAnim);
data.setPopExitAnim(popExitAnim);
return this;
}
示例14: replaceFragment
import android.support.annotation.AnimRes; //導入依賴的package包/類
/**
* 替換fragement 並添加動畫
*/
public void replaceFragment(@IdRes int id_content, @AnimRes int anim_in, @AnimRes int anim_out, Fragment fragment) {
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
// transaction.setCustomAnimations(anim_in, anim_out);
transaction.replace(id_content, fragment);
transaction.commit();
}
示例15: replaceFragmentWithBackStack
import android.support.annotation.AnimRes; //導入依賴的package包/類
/**
* 替換fragement 並添加動畫
* 替換fragement的同時對fragment進行“入back棧”操作 ,據我所知並不是真正的進入內存棧
*
* @param id_content
* @param anim_in
* @param anim_out
* @param fragment
*/
@Deprecated
public void replaceFragmentWithBackStack(@IdRes int id_content, @AnimRes int anim_in, @AnimRes int anim_out, Fragment fragment) {
String tag = fragment.getClass().getSimpleName();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
// transaction.setCustomAnimations(anim_in, anim_out);
transaction.replace(id_content, fragment, tag);
//記錄commit一次操作,與mFragmentManager.popBackStack();匹配使用
transaction.addToBackStack(tag);
//commitAllowingStateLoss 優於 commit 方法,當使用commit方法時,係統將進行狀態判斷,如果狀態(mStateSaved)已經保存,將發生"Can not perform this action after onSaveInstanceState"錯誤。
//如果mNoTransactionsBecause已經存在,將發生"Can not perform this action inside of " + mNoTransactionsBecause錯誤。
transaction.commitAllowingStateLoss();
}