Example usage for android.os Bundle size

List of usage examples for android.os Bundle size

Introduction

In this page you can find the example usage for android.os Bundle size.

Prototype

public int size() 

Source Link

Document

Returns the number of mappings contained in this Bundle.

Usage

From source file:com.groupme.sdk.util.HttpUtilsTest.java

public void testBundleToList() {
    Bundle params = new Bundle();
    params.putString("group", "myawesomegroup");
    params.putString("platform", "android");
    params.putString("locale", "us");

    List<NameValuePair> pairs = HttpUtils.bundleToList(params);
    assertNotNull(pairs);//from   w ww  .j a v a 2  s.c o  m
    assertEquals(pairs.size(), params.size());

    for (NameValuePair pair : pairs) {
        assertNotNull(pair);
        assertEquals(pair.getValue(), params.getString(pair.getName()));
    }
}

From source file:com.google.android.gcm.demo.logic.DeviceGroupsHelper.java

/**
 * Execute the HTTP call to delete a Device Group.
 *
 * This is obtained by removing all the members of the group.
 *///  w ww .j  av  a 2 s.  c  o m
public void asyncDeleteGroup(final String senderId, final String apiKey, final String groupName) {
    new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... voids) {
            Sender sender = mSenders.getSender(senderId);
            if (sender == null) {
                return null;
            }
            DeviceGroup group = sender.groups.get(groupName);
            if (group == null) {
                return null;
            }
            Bundle members2Remove = new Bundle();
            for (String name : group.tokens.keySet()) {
                members2Remove.putString(name, group.tokens.get(name));
            }
            if (members2Remove.size() > 0) {
                removeMembers(senderId, apiKey, groupName, group.notificationKey, members2Remove);
            }
            sender.groups.remove(group.notificationKeyName);
            mSenders.updateSender(sender);
            return null;
        }
    }.execute();
}

From source file:com.chilliworks.chillisource.core.LocalNotificationReceiver.java

/**
 * Called when a local notification broad cast is received. Funnels the notification
 * into the app if open or into the notification bar if not
 * /*  w  w w .  j  a v  a 2s  . c om*/
 * @author Steven Hendrie
 * 
 * @param The context.
 * @param The intent.
 */
@SuppressWarnings("deprecation")
@Override
public void onReceive(Context in_context, Intent in_intent) {
    //evaluate whether or not the main engine activity is in the foreground
    boolean isAppInForeground = false;
    if (CSApplication.get() != null && CSApplication.get().isActive() == true) {
        isAppInForeground = true;
    }

    //if the main engine activity is in the foreground, simply pass the
    //notification into it. Otherwise display a notification.
    if (isAppInForeground == true) {
        final Intent intent = new Intent(in_intent.getAction());
        Bundle mapParams = in_intent.getExtras();
        Iterator<String> iter = mapParams.keySet().iterator();

        while (iter.hasNext()) {
            String strKey = iter.next();
            intent.putExtra(strKey, mapParams.get(strKey).toString());
        }

        LocalNotificationNativeInterface localNotificationNI = (LocalNotificationNativeInterface) CSApplication
                .get().getSystem(LocalNotificationNativeInterface.InterfaceID);
        if (localNotificationNI != null) {
            localNotificationNI.onNotificationReceived(intent);
        }
    } else {
        //aquire a wake lock
        if (s_wakeLock != null) {
            s_wakeLock.release();
        }

        PowerManager pm = (PowerManager) in_context.getSystemService(Context.POWER_SERVICE);
        s_wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP
                | PowerManager.ON_AFTER_RELEASE, "NotificationWakeLock");
        s_wakeLock.acquire();

        //pull out the information from the intent
        Bundle params = in_intent.getExtras();
        CharSequence title = params.getString(k_paramNameTitle);
        CharSequence text = params.getString(k_paramNameBody);
        int intentId = params.getInt(LocalNotification.k_paramNameNotificationId);

        int paramSize = params.size();
        String[] keys = new String[paramSize];
        String[] values = new String[paramSize];
        Iterator<String> iter = params.keySet().iterator();
        int paramNumber = 0;
        while (iter.hasNext()) {
            keys[paramNumber] = iter.next();
            values[paramNumber] = params.get(keys[paramNumber]).toString();
            ++paramNumber;
        }

        Intent openAppIntent = new Intent(in_context, CSActivity.class);
        openAppIntent.setAction("android.intent.action.MAIN");
        openAppIntent.addCategory("android.intent.category.LAUNCHER");
        openAppIntent.putExtra(k_appOpenedFromNotification, true);
        openAppIntent.putExtra(k_arrayOfKeysName, keys);
        openAppIntent.putExtra(k_arrayOfValuesName, values);
        openAppIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        PendingIntent sContentIntent = PendingIntent.getActivity(in_context, intentId, openAppIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);

        Bitmap largeIconBitmap = null;
        int LargeIconID = ResourceHelper.GetDynamicResourceIDForField(in_context,
                ResourceHelper.RESOURCE_SUBCLASS.RESOURCE_DRAWABLE, "ic_stat_notify_large");

        //Use small icon if no large icon
        if (LargeIconID == 0) {
            LargeIconID = ResourceHelper.GetDynamicResourceIDForField(in_context,
                    ResourceHelper.RESOURCE_SUBCLASS.RESOURCE_DRAWABLE, "ic_stat_notify");
        }

        if (LargeIconID > 0) {
            largeIconBitmap = BitmapFactory.decodeResource(in_context.getResources(), LargeIconID);
        }

        Notification notification = new NotificationCompat.Builder(in_context).setContentTitle(title)
                .setContentText(text)
                .setSmallIcon(ResourceHelper.GetDynamicResourceIDForField(in_context,
                        ResourceHelper.RESOURCE_SUBCLASS.RESOURCE_DRAWABLE, "ic_stat_notify"))
                .setLargeIcon(largeIconBitmap).setContentIntent(sContentIntent).build();

        NotificationManager notificationManager = (NotificationManager) in_context
                .getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(intentId, notification);
        Toast.makeText(in_context, text, Toast.LENGTH_LONG).show();
    }
}

