Example usage for android.view ViewGroup invalidate

List of usage examples for android.view ViewGroup invalidate

Introduction

In this page you can find the example usage for android.view ViewGroup invalidate.

Prototype

public void invalidate() 

Source Link

Document

Invalidate the whole view.

Usage

From source file:com.grokkingandroid.sampleapp.samples.SampleBaseFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_demo_base, container, false);
    if (isFragmentWithInlineDescription()) {
        TextView description = (TextView) rootView.findViewById(R.id.demoapp_fragment_description);
        Spanned descSpannable = Html.fromHtml(getResources().getString(getDescriptionTextId()));
        description.setText(descSpannable);
        description.setMovementMethod(LinkMovementMethod.getInstance());
        ViewGroup linkContainer = (ViewGroup) rootView.findViewById(R.id.container_demo_blog_links);
        showLinks(linkContainer);//w w  w  . j av a 2s . co m
        linkContainer.invalidate();
    } else {
        rootView.findViewById(R.id.container_demo_description).setVisibility(View.GONE);
        rootView.findViewById(R.id.container_demo_blog_links).setVisibility(View.GONE);
    }

    // delegate to subclass for content view
    ViewGroup contentContainer = (ViewGroup) rootView.findViewById(R.id.container_demo_content);
    onCreateContentView(inflater, contentContainer, savedInstanceState);
    return rootView;
}

From source file:org.protocoder.MainActivity.java

/**
 * onDestroy//w  w  w  . j a  v  a2 s.  c o m
 */
@Override
protected void onDestroy() {
    super.onDestroy();
    ViewGroup vg = (ViewGroup) findViewById(R.layout.activity_forfragments);
    if (vg != null) {
        vg.invalidate();
        vg.removeAllViews();
    }
    mProtocoder.app.killConnections();
}

From source file:com.google.cloud.solutions.griddler.android.ui.game.QuestionAnswerView.java

/**
 * Initialize the answer layout and animations as well as setting up the skip button click event
 *//*  w w w .  j  a va  2 s.  c  o  m*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d(LOG_TAG, "onCreateView");

    final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_game_questionanswer, container,
            false);

    textViewSkip = (TextView) rootView.findViewById(R.id.textViewSkip);

    textViewSkip.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            gameManager.onQuestionSkipped();
            rootView.invalidate();
        }
    });

    if (wordRenderModel != null) {
        TextView questionText = (TextView) rootView.findViewById(R.id.questionText);
        questionText.setText(wordRenderModel.getQuestion());
    }

    return rootView;
}

From source file:org.zywx.wbpalmstar.plugin.uexiconlist.EUExIconList.java

/**
 * ??IconList view? ??/*from ww w .ja  va2s  . c  om*/
 * 
 */
private void resetFrame() {
    ((Activity) mContext).runOnUiThread(new Runnable() {

        @Override
        public void run() {
            if (mgr == null) {
                mgr = new LocalActivityManager((Activity) mContext, false);
                mgr.dispatchCreate(null);
            }
            Activity activity = mgr.getActivity(IconListActivity.TAG);
            if (activity != null) {
                ViewGroup subView = (ViewGroup) activity.getWindow().getDecorView();
                if (IconListOption.isFollowWebRoll()) {
                    AbsoluteLayout.LayoutParams lParams = (LayoutParams) subView.getLayoutParams();
                    lParams.width = (int) UIConfig.getScaleWidth();
                    lParams.height = (int) UIConfig.getScaleHight();
                    lParams.x = (int) UIConfig.getScaleX();
                    lParams.y = (int) UIConfig.getScaleY();
                    //                        AbsoluteLayout.LayoutParams lp = new AbsoluteLayout.LayoutParams(
                    //                                (int) UIConfig.getScaleWidth(),
                    //                                (int) UIConfig.getScaleHight(),
                    //                                (int) UIConfig.getScaleX(),
                    //                                (int) UIConfig.getScaleY());
                    subView.setLayoutParams(lParams);
                } else {
                    FrameLayout.LayoutParams lParams = (FrameLayout.LayoutParams) subView.getLayoutParams();
                    lParams.width = (int) UIConfig.getScaleWidth();
                    lParams.height = (int) UIConfig.getScaleHight();
                    lParams.leftMargin = (int) UIConfig.getScaleX();
                    lParams.topMargin = (int) UIConfig.getScaleY();
                    // FrameLayout.LayoutParams lp = new
                    // FrameLayout.LayoutParams(
                    // (int) UIConfig.getScaleWidth(),
                    // (int) UIConfig.getScaleHight());
                    // lp.leftMargin = (int) UIConfig.getScaleX();
                    // lp.topMargin = (int) UIConfig.getScaleY();
                    subView.setLayoutParams(lParams);
                }
                subView.invalidate();
                mEuExIconListHandler.send2Callback(WHAT_RESET_FRAME, null);
            }
        }
    });
}

