当前位置: 首页>>代码示例>>Java>>正文


Java AppWidgetHostView类代码示例

本文整理汇总了Java中android.appwidget.AppWidgetHostView的典型用法代码示例。如果您正苦于以下问题:Java AppWidgetHostView类的具体用法?Java AppWidgetHostView怎么用?Java AppWidgetHostView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AppWidgetHostView类属于android.appwidget包,在下文中一共展示了AppWidgetHostView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addAppWidgetImpl

import android.appwidget.AppWidgetHostView; //导入依赖的package包/类
void addAppWidgetImpl(int appWidgetId, ItemInfo info,
        AppWidgetHostView boundWidget, WidgetAddFlowHandler addFlowHandler, int delay) {
    if (!addFlowHandler.startConfigActivity(this, appWidgetId, info, REQUEST_CREATE_APPWIDGET)) {
        // If the configuration flow was not started, add the widget

        Runnable onComplete = new Runnable() {
            @Override
            public void run() {
                // Exit spring loaded mode if necessary after adding the widget
                exitSpringLoadedDragModeDelayed(true, EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT,
                        null);
            }
        };
        completeAddAppWidget(appWidgetId, info, boundWidget, addFlowHandler.getProviderInfo(this));
        mWorkspace.removeExtraEmptyScreenDelayed(true, onComplete, delay, false);
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:18,代码来源:Launcher.java

示例2: LauncherAppWidgetHostView

import android.appwidget.AppWidgetHostView; //导入依赖的package包/类
public LauncherAppWidgetHostView(Context context) {
    super(context);
    mContext = context;
    mLongPressHelper = new CheckLongPressHelper(this, this);
    mStylusEventHelper = new StylusEventHelper(new SimpleOnStylusPressListener(this), this);
    mInflater = LayoutInflater.from(context);
    setAccessibilityDelegate(Launcher.getLauncher(context).getAccessibilityDelegate());
    setBackgroundResource(R.drawable.widget_internal_focus_bg);

    if (AndroidVersion.isAtLeastOreo()) {
        try {
            Method asyncMethod = AppWidgetHostView.class
                    .getMethod("setExecutor", Executor.class);
            asyncMethod.invoke(this, Utilities.THREAD_POOL_EXECUTOR);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:20,代码来源:LauncherAppWidgetHostView.java

示例3: getDefaultOptionsForWidget

import android.appwidget.AppWidgetHostView; //导入依赖的package包/类
public static Bundle getDefaultOptionsForWidget(Context context, PendingAddWidgetInfo info) {
    Rect rect = new Rect();
    AppWidgetResizeFrame.getWidgetSizeRanges(context, info.spanX, info.spanY, rect);
    Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(context,
            info.componentName, null);

    float density = context.getResources().getDisplayMetrics().density;
    int xPaddingDips = (int) ((padding.left + padding.right) / density);
    int yPaddingDips = (int) ((padding.top + padding.bottom) / density);

    Bundle options = new Bundle();
    options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH,
            rect.left - xPaddingDips);
    options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT,
            rect.top - yPaddingDips);
    options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH,
            rect.right - xPaddingDips);
    options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT,
            rect.bottom - yPaddingDips);
    return options;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:22,代码来源:WidgetHostViewLoader.java

示例4: removeDroppedItem

import android.appwidget.AppWidgetHostView; //导入依赖的package包/类
private void removeDroppedItem(View dragObj) {
    if (mChildLock) return;

    try {
        mDragDropSource.removeView(dragObj);
        db().setAppCategoryOrder(mRevCategoryMap.get(mDragDropSource), mDragDropSource);

        if (mBeingDragged.isLink()) {
            db().deleteApp(mBeingDragged.getComponentName());
        }

        if (mBeingDragged.isWidget()) {

            db().deleteApp(mBeingDragged.getComponentName());
            AppWidgetHostView wid = mLoadedWidgets.remove(mBeingDragged.getActivityName());
            if (wid != null) {
                mWidgetHelper.widgetRemoved(wid.getAppWidgetId());
            }
        }
    } catch (Exception e) {
        Log.e(TAG, e.getMessage(), e);
    }
}
 
开发者ID:quaap,项目名称:LaunchTime,代码行数:24,代码来源:MainActivity.java

示例5: configureWidget

import android.appwidget.AppWidgetHostView; //导入依赖的package包/类
private AppWidgetHostView configureWidget(Intent data) {
    // Get the selected widget information
    Bundle extras = data.getExtras();
    int appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
    AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(appWidgetId);
    if (appWidgetInfo.configure != null) {
        // If the widget wants to be configured then start its configuration activity
        Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE);
        intent.setComponent(appWidgetInfo.configure);
        intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
        mParent.startActivityForResult(intent, REQUEST_CREATE_APPWIDGET);
    } else {
        // Otherwise simply create it
        return createWidget(data);
    }
    return null;
}
 
开发者ID:quaap,项目名称:LaunchTime,代码行数:18,代码来源:Widget.java

示例6: onActivityResult

import android.appwidget.AppWidgetHostView; //导入依赖的package包/类
public AppWidgetHostView onActivityResult(int requestCode, int resultCode, Intent data) {

        Log.d("LaunchWidgeth", "onActivityResult: requestCode=" + requestCode + " resultCode=" + resultCode);
        // listen for widget manager response
        if (resultCode == Activity.RESULT_OK) {
            if (requestCode == REQUEST_PICK_APPWIDGET) {
                Log.d("LaunchWidgeth", "configureWidget");
                return configureWidget(data);
            } else if (requestCode == REQUEST_CREATE_APPWIDGET || requestCode == REQUEST_BIND_APPWIDGET) {
                Log.d("LaunchWidgeth", "createWidget");
                return createWidget(data);
            } else {
                Log.d("LaunchWidgeth", "unknown RESULT_OK");
            }
        } else if (resultCode == Activity.RESULT_CANCELED) {
            Log.d("LaunchWidgeth", "RESULT_CANCELED");
            if (data!=null) {
                int appWidgetId = data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
                if (appWidgetId != -1) {
                    mAppWidgetHost.deleteAppWidgetId(appWidgetId);
                }
            }

        }
        return null;
    }
 
开发者ID:quaap,项目名称:LaunchTime,代码行数:27,代码来源:Widget.java

示例7: addAppWidgetToWorkspace

import android.appwidget.AppWidgetHostView; //导入依赖的package包/类
private void addAppWidgetToWorkspace(
        AppWidgetHostView hostView, LauncherAppWidgetInfo item,
        LauncherAppWidgetProviderInfo appWidgetInfo, boolean insert) {
    hostView.setTag(item);
    item.onBindAppWidget(this, hostView);

    hostView.setFocusable(true);
    hostView.setOnFocusChangeListener(mFocusHandler);

    mWorkspace.addInScreen(hostView, item.container, item.screenId,
            item.cellX, item.cellY, item.spanX, item.spanY, insert);

    if (!item.isCustomWidget()) {
        addWidgetToAutoAdvanceIfNeeded(hostView, appWidgetInfo);
    }
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:17,代码来源:Launcher.java

示例8: addAppWidgetImpl

import android.appwidget.AppWidgetHostView; //导入依赖的package包/类
void addAppWidgetImpl(int appWidgetId, ItemInfo info,
        AppWidgetHostView boundWidget, LauncherAppWidgetProviderInfo appWidgetInfo,
        int delay) {
    if (appWidgetInfo.configure != null) {
        setWaitingForResult(PendingRequestArgs.forWidgetInfo(appWidgetId, appWidgetInfo, info));

        // Launch over to configure widget, if needed
        mAppWidgetManager.startConfigActivity(appWidgetInfo, appWidgetId, this,
                mAppWidgetHost, REQUEST_CREATE_APPWIDGET);
    } else {
        // Otherwise just add it
        Runnable onComplete = new Runnable() {
            @Override
            public void run() {
                // Exit spring loaded mode if necessary after adding the widget
                exitSpringLoadedDragModeDelayed(true, EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT,
                        null);
            }
        };
        completeAddAppWidget(appWidgetId, info, boundWidget, appWidgetInfo);
        mWorkspace.removeExtraEmptyScreenDelayed(true, onComplete, delay, false);
    }
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:24,代码来源:Launcher.java

示例9: createWidgetByID

import android.appwidget.AppWidgetHostView; //导入依赖的package包/类
public void createWidgetByID(RelativeLayout widget, int  ID) {
    widget.removeAllViews();

    int appWidgetId = ID;

    int H = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 150, this.getResources().getDisplayMetrics());
    int W = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 300, this.getResources().getDisplayMetrics());

    AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(appWidgetId);
    AppWidgetHostView hostView = mAppWidgetHost.createView(this, appWidgetId, appWidgetInfo);
    hostView.setAppWidget(appWidgetId, appWidgetInfo);

    widgetWidth = appWidgetInfo.minWidth;
    widgetHeight = appWidgetInfo.minHeight;

    hostView.setMinimumWidth(widgetWidth);
    hostView.setMinimumHeight(widgetHeight);

    widget.addView(hostView);
    System.out.println(appWidgetInfo.provider.getClassName()
            + " Widget WH: " + appWidgetInfo.minWidth + "*" + appWidgetInfo.minHeight);
}
 
开发者ID:GeeksEmpireNet,项目名称:Shortcuts,代码行数:23,代码来源:WidgetHandler.java

示例10: addAppWidgetImpl

import android.appwidget.AppWidgetHostView; //导入依赖的package包/类
void addAppWidgetImpl(final int appWidgetId, final ItemInfo info,
        final AppWidgetHostView boundWidget, final LauncherAppWidgetProviderInfo appWidgetInfo,
        int delay) {
    if (appWidgetInfo.configure != null) {
        mPendingAddWidgetInfo = appWidgetInfo;
        mPendingAddWidgetId = appWidgetId;

        // Launch over to configure widget, if needed
        mAppWidgetManager.startConfigActivity(appWidgetInfo, appWidgetId, this,
                mAppWidgetHost, REQUEST_CREATE_APPWIDGET);

    } else {
        // Otherwise just add it
        Runnable onComplete = new Runnable() {
            @Override
            public void run() {
                // Exit spring loaded mode if necessary after adding the widget
                exitSpringLoadedDragModeDelayed(true, EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT,
                        null);
            }
        };
        completeAddAppWidget(appWidgetId, info.container, info.screenId, boundWidget,
                appWidgetInfo);
        mWorkspace.removeExtraEmptyScreenDelayed(true, onComplete, delay, false);
    }
}
 
开发者ID:Mr-lin930819,项目名称:SimplOS,代码行数:27,代码来源:Launcher.java

示例11: getDefaultOptionsForWidget

import android.appwidget.AppWidgetHostView; //导入依赖的package包/类
public static Bundle getDefaultOptionsForWidget(Launcher launcher, PendingAddWidgetInfo info) {
    Bundle options = null;
    Rect rect = new Rect();
    if (Utilities.ATLEAST_JB_MR1) {
        AppWidgetResizeFrame.getWidgetSizeRanges(launcher, info.spanX, info.spanY, rect);
        Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(launcher,
                info.componentName, null);

        float density = launcher.getResources().getDisplayMetrics().density;
        int xPaddingDips = (int) ((padding.left + padding.right) / density);
        int yPaddingDips = (int) ((padding.top + padding.bottom) / density);

        options = new Bundle();
        options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH,
                rect.left - xPaddingDips);
        options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT,
                rect.top - yPaddingDips);
        options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH,
                rect.right - xPaddingDips);
        options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT,
                rect.bottom - yPaddingDips);
    }
    return options;
}
 
