@Override
 protected Bundle doInBackground(Bundle... params) {
   Bundle result = new Bundle();
   try {
     PagableResponseList<User> friends; // = new PagableResponseList<User>();
     long cursor = -1;
     long userID = mSharedPreferences.getLong(SAVE_STATE_KEY_USER_ID, -1);
     ArrayList<String> friendIds = new ArrayList<String>();
     ArrayList<SocialPerson> socialPersons = new ArrayList<SocialPerson>();
     SocialPerson socialPerson = new SocialPerson();
     do {
       friends = mTwitter.getFriendsList(userID, cursor);
       for (User user : friends) {
         friendIds.add(String.valueOf(user.getId()));
         getSocialPerson(socialPerson, user);
         socialPersons.add(socialPerson);
         socialPerson = new SocialPerson();
       }
     } while ((cursor = friends.getNextCursor()) != 0);
     result.putStringArray(
         RESULT_GET_FRIENDS_ID, friendIds.toArray(new String[friendIds.size()]));
     result.putParcelableArrayList(RESULT_GET_FRIENDS, socialPersons);
   } catch (TwitterException e) {
     result.putString(RESULT_ERROR, e.getMessage());
   }
   return result;
 }
 @Override
 public Fragment getItem(int position) {
   // getItem is called to instantiate the fragment for the given page.
   // Return a DummySectionFragment (defined as a static inner class
   // below) with the page number as its lone argument.
   String menu = getArguments().getString("Menu");
   String username = getArguments().getString("User");
   String pass = getArguments().getString("Pass");
   String cokie = getArguments().getString("Cook");
   String sub_name[] = getArguments().getStringArray("Array");
   String day[] = getArguments().getStringArray("Array1");
   int rpc[] = getArguments().getIntArray("Array2");
   String cl_time[] = getArguments().getStringArray("Array3");
   String sub_fac[] = getArguments().getStringArray("Array4");
   String block[] = getArguments().getStringArray("Array5");
   Fragment fragment = new DummySectionFragment();
   Bundle args = new Bundle();
   args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, position + 1);
   args.putString("Menu", "He");
   args.putString("User", username);
   args.putString("Pass", pass);
   args.putString("Cook", cokie);
   args.putString("POSS", position + "");
   args.putStringArray("Array", sub_name);
   args.putStringArray("Array1", day);
   args.putIntArray("Array2", rpc);
   args.putStringArray("Array3", cl_time);
   args.putStringArray("Array4", sub_fac);
   args.putStringArray("Array5", block);
   fragment.setArguments(args);
   return fragment;
 }