From source file:com.android.leanlauncher.Workspace.java

/**
 * Removes items that match the item info specified. When applications are removed
 * as a part of an update, this is called to ensure that other widgets and application
 * shortcuts are not removed.// ww  w . j  a  v  a2 s . co m
 */
void removeItemsByComponentName(final HashSet<ComponentName> componentNames, final UserHandleCompat user) {
    final ViewGroup layout = mWorkspace.getShortcutsAndWidgets();

    final ArrayMap<ItemInfo, View> children = new ArrayMap<>();
    for (int j = 0; j < layout.getChildCount(); j++) {
        final View view = layout.getChildAt(j);
        children.put((ItemInfo) view.getTag(), view);
    }

    final ArrayList<View> childrenToRemove = new ArrayList<View>();
    LauncherModel.ItemInfoFilter filter = new LauncherModel.ItemInfoFilter() {
        @Override
        public boolean filterItem(ItemInfo parent, ItemInfo info, ComponentName cn) {
            if (componentNames.contains(cn) && info.user.equals(user)) {
                childrenToRemove.add(children.get(info));
                return true;
            }
            return false;
        }
    };
    LauncherModel.filterItemInfos(children.keySet(), filter);

    // Remove all the other children
    for (View child : childrenToRemove) {
        // Note: We can not remove the view directly from CellLayoutChildren as this
        // does not re-mark the spaces as unoccupied.
        mWorkspace.removeViewInLayout(child);
        if (child instanceof DropTarget) {
            mDragController.removeDropTarget((DropTarget) child);
        }
    }

    if (childrenToRemove.size() > 0) {
        layout.requestLayout();
        layout.invalidate();
    }
}

From source file:cc.flydev.launcher.Workspace.java

void removeItemsByComponentName(final HashSet<ComponentName> componentNames) {
    ArrayList<CellLayout> cellLayouts = getWorkspaceAndHotseatCellLayouts();
    for (final CellLayout layoutParent : cellLayouts) {
        final ViewGroup layout = layoutParent.getShortcutsAndWidgets();

        final HashMap<ItemInfo, View> children = new HashMap<ItemInfo, View>();
        for (int j = 0; j < layout.getChildCount(); j++) {
            final View view = layout.getChildAt(j);
            children.put((ItemInfo) view.getTag(), view);
        }/*from   ww w.  jav  a2  s  .  c o m*/

        final ArrayList<View> childrenToRemove = new ArrayList<View>();
        final HashMap<FolderInfo, ArrayList<ShortcutInfo>> folderAppsToRemove = new HashMap<FolderInfo, ArrayList<ShortcutInfo>>();
        LauncherModel.ItemInfoFilter filter = new LauncherModel.ItemInfoFilter() {
            @Override
            public boolean filterItem(ItemInfo parent, ItemInfo info, ComponentName cn) {
                if (parent instanceof FolderInfo) {
                    if (componentNames.contains(cn)) {
                        FolderInfo folder = (FolderInfo) parent;
                        ArrayList<ShortcutInfo> appsToRemove;
                        if (folderAppsToRemove.containsKey(folder)) {
                            appsToRemove = folderAppsToRemove.get(folder);
                        } else {
                            appsToRemove = new ArrayList<ShortcutInfo>();
                            folderAppsToRemove.put(folder, appsToRemove);
                        }
                        appsToRemove.add((ShortcutInfo) info);
                        return true;
                    }
                } else {
                    if (componentNames.contains(cn)) {
                        childrenToRemove.add(children.get(info));
                        return true;
                    }
                }
                return false;
            }
        };
        LauncherModel.filterItemInfos(children.keySet(), filter);

        // Remove all the apps from their folders
        for (FolderInfo folder : folderAppsToRemove.keySet()) {
            ArrayList<ShortcutInfo> appsToRemove = folderAppsToRemove.get(folder);
            for (ShortcutInfo info : appsToRemove) {
                folder.remove(info);
            }
        }

        // Remove all the other children
        for (View child : childrenToRemove) {
            // Note: We can not remove the view directly from CellLayoutChildren as this
            // does not re-mark the spaces as unoccupied.
            layoutParent.removeViewInLayout(child);
            if (child instanceof DropTarget) {
                mDragController.removeDropTarget((DropTarget) child);
            }
        }

        if (childrenToRemove.size() > 0) {
            layout.requestLayout();
            layout.invalidate();
        }
    }

    // Strip all the empty screens
    stripEmptyScreens();
}

