Example usage for android.os Bundle getLong

List of usage examples for android.os Bundle getLong

Introduction

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

Prototype

public long getLong(String key) 

Source Link

Document

Returns the value associated with the given key, or 0L if no mapping of the desired type exists for the given key.

Usage

From source file:ca.ualberta.cmput301w14t08.geochan.fragments.ThreadViewFragment.java

/**
 * Gets the fragment arguments, retrieves correct
 * ThreadComment object from either ThreadList or Cache or FavouritesLog,
 * Starts the refresh from server.// w w w. jav a2s  .c om
 * @param savedInstanceState The previously saved state of the Fragment.
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle bundle = getArguments();
    threadIndex = (int) bundle.getLong("id");
    isFavCom = bundle.getInt("favCom");
    thread = bundle.getParcelable("thread");
    if (locationListener == null) {
        locationListener = new LocationListenerService(getActivity());
    }
    if (prefManager == null) {
        prefManager = PreferencesManager.getInstance();
    }
    // Assign custom adapter to the thread listView.
    adapter = new ThreadViewAdapter(getActivity(), thread, getFragmentManager(), threadIndex);
    if (isFavCom != -1) {
        connectHelper = ConnectivityHelper.getInstance();
        cache = CacheManager.getInstance();
        ArrayList<Comment> comments = cache.deserializeThreadCommentById(thread.getId());
        if (comments != null) {
            thread.getBodyComment().setChildren(comments);
        }
        if (!connectHelper.isConnected()) {
            Toaster.toastShort("No network connection.");
        }
    }
}

From source file:de.dreier.mytargets.features.training.input.InputActivity.java

@Override
public Loader<LoaderResult> onCreateLoader(int id, Bundle args) {
    long trainingId = args.getLong(TRAINING_ID);
    long roundId = args.getLong(ROUND_ID);
    int endIndex = args.getInt(END_INDEX);
    return new UITaskAsyncTaskLoader(this, trainingId, roundId, endIndex);
}

From source file:cz.maresmar.sfm.view.credential.LoginDetailActivity.java

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);

    mPortalUri = savedInstanceState.getParcelable(PORTAL_URI);
    mCredentialUri = savedInstanceState.getParcelable(CREDENTIAL_URI);
    mValidatedCredentialId = savedInstanceState.getLong(VALIDATED_CREDENTIAL_ID);
    mSwipeRefreshLayout.setRefreshing(savedInstanceState.getBoolean(REFRESHING));
    mSaveAll = savedInstanceState.getBoolean(SAVE_ALL);
}

From source file:ca.ualberta.app.activity.CreateQuestionActivity.java

@Override
public void onStart() {
    super.onStart();
    Intent intent = getIntent();//from  w ww.j a  v  a 2s  .c  o  m
    if (intent != null) {
        Bundle extras = intent.getExtras();
        if (extras != null) {
            questionID = extras.getLong(QUESTION_ID);
            String questionTitle = extras.getString(QUESTION_TITLE);
            String questionContent = extras.getString(QUESTION_CONTENT);
            try {
                byte[] imageByteArray = Base64.decode(extras.getByteArray(IMAGE), Base64.NO_WRAP);
                image = BitmapFactory.decodeByteArray(imageByteArray, 0, imageByteArray.length);
                scaleImage(THUMBIMAGESIZE, THUMBIMAGESIZE, true);
                imageView.setVisibility(View.VISIBLE);
                imageView.setImageBitmap(imageThumb);
            } catch (Exception e) {
            }
            titleText.setText(questionTitle);
            contentText.setText(questionContent);
            edit = true;
        }
    }
}

From source file:com.piusvelte.cloudset.android.CloudSetMain.java

@Override
public Loader<List<SimpleDevice>> onCreateLoader(int which, Bundle args) {
    if (which > 0) {
        if (args != null && args.containsKey(EXTRA_DEREGISTER_ID)) {
            // create a loader for deregistering an additional device
            return new DevicesLoader(this, account, args.getLong(EXTRA_DEREGISTER_ID), devices);
        } else {//www .  jav a2s  .c om
            return new DevicesLoader(this, account);
        }
    } else if (deviceId != null && !INVALID_DEVICE_ID.equals(deviceId)) {
        // create loader 0 for loading devices
        return new DevicesLoader(this, account, deviceId);
    } else {
        return null;
    }
}

From source file:com.github.nutomic.pegasus.LocationService.java

/**
 * Receive start Intent, start learning an area or check if the 
 * sound profile for the current area has changed.
 *//*from   w ww .  j a  v  a2  s  . c  om*/
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent != null) {
        Bundle extras = intent.getExtras();
        if (extras != null) {
            Set<String> keys = extras.keySet();
            if (keys.contains(MESSAGE_LEARN_AREA)) {
                // Set the area to learn now and the learn duration.
                mLearnUntil = SystemClock.elapsedRealtime() + extras.getLong(MESSAGE_LEARN_INTERVAL);
                mLearnArea = extras.getLong(MESSAGE_LEARN_AREA);
            }
            if (keys.contains(MESSAGE_UPDATE)) {
                // Profile/area mappings have changed, reapply profile.
                mCellListener.applyProfile(mCurrentCell);
            }
        }
    }
    return START_STICKY;
}

From source file:com.nextgis.mobile.fragment.AttributesFragment.java