Exemple #3
0
    /** @description function to check the string returned by server and then proceed further. */
    protected void onPostExecute(String result) {
      // TODO: check this.exception
      // TODO: do something with the feed
      Log.d("postExecute!!", result);
      loading.dismiss();

      if (result.equals("not successfull")) {
        AlertDialog.Builder ad =
            new AlertDialog.Builder(
                TestMenu.this, com.raulgupta.exam.R.style.AppCompatAlertDialogStyle);
        ad.setTitle("Invalid selection");
        ad.setMessage("You have not given any exam!");
        ad.setIcon(android.R.drawable.stat_notify_error);
        ad.setNegativeButton(
            "Ok",
            new DialogInterface.OnClickListener() {

              @Override
              public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub

              }
            });
        ad.show();

      } // end of if
      else {
        try {
          JSONObject jObj = new JSONObject(result);
          JSONArray dataJsonArr = jObj.getJSONArray("Pre_score");
          for (int pos = 0; pos < dataJsonArr.length(); pos++) {

            JSONObject jsonObject = dataJsonArr.getJSONObject(pos);
            score[pos] = jsonObject.getString("score");
            test_Name[pos] = jsonObject.getString("test");
            Log.d("score : ", score[pos]);
          }
          Intent intent = new Intent(TestMenu.this, ViewTestScore.class);
          Bundle b = new Bundle();
          b.putStringArray("score", score);
          b.putStringArray("test_Name", test_Name);
          intent.putExtras(b);
          intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          getApplicationContext().startActivity(intent);
          /* JSONObject jObj = new JSONObject(result);
          score = jObj.getString("score");
          Log.d("score : ", score);
          Intent intent = new Intent(TestMenu.this, ViewTestScore.class);
          Bundle b=new Bundle();
          b.putString("score",score);
          intent.putExtras(b);
          intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          getApplicationContext().startActivity(intent);*/

        } catch (JSONException e) {
          Log.e("JSONException", "Error: " + e.toString());
        }
      } // end of else
    }
  public static PrefsFragment newInstance(
      String[] pairedDeviceNames, String[] pairedDeviceAddresses) {

    PrefsFragment prefsFragment = new PrefsFragment();

    Bundle args = new Bundle();
    args.putStringArray("pairedDeviceNames", pairedDeviceNames);
    args.putStringArray("pairedDeviceAddresses", pairedDeviceAddresses);

    prefsFragment.setArguments(args);
    return prefsFragment;
  }
  /**
   * Use this factory method to create a new instance of this fragment using the provided
   * parameters.
   *
   * @param gameResultsData object containing results data.
   * @return A new instance of fragment ResultsDialogFragment.
   */
  public static ResultsDialogFragment newInstance(GameResultsData gameResultsData) {
    ResultsDialogFragment fragment = new ResultsDialogFragment();
    Bundle args = new Bundle();

    args.putStringArray(ARG_PLACE, gameResultsData.getPlace());
    args.putStringArray(ARG_PLAYERS, gameResultsData.getNames());
    args.putStringArray(ARG_DURATION, gameResultsData.getDurations());
    args.putStringArray(ARG_WINS, gameResultsData.getWins());

    fragment.setArguments(args);
    return fragment;
  }
 @Override
 protected void onSaveInstanceState(Bundle saveInstanceState) {
   if (mColors != null) {
     saveInstanceState.putStringArray(KEY_COLORS, mColors);
   }
   super.onSaveInstanceState(saveInstanceState);
 }
 /**
  * Create Command with type "send".
  *
  * @param selectedSubConnector selected SubConnectorSpec
  * @param defPrefix default prefix
  * @param defSender default sender
  * @param recipients recipients
  * @param text text
  * @param flashSMS flashsms
  * @return created command
  */
 public static ConnectorCommand send(
     final String selectedSubConnector,
     final String defPrefix,
     final String defSender,
     final String[] recipients,
     final String text, // .
     final boolean flashSMS) {
   final Bundle b = new Bundle();
   b.putShort(TYPE, TYPE_SEND);
   b.putString(SELECTEDSUBCONNECTOR, selectedSubConnector);
   b.putString(DEFPREFIX, defPrefix);
   b.putString(DEFSENDER, defSender);
   final int l = recipients.length;
   ArrayList<String> r = new ArrayList<String>(l);
   String s;
   for (int i = 0; i < l; i++) {
     s = recipients[i];
     if (s != null && s.trim().length() > 0) {
       r.add(s);
     }
   }
   s = null;
   b.putStringArray(RECIPIENTS, r.toArray(new String[0]));
   b.putString(TEXT, text);
   b.putBoolean(FLASHSMS, flashSMS);
   b.putLong(TIMESTAMP, -1);
   b.putString(CUSTOMSENDER, null);
   return new ConnectorCommand(b);
 }
  public static Map<String, WidgetData> refreshWidgets(
      Context context, ArrayList<CharSequence> widgetsDesired) {
    synchronized (lock) {
      if (dataCache == null) dataCache = new HashMap<String, WidgetData>();

      for (InternalWidget widget : widgets) {
        widget.refresh(widgetsDesired);
        widget.get(widgetsDesired, dataCache);
      }

      Intent intent = new Intent("org.metawatch.manager.REFRESH_WIDGET_REQUEST");
      Bundle b = new Bundle();
      if (widgetsDesired == null) b.putBoolean("org.metawatch.manager.get_previews", true);
      else {
        String[] temp = widgetsDesired.toArray(new String[widgetsDesired.size()]);
        b.putStringArray("org.metawatch.manager.widgets_desired", temp);
      }

      intent.putExtras(b);

      context.sendBroadcast(intent);

      return dataCache;
    }
  }