From source file:com.popumovies.DetailActivityFragment.java

@Override
public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
    Log.d(LOG_TAG, "OnCreateView");
    mRootView = inflater.inflate(R.layout.fragment_detail, container, false);

    mTitleView = (TextView) mRootView.findViewById(R.id.textview_movie_title);
    mPosterView = (ImageView) mRootView.findViewById(R.id.imageview_movie_poster);
    mBackgroundView = (ImageView) mRootView.findViewById(R.id.imageview_movie_background);
    mYearView = (TextView) mRootView.findViewById(R.id.textview_movie_year);
    mVoteAverageView = (TextView) mRootView.findViewById(R.id.textview_movie_vote_average);
    mVoteAverageRatingBar = (RatingBar) mRootView.findViewById(R.id.ratingbar_movie_vote_average);
    mDescriptionView = (TextView) mRootView.findViewById(R.id.textview_movie_description);
    mFavoriteButton = (FloatingActionButton) mRootView.findViewById(R.id.button_fav);

    RecyclerView mRecyclerViewVideo = (RecyclerView) mRootView.findViewById(R.id.recyclerview_video);
    LinearLayoutManager mVideoLayoutManager = new LinearLayoutManager(getActivity(), 0, false);
    mRecyclerViewVideo.setLayoutManager(mVideoLayoutManager);
    mRecyclerViewVideo.getLayoutManager().setAutoMeasureEnabled(true);
    mRecyclerViewVideo.setHasFixedSize(false);
    mVideoAdapter = new VideoAdapter(getActivity(), null);
    mRecyclerViewVideo.setAdapter(mVideoAdapter);

    RecyclerView mRecyclerViewReview = (RecyclerView) mRootView.findViewById(R.id.recyclerview_review);
    mRecyclerViewReview.setHasFixedSize(true);
    LinearLayoutManager mReviewLayoutManager = new LinearLayoutManager(getActivity());
    mRecyclerViewReview.setLayoutManager(mReviewLayoutManager);
    mReviewAdapter = new ReviewAdapter(getActivity(), null);
    mRecyclerViewReview.setAdapter(mReviewAdapter);

    // Detect if details are present in the arguments (ViewPager) or if they need to be
    // read from the database again (landscape, two pane)
    Bundle arguments = getArguments();
    if (arguments != null) {
        mMovieId = Long.parseLong(arguments.getString(DETAIL_MOVIEID));
        mUri = MovieEntry.buildSingleMovieUri(mMovieId);

        if (arguments.size() > 1) {
            fillForm(arguments);//from ww w  .  j  av  a  2 s .co m
        } else {
            getLoaderManager().initLoader(FRAGMENT_DETAIL_MOVIE_LOADER, null, this);
        }
    }

    return mRootView;
}