From source file:com.example.launcher3.Workspace.java

void removeItemsByComponentName(final HashSet<ComponentName> componentNames) {
    ArrayList<CellLayout> cellLayouts = getWorkspaceAndHotseatCellLayouts();
    for (final CellLayout layoutParent : cellLayouts) {
        final ViewGroup layout = layoutParent.getShortcutsAndWidgets();

        final HashMap<ItemInfo, View> children = new HashMap<ItemInfo, View>();
        for (int j = 0; j < layout.getChildCount(); j++) {
            final View view = layout.getChildAt(j);
            children.put((ItemInfo) view.getTag(), view);
        }//from w  w w .j  a va2  s  . co  m

        final ArrayList<View> childrenToRemove = new ArrayList<View>();
        final HashMap<FolderInfo, ArrayList<ShortcutInfo>> folderAppsToRemove = new HashMap<FolderInfo, ArrayList<ShortcutInfo>>();
        LauncherModel.ItemInfoFilter filter = new LauncherModel.ItemInfoFilter() {
            @Override
            public boolean filterItem(ItemInfo parent, ItemInfo info, ComponentName cn) {
                if (parent instanceof FolderInfo) {
                    if (componentNames.contains(cn)) {
                        FolderInfo folder = (FolderInfo) parent;
                        ArrayList<ShortcutInfo> appsToRemove;
                        if (folderAppsToRemove.containsKey(folder)) {
                            appsToRemove = folderAppsToRemove.get(folder);
                        } else {
                            appsToRemove = new ArrayList<ShortcutInfo>();
                            folderAppsToRemove.put(folder, appsToRemove);
                        }
                        appsToRemove.add((ShortcutInfo) info);
                        return true;
                    }
                } else {
                    if (componentNames.contains(cn)) {
                        childrenToRemove.add(children.get(info));
                        return true;
                    }
                }
                return false;
            }
        };
        LauncherModel.filterItemInfos(children.keySet(), filter);

        // Remove all the apps from their folders
        for (FolderInfo folder : folderAppsToRemove.keySet()) {
            ArrayList<ShortcutInfo> appsToRemove = folderAppsToRemove.get(folder);
            for (ShortcutInfo info : appsToRemove) {
                folder.remove(info);
            }
        }

        // Remove all the other children
        for (View child : childrenToRemove) {
            // Note: We can not remove the view directly from
            // CellLayoutChildren as this
            // does not re-mark the spaces as unoccupied.
            layoutParent.removeViewInLayout(child);
            if (child instanceof DropTarget) {
                mDragController.removeDropTarget((DropTarget) child);
            }
        }

        if (childrenToRemove.size() > 0) {
            layout.requestLayout();
            layout.invalidate();
        }
    }

    // Strip all the empty screens
    stripEmptyScreens();
}

From source file:com.aidy.launcher3.ui.workspace.Workspace.java