Exemple #9
0
 static Bundle a(bs bsVar) {
   String str = null;
   int i = 0;
   if (bsVar == null) {
     return null;
   }
   Bundle bundle = new Bundle();
   if (bsVar.e() != null && bsVar.e().length > 1) {
     str = bsVar.e()[0];
   }
   Parcelable[] parcelableArr = new Parcelable[bsVar.a().length];
   while (i < parcelableArr.length) {
     Bundle bundle2 = new Bundle();
     bundle2.putString(p, bsVar.a()[i]);
     bundle2.putString(o, str);
     parcelableArr[i] = bundle2;
     i++;
   }
   bundle.putParcelableArray(q, parcelableArr);
   ca h = bsVar.h();
   if (h != null) {
     bundle.putParcelable(r, C0056bn.a(h));
   }
   bundle.putParcelable(s, bsVar.c());
   bundle.putParcelable(t, bsVar.d());
   bundle.putStringArray(u, bsVar.e());
   bundle.putLong(v, bsVar.g());
   return bundle;
 }
  public static SelectModeDialogFragment newInstance(
      Bundle args, ArrayList<String> ways, String title) {
    ArrayList<String> choicesDisplay;
    if (ways == null) {
      choicesDisplay = new ArrayList<String>();
    } else {
      choicesDisplay = new ArrayList<String>(ways);
    }
    if (args != null && args.getBoolean(CHOICE_MODE_MULTIPLE)) {
      args.putBoolean(WITH_CANCEL_ITEM, false);
    }
    if (args != null && args.getBoolean(WITH_CANCEL_ITEM, false)) {
      choicesDisplay.add(CustomApplication.getStringById(R.string.Dialog_Button_Label_Negative));
    }

    SelectModeDialogFragment fragment = new SelectModeDialogFragment();
    if (args == null) args = new Bundle();
    args = initializeSettings(args, title, null, null);
    if (!args.getBoolean(CHOICE_MODE_MULTIPLE, false)
        && !args.getBoolean(CHOICE_MODE_SINGLE, false)) {
      args.putString(POSITIVE_TEXT, null);
      args.putString(NEGATIVE_TEXT, null);
    }
    args.putStringArray(WAYS, choicesDisplay.toArray(new String[] {}));
    fragment.setArguments(args);
    return fragment;
  }
 @Override
 public boolean onBackPressed() {
   if (isTablet && !isPortrait) {
     return false;
   } else {
     Fragment currentFragment = getChildFragmentManager().findFragmentById(R.id.fragmentContainer);
     if (currentFragment instanceof ContentDetailFragment) {
       contentListFragment = new ContentListFragment();
       Bundle bundle = new Bundle();
       bundle.putStringArray(MainActivity.EXTRA_CONTENT_NAMES, contentNames);
       bundle.putIntArray(MainActivity.EXTRA_CONTENT_IMAGES, contentImages);
       contentListFragment.setArguments(bundle);
       showPrimaryFragment(contentListFragment, false, null, true);
       isDetailShowing = false;
       // going back to main content
       new Handler()
           .postDelayed(
               new Runnable() {
                 @Override
                 public void run() {
                   ((MainActivity) getActivity()).setUpNavOff();
                 }
               },
               250);
       return true;
     } else {
       return false;
     }
   }
 }
 /**
  * Add extended data to the extra.
  *
  * @param name The name of the extra data, with package prefix.
  * @param value The String array data value.
  * @return Returns the same extra object, for chaining multiple calls into a single statement.
  * @see #putExtras
  * @see #removeExtra
  * @see #getStringArrayExtra(String)
  */
 public Request putExtra(String name, String[] value) {
   if (mExtras == null) {
     mExtras = new Bundle();
   }
   mExtras.putStringArray(name, value);
   return this;
 }
 private void previewImage(String filename) {
   String images[] = {filename};
   photosBundle.putStringArray("images", images);
   Intent intent = new Intent(this, ImagePreviewer.class);
   intent.putExtra("photos", photosBundle);
   startActivityForResult(intent, 0);
   setResult(RESULT_OK, intent);
 }
 protected long run() throws RemoteException {
   Bundle request = makeRequestBundle("CONFIRM_NOTIFICATIONS");
   request.putStringArray(Consts.BILLING_REQUEST_NOTIFY_IDS, this.mNotifyIds);
   Bundle response = mService.sendBillingRequest(request);
   logResponseCode("confirmNotifications", response);
   return response.getLong(
       Consts.BILLING_RESPONSE_REQUEST_ID, Consts.BILLING_RESPONSE_INVALID_REQUEST_ID);
 }
    @Override
    protected synchronized boolean onTransact(int code, Parcel data, Parcel reply, int flags) {
      DATABASE_NAME = getString(R.string.db_name);
      DATABASE_TABLE = getString(R.string.db_table);
      if (code == BDB_SERVICE_CODE) {
        Bundle bundle = data.readBundle();
        String command = bundle.getString("COMMAND");
        Log.i(TAG, "COMMAND=" + command);
        if (command.equals("ADD")) {
          String title = bundle.getString("TITLE");
          String isbn = bundle.getString("ISBN");
          String price = bundle.getString("PRICE");
          Log.i(TAG, "TITLE=" + command);
          Log.i(TAG, "ISBN=" + isbn);
          Log.i(TAG, "PRICE=" + price);
          bundle = new Bundle();
          if (doAdd(title, isbn, price)) bundle.putString("STATUS", "succeed");
          else bundle.putString("STATUS", "failed");
          reply.writeBundle(bundle);
        } else if (command.equals("SUM")) {
          String[][] dbdata = getData();
          // int sumprice = sumPrice();
          bundle = new Bundle();
          if (dbdata == null) {
            bundle.putString("STATUS", "failed");
            bundle.putStringArray("ID", null);
            bundle.putStringArray("TITLE", null);
            bundle.putStringArray("ISBN", null);
            bundle.putStringArray("PRICE", null);
            bundle.putString("TOTAL", "0");
          } else { // if(sumprice!=0){
            bundle.putString("STATUS", "succeed");
            bundle.putStringArray("ID", dbdata[0]);
            bundle.putStringArray("TITLE", dbdata[1]);
            bundle.putStringArray("ISBN", dbdata[2]);
            bundle.putStringArray("PRICE", dbdata[3]);
            // bundle.putString("TOTAL", Integer.toString(sumprice));
          } /*else if(sumprice==0){
            	bundle.putString("STATUS", "no data");
            	bundle.putStringArray("ID", dbdata[0]);
            	bundle.putStringArray("TITLE", dbdata[1]);
            	bundle.putStringArray("ISBN", dbdata[2]);
            	bundle.putStringArray("PRICE", dbdata[3]);
            	bundle.putString("TOTAL", Integer.toString(sumprice));
            }*/
          reply.writeBundle(bundle);
        }

        return true;
      } else {
        Log.e(
            getClass().getSimpleName(),
            "Transaction code should be " + BDB_SERVICE_CODE + ";" + " received instead " + code);
        return false;
      }
    }
 private void addPhoneViews() {
   contentListFragment = new ContentListFragment();
   Bundle bundle = new Bundle();
   bundle.putStringArray(MainActivity.EXTRA_CONTENT_NAMES, contentNames);
   bundle.putIntArray(MainActivity.EXTRA_CONTENT_IMAGES, contentImages);
   contentListFragment.setArguments(bundle);
   showPrimaryFragment(contentListFragment, false, null, false);
 }
 @Override
 public void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   outState.putBoolean(IS_DETAIL_SHOWING, isDetailShowing);
   outState.putInt(DETAIL_ITEM_POSITION, detailItemPosition);
   outState.putStringArray(MainActivity.EXTRA_CONTENT_NAMES, contentNames);
   outState.putIntArray(MainActivity.EXTRA_CONTENT_IMAGES, contentImages);
 }
  @Override
  protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    if (outState != null && _tile_array == null && _tile_array.length > 0) {
      outState.putStringArray(TILE_ARRAY_BUNDLE_KEY, _tile_array);
    }
  }