From source file:com.jana.android.ui.fragment.AbstractMapFragment.java

@SuppressWarnings("deprecation")
@Override// ww w.java 2s  .c o m
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    Logger.i("AbstractMapFragment.onCreate()");

    Bundle args = getArguments();

    if (args != null && args.size() > 0) {
        mCurrentLocation = args.getParcelable(EXTRA_CURRENT_LOCATION);
    }

    mImageLoader = ImageLoader.getInstance();

    mConfigs = new ImageLoaderConfiguration.Builder(getActivity().getApplicationContext())
            .memoryCacheSize(5 * 1024 * 1024).discCacheSize(10 * 1024 * 1024).build();
    mImageLoader.init(mConfigs);

    mOptions = new DisplayImageOptions.Builder().showImageForEmptyUri(R.mipmap.ic_launcher)
            .showImageOnFail(R.mipmap.ic_launcher).resetViewBeforeLoading(true).cacheOnDisc(true)
            .cacheInMemory(true).imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2)
            .bitmapConfig(Bitmap.Config.RGB_565).considerExifParams(true)
            .displayer(new FadeInBitmapDisplayer(300)).build();

    mInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

From source file:com.oneteam.framework.android.ui.impl.fragment.AbstractMapFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    Logger.i("AbstractMapFragment.onCreate()");

    Bundle args = getArguments();

    if (args != null && args.size() > 0) {
        mCurrentLocation = args.getParcelable(EXTRA_CURRENT_LOCATION);
    }/*  www .  j  a va2s.  co m*/

    mImageLoader = ImageLoader.getInstance();

    mConfigs = new ImageLoaderConfiguration.Builder(getActivity().getApplicationContext())
            .memoryCacheSize(5 * 1024 * 1024).discCacheSize(10 * 1024 * 1024).build();
    mImageLoader.init(mConfigs);

    mOptions = new DisplayImageOptions.Builder().showImageForEmptyUri(R.drawable.ic_launcher)
            .showImageOnFail(R.drawable.ic_launcher).resetViewBeforeLoading(true).cacheOnDisc(true)
            .cacheInMemory(true).imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2)
            .bitmapConfig(Bitmap.Config.RGB_565).considerExifParams(true)
            .displayer(new FadeInBitmapDisplayer(300)).build();

    mInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

From source file:com.google.android.gcm.demo.logic.DeviceGroupsHelper.java

/**
 * Execute in background the HTTP calls to add and remove members.
 *//*ww  w . j  a  v a 2 s.com*/
public void asyncUpdateGroup(final String senderId, final String apiKey, final String groupName,
        final String groupKey, Bundle newMembers, Bundle removedMembers) {
    final Bundle members2Add = new Bundle(newMembers);
    final Bundle members2Remove = new Bundle(removedMembers);
    new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... voids) {
            if (members2Add.size() > 0) {
                addMembers(senderId, apiKey, groupName, groupKey, members2Add);
            }
            if (members2Remove.size() > 0) {
                removeMembers(senderId, apiKey, groupName, groupKey, members2Remove);
            }
            return null;
        }
    }.execute();
}

From source file:com.kakao.auth.authorization.authcode.KakaoWebViewDialog.java

public KakaoWebViewDialog(final Context context, final String url, Bundle extras, final boolean isUsingTimer,
        final OnWebViewCompleteListener listener) {
    super(context, DEFAULT_THEME);
    this.url = url;
    this.isUsingTimer = isUsingTimer;
    this.onCompleteListener = listener;
    this.headers.put(CommonProtocol.KA_HEADER_KEY, SystemInfo.getKAHeader());
    if (extras != null && extras.size() > 0) {
        for (String key : extras.keySet()) {
            headers.put(key, extras.getString(key));
        }//from w  w  w.  j a v  a 2  s. c  o m
    }
}