public void removeItemsByComponentName(final HashSet<ComponentName> componentNames) {
    ArrayList<CellLayout> cellLayouts = getWorkspaceAndHotseatCellLayouts();
    for (final CellLayout layoutParent : cellLayouts) {
        final ViewGroup layout = layoutParent.getShortcutsAndWidgets();

        final HashMap<ItemInfoBean, View> children = new HashMap<ItemInfoBean, View>();
        for (int j = 0; j < layout.getChildCount(); j++) {
            final View view = layout.getChildAt(j);
            children.put((ItemInfoBean) view.getTag(), view);
        }/*from   w  w w. j a va2 s.com*/

        final ArrayList<View> childrenToRemove = new ArrayList<View>();
        final HashMap<FolderInfoBean, ArrayList<ShortcutInfo>> folderAppsToRemove = new HashMap<FolderInfoBean, ArrayList<ShortcutInfo>>();
        LauncherModel.ItemInfoFilter filter = new LauncherModel.ItemInfoFilter() {
            @Override
            public boolean filterItem(ItemInfoBean parent, ItemInfoBean info, ComponentName cn) {
                if (parent instanceof FolderInfoBean) {
                    if (componentNames.contains(cn)) {
                        FolderInfoBean folder = (FolderInfoBean) parent;
                        ArrayList<ShortcutInfo> appsToRemove;
                        if (folderAppsToRemove.containsKey(folder)) {
                            appsToRemove = folderAppsToRemove.get(folder);
                        } else {
                            appsToRemove = new ArrayList<ShortcutInfo>();
                            folderAppsToRemove.put(folder, appsToRemove);
                        }
                        appsToRemove.add((ShortcutInfo) info);
                        return true;
                    }
                } else {
                    if (componentNames.contains(cn)) {
                        childrenToRemove.add(children.get(info));
                        return true;
                    }
                }
                return false;
            }
        };
        LauncherModel.filterItemInfos(children.keySet(), filter);

        // Remove all the apps from their folders
        for (FolderInfoBean folder : folderAppsToRemove.keySet()) {
            ArrayList<ShortcutInfo> appsToRemove = folderAppsToRemove.get(folder);
            for (ShortcutInfo info : appsToRemove) {
                folder.remove(info);
            }
        }

        // Remove all the other children
        for (View child : childrenToRemove) {
            // Note: We can not remove the view directly from
            // CellLayoutChildren as this
            // does not re-mark the spaces as unoccupied.
            layoutParent.removeViewInLayout(child);
            if (child instanceof DropTarget) {
                mDragController.removeDropTarget((DropTarget) child);
            }
        }

        if (childrenToRemove.size() > 0) {
            layout.requestLayout();
            layout.invalidate();
        }
    }

    // Strip all the empty screens
    stripEmptyScreens();
}

From source file:com.android.launcher2.Workspace.java

void removeItems(final ArrayList<String> packages) {
    final HashSet<String> packageNames = new HashSet<String>();
    packageNames.addAll(packages);/*  www.ja  va  2  s  . co m*/

    ArrayList<CellLayout> cellLayouts = getWorkspaceAndHotseatCellLayouts();
    for (final CellLayout layoutParent : cellLayouts) {
        final ViewGroup layout = layoutParent.getShortcutsAndWidgets();

        // Avoid ANRs by treating each screen separately
        post(new Runnable() {
            public void run() {
                final ArrayList<View> childrenToRemove = new ArrayList<View>();
                childrenToRemove.clear();

                int childCount = layout.getChildCount();
                for (int j = 0; j < childCount; j++) {
                    final View view = layout.getChildAt(j);
                    Object tag = view.getTag();

                    if (tag instanceof ShortcutInfo) {
                        final ShortcutInfo info = (ShortcutInfo) tag;
                        final Intent intent = info.intent;
                        final ComponentName name = intent.getComponent();

                        if (name != null) {
                            if (packageNames.contains(name.getPackageName())) {
                                LauncherModel.deleteItemFromDatabase(mLauncher, info);
                                childrenToRemove.add(view);
                            }
                        }
                    } else if (tag instanceof FolderInfo) {
                        final FolderInfo info = (FolderInfo) tag;
                        final ArrayList<ShortcutInfo> contents = info.contents;
                        final int contentsCount = contents.size();
                        final ArrayList<ShortcutInfo> appsToRemoveFromFolder = new ArrayList<ShortcutInfo>();

                        for (int k = 0; k < contentsCount; k++) {
                            final ShortcutInfo appInfo = contents.get(k);
                            final Intent intent = appInfo.intent;
                            final ComponentName name = intent.getComponent();

                            if (name != null) {
                                if (packageNames.contains(name.getPackageName())) {
                                    appsToRemoveFromFolder.add(appInfo);
                                }
                            }
                        }
                        for (ShortcutInfo item : appsToRemoveFromFolder) {
                            info.remove(item);
                            LauncherModel.deleteItemFromDatabase(mLauncher, item);
                        }
                    } else if (tag instanceof LauncherAppWidgetInfo) {
                        final LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) tag;
                        final ComponentName provider = info.providerName;
                        if (provider != null) {
                            if (packageNames.contains(provider.getPackageName())) {
                                LauncherModel.deleteItemFromDatabase(mLauncher, info);
                                childrenToRemove.add(view);
                            }
                        }
                    }
                }

                childCount = childrenToRemove.size();
                for (int j = 0; j < childCount; j++) {
                    View child = childrenToRemove.get(j);
                    // Note: We can not remove the view directly from CellLayoutChildren as this
                    // does not re-mark the spaces as unoccupied.
                    layoutParent.removeViewInLayout(child);
                    if (child instanceof DropTarget) {
                        mDragController.removeDropTarget((DropTarget) child);
                    }
                }

                if (childCount > 0) {
                    layout.requestLayout();
                    layout.invalidate();
                }
            }
        });
    }

    // Clean up new-apps animation list
    final Context context = getContext();
    post(new Runnable() {
        @Override
        public void run() {
            String spKey = LauncherApplication.getSharedPreferencesKey();
            SharedPreferences sp = context.getSharedPreferences(spKey, Context.MODE_PRIVATE);
            Set<String> newApps = sp.getStringSet(InstallShortcutReceiver.NEW_APPS_LIST_KEY, null);

            // Remove all queued items that match the same package
            if (newApps != null) {
                synchronized (newApps) {
                    Iterator<String> iter = newApps.iterator();
                    while (iter.hasNext()) {
                        try {
                            Intent intent = Intent.parseUri(iter.next(), 0);
                            String pn = ItemInfo.getPackageName(intent);
                            if (packageNames.contains(pn)) {
                                iter.remove();
                            }

                            // It is possible that we've queued an item to be loaded, yet it has
                            // not been added to the workspace, so remove those items as well.
                            ArrayList<ItemInfo> shortcuts;
                            shortcuts = LauncherModel.getWorkspaceShortcutItemInfosWithIntent(intent);
                            for (ItemInfo info : shortcuts) {
                                LauncherModel.deleteItemFromDatabase(context, info);
                            }
                        } catch (URISyntaxException e) {
                        }
                    }
                }
            }
        }
    });
}