Exemple #19
0
  private void TransMessage() {

    Intent intent = this.getIntent();
    Bundle bundle = new Bundle();
    CoreMember = s_array[step];
    bundle.putStringArray("CoreMember", CoreMember);
    intent.putExtras(bundle);
    MyCoreSelect.this.setResult(3, intent);
  }
  @Override
  protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    String[] mainFragmentTags = _stringSetToStringArray(stringFragmentHashMap.keySet());

    outState.putInt(BUNDLE_KEY_LAST_MENU_ITEM_ID_REQUESTED, _lastMenuItemIDRequested);
    outState.putBoolean(BUNDLE_KEY_IS_A_NON_DRAWER_SCREEN_SHOWING, _isANonDrawerScreenShowing);
    outState.putStringArray(BUNDLE_KEY_MAIN_FRAGMENT_TAGS, mainFragmentTags);
  }
  private void previewImage(int position) {
    photosBundle.putInt("position", position);

    photosBundle.putStringArray("images", thumbnails);
    Intent intent = new Intent(this, ImagePreviewer.class);
    intent.putExtra("photos", photosBundle);
    startActivityForResult(intent, 0);
    setResult(RESULT_OK, intent);
  }
  @Override
  protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    assert getActionBar() != null;
    getActionBar().setDisplayHomeAsUpEnabled(true);

    Bundle bundle = new Bundle();
    bundle.putStringArray(Libs.BUNDLE_FIELDS, Libs.toStringArray(R.string.class.getFields()));
    bundle.putStringArray(Libs.BUNDLE_LIBS, LIBRARIES);
    bundle.putBoolean(Libs.BUNDLE_VERSION, true);
    bundle.putBoolean(Libs.BUNDLE_LICENSE, true);
    bundle.putBoolean(Libs.BUNDLE_LICENSE_DIALOG, true);

    LibsFragment fragment = new LibsFragment();
    fragment.setLibraryComparator(new LibraryComparator());
    fragment.setArguments(bundle);
    getFragmentManager().beginTransaction().add(android.R.id.content, fragment).commit();
  }
 protected long run() throws RemoteException {
   this.mNonce = Security.generateNonce();
   Bundle request = makeRequestBundle("GET_PURCHASE_INFORMATION");
   request.putLong(Consts.BILLING_REQUEST_NONCE, this.mNonce);
   request.putStringArray(Consts.BILLING_REQUEST_NOTIFY_IDS, this.mNotifyIds);
   Bundle response = mService.sendBillingRequest(request);
   logResponseCode("getPurchaseInformation", response);
   return response.getLong(
       Consts.BILLING_RESPONSE_REQUEST_ID, Consts.BILLING_RESPONSE_INVALID_REQUEST_ID);
 }
 private static StringPickerDialogFragment newInstanceInternal(
     DialogFragmentCallbackProvider provider, int theme, String[] values) {
   assertListenerBindable(provider);
   StringPickerDialogFragment fragment = new StringPickerDialogFragment();
   Bundle args = new Bundle();
   args.putInt(THEME, theme);
   args.putStringArray(VALUES, values);
   fragment.setArguments(args);
   return fragment;
 }
  /**
   * Creates an instance
   *
   * @param items The items to display in the list
   * @return
   */
  public static PopupItemChooserDialog createInstance(String[] items) {
    if (items == null || items.length <= 0) {
      throw new IllegalArgumentException("Items can not be null or empty");
    }

    PopupItemChooserDialog fragment = new PopupItemChooserDialog();
    Bundle args = new Bundle();
    args.putStringArray(KEY_ITEMS, items);
    fragment.setArguments(args);
    return fragment;
  }
 public static NewPostFragment newInstanceForEdit(
     String id, String text, String[] tags, boolean isPrivate) {
   NewPostFragment fragment = new NewPostFragment();
   Bundle args = new Bundle();
   args.putString(ARG_ID, id);
   args.putString(ARG_TEXT, text);
   args.putStringArray(ARG_TAGS, tags);
   args.putBoolean(ARG_PRIVATE, isPrivate);
   fragment.setArguments(args);
   return fragment;
 }
    @Override
    public Fragment getItem(int position) { // 返回Fragment
      Fragment fragment = new DiscountFragment();

      Bundle args = new Bundle();

      args.putInt("no", position);
      args.putStringArray("info", info2);
      fragment.setArguments(args);
      return fragment;
    }
    @Override
    protected long doExecute() throws RemoteException {

      Log.d(TAG, "Confirming notifications for notification ids: " + notifyIds);

      Bundle request = makeRequestBundle(CONFIRM_NOTIFICATIONS);
      request.putStringArray(BILLING_REQUEST_NOTIFY_IDS, notifyIds);
      Bundle response = service.sendBillingRequest(request);
      logResponseCode("ConfirmNotifications", response);
      return response.getLong(BILLING_RESPONSE_REQUEST_ID, BILLING_RESPONSE_INVALID_REQUEST_ID);
    }
 @Override
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   // 传递urls position参数 跳转到Show
   Bundle bundle = new Bundle();
   Intent intent = new Intent();
   bundle.putStringArray("url", good.getPicture().toArray(new String[] {})); // 传递图片列表的URL数组
   bundle.putInt("pos", position);
   intent.setClass(DetailActivity.this, ShowActivity.class);
   intent.putExtras(bundle);
   startActivity(intent);
 }
 @Override
 protected void setInternalArguments(Bundle args) {
   super.setInternalArguments(args);
   args.putParcelable(DBDEFINITION, tbd);
   args.putInt(LAYOUT, layout);
   args.putInt(VIEWHOLDERLAYOUT, listLayout);
   args.putIntArray(VIEWRESIDS, viewResId);
   args.putIntArray(FROMRESIDS, fromResId);
   args.putString(SELECTION, selection);
   args.putStringArray(SELECTIONARGS, selectionArgs);
 }