From source file:ca.farrelltonsolar.classic.ModbusTask.java

private void loadDayLogs() throws ModbusException {
    String dayLogCacheName = chargeControllerInfo.dayLogCacheName();
    try {//from   w w w . j av a2  s .c o m
        Bundle dayLogs = BundleCache.getInstance(context).getBundle(dayLogCacheName);
        if (dayLogs != null && dayLogs.size() > 0) {
            dayLogEntry = new LogEntry(dayLogs);
            DateTime logDate = dayLogEntry.getLogDate();
            if (logDate.isAfter(DateTime.now().withTimeAtStartOfDay())) { // still good?
                Log.d(getClass().getName(), "DayLog cache still good to go");
                return;
            }
            Log.d(getClass().getName(), "DayLog cache stale, reload data from modbus");
        }
        dayLogEntry.set(Constants.CLASSIC_KWHOUR_DAILY_CATEGORY,
                ReadLogs(365, Constants.CLASSIC_KWHOUR_DAILY_CATEGORY, Constants.MODBUS_FILE_DAILIES_LOG, 1));
        dayLogEntry.set(Constants.CLASSIC_FLOAT_TIME_DAILY_CATEGORY, ReadLogs(365,
                Constants.CLASSIC_FLOAT_TIME_DAILY_CATEGORY, Constants.MODBUS_FILE_DAILIES_LOG, 1));
        dayLogEntry.set(Constants.CLASSIC_HIGH_POWER_DAILY_CATEGORY, ReadLogs(365,
                Constants.CLASSIC_HIGH_POWER_DAILY_CATEGORY, Constants.MODBUS_FILE_DAILIES_LOG, 1));
        dayLogEntry.set(Constants.CLASSIC_HIGH_TEMP_DAILY_CATEGORY, ReadLogs(365,
                Constants.CLASSIC_HIGH_TEMP_DAILY_CATEGORY, Constants.MODBUS_FILE_DAILIES_LOG, 1));
        dayLogEntry.set(Constants.CLASSIC_HIGH_PV_VOLT_DAILY_CATEGORY, ReadLogs(365,
                Constants.CLASSIC_HIGH_PV_VOLT_DAILY_CATEGORY, Constants.MODBUS_FILE_DAILIES_LOG, 1));
        dayLogEntry.set(Constants.CLASSIC_HIGH_BATTERY_VOLT_DAILY_CATEGORY, ReadLogs(365,
                Constants.CLASSIC_HIGH_BATTERY_VOLT_DAILY_CATEGORY, Constants.MODBUS_FILE_DAILIES_LOG, 1));
        Log.d(getClass().getName(), "Completed reading Day logs");
        dayLogEntry.setLogDate(DateTime.now());
        BundleCache.getInstance(context).putBundle(dayLogCacheName, dayLogEntry.getLogs());
        BroadcastToast(context.getString(R.string.toast_day_logs));
    } catch (ModbusIOException ex) {
        if (ex.isEOF()) {
            Log.w(getClass().getName(), String.format("loadDayLogs reached EOF ex: %s", ex));
            dayLogEntry.setLogDate(DateTime.now());
            BundleCache.getInstance(context).putBundle(dayLogCacheName, dayLogEntry.getLogs());
            BroadcastToast(context.getString(R.string.toast_day_logs));
            return;
        }
        BundleCache.getInstance(context).clearCache(dayLogCacheName);
        dayLogEntry = new LogEntry();
        dayLogEntry.setLogDate(DateTime.now().plusMinutes(5)); // try it again later
        Log.w(getClass().getName(), String.format("loadDayLogs failed ex: %s", ex));
    } catch (Exception ex) {
        BundleCache.getInstance(context).clearCache(dayLogCacheName);
        dayLogEntry = new LogEntry();
        dayLogEntry.setLogDate(DateTime.now().plusMinutes(5)); // try it again later
        Log.w(getClass().getName(), String.format("loadDayLogs failed ex: %s", ex));
    }
}

From source file:ca.farrelltonsolar.classic.ModbusTask.java

