本文整理汇总了Java中com.google.android.apps.dashclock.api.ExtensionData.visible方法的典型用法代码示例。如果您正苦于以下问题:Java ExtensionData.visible方法的具体用法?Java ExtensionData.visible怎么用?Java ExtensionData.visible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.apps.dashclock.api.ExtensionData
的用法示例。
在下文中一共展示了ExtensionData.visible方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
@Override
protected void onUpdateData(int reason) {
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
Countdown countdown = new Countdown(this, getCountdownNumber());
int[] diffs = countdown.getTimeRemaining();
ExtensionData extensionData = new ExtensionData();
extensionData.status(countdown.getStatus(diffs));
extensionData.expandedTitle(sharedPreferences.getString("pref_title_" + getCountdownNumber(), getString(R.string.no_countdown_title)));
extensionData.expandedBody(countdown.getBody(diffs));
extensionData.icon(sharedPreferences.getInt("pref_icon_" + getCountdownNumber(), R.drawable.ic_launcher));
extensionData.clickIntent(getClickIntent());
extensionData.visible(true);
publishUpdate(extensionData);
}
示例2: handleMessage
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
/**
* Handler method that that acts an and expiration checker that upon expiry simple hides the
* dashclock notification.
*/
@Override
public void handleMessage(Message msgMessage) {
try {
Log.d(getTag(), "User has been notified of logoff so hide message");
ExtensionData edtInformation = new ExtensionData();
edtInformation.visible(false);
doUpdate(edtInformation);
} catch (Exception e) {
Log.e(ComputerWidget.this.getTag(), "Error hiding the notification", e);
}
}
示例3: update
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
/**
* Updated the notification data copy and also updates the notification in the notification
* shade.
* <br />
* All the extension data is consumed and used for building the notification. The title of the
* extension data becomes the notification's title, the body of the extension data becomes the
* notification's content, the click intent of the extension data becomes the notification's
* click intent, the icon of the extension data becomes the notification's icon and the status
* of the extension data becomes the notifications info only if the status does not match the
* title or the body (to prevent redundant information cluttering up the notification.)
*
* @param component the component name of the extension
* @param data the data passed from the extension
*/
@SuppressWarnings("deprecation")
private void update(ComponentName component, ExtensionData data) {
if (data != null && data.visible()) {
int colour = getResources().getColor(R.color.notification_color);
NotificationCompat.Builder notification = new NotificationCompat.Builder(this);
notification.setColor(colour);
notification.setCategory(NotificationCompat.CATEGORY_SERVICE);
notification.setPriority(Integer.MIN_VALUE);
notification.setOnlyAlertOnce(true);
notification.setOngoing(true);
notification.setShowWhen(true);
PendingIntent click = PendingIntent.getActivity(getApplicationContext(), 0, data.clickIntent(), 0);
Bitmap icon = Utils.loadExtensionIcon(getApplicationContext(), component, data.icon(), null, colour);
notification.setStyle(new BigTextStyle().bigText(data.expandedBody()));
notification.setSmallIcon(R.drawable.ic_notification);
notification.setContentTitle(data.expandedTitle());
notification.setContentText(data.expandedBody());
notification.setGroup("dashbar");
if (data.status() != null && !data.status().equalsIgnoreCase(data.expandedBody())
&& !data.status().equalsIgnoreCase(data.expandedTitle())) {
notification.setContentInfo(data.status());
}
notification.setContentIntent(click);
notification.setLargeIcon(icon);
mNotifier.notify(component.getPackageName(), 1, notification.build());
}
}
示例4: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
@Override
protected void onUpdateData(int intReason) {
Log.d(getTag(), "Checking for any wireless displays on the network");
final ExtensionData edtInformation = new ExtensionData();
setUpdateWhenScreenOn(true);
try {
Integer intDisplays = hndDiscoverer.getDetectedDisplays();
if (hndDiscoverer.getDetectedDisplays() > 0) {
edtInformation.expandedTitle(getString(R.string.found_devices));
} else {
edtInformation.expandedTitle(getString(R.string.no_devices));
}
edtInformation.expandedBody(getQuantityString(R.plurals.devices, intDisplays, intDisplays));
edtInformation.status(hndDiscoverer.getDetectedDisplays().toString());
edtInformation.visible(true);
} catch (Exception e) {
edtInformation.visible(false);
Log.e(getTag(), "Encountered an error", e);
ACRA.getErrorReporter().handleSilentException(e);
}
edtInformation.icon(R.drawable.ic_dashclock);
edtInformation.clickIntent(new Intent().setComponent(new ComponentName("com.android.settings", "com.android.settings.Settings$WifiDisplaySettingsActivity")));
doUpdate(edtInformation);
}
示例5: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
@Override
protected void onUpdateData(int intReason) {
Log.d(getTag(), "Calculating the amount of data transferred");
ExtensionData edtInformation = new ExtensionData();
setUpdateWhenScreenOn(true);
try {
ComponentName cmpActivity = new ComponentName("com.android.settings", "com.android.settings.Settings$DataUsageSummaryActivity");
Long lngMobile = this.lngMobile + TrafficStats.getMobileRxBytes() + TrafficStats.getMobileTxBytes();
Long lngTotal = this.lngTotal + TrafficStats.getTotalRxBytes() + TrafficStats.getTotalTxBytes();
Long lngWifi = lngTotal - lngMobile;
String strMobile = Formatter.formatFileSize(getApplicationContext(), lngMobile);
String strTotal = Formatter.formatFileSize(getApplicationContext(), lngTotal);
String strWifi = Formatter.formatFileSize(getApplicationContext(), lngWifi);
edtInformation.expandedTitle(String.format(getString(R.string.status), strTotal));
edtInformation.status(strTotal);
edtInformation.expandedBody(String.format(getString(R.string.message), strMobile, strWifi));
edtInformation.visible(true);
edtInformation.clickIntent(new Intent().setComponent(cmpActivity));
} catch (Exception e) {
edtInformation.visible(false);
Log.e(getTag(), "Encountered an error", e);
ACRA.getErrorReporter().handleSilentException(e);
}
edtInformation.icon(R.drawable.ic_dashclock);
doUpdate(edtInformation);
}
示例6: publishGerritState
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
private void publishGerritState() {
ExtensionData extensionData = new ExtensionData();
extensionData.visible(false);
if (endpoint.getUrl() != null) {
fetchFromGerrit();
updateStatus(extensionData);
}
publishUpdate(extensionData);
}
示例7: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
@Override
protected void onUpdateData(int intReason) {
Log.d(getTag(), "Getting the status of the processes");
ExtensionData edtInformation = new ExtensionData();
setUpdateWhenScreenOn(true);
try {
Log.d(getTag(), "Calculating the number of tasks and services");
ActivityManager mgrActivity = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
Integer intServices = mgrActivity.getRunningServices(Integer.MAX_VALUE).size();
Integer intRecents = mgrActivity.getRecentTasks(Integer.MAX_VALUE, 2).size() - 1;
Integer intProcess = mgrActivity.getRunningAppProcesses().size();
String strServices = getQuantityString(R.plurals.service, intServices, intServices);
String strRecents = getQuantityString(R.plurals.activity, intRecents, intRecents);
Log.d(getTag(), String.format("%d running processes", intProcess));
edtInformation.clickIntent(new Intent(Intent.ACTION_VIEW).setClassName("com.android.settings", "com.android.settings.RunningServices"));
edtInformation.status(Integer.toString(intRecents + intServices));
edtInformation.expandedTitle(getString(R.string.and, strRecents, strServices));
edtInformation.expandedBody(getQuantityString(R.plurals.process, intProcess, intProcess));
edtInformation.visible(true);
} catch (Exception e) {
edtInformation.visible(false);
Log.e(getTag(), "Encountered an error", e);
ACRA.getErrorReporter().handleSilentException(e);
}
edtInformation.icon(R.drawable.ic_dashclock);
doUpdate(edtInformation);
}
示例8: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
@Override
protected void onUpdateData(int intReason) {
Log.d(getTag(), "Fetching processor and memory utilisation information");
final ExtensionData edtInformation = new ExtensionData();
setUpdateWhenScreenOn(true);
try {
ActivityManager mgrActivity = ((ActivityManager) getSystemService(Context.ACTIVITY_SERVICE));
MemoryInfo memInformation = new MemoryInfo();
mgrActivity.getMemoryInfo(memInformation);
Long lngFree = memInformation.availMem / 1048576L;
Long lngTotal = memInformation.totalMem / 1048576L;
Integer intLevel = (int) ((100.0 * (lngFree / (lngTotal + 0.01))) / 25);
edtInformation.status(hndNotifier.getUsagePercentage().toString());
edtInformation.expandedTitle(getString(R.string.processor, hndNotifier.getUsagePercentage()));
edtInformation.expandedBody(getString(R.string.memory, lngFree, lngTotal));
edtInformation.visible(true);
notBuilder = notBuilder.setContentTitle(getResources().getStringArray(R.array.usage)[intLevel]);
notBuilder = notBuilder.setContentText(getString(R.string.memory, lngFree, lngTotal));
} catch (Exception e) {
edtInformation.visible(false);
Log.e(getTag(), "Encountered an error", e);
ACRA.getErrorReporter().handleSilentException(e);
}
edtInformation.icon(R.drawable.ic_dashclock);
doUpdate(edtInformation);
}
示例9: getView
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.extension_item, parent, false);
holder = new ViewHolder();
holder.icon = (ImageView) convertView.findViewById(R.id.icon);
holder.title = (TextView) convertView.findViewById(R.id.title);
holder.description = (TextView) convertView.findViewById(R.id.description);
holder.status = (TextView) convertView.findViewById(R.id.status);
holder.expandedTitle = (TextView) convertView.findViewById(R.id.expandedTitle);
holder.expandedBody = (TextView) convertView.findViewById(R.id.expandedBody);
holder.worldReadable = (ImageView) convertView.findViewById(R.id.world_readable);
holder.settings = (ImageView) convertView.findViewById(R.id.settings);
holder.settings.setOnClickListener(mListener);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
ExtensionListing info = getItem(position);
holder.title.setText(info.title());
holder.description.setText(info.description());
try {
if (info.icon() != 0) {
Resources res = getContext().createPackageContext(
info.componentName().getPackageName(), 0).getResources();
Drawable dw = res.getDrawable(info.icon());
dw.setColorFilter(Color.GRAY, PorterDuff.Mode.SRC_IN);
holder.icon.setImageDrawable(dw);
} else {
holder.icon.setImageDrawable(null);
}
} catch (PackageManager.NameNotFoundException e) {
holder.icon.setImageDrawable(null);
}
boolean hasSettings = info.settingsActivity() != null;
holder.settings.setVisibility(hasSettings ? View.VISIBLE : View.GONE);
holder.settings.setTag(info);
holder.worldReadable.setVisibility(info.worldReadable() ? View.VISIBLE : View.GONE);
ExtensionData data = mHost.getExtensionData(info.componentName());
if (data != null) {
if (!data.visible()) {
String dataText = getContext().getString(R.string.data_invalid);
holder.status.setText(dataText);
holder.status.setVisibility(
TextUtils.isEmpty(dataText) ? View.GONE : View.VISIBLE);
holder.expandedTitle.setVisibility(View.GONE);
holder.expandedBody.setVisibility(View.GONE);
} else {
holder.status.setText(data.status());
holder.status.setVisibility(
TextUtils.isEmpty(data.status()) ? View.GONE : View.VISIBLE);
holder.expandedTitle.setText(data.expandedTitle());
holder.expandedTitle.setVisibility(
TextUtils.isEmpty(data.expandedTitle()) ? View.GONE : View.VISIBLE);
holder.expandedBody.setText(data.expandedBody());
holder.expandedBody.setVisibility(
TextUtils.isEmpty(data.expandedBody()) ? View.GONE : View.VISIBLE);
}
}
return convertView;
}
示例10: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
@Override
protected void onUpdateData(int intReason) {
Log.d(getTag(), "Calculating the number of warnings and failures");
final ExtensionData edtInformation = new ExtensionData();
setUpdateWhenScreenOn(true);
try {
Integer intFailures = getSet("failure", new HashSet<String>()).size();
Integer intWarnings = getSet("warning", new HashSet<String>()).size();
if (intFailures + intWarnings > 0) {
Log.d(getTag(), String.format("Found %d warnings and %d failures", intWarnings, intFailures));
String strFailures = getQuantityString(R.plurals.failure, intFailures, intFailures);
String strWarnings = getQuantityString(R.plurals.warning, intWarnings, intWarnings);
String strBookmark = DateUtils.formatDateTime(this, speSettings.getLong("bookmark", Long.MIN_VALUE), 17);
edtInformation.clickIntent(new Intent(this, WarningActivity.class).addCategory(Intent.CATEGORY_LAUNCHER));
edtInformation.expandedBody(getString(R.string.body, strBookmark));
edtInformation.expandedTitle(getString(R.string.title, strFailures, strWarnings));
edtInformation.status(String.valueOf(intFailures + intWarnings));
edtInformation.visible(true);
} else {
Log.d(getTag(), "Found no warnings or failures");
edtInformation.visible(false);
}
} catch (Exception e) {
edtInformation.visible(true);
Log.e(getTag(), "Encountered an error", e);
ACRA.getErrorReporter().handleSilentException(e);
}
edtInformation.icon(R.drawable.ic_dashclock);
doUpdate(edtInformation);
}
示例11: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
@Override
protected void onUpdateData(int intReason) {
Log.d(getTag(), "Fetching wireless debugging status");
ExtensionData edtInformation = new ExtensionData();
setUpdateWhenScreenOn(false);
try {
Integer intPort = Settings.Secure.getInt(getContentResolver(), "adb_port", -1);
if (intPort > 0) {
Log.d(getTag(), "Wireless debugging is enabled");
WifiManager wm = (WifiManager) getSystemService(WIFI_SERVICE);
Log.d(getTag(), "Checking if wireless connectivity is enabled");
if (wm.isWifiEnabled()) {
String strIP = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress());
Log.d(getTag(), "Wireless connectivity is enabled");
edtInformation.status(getString(R.string.enabled));
edtInformation.expandedBody(getString(R.string.portno, strIP, intPort));
edtInformation.visible(true);
} else {
Log.d(getTag(), "Wireless connectivity isn't enabled");
edtInformation.status(getString(R.string.disabled));
edtInformation.expandedBody(getString(R.string.plugin));
edtInformation.visible(getBoolean("always", true));
}
} else {
Log.d(getTag(), "Wireless debugging is disabled");
edtInformation.status(getString(R.string.disabled));
edtInformation.expandedBody(getString(R.string.plugin));
edtInformation.visible(getBoolean("always", true));
}
edtInformation.clickIntent(new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS));
} catch (Exception e) {
edtInformation.visible(false);
Log.e(getTag(), "Encountered an error", e);
ACRA.getErrorReporter().handleSilentException(e);
}
edtInformation.icon(R.drawable.ic_dashclock);
doUpdate(edtInformation);
}
示例12: onReceiveIntent
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
@Override
protected void onReceiveIntent(Context ctxContext, Intent ittIntent) {
ExtensionData edtInformation = new ExtensionData();
try {
Bundle bndBundle = ittIntent.getExtras();
String strUsername = bndBundle.getString("username").toLowerCase();
String strMachine = bndBundle.getString("machine");
notBuilder = notBuilder.setWhen(System.currentTimeMillis());
notBuilder = notBuilder.setContentTitle(strMachine);
edtInformation.visible(true);
edtInformation.expandedBody(strMachine);
if (bndBundle.getString("event").equalsIgnoreCase("logon")) {
Log.d(getTag(), strUsername + " logged on at " + strMachine);
edtInformation.expandedTitle(getString(R.string.logon, strUsername));
notBuilder = notBuilder.setContentText(edtInformation.expandedTitle());
mgrNotifications.notify(115, notBuilder.build());
} else if (bndBundle.getString("event").equalsIgnoreCase("lock")) {
Log.d(getTag(), strUsername + " locked the computer " + strMachine);
edtInformation.expandedTitle(getString(R.string.lock, strUsername));
notBuilder = notBuilder.setContentText(edtInformation.expandedTitle());
mgrNotifications.notify(115, notBuilder.build());
} else if (bndBundle.getString("event").equalsIgnoreCase("unlock")) {
Log.d(getTag(), strUsername + " unlocked the computer " + strMachine);
edtInformation.expandedTitle(getString(R.string.unlock, strUsername));
notBuilder = notBuilder.setContentText(edtInformation.expandedTitle());
mgrNotifications.notify(115, notBuilder.build());
} else if (bndBundle.getString("event").equalsIgnoreCase("logoff")) {
Log.d(getTag(), strUsername + " logged off at " + strMachine);
edtInformation.expandedTitle(getString(R.string.logoff, strUsername));
notBuilder = notBuilder.setContentText(edtInformation.expandedTitle());
mgrNotifications.notify(115, notBuilder.build());
} else {
Log.v(getTag(), strUsername + " is active on " + strMachine);
edtInformation.expandedTitle(getString(R.string.active, strUsername));
}
hndWaiter.removeMessages(1);
hndWaiter.sendEmptyMessageDelayed(1, 120000);
} catch (Exception e) {
edtInformation.visible(false);
Log.e(getTag(), "Encountered an error", e);
ACRA.getErrorReporter().handleSilentException(e);
}
edtInformation.icon(R.drawable.ic_dashclock);
doUpdate(edtInformation);
}
示例13: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
@SuppressLint("SimpleDateFormat")
@Override
protected void onUpdateData(int intReason) {
Log.d(getTag(), "Checking nightly commits");
ExtensionData edtInformation = new ExtensionData();
setUpdateWhenScreenOn(false);
try {
Log.d(getTag(), "Checking if it is a nightly build");
if (HelperFunctions.getType().equalsIgnoreCase("NIGHTLY")) {
Date datBuild = new SimpleDateFormat("yyyyMMdd").parse(HelperFunctions.getDate());
Integer intDays = Days.daysBetween(new DateTime(datBuild), new DateTime(new Date())).getDays();
Log.d(getTag(), "Checking if it is older than zero days");
if (intDays > 0) {
ComponentName cmpActivity = new ComponentName("com.cyanogenmod.updater", "com.cyanogenmod.updater.UpdatesSettings");
edtInformation.clickIntent(new Intent().setComponent(cmpActivity));
edtInformation.visible(true);
edtInformation.expandedTitle(getQuantityString(R.plurals.changes, intDays, intDays));
edtInformation.expandedBody(HelperFunctions.getBuildString());
edtInformation.status(intDays.toString());
} else {
Log.d(getTag(), "It isn't older than zero days");
}
} else {
Log.d(getTag(), "Not a nightly build");
}
} catch (Exception e) {
edtInformation.visible(false);
Log.e(getTag(), "Encountered an error", e);
ACRA.getErrorReporter().handleSilentException(e);
}
edtInformation.icon(R.drawable.ic_dashclock);
doUpdate(edtInformation);
}
示例14: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
@Override
protected void onUpdateData(int intReason) {
Log.d(getTag(), "Fetching near-field communication information");
ExtensionData edtInformation = new ExtensionData();
setUpdateWhenScreenOn(true);
try {
BluetoothAdapter bluAdapter = BluetoothAdapter.getDefaultAdapter();
if (bluAdapter != null) {
Log.d(getTag(), "Checking if the bluetooth radio is enabled");
edtInformation.clickIntent(new Intent(Settings.ACTION_BLUETOOTH_SETTINGS));
if (bluAdapter.isEnabled()) {
Log.d(getTag(), "Bluetooth radio is enabled");
if (booConnected) {
edtInformation.expandedTitle(getString(R.string.device_connected));
} else {
edtInformation.expandedTitle(getString(R.string.not_connected));
}
edtInformation.visible(true);
edtInformation.status(getString(R.string.enabled));
edtInformation.expandedBody(getString(R.string.visible_as, bluAdapter.getName()));
} else {
Log.d(getTag(), "Bluetooth radio is disabled");
edtInformation.visible(getBoolean("always", true));
edtInformation.status(getString(R.string.disabled));
edtInformation.expandedTitle(getString(R.string.not_enabled));
edtInformation.expandedBody(getString(R.string.tap_enable, bluAdapter.getName()));
}
} else {
Log.d(getTag(), "Device doesn't have a bluetooth radio");
}
} catch (Exception e) {
edtInformation.visible(false);
Log.e(getTag(), "Encountered an error", e);
ACRA.getErrorReporter().handleSilentException(e);
}
edtInformation.icon(R.drawable.ic_dashclock);
doUpdate(edtInformation);
}
示例15: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
@Override
protected void onUpdateData(int intReason) {
Log.d(getTag(), "Fetching near-field communication information");
ExtensionData edtInformation = new ExtensionData();
setUpdateWhenScreenOn(false);
try {
NfcManager nfcManager = (NfcManager) getSystemService(Context.NFC_SERVICE);
if (nfcManager != null && nfcManager.getDefaultAdapter() != null) {
Log.d(getTag(), "Checking if near-field communication is enabled");
if (nfcManager.getDefaultAdapter().isEnabled()) {
Log.d(getTag(), "Near-field communication is enabled");
edtInformation.visible(true);
edtInformation.status(getString(R.string.title));
edtInformation.clickIntent(new Intent("android.settings.NFC_SETTINGS"));
if (nfcManager.getDefaultAdapter().isNdefPushEnabled()) {
edtInformation.expandedBody(getString(R.string.beam_enabled));
} else {
edtInformation.expandedBody(getString(R.string.beam_disabled));
}
} else {
Log.d(getTag(), "Near-field communication is disabled");
}
} else {
Log.d(getTag(), "Device doesn't support near-field communication");
}
} catch (Exception e) {
edtInformation.visible(false);
Log.e(getTag(), "Encountered an error", e);
ACRA.getErrorReporter().handleSilentException(e);
}
edtInformation.icon(R.drawable.ic_dashclock);
doUpdate(edtInformation);
}