本文整理汇总了Java中android.support.v4.util.SimpleArrayMap.size方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleArrayMap.size方法的具体用法?Java SimpleArrayMap.size怎么用?Java SimpleArrayMap.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.util.SimpleArrayMap
的用法示例。
在下文中一共展示了SimpleArrayMap.size方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toJson
import android.support.v4.util.SimpleArrayMap; //导入方法依赖的package包/类
public static String toJson(SimpleArrayMap<String, Task> tasks)
throws JSONException {
JSONObject root = new JSONObject();
JSONObject jsonTasks = new JSONObject();
for (int i = 0; i < tasks.size(); ++i) {
String cardId = tasks.keyAt(i);
Task task = tasks.valueAt(i);
jsonTasks.put(cardId, toJson(task));
}
root.put(KEY_TASKS, jsonTasks);
String json = root.toString();
LogUtils.d(TAG, "Generated tasks JSON " + json);
return json;
}
示例2: forName
import android.support.v4.util.SimpleArrayMap; //导入方法依赖的package包/类
Method forName(String methodName) {
Method handler = immediateHandlers.get(methodName);
if (handler != null) {
return handler;
}
SimpleArrayMap<String, Method> wildcardHandlers = this.wildcardHandlers;
int size = wildcardHandlers.size();
for (int i = 0; i < size; i++) {
String wildcard = wildcardHandlers.keyAt(i);
if (methodName.matches(wildcard.replace("*", ".*?"))) {
return wildcardHandlers.get(wildcard);
}
}
return fallback;
}
示例3: writeSimpleArrayMap
import android.support.v4.util.SimpleArrayMap; //导入方法依赖的package包/类
static void writeSimpleArrayMap(Parcel dest,
@Nullable SimpleArrayMap<String, SparseIntArray> map) {
if (map == null) {
dest.writeInt(-1);
} else {
int size = map.size();
dest.writeInt(size);
for (int i = 0; i < size; ++i) {
dest.writeString(map.keyAt(i));
writeSparseIntArray(dest, map.valueAt(i));
}
}
}
示例4: getAllSounds
import android.support.v4.util.SimpleArrayMap; //导入方法依赖的package包/类
@NonNull
public static List<Sound> getAllSounds() {
List<Sound> sounds = new ArrayList<>();
SimpleArrayMap<String, List<Sound>> map = getSounds();
for (int i = 0; i < map.size(); i++) {
sounds.addAll(getSounds().get(map.valueAt(i)));
}
return sounds;
}
示例5: sendPostsToWearable
import android.support.v4.util.SimpleArrayMap; //导入方法依赖的package包/类
private void sendPostsToWearable(@NonNull List<Post> posts, @NonNull final String msg,
@Nullable SimpleArrayMap<String, Asset> assets) {
if (mGoogleApiClient.isConnected()) {
// convert to json for sending to watch and to save to shared prefs
// don't need to preserve the order like having separate String lists, can more easily add/remove fields
PutDataMapRequest mapRequest = PutDataMapRequest.create(Constants.PATH_REDDIT_POSTS);
DataMap dataMap = mapRequest.getDataMap();
if (assets != null && !assets.isEmpty()) {
for (int i = 0; i < assets.size(); i++) {
dataMap.putAsset(assets.keyAt(i), assets.valueAt(i));
}
}
dataMap.putLong("timestamp", System.currentTimeMillis());
dataMap.putString(Constants.KEY_REDDIT_POSTS, mGson.toJson(posts));
dataMap.putBoolean(Constants.KEY_DISMISS_AFTER_ACTION,
mUserStorage.openOnPhoneDismissesAfterAction());
dataMap.putIntegerArrayList(Constants.KEY_ACTION_ORDER,
mWearableActionStorage.getSelectedActionIds());
PutDataRequest request = mapRequest.asPutDataRequest();
Wearable.DataApi.putDataItem(mGoogleApiClient, request)
.setResultCallback(dataItemResult -> {
Timber.d(msg + ", final timestamp: " + mUserStorage.getTimestamp() + " result: " + dataItemResult
.getStatus());
if (dataItemResult.getStatus().isSuccess()) {
if (mGoogleApiClient.isConnected()) {
mGoogleApiClient.disconnect();
}
} else {
Timber.d("Failed to send posts to wearable " + dataItemResult.getStatus()
.getStatusMessage());
}
});
}
}
示例6: refresh
import android.support.v4.util.SimpleArrayMap; //导入方法依赖的package包/类
@Override
public void refresh() {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
final String instanceId = mInstanceIdHelper.getInstanceId();
final String creationTime = DateFormat.getDateTimeInstance()
.format(new Date(mInstanceIdHelper.getCreationTime()));
final Activity activity = getActivity();
if (activity != null) {
Handler handler = new Handler(activity.getMainLooper());
handler.post(new Runnable() {
public void run() {
setValue(activity.findViewById(R.id.iid_instance_id), instanceId);
setValue(activity.findViewById(R.id.iid_creation_time), creationTime);
}
});
}
return null;
}
}.execute();
float density = getActivity().getResources().getDisplayMetrics().density;
SimpleArrayMap<String, Sender> addressBook = mSenders.getSenders();
LinearLayout sendersList = new LinearLayout(getActivity());
sendersList.setOrientation(LinearLayout.VERTICAL);
for (int i = 0; i < addressBook.size(); i++) {
Sender sender = addressBook.valueAt(i);
if (sender.appTokens.size() > 0) {
LinearLayout senderRow = (LinearLayout) getActivity().getLayoutInflater()
.inflate(R.layout.widget_icon_text_button_row, sendersList, false);
ImageView senderIcon = (ImageView) senderRow.findViewById(R.id.widget_itbr_icon);
TextView senderLabel = (TextView) senderRow.findViewById(R.id.widget_itbr_text);
senderRow.findViewById(R.id.widget_itbr_button).setVisibility(View.GONE);
senderIcon.setImageResource(R.drawable.cloud_googblue);
senderIcon.setPadding(0, 0, (int) (8 * density), 0);
senderLabel.setText(getString(R.string.topics_sender_id, sender.senderId));
sendersList.addView(senderRow);
for (Token token : sender.appTokens.values()) {
LinearLayout row = (LinearLayout) getActivity().getLayoutInflater()
.inflate(R.layout.widget_icon_text_button_row, sendersList, false);
ImageView icon = (ImageView) row.findViewById(R.id.widget_itbr_icon);
TextView label = (TextView) row.findViewById(R.id.widget_itbr_text);
Button button = (Button) row.findViewById(R.id.widget_itbr_button);
icon.setImageResource(R.drawable.smartphone_grey600);
label.setText(token.scope + " - "
+ AbstractFragment.truncateToMediumString(token.token));
button.setText(R.string.iid_delete_token);
button.setTag(R.id.tag_senderid, sender.senderId);
button.setTag(R.id.tag_scope, token.scope);
button.setOnClickListener(this);
row.setPadding((int) (16 * density), 0, 0, 0);
sendersList.addView(row);
}
}
}
if (sendersList.getChildCount() == 0) {
TextView noTokens = new TextView(getActivity());
noTokens.setText(getString(R.string.iid_no_tokens));
noTokens.setTypeface(null, Typeface.ITALIC);
sendersList.addView(noTokens);
}
FrameLayout tokensView = (FrameLayout) getActivity().findViewById(R.id.iid_tokens_wrapper);
tokensView.removeAllViews();
tokensView.addView(sendersList);
}
示例7: refresh
import android.support.v4.util.SimpleArrayMap; //导入方法依赖的package包/类
@Override
public void refresh() {
float density = getActivity().getResources().getDisplayMetrics().density;
SimpleArrayMap<String, Sender> addressBook = mSenders.getSenders();
LinearLayout sendersList = new LinearLayout(getActivity());
sendersList.setOrientation(LinearLayout.VERTICAL);
for (int i = 0; i < addressBook.size(); i++) {
Sender sender = addressBook.valueAt(i);
// Check if at least a topic is subscribed for this sender
int subscribedTopics = 0;
for (Boolean subscribed : sender.topics.values()) {
if (subscribed) {
subscribedTopics++;
}
}
if (subscribedTopics > 0) {
LinearLayout senderRow = (LinearLayout) getActivity().getLayoutInflater()
.inflate(R.layout.widget_icon_text_button_row, sendersList, false);
ImageView senderIcon = (ImageView) senderRow.findViewById(R.id.widget_itbr_icon);
TextView senderLabel = (TextView) senderRow.findViewById(R.id.widget_itbr_text);
senderRow.findViewById(R.id.widget_itbr_button).setVisibility(View.GONE);
senderIcon.setImageResource(R.drawable.cloud_googblue);
senderIcon.setPadding(0, 0, (int) (8 * density), 0);
senderLabel.setText(getString(R.string.topics_sender_id, sender.senderId));
sendersList.addView(senderRow);
for (Map.Entry<String, Boolean> topic : sender.topics.entrySet()) {
if (topic.getValue()) {
LinearLayout row = (LinearLayout) getActivity().getLayoutInflater()
.inflate(R.layout.widget_icon_text_button_row, sendersList, false);
ImageView icon = (ImageView) row.findViewById(R.id.widget_itbr_icon);
TextView label = (TextView) row.findViewById(R.id.widget_itbr_text);
Button button = (Button) row.findViewById(R.id.widget_itbr_button);
icon.setImageResource(R.drawable.bigtop_updates_grey600);
label.setText(topic.getKey());
button.setText(R.string.topics_unsubscribe);
button.setTag(R.id.tag_action, ACTION_UNSUBSCRIBE);
button.setTag(R.id.tag_senderid, sender.senderId);
button.setTag(R.id.tag_topic, topic.getKey());
button.setOnClickListener(this);
row.setPadding((int) (16 * density), 0, 0, 0);
sendersList.addView(row);
}
}
}
}
if (sendersList.getChildCount() == 0) {
TextView noTokens = new TextView(getActivity());
noTokens.setText(getString(R.string.topics_no_topic_subscribed));
noTokens.setTypeface(null, Typeface.ITALIC);
sendersList.addView(noTokens);
}
FrameLayout topicsView = (FrameLayout) getActivity().findViewById(R.id.topics_list_wrapper);
topicsView.removeAllViews();
topicsView.addView(sendersList);
}
示例8: refresh
import android.support.v4.util.SimpleArrayMap; //导入方法依赖的package包/类
@Override
public void refresh() {
float density = getActivity().getResources().getDisplayMetrics().density;
SimpleArrayMap<String, Sender> senders = mSenders.getSenders();
LinearLayout sendersList = new LinearLayout(getActivity());
sendersList.setOrientation(LinearLayout.VERTICAL);
for (int i = 0; i < senders.size(); i++) {
Sender sender = senders.valueAt(i);
if (sender.groups.size() > 0) {
LinearLayout senderRow = (LinearLayout) getActivity().getLayoutInflater()
.inflate(R.layout.widget_icon_text_button_row, sendersList, false);
ImageView senderIcon = (ImageView) senderRow.findViewById(R.id.widget_itbr_icon);
TextView senderText = (TextView) senderRow.findViewById(R.id.widget_itbr_text);
senderRow.findViewById(R.id.widget_itbr_button).setVisibility(View.GONE);
senderIcon.setImageResource(R.drawable.cloud_googblue);
senderIcon.setPadding(0, 0, (int) (8 * density), 0);
senderText.setText(getString(R.string.groups_sender_id, sender.senderId));
sendersList.addView(senderRow);
for (DeviceGroup deviceGroup : sender.groups.values()) {
LinearLayout row = (LinearLayout) getActivity().getLayoutInflater()
.inflate(R.layout.widget_icon_text_button_row, sendersList, false);
ImageView icon = (ImageView) row.findViewById(R.id.widget_itbr_icon);
TextView label = (TextView) row.findViewById(R.id.widget_itbr_text);
Button button = (Button) row.findViewById(R.id.widget_itbr_button);
icon.setImageResource(R.drawable.group_grey600);
label.setText(deviceGroup.notificationKeyName);
label.setBackgroundResource(selectableBackgroundResource);
label.setTag(R.id.tag_action, ACTION_OPEN_GROUP);
label.setTag(R.id.tag_senderid, sender.senderId);
label.setTag(R.id.tag_group, deviceGroup.notificationKeyName);
label.setOnClickListener(this);
button.setText(R.string.groups_delete);
button.setTag(R.id.tag_action, ACTION_DELETE_GROUP);
button.setTag(R.id.tag_senderid, sender.senderId);
button.setTag(R.id.tag_group, deviceGroup.notificationKeyName);
button.setOnClickListener(this);
row.setPadding((int) (16 * density), 0, 0, 0);
sendersList.addView(row);
}
}
}
if (sendersList.getChildCount() == 0) {
TextView noTokens = new TextView(getActivity());
noTokens.setText(getString(R.string.groups_no_groups_available));
noTokens.setTypeface(null, Typeface.ITALIC);
sendersList.addView(noTokens);
}
FrameLayout topicsView = (FrameLayout) getActivity().findViewById(R.id.groups_list_wrapper);
topicsView.removeAllViews();
topicsView.addView(sendersList);
}
示例9: isEqualTo
import android.support.v4.util.SimpleArrayMap; //导入方法依赖的package包/类
@Override
public boolean isEqualTo(final SimpleArrayMap<?, ?> array) {
int count = 0;
for (final SimpleArrayMapEntry<K, V> entry : this) {
final Object value = array.get(entry.getKey());
if (value == null) {
if (entry.getValue() != null) {
return false;
}
} else if (!value.equals(entry.getValue())) {
return false;
}
++count;
}
return (count == array.size());
}
示例10: SimpleArrayMapReverseIterator
import android.support.v4.util.SimpleArrayMap; //导入方法依赖的package包/类
public SimpleArrayMapReverseIterator(final SimpleArrayMap<K, V> arrayMap) {
super(arrayMap.size());
mArrayMap = arrayMap;
}
示例11: SimpleArrayMapIterator
import android.support.v4.util.SimpleArrayMap; //导入方法依赖的package包/类
public SimpleArrayMapIterator(final SimpleArrayMap<K, V> arrayMap) {
super(arrayMap.size());
mArrayMap = arrayMap;
}