private void loadMinuteLogs() throws ModbusException {
    String minuteLogCacheName = chargeControllerInfo.minuteLogCacheName();
    try {/*from   ww  w .ja v  a2  s.c  o m*/
        Bundle minuteLog = BundleCache.getInstance(context).getBundle(minuteLogCacheName);
        if (minuteLog != null && minuteLog.size() > 0) {
            minuteLogEntry = new LogEntry(minuteLog);
            DateTime logDate = minuteLogEntry.getLogDate();
            if (logDate.isAfter(DateTime.now().minusHours(1))) { // still good?
                Log.d(getClass().getName(), "MinuteLog cache still good to go");
                return;
            }
            Log.d(getClass().getName(), "MinuteLog cache stale, reload data from modbus");
        }
        int requiredEntries = ReadMinuteLogTimestamps(); // sum of minutes log up to 24 hours
        minuteLogEntry.set(Constants.CLASSIC_POWER_HOURLY_CATEGORY, ReadLogs(requiredEntries,
                Constants.CLASSIC_POWER_HOURLY_CATEGORY, Constants.MODBUS_FILE_MINUTES_LOG, 1));
        minuteLogEntry.set(Constants.CLASSIC_INPUT_VOLTAGE_HOURLY_CATEGORY, ReadLogs(requiredEntries,
                Constants.CLASSIC_INPUT_VOLTAGE_HOURLY_CATEGORY, Constants.MODBUS_FILE_MINUTES_LOG, 10));
        minuteLogEntry.set(Constants.CLASSIC_BATTERY_VOLTAGE_HOURLY_CATEGORY, ReadLogs(requiredEntries,
                Constants.CLASSIC_BATTERY_VOLTAGE_HOURLY_CATEGORY, Constants.MODBUS_FILE_MINUTES_LOG, 10));
        minuteLogEntry.set(Constants.CLASSIC_OUTPUT_CURRENT_HOURLY_CATEGORY, ReadLogs(requiredEntries,
                Constants.CLASSIC_OUTPUT_CURRENT_HOURLY_CATEGORY, Constants.MODBUS_FILE_MINUTES_LOG, 10));
        minuteLogEntry.set(Constants.CLASSIC_ENERGY_HOURLY_CATEGORY, ReadLogs(requiredEntries,
                Constants.CLASSIC_ENERGY_HOURLY_CATEGORY, Constants.MODBUS_FILE_MINUTES_LOG, 10));
        minuteLogEntry.set(Constants.CLASSIC_CHARGE_STATE_HOURLY_CATEGORY, ReadLogs(requiredEntries,
                Constants.CLASSIC_CHARGE_STATE_HOURLY_CATEGORY, Constants.MODBUS_FILE_MINUTES_LOG, 256));
        Log.d(getClass().getName(), "Completed reading minute logs");
        minuteLogEntry.setLogDate(DateTime.now());
        BundleCache.getInstance(context).putBundle(minuteLogCacheName, minuteLogEntry.getLogs());
        BroadcastToast(context.getString(R.string.toast_minute_logs));
    } catch (ModbusIOException ex) {
        if (ex.isEOF()) {
            Log.w(getClass().getName(), String.format("loadMinuteLogs reached EOF ex: %s", ex));
            minuteLogEntry.setLogDate(DateTime.now());
            BundleCache.getInstance(context).putBundle(minuteLogCacheName, minuteLogEntry.getLogs());
            BroadcastToast(context.getString(R.string.toast_minute_logs));
            return;
        }
        BundleCache.getInstance(context).clearCache(minuteLogCacheName);
        minuteLogEntry = new LogEntry();
        minuteLogEntry.setLogDate(DateTime.now().plusMinutes(5)); // try it again later
        Log.w(getClass().getName(), String.format("loadDayLogs failed ex: %s", ex));

    } catch (Exception ex) {
        BundleCache.getInstance(context).clearCache(minuteLogCacheName);
        minuteLogEntry = new LogEntry();
        minuteLogEntry.setLogDate(DateTime.now().plusMinutes(5)); // try it again later
        Log.w(getClass().getName(), String.format("LoadMinuteLogs failed ex: %s", ex));
    }
}