开发者ID:Mr-lin930819,项目名称:SimplOS,代码行数:25,代码来源:WidgetHostViewLoader.java

示例12: getDefaultOptionsForWidget

import android.appwidget.AppWidgetHostView; //导入依赖的package包/类
Bundle getDefaultOptionsForWidget(Launcher launcher, PendingAddWidgetInfo info) {
    Bundle options = null;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        AppWidgetResizeFrame.getWidgetSizeRanges(mLauncher, info.spanX, info.spanY, mTmpRect);
        Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(mLauncher,
                info.componentName, null);

        float density = getResources().getDisplayMetrics().density;
        int xPaddingDips = (int) ((padding.left + padding.right) / density);
        int yPaddingDips = (int) ((padding.top + padding.bottom) / density);

        options = new Bundle();
        options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH,
                mTmpRect.left - xPaddingDips);
        options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT,
                mTmpRect.top - yPaddingDips);
        options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH,
                mTmpRect.right - xPaddingDips);
        options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT,
                mTmpRect.bottom - yPaddingDips);
    }
    return options;
}
 
开发者ID:Phonemetra,项目名称:TurboLauncher,代码行数:24,代码来源:AppsCustomizePagedView.java

示例13: addProvider

import android.appwidget.AppWidgetHostView; //导入依赖的package包/类
public void addProvider(MainActivity m, AppWidgetHost host, AppWidgetManager manager, AppWidgetProviderInfo provider) {
    int id = host.allocateAppWidgetId();
    boolean success;
    success = manager.bindAppWidgetIdIfAllowed(id, provider.provider);

    if (success) {
        AppWidgetHostView hostView = host.createView(getActivity(), id, provider);
        AppWidgetProviderInfo appWidgetInfo = manager.getAppWidgetInfo(id);

        LauncherAppWidgetInfo info = new LauncherAppWidgetInfo(id);
        info.setHostView(hostView);
        info.getHostView().setAppWidget(id, appWidgetInfo);

        ItemInfo launcherInfo = attachWidget(info);
        if (launcherInfo != null) {
            WidgetPersistance.addDesktopAppWidget(screen, launcherInfo);
        }

    } else {
        Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
        intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, id);
        intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, provider.provider);
        m.startActivityForResult(intent, MainActivity.REQUEST_BIND_APPWIDGET);
    }

}
 