@Override
public void onViewStateRestored(@Nullable Bundle savedInstanceState) {
    super.onViewStateRestored(savedInstanceState);

    if (savedInstanceState != null) {
        mItemId = savedInstanceState.getLong(KEY_ITEM_ID);
        mItemPosition = savedInstanceState.getInt(KEY_ITEM_POSITION);
    }//from   w  ww. jav  a  2s  . co m
}

From source file:at.jclehner.rxdroid.ui.ScheduleGridFragment.java

private void onRestoreInstanceState(Bundle state) {
    if (state == null)
        return;/*from w ww.j  ava 2 s.  c  om*/

    for (int i = 0; i != mHolders.length; ++i) {
        Fraction[] doses = (Fraction[]) state.getParcelableArray("doses_" + i);
        if (doses != null) {
            for (int j = 0; j != doses.length; ++j)
                mHolders[i].doseViews[j].setDose(doses[j]);
        }
    }

    mDayStatus.set(state.getLong("day_status"));
}

From source file:com.fenlisproject.elf.core.framework.ElfBinder.java

public static void bindFragmentArgument(Fragment receiver) {
    Field[] fields = receiver.getClass().getDeclaredFields();
    for (Field field : fields) {
        field.setAccessible(true);//w  w  w .  j  a v  a2 s  .  co m
        FragmentArgument fragmentArgument = field.getAnnotation(FragmentArgument.class);
        if (fragmentArgument != null) {
            try {
                Bundle bundle = receiver.getArguments();
                if (bundle != null) {
                    Class<?> type = field.getType();
                    if (type == Boolean.class || type == boolean.class) {
                        field.set(receiver, bundle.getBoolean(fragmentArgument.value()));
                    } else if (type == Byte.class || type == byte.class) {
                        field.set(receiver, bundle.getByte(fragmentArgument.value()));
                    } else if (type == Character.class || type == char.class) {
                        field.set(receiver, bundle.getChar(fragmentArgument.value()));
                    } else if (type == Double.class || type == double.class) {
                        field.set(receiver, bundle.getDouble(fragmentArgument.value()));
                    } else if (type == Float.class || type == float.class) {
                        field.set(receiver, bundle.getFloat(fragmentArgument.value()));
                    } else if (type == Integer.class || type == int.class) {
                        field.set(receiver, bundle.getInt(fragmentArgument.value()));
                    } else if (type == Long.class || type == long.class) {
                        field.set(receiver, bundle.getLong(fragmentArgument.value()));
                    } else if (type == Short.class || type == short.class) {
                        field.set(receiver, bundle.getShort(fragmentArgument.value()));
                    } else if (type == String.class) {
                        field.set(receiver, bundle.getString(fragmentArgument.value()));
                    } else if (type == Boolean[].class || type == boolean[].class) {
                        field.set(receiver, bundle.getBooleanArray(fragmentArgument.value()));
                    } else if (type == Byte[].class || type == byte[].class) {
                        field.set(receiver, bundle.getByteArray(fragmentArgument.value()));
                    } else if (type == Character[].class || type == char[].class) {
                        field.set(receiver, bundle.getCharArray(fragmentArgument.value()));
                    } else if (type == Double[].class || type == double[].class) {
                        field.set(receiver, bundle.getDoubleArray(fragmentArgument.value()));
                    } else if (type == Float[].class || type == float[].class) {
                        field.set(receiver, bundle.getFloatArray(fragmentArgument.value()));
                    } else if (type == Integer[].class || type == int[].class) {
                        field.set(receiver, bundle.getIntArray(fragmentArgument.value()));
                    } else if (type == Long[].class || type == long[].class) {
                        field.set(receiver, bundle.getLongArray(fragmentArgument.value()));
                    } else if (type == Short[].class || type == short[].class) {
                        field.set(receiver, bundle.getShortArray(fragmentArgument.value()));
                    } else if (type == String[].class) {
                        field.set(receiver, bundle.getStringArray(fragmentArgument.value()));
                    } else if (Serializable.class.isAssignableFrom(type)) {
                        field.set(receiver, bundle.getSerializable(fragmentArgument.value()));
                    } else if (type == Bundle.class) {
                        field.set(receiver, bundle.getBundle(fragmentArgument.value()));
                    }
                }
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:com.nextgis.firereporter.ScanexNotificationsActivity.java

public void onReceiveResult(int resultCode, Bundle resultData) {
    if ((resultCode & GetFiresService.SERVICE_SCANEXSTART) != 0) {
        refresh();/*from  w w w  . j ava2  s . c o  m*/
    }

    if ((resultCode & GetFiresService.SERVICE_SCANEXDATA) != 0) {
        ScanexNotificationsFragment NotesFragment = (ScanexNotificationsFragment) getSupportFragmentManager()
                .findFragmentByTag("DETAILES");
        if (NotesFragment != null) {
            int nType = resultData.getInt(GetFiresService.TYPE);
            long nSubID = resultData.getLong(GetFiresService.SUBSCRIPTION_ID);
            if (nType == GetFiresService.SCANEX_NOTIFICATION && nSubID == mnSubscriptionId) {
                //long nNoteID = resultData.getLong("note_id");
                ScanexNotificationItem item = (ScanexNotificationItem) resultData
                        .getParcelable(GetFiresService.ITEM);
                mNotesFragment.add(item);
            }
        }
    }

    if ((resultCode & GetFiresService.SERVICE_STOP) != 0) {
        completeRefresh();
    }

    if ((resultCode & GetFiresService.SERVICE_ERROR) != 0) {
        Toast.makeText(this, resultData.getString(GetFiresService.ERR_MSG), Toast.LENGTH_LONG).show();
    }
}