public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = createView(parent); } ViewHolder holder = (ViewHolder) convertView.getTag(); // index is reverse since most recent appears at the bottom... final int index = position; final TaskDescription td = mRecentTaskDescriptions.get(index); // holder.thumbnailView.setContentDescription(td.getLabel()); holder.loadedThumbnailAndIcon = td.isLoaded(); if (td.isLoaded()) { updateIcon(holder, td.getIcon(), true, false); } if (index == 0) { if (mAnimateIconOfFirstTask) { if (mItemToAnimateInWhenWindowAnimationIsFinished != null) { holder.iconView.setAlpha(1f); holder.iconView.setTranslationX(0f); holder.iconView.setTranslationY(0f); } mItemToAnimateInWhenWindowAnimationIsFinished = holder; final int translation = -getResources() .getDimensionPixelSize(R.dimen.status_bar_recents_app_icon_translate_distance); final Configuration config = getResources().getConfiguration(); if (config.orientation == Configuration.ORIENTATION_PORTRAIT) { holder.iconView.setAlpha(0f); holder.iconView.setTranslationX(translation); } else { holder.iconView.setAlpha(0f); holder.iconView.setTranslationY(translation); } if (!mWaitingForWindowAnimation) { animateInIconOfFirstTask(); } } } holder.taskDescription = td; holder.position = index; RecentsScrollView scrollView = (RecentsScrollView) mRecentsContainer; final View animView = scrollView.getChildContentView(convertView); animView.setAlpha(1f); animView.setTranslationY(0f); return convertView; }
private String makeTaskSpec() { double minXPos = -12.0d; double maxXPos = 12.0d; double minYPos = -12.0d; double maxYPos = 6.0d; double minVel = -1.0d; double maxVel = 1.0d; double minAction = 0.0d; double maxAction = 1.0d; TaskDescription ts = getTaskSpec(); TaskSpecVRLGLUE3 theTaskSpecObject = new TaskSpecVRLGLUE3(); theTaskSpecObject.setEpisodic(); theTaskSpecObject.setDiscountFactor(1.0d); // Angle of the arm theTaskSpecObject.addContinuousObservation(new DoubleRange(-4.0d * Math.PI, 4.0d * Math.PI)); // Angular Velocity theTaskSpecObject.addContinuousObservation(new DoubleRange(-1.0d, 1.0d)); // Now we want to add the variable for all the compartments for (int i = 0; i < 4 * (2 * arm.getCompartments().size() + allFood.size()); i++) { if (i % 4 == 0) { theTaskSpecObject.addContinuousObservation(new DoubleRange(minXPos, maxXPos)); } if (i % 4 == 1) { theTaskSpecObject.addContinuousObservation(new DoubleRange(minYPos, maxYPos)); } if (i % 4 == 2 || i % 4 == 3) { theTaskSpecObject.addContinuousObservation(new DoubleRange(minVel, maxVel)); } } int NDA = 8; if (useDiscreteActions) { theTaskSpecObject.addDiscreteAction(new IntRange(0, NDA - 1)); } else { theTaskSpecObject.addContinuousAction( (new DoubleRange(minAction, maxAction, ts.getNumActionVariables()))); } theTaskSpecObject.setRewardRange(new DoubleRange(-1, 20)); String newTaskSpecString = theTaskSpecObject.toTaskSpec(); TaskSpec.checkTaskSpec(newTaskSpecString); return newTaskSpecString; }
// Update header content. public void updateHeader(TaskDescription td, float scaleFactor) { mTaskDescription = td; mLabel = td.getLabel(); if (scaleFactor != mScaleFactor) { mScaleFactorChanged = true; mScaleFactor = scaleFactor; initDimensions(); } }
public RecentHeader(Context context, TaskDescription td, float scaleFactor) { super(context); mTaskDescription = td; mContext = context; mLabel = td.getLabel(); mScaleFactor = scaleFactor; initDimensions(); Drawable d = mContext.getResources().getDrawable(R.drawable.card_menu_button_expand); mExpandedButtonWidth = d.getIntrinsicWidth(); }
public void handleSwipe(View view) { TaskDescription ad = ((ViewHolder) view.getTag()).taskDescription; if (ad == null || mRecentTaskDescriptions == null) { if (DEBUG) Log.v( TAG, "Not able to find activity description for swiped task; view=" + view + " tag=" + view.getTag()); return; } if (DEBUG) Log.v(TAG, "Jettison " + ad.getLabel()); mRecentTaskDescriptions.remove(ad); mRecentTasksLoader.remove(ad); /* YUNOS BEGIN */ // ##modules(systemui recents) // ##date:2013-11-19 // ##author:[email protected]/[email protected] updateRecentTaskCount(); /* YUNOS END */ // Handled by widget containers to enable LayoutTransitions properly // mListAdapter.notifyDataSetChanged(); if (mRecentTaskDescriptions.size() == 0) { /* YUNOS BEGIN */ // ##modules(Systemui recent): // ##date: 2013-11.18 ##author: [email protected] // dismissAndGoBack(); /* YUNOS END */ mRecentsNoApps.setVisibility(View.VISIBLE); } // Currently, either direction means the same thing, so ignore direction // and remove // the task. final ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); if (am != null) { // am.removeTask(ad.persistentTaskId, // ActivityManager.REMOVE_TASK_KILL_PROCESS); /* YUNOS_BEGIN */ // ##modules(Systemui recent): RecentTasks consistent with // SecurityCenter experience // ##date: 2014.1.11 author: [email protected] if (!"com.aliyun.SecurityCenter".equals(ad.packageName) && !"com.android.deskclock".equals(ad.packageName)) { // am.forceStopPackage(ad.packageName); } /* YUNOS_END */ // Accessibility feedback setContentDescription( String.format( getResources().getString(R.string.accessibility_recents_item_dismissed), ad.getLabel())); sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED); setContentDescription(null); } if (mClearAppType == CLEARONEAPP) updateMemInfo(); }
public void handleOnClick(View view) { ViewHolder holder = (ViewHolder) view.getTag(); TaskDescription ad = holder.taskDescription; if (ad == null) { return; } final Context context = view.getContext(); final ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); /* YUNOS_BEGIN */ // ##module(RecentTasks) // ##date: 2014/3/27 // ##author: [email protected] // ##BugID:105383:add scaleup animation when click recent task app Bundle opts = (view == null) ? null : ActivityOptions.makeScaleUpAnimation( view, 0, 0, view.getMeasuredWidth(), view.getMeasuredHeight()) .toBundle(); /* YUNOS_END */ show(false); /* YUNOS_BEGIN */ // ##modules(Systemui recent): usertrack // ##date: 2013-12.26 author: [email protected] int position = holder.position; String packageName = ad.getPackageName(); String kvs = "packageName= " + packageName + " position= " + position + " action= " + "click"; /* YUNOS_END */ if (ad.taskId >= 0) { // This is an active task; it should just go to the foreground. /* YUNOS BEGIN */ // ##module(SecurityCenter) bug id 80981(secutitycenter lock app) // ##date:2014/1/2 ##author:[email protected] // SecureManager secure = SecureManager.get(mContext); // if (secure != null) { // boolean isBlocked = secure.filterSyncTask(ad.taskId, ad.intent); // if (isBlocked) { // if (context instanceof RecentsActivity) { // RecentsActivity recentsActivity = ((RecentsActivity) context); // recentsActivity.moveTaskToBack(true); // } // } else { // am.moveTaskToFront(ad.taskId, // ActivityManager.MOVE_TASK_WITH_HOME,opts); // } // } /* YUNOS END */ } else { Intent intent = ad.intent; intent.addFlags( Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY | Intent.FLAG_ACTIVITY_TASK_ON_HOME | Intent.FLAG_ACTIVITY_NEW_TASK); if (DEBUG) Log.v(TAG, "Starting activity " + intent); try { // context.startActivityAsUser(intent, opts, new UserHandle( // UserHandle.USER_CURRENT)); context.startActivity(intent, opts); } catch (SecurityException e) { Log.e(TAG, "Recents does not have the permission to launch " + intent, e); } catch (ActivityNotFoundException e) { Log.e(TAG, "Error launching activity " + intent, e); } } }