开发者ID:DagW,项目名称:FragmentHomescreen,代码行数:27,代码来源:WidgetFragment.java

示例14: addAppWidgetImpl

import android.appwidget.AppWidgetHostView; //导入依赖的package包/类
void addAppWidgetImpl(final int appWidgetId, final ItemInfo info,
        final AppWidgetHostView boundWidget, final AppWidgetProviderInfo appWidgetInfo, int
        delay) {
    if (appWidgetInfo.configure != null) {
        mPendingAddWidgetInfo = appWidgetInfo;
        mPendingAddWidgetId = appWidgetId;

        // Launch over to configure widget, if needed
        mAppWidgetManager.startConfigActivity(appWidgetInfo, appWidgetId, this,
                mAppWidgetHost, REQUEST_CREATE_APPWIDGET);

    } else {
        // Otherwise just add it
        Runnable onComplete = new Runnable() {
            @Override
            public void run() {
                // Exit spring loaded mode if necessary after adding the widget
                exitSpringLoadedDragModeDelayed(true, EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT,
                        null);
            }
        };
        completeAddAppWidget(appWidgetId, info.container, info.screenId, boundWidget,
                appWidgetInfo);
        mWorkspace.removeExtraEmptyScreenDelayed(true, onComplete, delay, false);
    }
}
 
开发者ID:AndroidDeveloperLB,项目名称:LB-Launcher,代码行数:27,代码来源:Launcher.java

示例15: getDefaultOptionsForWidget

import android.appwidget.AppWidgetHostView; //导入依赖的package包/类
static Bundle getDefaultOptionsForWidget(Launcher launcher, PendingAddWidgetInfo info) {
    Bundle options = null;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        AppWidgetResizeFrame.getWidgetSizeRanges(launcher, info.spanX, info.spanY, sTmpRect);
        Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(launcher,
                info.componentName, null);

        float density = launcher.getResources().getDisplayMetrics().density;
        int xPaddingDips = (int) ((padding.left + padding.right) / density);
        int yPaddingDips = (int) ((padding.top + padding.bottom) / density);

        options = new Bundle();
        options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH,
                sTmpRect.left - xPaddingDips);
        options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT,
                sTmpRect.top - yPaddingDips);
        options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH,
                sTmpRect.right - xPaddingDips);
        options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT,
                sTmpRect.bottom - yPaddingDips);
    }
    return options;
}
 
开发者ID:AndroidDeveloperLB,项目名称:LB-Launcher,代码行数:24,代码来源:AppsCustomizePagedView.java


注:本文中的android.appwidget.AppWidgetHostView类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。