From source file:com.fairphone.fplauncher3.Workspace.java

void removeItemsByComponentName(final HashSet<ComponentName> componentNames, final UserHandleCompat user) {
    ArrayList<CellLayout> cellLayouts = getWorkspaceAndHotseatCellLayouts();
    for (final CellLayout layoutParent : cellLayouts) {
        final ViewGroup layout = layoutParent.getShortcutsAndWidgets();

        final HashMap<ItemInfo, View> children = new HashMap<ItemInfo, View>();
        for (int j = 0; j < layout.getChildCount(); j++) {
            final View view = layout.getChildAt(j);
            children.put((ItemInfo) view.getTag(), view);
        }/*  www.j av a 2 s  .  c o m*/

        final ArrayList<View> childrenToRemove = new ArrayList<View>();
        final HashMap<FolderInfo, ArrayList<ShortcutInfo>> folderAppsToRemove = new HashMap<FolderInfo, ArrayList<ShortcutInfo>>();
        LauncherModel.ItemInfoFilter filter = new LauncherModel.ItemInfoFilter() {
            @Override
            public boolean filterItem(ItemInfo parent, ItemInfo info, ComponentName cn) {
                if (parent instanceof FolderInfo) {
                    if (componentNames.contains(cn) && info.user.equals(user)) {
                        FolderInfo folder = (FolderInfo) parent;
                        ArrayList<ShortcutInfo> appsToRemove;
                        if (folderAppsToRemove.containsKey(folder)) {
                            appsToRemove = folderAppsToRemove.get(folder);
                        } else {
                            appsToRemove = new ArrayList<ShortcutInfo>();
                            folderAppsToRemove.put(folder, appsToRemove);
                        }
                        appsToRemove.add((ShortcutInfo) info);
                        return true;
                    }
                } else {
                    if (componentNames.contains(cn) && info.user.equals(user)) {
                        childrenToRemove.add(children.get(info));
                        return true;
                    }
                }
                return false;
            }
        };
        LauncherModel.filterItemInfos(children.keySet(), filter);

        // Remove all the apps from their folders
        for (FolderInfo folder : folderAppsToRemove.keySet()) {
            ArrayList<ShortcutInfo> appsToRemove = folderAppsToRemove.get(folder);
            for (ShortcutInfo info : appsToRemove) {
                folder.remove(info);
            }
        }

        // Remove all the other children
        for (View child : childrenToRemove) {
            // Note: We can not remove the view directly from CellLayoutChildren as this
            // does not re-mark the spaces as unoccupied.
            layoutParent.removeViewInLayout(child);
            if (child instanceof DropTarget) {
                mDragController.removeDropTarget((DropTarget) child);
            }
        }

        if (!childrenToRemove.isEmpty()) {
            layout.requestLayout();
            layout.invalidate();
        }
    }

    // Strip all the empty screens
    stripEmptyScreens();
}