List of usage examples for android.os Bundle putLong
public void putLong(@Nullable String key, long value)
From source file:ca.ualberta.cmput301w14t08.geochan.adapters.ThreadViewAdapter.java
/** * Listener for the buttons of the thread op (TYPE_OP) listView item. Comments have * listeners in ThreadViewFragment because they are only displayed after * onItemClick, threadComment buttons have a listener in the adapter for * ease of access to the permanently displayed buttons. * //from ww w . ja va2s .c om * @param convertView view that contains the ThreadComments OP. * @param thread threadComment object that contains the ThreadComments OP. * */ private void listenForThreadButtons(View convertView, final ThreadComment thread) { // Here handle button presses final ImageButton replyButton = (ImageButton) convertView.findViewById(R.id.comment_reply_button); final ImageButton starButton = (ImageButton) convertView.findViewById(R.id.comment_star_button); if (FavouritesLog.getInstance(context).hasThreadComment(thread.getId())) { starButton.setImageResource(R.drawable.ic_rating_marked); } final ImageButton mapButton = (ImageButton) convertView.findViewById(R.id.thread_map_button); final ImageButton editButton = (ImageButton) convertView.findViewById(R.id.thread_edit_button); if (HashHelper.getHash(thread.getBodyComment().getUser()).equals(thread.getBodyComment().getHash())) { editButton.setVisibility(View.VISIBLE); } if (thread.getBodyComment().hasImage()) { listenForThumbnail(convertView, thread.getBodyComment()); } // Listen for the star(favourites) button. if (starButton != null) { starButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Perform action on click depending on if the thread has // been favourited. if (!FavouritesLog.getInstance(context).hasThreadComment(thread.getId())) { Toast.makeText(context, "Thread saved to Favourites.", Toast.LENGTH_SHORT).show(); starButton.setImageResource(R.drawable.ic_rating_marked); FavouritesLog log = FavouritesLog.getInstance(context); log.addThreadComment(thread); } else { Toast.makeText(context, "Thread removed from Favourites.", Toast.LENGTH_SHORT).show(); starButton.setImageResource(R.drawable.ic_rating_important); FavouritesLog log = FavouritesLog.getInstance(context); log.removeThreadComment(thread); } } }); } // Listen for the edit button. if (editButton != null) { editButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Fragment fragment = new EditFragment(); Bundle bundle = new Bundle(); bundle.putInt("threadIndex", id); bundle.putString("commentId", thread.getBodyComment().getId()); fragment.setArguments(bundle); manager.beginTransaction().replace(R.id.fragment_container, fragment, "editFrag") .addToBackStack(null).commit(); manager.executePendingTransactions(); } }); } // Listen for the map button. if (mapButton != null) { mapButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Perform action on click to launch mapFragment Bundle bundle = new Bundle(); bundle.putParcelable("thread_comment", thread.getBodyComment()); Fragment mapFrag = new MapViewFragment(); mapFrag.setArguments(bundle); Fragment fav = manager.findFragmentByTag("favThrFragment"); if (fav != null) { manager.beginTransaction().replace(R.id.container, mapFrag, "mapFrag").addToBackStack(null) .commit(); } else { manager.beginTransaction().replace(R.id.fragment_container, mapFrag, "mapFrag") .addToBackStack(null).commit(); } manager.executePendingTransactions(); } }); } // Listen for the reply button. if (replyButton != null) { replyButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Perform action on click to launch postCommentFragment Fragment fragment = new PostFragment(); Bundle bundle = new Bundle(); bundle.putParcelable("cmt", thread.getBodyComment()); bundle.putLong("id", id); fragment.setArguments(bundle); Fragment fav = manager.findFragmentByTag("favThrFragment"); if (fav != null) { manager.beginTransaction().replace(R.id.container, fragment, "postFrag") .addToBackStack(null).commit(); manager.executePendingTransactions(); } else { manager.beginTransaction().replace(R.id.fragment_container, fragment, "postFrag") .addToBackStack(null).commit(); manager.executePendingTransactions(); } } }); } }
From source file:com.facebook.LegacyTokenHelper.java
private void deserializeKey(String key, Bundle bundle) throws JSONException { String jsonString = cache.getString(key, "{}"); JSONObject json = new JSONObject(jsonString); String valueType = json.getString(JSON_VALUE_TYPE); if (valueType.equals(TYPE_BOOLEAN)) { bundle.putBoolean(key, json.getBoolean(JSON_VALUE)); } else if (valueType.equals(TYPE_BOOLEAN_ARRAY)) { JSONArray jsonArray = json.getJSONArray(JSON_VALUE); boolean[] array = new boolean[jsonArray.length()]; for (int i = 0; i < array.length; i++) { array[i] = jsonArray.getBoolean(i); }/*from w w w . j av a 2 s . co m*/ bundle.putBooleanArray(key, array); } else if (valueType.equals(TYPE_BYTE)) { bundle.putByte(key, (byte) json.getInt(JSON_VALUE)); } else if (valueType.equals(TYPE_BYTE_ARRAY)) { JSONArray jsonArray = json.getJSONArray(JSON_VALUE); byte[] array = new byte[jsonArray.length()]; for (int i = 0; i < array.length; i++) { array[i] = (byte) jsonArray.getInt(i); } bundle.putByteArray(key, array); } else if (valueType.equals(TYPE_SHORT)) { bundle.putShort(key, (short) json.getInt(JSON_VALUE)); } else if (valueType.equals(TYPE_SHORT_ARRAY)) { JSONArray jsonArray = json.getJSONArray(JSON_VALUE); short[] array = new short[jsonArray.length()]; for (int i = 0; i < array.length; i++) { array[i] = (short) jsonArray.getInt(i); } bundle.putShortArray(key, array); } else if (valueType.equals(TYPE_INTEGER)) { bundle.putInt(key, json.getInt(JSON_VALUE)); } else if (valueType.equals(TYPE_INTEGER_ARRAY)) { JSONArray jsonArray = json.getJSONArray(JSON_VALUE); int[] array = new int[jsonArray.length()]; for (int i = 0; i < array.length; i++) { array[i] = jsonArray.getInt(i); } bundle.putIntArray(key, array); } else if (valueType.equals(TYPE_LONG)) { bundle.putLong(key, json.getLong(JSON_VALUE)); } else if (valueType.equals(TYPE_LONG_ARRAY)) { JSONArray jsonArray = json.getJSONArray(JSON_VALUE); long[] array = new long[jsonArray.length()]; for (int i = 0; i < array.length; i++) { array[i] = jsonArray.getLong(i); } bundle.putLongArray(key, array); } else if (valueType.equals(TYPE_FLOAT)) { bundle.putFloat(key, (float) json.getDouble(JSON_VALUE)); } else if (valueType.equals(TYPE_FLOAT_ARRAY)) { JSONArray jsonArray = json.getJSONArray(JSON_VALUE); float[] array = new float[jsonArray.length()]; for (int i = 0; i < array.length; i++) { array[i] = (float) jsonArray.getDouble(i); } bundle.putFloatArray(key, array); } else if (valueType.equals(TYPE_DOUBLE)) { bundle.putDouble(key, json.getDouble(JSON_VALUE)); } else if (valueType.equals(TYPE_DOUBLE_ARRAY)) { JSONArray jsonArray = json.getJSONArray(JSON_VALUE); double[] array = new double[jsonArray.length()]; for (int i = 0; i < array.length; i++) { array[i] = jsonArray.getDouble(i); } bundle.putDoubleArray(key, array); } else if (valueType.equals(TYPE_CHAR)) { String charString = json.getString(JSON_VALUE); if (charString != null && charString.length() == 1) { bundle.putChar(key, charString.charAt(0)); } } else if (valueType.equals(TYPE_CHAR_ARRAY)) { JSONArray jsonArray = json.getJSONArray(JSON_VALUE); char[] array = new char[jsonArray.length()]; for (int i = 0; i < array.length; i++) { String charString = jsonArray.getString(i); if (charString != null && charString.length() == 1) { array[i] = charString.charAt(0); } } bundle.putCharArray(key, array); } else if (valueType.equals(TYPE_STRING)) { bundle.putString(key, json.getString(JSON_VALUE)); } else if (valueType.equals(TYPE_STRING_LIST)) { JSONArray jsonArray = json.getJSONArray(JSON_VALUE); int numStrings = jsonArray.length(); ArrayList<String> stringList = new ArrayList<String>(numStrings); for (int i = 0; i < numStrings; i++) { Object jsonStringValue = jsonArray.get(i); stringList.add(i, jsonStringValue == JSONObject.NULL ? null : (String) jsonStringValue); } bundle.putStringArrayList(key, stringList); } else if (valueType.equals(TYPE_ENUM)) { try { String enumType = json.getString(JSON_VALUE_ENUM_TYPE); @SuppressWarnings({ "unchecked", "rawtypes" }) Class<? extends Enum> enumClass = (Class<? extends Enum>) Class.forName(enumType); @SuppressWarnings("unchecked") Enum<?> enumValue = Enum.valueOf(enumClass, json.getString(JSON_VALUE)); bundle.putSerializable(key, enumValue); } catch (ClassNotFoundException e) { } catch (IllegalArgumentException e) { } } }
From source file:com.android.contacts.quickcontact.QuickContactActivity.java
@Override public void onSaveInstanceState(Bundle savedInstanceState) { super.onSaveInstanceState(savedInstanceState); if (mColorFilter != null) { savedInstanceState.putInt(KEY_THEME_COLOR, mColorFilterColor); }/*from ww w . j a v a2s .c o m*/ savedInstanceState.putBoolean(KEY_IS_SUGGESTION_LIST_COLLAPSED, mIsSuggestionListCollapsed); savedInstanceState.putLong(KEY_PREVIOUS_CONTACT_ID, mPreviousContactId); savedInstanceState.putBoolean(KEY_SUGGESTIONS_AUTO_SELECTED, mSuggestionsShouldAutoSelected); savedInstanceState.putSerializable(KEY_SELECTED_SUGGESTION_CONTACTS, mSelectedAggregationIds); }
From source file:com.entradahealth.entrada.android.app.personal.activities.job_list.JobListActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); activity = this; application = (EntradaApplication) EntradaApplication.getAppContext(); sp = getSharedPreferences("Entrada", Context.MODE_WORLD_READABLE); if (sp.getBoolean("SECURE_MSG", true)) getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE); else/* w ww. ja va 2 s .c o m*/ getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE); final JobListActivity thisActivity = this; //Custom view as action bar LayoutInflater mInflater = LayoutInflater.from(this); View mCustomView = mInflater.inflate(R.layout.acbar_job_list, null); tvAcTitle = (TextView) mCustomView.findViewById(R.id.tvAcTitle); ivInbox = (ImageView) mCustomView.findViewById(R.id.ivInbox); ivAddJob = (ImageView) mCustomView.findViewById(R.id.ivAddJob); ivSync = (ImageView) mCustomView.findViewById(R.id.ivSync); ivSchedule = (ImageView) mCustomView.findViewById(R.id.ivSchedule); tvAcTitle.setText(BundleKeys.title); //Sample icon badger on Action bar item badge = new BadgeView(this, ivInbox); if (BundleKeys.fromSecureMessaging || !application.isJobListEnabled()) { startActivity(new Intent(JobListActivity.this, SecureMessaging.class)); finish(); } ivInbox.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub startActivity(new Intent(JobListActivity.this, SecureMessaging.class)); finish(); } }); ivAddJob.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent addJobIntent = new Intent(JobListActivity.this, AddJobActivity.class); addJobIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(addJobIntent); finish(); } }); ivSync.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub ns = new NetworkState(getApplicationContext()); isConnected = ns.isConnectingToInternet(); if (isConnected) { running = false; ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if ("com.entradahealth.entrada.android.app.personal.sync.SyncService" .equals(service.service.getClassName()) || "com.entradahealth.entrada.android.app.personal.sync.DictationUploadService" .equals(service.service.getClassName())) { running = true; } } if (!running) { etSearch.setText(null); if (!isFinishing()) { //retryUploads(); boolean canSync = true; try { List<Job> jobs = AndroidState.getInstance().getUserState() .getProvider(currentAccount).getJobs(); for (Job j : jobs) { if (j.isPending()) { canSync = false; UserState state = AndroidState.getInstance().getUserState(); Log.e("", "onOptionsItemSelected-syncMenuItem--" + j.id); DictationUploadService.startUpload(JobListActivity.this, state, currentAccount, j); } } } catch (Exception ex) { ACRA.getErrorReporter().handleSilentException(ex); canSync = false; } if (!canSync) { Toast.makeText(JobListActivity.this, "Please wait for all uploads to complete before syncing.", Toast.LENGTH_SHORT).show(); } else { rlSyncError.setVisibility(View.GONE); rlUpdated.setVisibility(View.INVISIBLE); tvUpdating.setVisibility(View.VISIBLE); Intent i = new Intent(JobListActivity.this, SyncService.class); startService(i); } isSyncing = true; BundleKeys.SYNC_FOR_ACC = currentAccount.getDisplayName(); //BundleKeys.SYNC_FOR_CLINIC = currentAccount.getClinicCode(); /*task1 = buildMinderTask(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { task1.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else { task1.execute(); }*/ } } else { if (!isResumed) Toast.makeText(JobListActivity.this, "Please wait for all uploads to complete before syncing.", Toast.LENGTH_SHORT) .show(); } isResumed = false; } else { rlSyncError.setVisibility(View.VISIBLE); rlUpdated.setVisibility(View.GONE); tvUpdating.setVisibility(View.GONE); } } }); ivSchedule.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(JobListActivity.this, ScheduleActivity.class)); finish(); } }); getActionBar().setCustomView(mCustomView); getActionBar().setDisplayShowCustomEnabled(true); //ActionBar ab = getActionBar(); //ab.setTitle(BundleKeys.title); this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); registerReceiver(broadcastReceiver, new IntentFilter("CONNECTIVITY_CHANGED")); jobIds = new ArrayList<Long>(); BundleKeys.fromImageDisplay = false; BundleKeys.fromCaputreImages = false; BundleKeys.fromSecureMessaging = false; /*Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread paramThread, Throwable paramThrowable) { Log.e("Job-List-Activity","Uncaught-Exception"); System.exit(2); } });*/ setBehindContentView(R.layout.job_list_sliding_menu); tvListTitle = (TextView) findViewById(R.id.tvListTitle); tvListTitle.setText("Jobs"); lvSliding = (ListView) findViewById(R.id.lvSlidingMenu); lvSliding.setBackgroundColor(Color.parseColor("#262b38")); // Get screen width and set sliding width to 3/4 Display display = getWindowManager().getDefaultDisplay(); int width = display.getWidth(); int req_width = width * 3 / 4; slidingMenu = getSlidingMenu(); slidingMenu.setFadeEnabled(true); slidingMenu.setFadeDegree(0.35f); slidingMenu.setBehindWidth(req_width); slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN); setContentView(R.layout.job_list); ivDrawer = (ImageView) findViewById(R.id.ivDrawer); ivDrawer.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub slidingMenu.toggle(); // JobCountTask(); } }); rlUpdated = (RelativeLayout) findViewById(R.id.rlDateTime); rlSyncError = (RelativeLayout) findViewById(R.id.rlSyncError); rlSyncError.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub AlertDialog.Builder builder = new AlertDialog.Builder(JobListActivity.this); builder.setTitle(R.string.title_sync_error); builder.setMessage(R.string.msg_sync_error); builder.setPositiveButton("OK", null); dgSyncError = builder.create(); dgSyncError.show(); } }); tvDate = (TextView) findViewById(R.id.tvDate); tvTime = (TextView) findViewById(R.id.tvTime); tvUpdating = (TextView) findViewById(R.id.lblUpdating); tvSyncFailed = (TextView) findViewById(R.id.lblSyncError); handler = new Handler(); handler.postDelayed(runnable, BundleKeys.mins_to_sync * 60 * 1000); handler.postDelayed(runnable_logs, 5 * 60 * 1000); jobListView = (ListView) findViewById(R.id.jobListView); jobListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); jobListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { // TODO: evaluate whether to save search text in // UserState to repopulate on back press. itemClicked = true; if (searchTask != null) { searchTask.cancel(true); } Log.d("", "-- Job ItemClick --"); List<Long> jobList = thisActivity.getJobIdList(); Preconditions.checkNotNull(jobList, "null List<Job> when adapter view clicked."); Job job = AndroidState.getInstance().getUserState().getProvider(currentAccount) .getJob(jobList.get(position)); if (job != null) { Preconditions.checkNotNull(job, "null item in List<Job> when adapter view clicked."); if (job.isFlagSet(Job.Flags.UPLOAD_COMPLETED) || job.isFlagSet(Job.Flags.UPLOAD_IN_PROGRESS) || (job.isFlagSet(Job.Flags.UPLOAD_PENDING) && BundleKeys.which == 6)) { Toast.makeText(thisActivity, "Cannot open a completed dictation.", Toast.LENGTH_SHORT) .show(); return; } else if (job.isFlagSet(Job.Flags.LOCALLY_DELETED)) { return; } Intent intent = new Intent(thisActivity, JobDisplayActivity.class); Bundle b = new Bundle(); if (!job.isFlagSet(Flags.HOLD)) job = job.setFlag(Flags.IS_FIRST); else job = job.clearFlag(Flags.IS_FIRST); try { AndroidState.getInstance().getUserState().getProvider(currentAccount).updateJob(job); } catch (DomainObjectWriteException e) { // TODO Auto-generated catch block e.printStackTrace(); } b.putBoolean("isFirst", true); b.putBoolean("isFromList", true); b.putBoolean("isNew", false); b.putLong(BundleKeys.SELECTED_JOB, job.id); b.putString(BundleKeys.SELECTED_JOB_ACCOUNT, currentAccount.getName()); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtras(b); thisActivity.startActivity(intent); thisActivity.finish(); } } }); jobListView.setMultiChoiceModeListener(new JobListMultiChoiceModeListener(this)); slidingMenu.setOnOpenListener(new OnOpenListener() { @Override public void onOpen() { // TODO Auto-generated method stub openSlide(); } }); lvSliding.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long arg3) { // TODO Auto-generated method stub switch (pos) { case 1: //getActionBar().setTitle("Today's Jobs"); tvAcTitle.setText("Today's Jobs"); BundleKeys.title = "Today's Jobs"; BundleKeys.which = 1; //menuItem = j_Menu.findItem(R.id.addJobMenuItem); //menuItem.setVisible(true); ivAddJob.setVisibility(View.VISIBLE); jobListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); etSearch.setText(""); break; case 2: //getActionBar().setTitle("Tomorrow's Jobs"); tvAcTitle.setText("Tomorrow's Jobs"); BundleKeys.which = 2; BundleKeys.title = "Tomorrow's Jobs"; //menuItem = j_Menu.findItem(R.id.addJobMenuItem); //menuItem.setVisible(true); ivAddJob.setVisibility(View.VISIBLE); jobListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); etSearch.setText(""); break; case 3: //getActionBar().setTitle("Stat Jobs"); tvAcTitle.setText("Stat Jobs"); BundleKeys.which = 3; BundleKeys.title = "Stat Jobs"; //menuItem = j_Menu.findItem(R.id.addJobMenuItem); //menuItem.setVisible(true); ivAddJob.setVisibility(View.VISIBLE); jobListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); etSearch.setText(""); break; case 4: //getActionBar().setTitle("All Jobs"); tvAcTitle.setText("All Jobs"); BundleKeys.which = 4; BundleKeys.title = "All Jobs"; //menuItem = j_Menu.findItem(R.id.addJobMenuItem); //menuItem.setVisible(true); ivAddJob.setVisibility(View.VISIBLE); jobListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); etSearch.setText(""); break; case 6: //getActionBar().setTitle("Hold Jobs"); tvAcTitle.setText("Hold Jobs"); BundleKeys.which = 5; BundleKeys.title = "Hold Jobs"; //menuItem = j_Menu.findItem(R.id.addJobMenuItem); //menuItem.setVisible(true); ivAddJob.setVisibility(View.VISIBLE); jobListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); etSearch.setText(""); break; case 7: //getActionBar().setTitle("Deleted Jobs"); tvAcTitle.setText("Deleted Jobs"); BundleKeys.which = 7; BundleKeys.title = "Deleted Jobs"; // Hide "Add Job" menu item //menuItem = j_Menu.findItem(R.id.addJobMenuItem); //menuItem.setVisible(false); ivAddJob.setVisibility(View.GONE); jobListView.setChoiceMode(ListView.CHOICE_MODE_NONE); etSearch.setText(""); break; case 8: //getActionBar().setTitle("Completed Jobs"); tvAcTitle.setText("Completed Jobs"); BundleKeys.which = 6; BundleKeys.title = "Completed Jobs"; // Hide "Add Job" menu item //menuItem = j_Menu.findItem(R.id.addJobMenuItem); //menuItem.setVisible(false); ivAddJob.setVisibility(View.GONE); jobListView.setChoiceMode(ListView.CHOICE_MODE_NONE); etSearch.setText(""); break; case 10: isSetting = true; //getActionBar().setTitle("Settings"); tvAcTitle.setText("Settings Jobs"); startActivity(new Intent(JobListActivity.this, EntradaSettings.class) .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)); finish(); break; case 11: // Check if there are any held jobs or any uploads in // progress boolean isHeld = true, isPending = true; try { List<Job> jobs = AndroidState.getInstance().getUserState().getProvider(currentAccount) .getJobs(); for (Job j : jobs) { if (j.isPending()) isPending = false; if (j.isFlagSet(Job.Flags.HOLD)) isHeld = false; } } catch (Exception ex) { ACRA.getErrorReporter().handleSilentException(ex); isPending = false; isHeld = false; } if (SyncService.isRunning()) { AlertDialog.Builder builder = new AlertDialog.Builder(JobListActivity.this); builder.setTitle(R.string.del_acc_err_title); builder.setMessage(R.string.manage_q_upload_error); builder.setPositiveButton("OK", null); builder.setCancelable(true); dgManageQ = builder.create(); dgManageQ.show(); } else if (isPending && isHeld) { Intent qIntent = new Intent(JobListActivity.this, ManageQueuesActivity.class); qIntent.putExtra("from_settings", false); qIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(qIntent); finish(); } else if (!isHeld) { AlertDialog.Builder builder = new AlertDialog.Builder(JobListActivity.this); builder.setTitle(R.string.del_acc_err_title); builder.setMessage(R.string.manage_q_hold_error); builder.setPositiveButton("OK", null); builder.setCancelable(true); dgManageQ = builder.create(); dgManageQ.show(); } else if (!isPending) { AlertDialog.Builder builder = new AlertDialog.Builder(JobListActivity.this); builder.setTitle(R.string.del_acc_err_title); builder.setMessage(R.string.manage_q_upload_error); builder.setPositiveButton("OK", null); builder.setCancelable(true); dgManageQ = builder.create(); dgManageQ.show(); } break; default: //getActionBar().setTitle("Today's Jobs"); tvAcTitle.setText("Today's Jobs"); BundleKeys.title = "Today's Jobs"; BundleKeys.which = 1; //menuItem = j_Menu.findItem(R.id.addJobMenuItem); //menuItem.setVisible(true); ivAddJob.setVisibility(View.VISIBLE); jobListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); } Log.e(LOG_NAME, Integer.toString(BundleKeys.which) + " - " + BundleKeys.title); isSync = false; slidingMenu.toggle(true); /* * Log.e("isSetting", Boolean.toString(isSetting)); * if(BundleKeys.which != 8 && BundleKeys.which != 9 && * !isSetting) etSearch.setText(""); */ } }); rlSearch = (RelativeLayout) findViewById(R.id.rlSearch); etSearch = (EditText) findViewById(R.id.etSearch); etSearch.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { //launchSearchTask(); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub try { Thread.sleep(200); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } launchSearchTask(); } }); GetResourcesTask task = new GetResourcesTask(); task.execute(); }
From source file:com.vegnab.vegnab.MainVNActivity.java
public void goToEditPlaceholderScreen(Bundle enteredArgs) { // swap EditPlaceholderFragment in place of existing fragment if (LDebug.ON) Log.d(LOG_TAG, "About to go to EditPlaceholder"); Bundle args = new Bundle(); // fn structure, but not functional yet /*available args final static String ARG_PLACEHOLDER_ID = "placeholderId"; final static String ARG_PLACEHOLDER_CODE = "placeholderCode"; final static String ARG_PLACEHOLDER_DESCRIPTION = "placeholderDescription"; final static String ARG_PLACEHOLDER_HABITAT = "placeholderHabitat"; final static String ARG_PLACEHOLDER_LABELNUMBER = "placeholderLabelnumber"; final static String ARG_PH_PROJID = "phProjId"; final static String ARG_PH_VISITID = "phVisitId"; final static String ARG_PH_VISIT_NAME = "phVisitName"; final static String ARG_PH_LOCID = "phLocId"; final static String ARG_PH_LOC_TEXT = "phLocText"; final static String ARG_PH_NAMERID = "phNamerId"; final static String ARG_PH_NAMER_NAME = "phNamerName"; final static String ARG_PH_SCRIBE = "phScribe"; final static String ARG_PLACEHOLDER_TIME = "phTimeStamp"; */ args.putLong(EditPlaceholderFragment.ARG_PLACEHOLDER_ID, 0); // fix this args.putString(EditPlaceholderFragment.ARG_PLACEHOLDER_CODE, ""); // fix this EditPlaceholderFragment editPhFrag = EditPlaceholderFragment.newInstance(args); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); // put the present fragment on the backstack so the user can navigate back to it // the tag is for the fragment now being added, not the one replaced transaction.replace(R.id.fragment_container, editPhFrag, Tags.EDIT_PLACEHOLDER); transaction.addToBackStack(null);/*from ww w .j a v a 2s . c om*/ transaction.commit(); }
From source file:com.vegnab.vegnab.MainVNActivity.java
public void goToPhPixGridScreen(Bundle enteredArgs) { // swap PhPixGridFragment in place of existing fragment if (LDebug.ON) Log.d(LOG_TAG, "About to go to Placeholder Pictures"); Bundle args = new Bundle(); // fn structure, but not functional yet /*available args final static String ARG_PLACEHOLDER_ID = "placeholderId"; final static String ARG_PLACEHOLDER_CODE = "placeholderCode"; final static String ARG_PLACEHOLDER_DESCRIPTION = "placeholderDescription"; final static String ARG_PLACEHOLDER_HABITAT = "placeholderHabitat"; final static String ARG_PLACEHOLDER_LABELNUMBER = "placeholderLabelnumber"; final static String ARG_PH_PROJID = "phProjId"; final static String ARG_PH_VISITID = "phVisitId"; final static String ARG_PH_VISIT_NAME = "phVisitName"; final static String ARG_PH_LOCID = "phLocId"; final static String ARG_PH_LOC_TEXT = "phLocText"; final static String ARG_PH_NAMERID = "phNamerId"; final static String ARG_PH_NAMER_NAME = "phNamerName"; final static String ARG_PH_SCRIBE = "phScribe"; final static String ARG_PLACEHOLDER_TIME = "phTimeStamp"; */ args.putLong(EditPlaceholderFragment.ARG_PLACEHOLDER_ID, 0); // fix this args.putString(EditPlaceholderFragment.ARG_PLACEHOLDER_CODE, ""); // fix this PhPixGridFragment phPixGridFrag = newInstance(args); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); // put the present fragment on the backstack so the user can navigate back to it // the tag is for the fragment now being added, not the one replaced transaction.replace(R.id.fragment_container, phPixGridFrag, Tags.PLACEHOLDER_PIX_GRID); transaction.addToBackStack(null);//from w w w .j a v a2s . c o m transaction.commit(); }
From source file:com.dwdesign.tweetings.util.Utils.java
public static Bundle parseArguments(final String string) { final Bundle bundle = new Bundle(); if (string != null) { try {//from w ww.j ava 2 s . c om final JSONObject json = new JSONObject(string); final Iterator<?> it = json.keys(); while (it.hasNext()) { final Object key_obj = it.next(); if (key_obj == null) { continue; } final String key = key_obj.toString(); final Object value = json.get(key); if (value instanceof Boolean) { bundle.putBoolean(key, json.getBoolean(key)); } else if (value instanceof Integer) { // Simple workaround for account_id if (INTENT_KEY_ACCOUNT_ID.equals(key)) { bundle.putLong(key, json.getLong(key)); } else { bundle.putInt(key, json.getInt(key)); } } else if (value instanceof Long) { bundle.putLong(key, json.getLong(key)); } else if (value instanceof String) { bundle.putString(key, json.getString(key)); } else { Log.w(LOGTAG, "Unknown type " + value.getClass().getSimpleName() + " in arguments key " + key); } } } catch (final JSONException e) { e.printStackTrace(); } catch (final ClassCastException e) { e.printStackTrace(); } } return bundle; }
From source file:com.nttec.everychan.ui.presentation.BoardFragment.java
public static Fragment newInstance(long tabId) { TabsState tabsState = MainApplication.getInstance().tabsState; if (tabsState == null) throw new IllegalStateException("tabsState was not initialized in the MainApplication singleton"); TabModel model = tabsState.findTabById(tabId); if (model == null) throw new IllegalArgumentException("cannot find tab with id " + tabId); if (model.pageModel.type == UrlPageModel.TYPE_INDEXPAGE) { Logger.d(TAG, "instantiating BoardsListFragment"); return BoardsListFragment.newInstance(tabId); }/*w w w . j av a 2 s . c o m*/ if (model.pageModel.type == UrlPageModel.TYPE_OTHERPAGE) throw new IllegalArgumentException("page could not be handled (pageModel.type == TYPE_OTHERPAGE)"); BoardFragment fragment = new BoardFragment(); Bundle args = new Bundle(1); args.putLong("TabModelId", tabId); fragment.setArguments(args); return fragment; }
From source file:de.vanita5.twittnuker.util.Utils.java
public static void openImage(final Context context, final long accountId, final String uri, final boolean isPossiblySensitive) { if (context == null || uri == null) return;// www .jav a 2s . c o m final SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); if (context instanceof FragmentActivity && isPossiblySensitive && !prefs.getBoolean(KEY_DISPLAY_SENSITIVE_CONTENTS, false)) { final FragmentActivity activity = (FragmentActivity) context; final FragmentManager fm = activity.getSupportFragmentManager(); final DialogFragment fragment = new SensitiveContentWarningDialogFragment(); final Bundle args = new Bundle(); args.putLong(EXTRA_ACCOUNT_ID, accountId); args.putParcelable(EXTRA_URI, Uri.parse(uri)); fragment.setArguments(args); fragment.show(fm, "sensitive_content_warning"); } else { openImageDirectly(context, accountId, uri); } }
From source file:com.android.leanlauncher.LauncherTransitionable.java
@Override protected void onSaveInstanceState(Bundle outState) { outState.putInt(RUNTIME_STATE, mState.ordinal()); if (mPendingAddInfo.container != ItemInfo.NO_ID && mWaitingForResult) { outState.putLong(RUNTIME_STATE_PENDING_ADD_CONTAINER, mPendingAddInfo.container); outState.putInt(RUNTIME_STATE_PENDING_ADD_CELL_X, mPendingAddInfo.cellX); outState.putInt(RUNTIME_STATE_PENDING_ADD_CELL_Y, mPendingAddInfo.cellY); outState.putInt(RUNTIME_STATE_PENDING_ADD_SPAN_X, mPendingAddInfo.spanX); outState.putInt(RUNTIME_STATE_PENDING_ADD_SPAN_Y, mPendingAddInfo.spanY); outState.putParcelable(RUNTIME_STATE_PENDING_ADD_WIDGET_INFO, mPendingAddWidgetInfo); outState.putInt(RUNTIME_STATE_PENDING_ADD_WIDGET_ID, mPendingAddWidgetId); }/*w w w.j a va 2s .c om*/ // Save the current AppsCustomize tab if (mAppsCustomizeTabHost != null) { AppsCustomizePagedView.ContentType type = mAppsCustomizeContent.getContentType(); String currentTabTag = mAppsCustomizeTabHost.getTabTagForContentType(type); if (currentTabTag != null) { outState.putString("apps_customize_currentTab", currentTabTag); } int currentIndex = mAppsCustomizeContent.getSaveInstanceStateIndex(); outState.putInt("apps_customize_currentIndex", currentIndex); } outState.putSerializable(RUNTIME_STATE_VIEW_IDS, mItemIdToViewId); super.onSaveInstanceState(outState); }