示例#1
0
        public void run() {

          User user = new User();
          user.setUsername(nameText.getText().toString());
          user.setPasswd(pwdText.getText().toString());
          Message msg = new Message();
          Bundle b = new Bundle();

          ILoginService ls = ClientServiceHelper.getLoginService();
          Map<String, Object> result = ls.login(user.getUsername(), user.getPasswd());
          if (result == null) {
            b.putInt("result", 1);
            b.putString("msg", "连不上服务器");
          } else {
            int status = (Integer) result.get("status");
            if (status == 0) {
              b.putInt("result", 0);
              user = (User) result.get("User");
              ((MyApplication) getApplication()).setUser(user);
            } else {
              b.putInt("result", 1);
              String backMsg = (String) result.get("msg");
              b.putString("msg", backMsg);
            }
          }

          // user.setContactId(1);
          // user.setId(1);
          // user.setKey("abc");
          // user.setType(1);
          // ((MyApplication) getApplication()).setUser(user);
          // b.putInt("result", 0);
          msg.setData(b);
          LoginActivity.this.myHandler.sendMessage(msg);
        }
示例#2
0
  private Bundle parserRecProgram() {
    ServiceInfoDao serInfoDao = new ServiceInfoDaoImpl(this);
    SharedPreferences spRec =
        getSharedPreferences("dvb_rec", MODE_WORLD_READABLE | MODE_WORLD_WRITEABLE);

    // parser rec programme.
    int recServiceId = spRec.getInt("rec_serviceId", 0);
    int recNumber = spRec.getInt("rec_logicalNumber", 0);
    int recServicePos = spRec.getInt("rec_servicePosition", 0);
    String recServiceName = spRec.getString("rec_serviceName", null);

    ServiceInfoBean rBean = serInfoDao.getChannelInfoByServiceId(recServiceId, recNumber);
    Bundle bundle = new Bundle();
    if (null != rBean) {
      bundle.putInt("ServicePos", recServicePos);
      bundle.putInt("LogicalNumber", recNumber);
      bundle.putInt("ServiceId", recServiceId);
      bundle.putString("ServiceName", recServiceName);
      bundle.putChar("ServiceType", serviceType);
      bundle.putString("superPwd", superPwd);
      bundle.putInt("Grade", grade);
      bundle.putBoolean("RecStatus", recStatus);
    }
    return bundle;
  }
  @Override
  public void displayTracks(String spotifyID, String artistName) {

    if (mTwoPane) {

      Bundle b = new Bundle();
      b.putString(Utils.SPOTIFY_ID, spotifyID);
      b.putString(Utils.ARTIST_NAME, artistName);

      mArtistName = artistName;

      mTrackFragment = new TrackFragment();
      mTrackFragment.setArguments(b);

      getSupportFragmentManager()
          .beginTransaction()
          .replace(R.id.track_fragment_container, mTrackFragment, TRACK_FRAGMENT_TAG)
          .commit();

    } else {

      Intent trackIntent = new Intent(MainActivity.this, TrackActivity.class);
      trackIntent.putExtra(Utils.ARTIST_NAME, artistName);
      trackIntent.putExtra(Utils.SPOTIFY_ID, spotifyID);
      trackIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
      startActivity(trackIntent);
    }
  } // displayTracks
  @SuppressWarnings("deprecation")
  public static void save(Activity context, User user, String password) {
    AccountManager manager = AccountManager.get(context);
    Account[] accounts = manager.getAccountsByType(AuthenticatorService.ACCOUNT_TYPE);
    for (Account account : accounts) {
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
        manager.removeAccountExplicitly(account);
      } else {
        manager.removeAccount(account, null, null);
      }
    }

    Account myAccount = new Account(user.email(), AuthenticatorService.ACCOUNT_TYPE);

    Bundle data = new Bundle();
    data.putString(User.KEY_SERVER_ID, user.id());
    data.putString(User.KEY_NAME, user.name());
    data.putString(
        User.KEY_PROFILE_PICTURE, user.picture() != null ? user.picture().toString() : null);

    manager.addAccountExplicitly(myAccount, password, data);
    manager.setAuthToken(myAccount, AuthenticatorService.AUTH_TOKEN_TYPE_FULL, user.token());

    MainActivity.start(context);
  }
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.shareqq_commit: // 提交
       final Bundle params = new Bundle();
       params.putString(GameAppOperation.QQFAV_DATALINE_APPNAME, appName.getText().toString());
       params.putString(GameAppOperation.QQFAV_DATALINE_TITLE, title.getText().toString());
       params.putString(GameAppOperation.QQFAV_DATALINE_DESCRIPTION, summary.getText().toString());
       params.putString(GameAppOperation.TROOPBAR_ID, troopbarId.getText().toString());
       String srFileData = imageUrl.getText().toString();
       if (!TextUtils.isEmpty(srFileData)) {
         ArrayList<String> fileDataList = new ArrayList<String>();
         srFileData.replace(" ", "");
         String[] filePaths = srFileData.split(";");
         int size = filePaths.length;
         for (int i = 0; i < size; i++) {
           String path = filePaths[i].trim();
           if (!TextUtils.isEmpty(path)) {
             fileDataList.add(path);
           }
         }
         params.putStringArrayList(GameAppOperation.QQFAV_DATALINE_FILEDATA, fileDataList);
       }
       doShareToTroopBar(params);
       return;
     case R.id.radioBtn_local_image: // 本地图片
       startPickLocaleImage(this);
       return;
     default:
       break;
   }
 }
示例#6
0
  /**
   * Start the ConnectedThread to begin managing a Bluetooth connection
   *
   * @param socket The BluetoothSocket on which the connection was made
   * @param device The BluetoothDevice that has been connected
   */
  public synchronized void connected(BluetoothSocket socket, BluetoothDevice device) {
    if (D) Log.d(TAG, "connected");

    // Cancel the thread that completed the connection
    if (mConnectThread != null) {
      mConnectThread.cancel();
      mConnectThread = null;
    }

    // Cancel any thread currently running a connection
    if (mConnectedThread != null) {
      mConnectedThread.cancel();
      mConnectedThread = null;
    }

    // Cancel the accept thread because we only want to connect to one device
    if (mAcceptThread != null) {
      mAcceptThread.cancel();
      mAcceptThread = null;
    }

    // Start the thread to manage the connection and perform transmissions
    mConnectedThread = new ConnectedThread(socket);
    mConnectedThread.start();

    // Send the name of the connected device back to the UI Activity
    Message msg = mHandler.obtainMessage(Papandro.MESSAGE_DEVICE_NAME);
    Bundle bundle = new Bundle();
    bundle.putString(Papandro.DEVICE_NAME, device.getName());
    bundle.putString(Papandro.DEVICE_ADDR, device.getAddress());
    msg.setData(bundle);
    mHandler.sendMessage(msg);

    setState(STATE_CONNECTED);
  }
      @Override
      public void onClick(View view) {
        try {
          long genreId = genres.get(getAdapterPosition()).getId();
          Context context = getActivity();
          Intent mIntent = new Intent(context, PlaylistActivity.class);

          Bundle mBundle = new Bundle();
          mBundle.putLong("id", genreId);
          mBundle.putLong("tagfor", PhoneMediaControl.SongsLoadFor.Genre.ordinal());
          mBundle.putString(
              "albumname", ((TextView) view.findViewById(R.id.title)).getText().toString().trim());
          mBundle.putString("title_one", "All my songs");
          mBundle.putString(
              "title_sec",
              ((TextView) view.findViewById(R.id.details)).getText().toString().trim());

          mIntent.putExtras(mBundle);

          context.startActivity(mIntent);
          ((Activity) context).overridePendingTransition(0, 0);
        } catch (Exception e) {
          Log.i(TAG, Log.getStackTraceString(e));
        }
      }
示例#8
0
 @Override
 public Fragment getItem(int i) {
   Bundle bundle = new Bundle();
   bundle.putString("institution_name", institution_name);
   bundle.putString("institution_code", institution_code);
   bundle.putString("id", id);
   bundle.putString("classId", classId);
   bundle.putString("classGradeId", classGradeId);
   switch (i) {
     case 0:
       // Fragement for student information
       Fragment student_info = new student_info();
       student_info.setArguments(bundle);
       return student_info;
     case 1:
       // Fragment for attendance
       Fragment student_attendance = new student_attendance();
       student_attendance.setArguments(bundle);
       return student_attendance;
     case 2:
       // Fragment for result
       Fragment student_result = new student_result();
       student_result.setArguments(bundle);
       return student_result;
   }
   return null;
 }
 @Override
 public void onValidationFinished(ValidationType validationType) {
   if (validationType.equals(ValidationType.SKIPPED)) {
     Log.d("ValidationType: ", "SKIPPED. Launching login activity...");
     startActivityForResult(new Intent(getBaseContext(), WelcomeActivity.class), 364);
     Bundle data = new Bundle();
     data.putString(WelcomeActivity.VALIDATION_TYPE, ValidationType.SKIPPED.name());
     Intent missingToken = new Intent(getBaseContext(), WelcomeActivity.class);
     missingToken.putExtras(data);
     startActivityForResult(missingToken, 364);
   } else if (validationType.equals(ValidationType.MISSING_CREDENTIALS)) {
     Log.d("ValidationType: ", "MISSING_CREDENTIALS. Launching login activity...");
     Bundle data = new Bundle();
     data.putString(WelcomeActivity.VALIDATION_TYPE, ValidationType.MISSING_CREDENTIALS.name());
     Intent missingToken = new Intent(getBaseContext(), WelcomeActivity.class);
     missingToken.putExtras(data);
     startActivityForResult(missingToken, 364);
   } else if (validationType.equals(ValidationType.MISSING_TOKEN)) {
     Log.d("ValidationType:", "MISSING_TOKEN. Launching Login Activity");
     Bundle data = new Bundle();
     data.putString(WelcomeActivity.VALIDATION_TYPE, ValidationType.MISSING_TOKEN.name());
     Intent missingToken = new Intent(getBaseContext(), WelcomeActivity.class);
     missingToken.putExtras(data);
     startActivityForResult(missingToken, 364);
   } else if (validationType.equals(ValidationType.SUCCESS)) {
     Log.d("ValidationType: ", "SUCCESS. Get user info/retrieve updated data from server");
     onLoginSuccess(
         new LinodeUser(
             LinodeApi.getInstance().getPreferences().getCurrentUsername(),
             LinodeApi.getInstance().getPreferences().getCurrentPassword(),
             LinodeApi.getInstance().getPreferences().getCurrentApiKey()));
   } else if (validationType.equals(ValidationType.UNKNOWN_ERROR)) {
     AndroidHelper.shortToast(getBaseContext(), "Unknown error. ¯\\_(ツ)_/¯");
   }
 }
  private static synchronized void retrieveTestAccountsForAppIfNeeded() {
    if (appTestAccounts != null) {
      return;
    }

    appTestAccounts = new HashMap<String, TestAccount>();

    // The data we need is split across two different FQL tables. We construct two queries, submit
    // them
    // together (the second one refers to the first one), then cross-reference the results.

    // Get the test accounts for this app.
    String testAccountQuery =
        String.format(
            "SELECT id,access_token FROM test_account WHERE app_id = %s", testApplicationId);
    // Get the user names for those accounts.
    String userQuery = "SELECT uid,name FROM user WHERE uid IN (SELECT id FROM #test_accounts)";

    Bundle parameters = new Bundle();

    // Build a JSON string that contains our queries and pass it as the 'q' parameter of the query.
    JSONObject multiquery;
    try {
      multiquery = new JSONObject();
      multiquery.put("test_accounts", testAccountQuery);
      multiquery.put("users", userQuery);
    } catch (JSONException exception) {
      throw new FacebookException(exception);
    }
    parameters.putString("q", multiquery.toString());

    // We need to authenticate as this app.
    parameters.putString("access_token", getAppAccessToken());

    Request request = new Request(null, "fql", parameters, null);
    Response response = request.executeAndWait();

    if (response.getError() != null) {
      throw response.getError().getException();
    }

    FqlResponse fqlResponse = response.getGraphObjectAs(FqlResponse.class);

    GraphObjectList<FqlResult> fqlResults = fqlResponse.getData();
    if (fqlResults == null || fqlResults.size() != 2) {
      throw new FacebookException("Unexpected number of results from FQL query");
    }

    // We get back two sets of results. The first is from the test_accounts query, the second from
    // the users query.
    Collection<TestAccount> testAccounts =
        fqlResults.get(0).getFqlResultSet().castToListOf(TestAccount.class);
    Collection<UserAccount> userAccounts =
        fqlResults.get(1).getFqlResultSet().castToListOf(UserAccount.class);

    // Use both sets of results to populate our static array of accounts.
    populateTestAccounts(testAccounts, userAccounts);

    return;
  }
  public static void sendMsgToHandler(Handler handler, Object object, boolean isSucc) {
    if (handler == null || object == null) {
      Log.e(TAG, "传入参数不能为空");
      return;
    }
    Message message = handler.obtainMessage();
    Bundle bundle = new Bundle();

    if (object instanceof String) {
      bundle.putString("data", object.toString());
    } else if (object instanceof ArrayList<?>) {
      bundle.putStringArrayList("data", (ArrayList) object);
    } else if (object instanceof OrderStatus_O_Data) {
      bundle.putSerializable("data", (OrderStatus_O_Data) object);
    } else if (object instanceof Result) {
      bundle.putSerializable("data", (Result) object);
    } else if (object instanceof AddRespData) {
      bundle.putSerializable("data", (AddRespData) object);
    } else if (object instanceof AddPhoneInfoRespData) {
      bundle.putSerializable("data", (AddPhoneInfoRespData) object);
    } else if (object instanceof AddOrderInfo) {
      bundle.putSerializable("data", (AddOrderInfo) object);
    } else if (object instanceof JuheOrderInfo) {
      bundle.putSerializable("data", (JuheOrderInfo) object);
    } else {
      bundle.putString("data", "参数类型未定义,请至工具类定义");
    }
    message.setData(bundle);
    if (isSucc) {
      message.what = 1;
    } else {
      message.what = -1;
    }
    handler.sendMessage(message);
  }
  /**
   * Copy data from passed Bundle to current accumulated data. Does some careful processing of the
   * data.
   *
   * @param bookData Source
   */
  private void accumulateData(int searchId) {
    // See if we got data from this source
    if (!mSearchResults.containsKey(searchId)) return;
    Bundle bookData = mSearchResults.get(searchId);

    // See if we REALLY got data from this source
    if (bookData == null) return;

    for (String k : bookData.keySet()) {
      // If its not there, copy it.
      if (!mBookData.containsKey(k)
          || mBookData.getString(k) == null
          || mBookData.getString(k).trim().length() == 0)
        mBookData.putString(k, bookData.get(k).toString());
      else {
        // Copy, append or update data as appropriate.
        if (k.equals(CatalogueDBAdapter.KEY_AUTHOR_DETAILS)) {
          appendData(k, bookData, mBookData);
        } else if (k.equals(CatalogueDBAdapter.KEY_SERIES_DETAILS)) {
          appendData(k, bookData, mBookData);
        } else if (k.equals(CatalogueDBAdapter.KEY_DATE_PUBLISHED)) {
          // Grab a different date if we can parse it.
          Date newDate = Utils.parseDate(bookData.getString(k));
          if (newDate != null) {
            String curr = mBookData.getString(k);
            if (Utils.parseDate(curr) == null) {
              mBookData.putString(k, Utils.toSqlDateOnly(newDate));
            }
          }
        } else if (k.equals("__thumbnail")) {
          appendData(k, bookData, mBookData);
        }
      }
    }
  }
 @Override
 public void onSaveInstanceState(Bundle outState) {
   outState.putString(KEY_STATUSMESSAGE, statusMessage);
   outState.putString(KEY_FILENAME, filename);
   outState.putInt(KEY_ADVANCEDSETTINGS, advancedRl.getVisibility());
   super.onSaveInstanceState(outState);
 }
  public void register(View view) {

    if (user.getText().toString().equals("")
        || email.getText().toString().equals("")
        || pass.getText().toString().equals("")) {
      UI.showAlertDialog(
          getString(android.R.string.dialog_alert_title),
          "Favor de llenar todos los campos solicitados",
          getString(android.R.string.ok),
          context,
          null);
    } else {

      Bundle b = new Bundle();
      b.putBoolean("REGISTER", true);
      b.putString(USER, user.getText().toString());
      b.putString(EMAIL, email.getText().toString());
      b.putString(PASS, pass.getText().toString());

      String country =
          getResources()
              .getStringArray(R.array.country_arrays_values)[(int) countries.getSelectedItemId()];
      b.putString(COUNTRY, country);
      b.putString(SEX, sex.isChecked() ? "H" : "M");

      setResult(Activity.RESULT_OK, new Intent().putExtras(b));
      finish();

      // TODO
    }
  }
  private void sendRequestDialog(String userId) {
    Bundle params = new Bundle();
    params.putString("message", "Send items to your friends when they arrive at the location.");
    params.putString("to", userId);
    WebDialog requestsDialog =
        (new WebDialog.RequestsDialogBuilder(this, Session.getActiveSession(), params))
            .setOnCompleteListener(
                new OnCompleteListener() {

                  public void onComplete(Bundle values, FacebookException error) {
                    if (values == null) return;
                    final String requestId = values.getString("request");
                    if (requestId != null) {
                      Toast.makeText(getApplicationContext(), "Request sent", Toast.LENGTH_SHORT)
                          .show();
                    } else {
                      Toast.makeText(
                              getApplicationContext(), "Request cancelled", Toast.LENGTH_SHORT)
                          .show();
                    }
                  }
                })
            .build();

    requestsDialog.show();
  }
示例#16
0
    @Override
    protected Intent doInBackground(String... params) {
      final String userName = mEmailView.getText().toString();
      final String userPass = mPasswordView.getText().toString();

      final String accountType = getIntent().getStringExtra(ARG_ACCOUNT_TYPE);

      Log.d(TAG, "Started authenticating");

      String authtoken = null;
      Bundle data = new Bundle();
      try {
        authtoken = sServerAuthenticate.userSignIn(userName, userPass, mAuthTokenType);

        data.putString(AccountManager.KEY_ACCOUNT_NAME, userName);
        data.putString(AccountManager.KEY_ACCOUNT_TYPE, accountType);
        data.putString(AccountManager.KEY_AUTHTOKEN, authtoken);
        data.putString(PARAM_USER_PASS, userPass);

      } catch (Exception e) {
        data.putString(KEY_ERROR_MESSAGE, e.getMessage());
      }

      final Intent res = new Intent();
      res.putExtras(data);
      return res;
    }
示例#17
0
 @Override
 public Fragment getItem(int i) {
   Bundle bundle = new Bundle();
   bundle.putString("imgurl", slides.get(i).getImageurl());
   bundle.putString("url", slides.get(i).getSiteurl());
   return SlideImageFragment.newInstance(bundle);
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_display_novel_tab, container, false);

    mTabHost = (FragmentTabHost) view.findViewById(android.R.id.tabhost);
    mTabHost.setup(getSherlockActivity(), getChildFragmentManager(), R.id.content);

    Bundle mainBundle = new Bundle();
    mainBundle.putString(Constants.EXTRA_NOVEL_LIST_MODE, Constants.EXTRA_NOVEL_LIST_MODE_MAIN);
    mainBundle.putBoolean(Constants.EXTRA_ONLY_WATCHED, false);
    mTabHost.addTab(
        mTabHost.newTabSpec(MAIN_SPEC).setIndicator(MAIN_SPEC),
        DisplayLightNovelListFragment.class,
        mainBundle);

    Bundle teaserBundle = new Bundle();
    teaserBundle.putString(Constants.EXTRA_NOVEL_LIST_MODE, Constants.EXTRA_NOVEL_LIST_MODE_TEASER);
    mTabHost.addTab(
        mTabHost.newTabSpec(TEASER_SPEC).setIndicator(TEASER_SPEC),
        DisplayLightNovelListFragment.class,
        teaserBundle);

    Bundle oriBundle = new Bundle();
    oriBundle.putString(Constants.EXTRA_NOVEL_LIST_MODE, Constants.EXTRA_NOVEL_LIST_MODE_ORIGINAL);
    mTabHost.addTab(
        mTabHost.newTabSpec(ORIGINAL_SPEC).setIndicator(ORIGINAL_SPEC),
        DisplayLightNovelListFragment.class,
        oriBundle);

    return view;
  }
  /**
   * 保存checkbox被选中的信息
   *
   * @param mReceivers
   */
  public void selected(ArrayList<ReceiverItem> mReceivers) {
    Intent receiverIntent = new Intent();

    StringBuffer ownername = new StringBuffer();
    StringBuffer ownerid = new StringBuffer();

    if (mReceivers.size() > 0) {
      for (int i = 0; i < mReceivers.size(); i++) {
        if (mReceivers.get(i).ischecked) {
          ownername.append(mReceivers.get(i).receiver_name);
          ownername.append(",");

          ownerid.append(mReceivers.get(i).receiver_id);
          ownerid.append(",");
        }
      }
    }

    String ownernames = ownername.toString();
    String ownerids = ownerid.toString();
    if (ownernames.lastIndexOf(",") > 0) {
      ownernames = ownernames.substring(0, ownernames.lastIndexOf(","));
      ownerids = ownerids.substring(0, ownerids.lastIndexOf(","));
    }

    Bundle bundle = new Bundle();
    bundle.putString(AddApplicationActivity.KEY_RECEIVER_LIST, ownernames);
    bundle.putString(AddApplicationActivity.KEY_RECEIVER_ID, ownerids);

    receiverIntent.putExtra(AddApplicationActivity.KEY_RECEIVER_BUNDLE, bundle);

    ((Activity) context).setResult(StateActivity.RESULT_CODE, receiverIntent);
  }
  private void doShare(
      Context context, String link, String thumb, String name, String description) {
    Bundle params = new Bundle();
    params.putString("link", link);
    params.putString("picture", thumb);
    params.putString("name", name);
    params.putString("description", description);

    facebook.dialog(
        context,
        "feed",
        params,
        new DialogListener() {

          @Override
          public void onFacebookError(FacebookError arg0) {}

          @Override
          public void onError(DialogError arg0) {}

          @Override
          public void onComplete(Bundle arg0) {}

          @Override
          public void onCancel() {}
        });

    context = null; // release for gc
  }
  public boolean onSavePassword(
      String schemePlusHost, String username, String password, Message resumeMsg) {
    // resumeMsg should be null at this point because we want to create it
    // within the CallbackProxy.
    if (Config.DEBUG) {
      junit.framework.Assert.assertNull(resumeMsg);
    }
    resumeMsg = obtainMessage(NOTIFY);

    Message msg = obtainMessage(SAVE_PASSWORD, resumeMsg);
    Bundle bundle = msg.getData();
    bundle.putString("host", schemePlusHost);
    bundle.putString("username", username);
    bundle.putString("password", password);
    synchronized (this) {
      sendMessage(msg);
      try {
        wait();
      } catch (InterruptedException e) {
        Log.e(LOGTAG, "Caught exception while waiting for onSavePassword");
        Log.e(LOGTAG, Log.getStackTraceString(e));
      }
    }
    // Doesn't matter here
    return false;
  }
示例#22
0
  public void share(Day giorno) {

    Bundle params = new Bundle();
    params.putString("name", "Ecco cosa mi è successo " + giorno.getData());
    params.putString("caption", giorno.getTesto());
    params.putString("description", "DearDiary è il tuo diario quotidiano su Android!");
    params.putString("link", "https://www.facebook.com/peppeuz");
    params.putString("picture", "http://imgbin.org/images/12252.png");
    if (Session.getActiveSession() == null) {
      alert();

    } else {
      WebDialog feedDialog =
          (new WebDialog.FeedDialogBuilder(activity, Session.getActiveSession(), params))
              .setOnCompleteListener(
                  new OnCompleteListener() {

                    @Override
                    public void onComplete(Bundle values, FacebookException error) {
                      if (error == null) {

                        final String postId = values.getString("post_id");
                        if (postId != null) {
                          Toast.makeText(
                                  activity,
                                  "Post effettuato correttamente!"
                                  // + postId

                                  ,
                                  Toast.LENGTH_SHORT)
                              .show();
                        } else {
                          // User clicked the Cancel button
                          Toast.makeText(
                                  activity.getApplicationContext(),
                                  "Post annullato",
                                  Toast.LENGTH_SHORT)
                              .show();
                        }
                      } else if (error instanceof FacebookOperationCanceledException) {
                        // User clicked the "x" button
                        Toast.makeText(
                                activity.getApplicationContext(),
                                "Post annullato",
                                Toast.LENGTH_SHORT)
                            .show();
                      } else {
                        // Generic, ex: network error
                        Toast.makeText(
                                activity.getApplicationContext(),
                                "Si è presentato un errore durante la pubblicazione",
                                Toast.LENGTH_SHORT)
                            .show();
                      }
                    }
                  })
              .build();
      feedDialog.show();
    }
  }
 public void click(int index) {
   switch (index) {
     case 0: // 回复评论
       if (!ReplayPermit.isMayClick) {
         return;
       }
       ReplayPermit.isMayClick = false;
       Message message1 = new Message();
       message1.what = MessageID.MESSAGE_MENUCLICK_COMMENTC_MSG_REPLY;
       Bundle data = new Bundle();
       data.putInt("is_subject", isSubject);
       data.putInt("subjectid", Integer.parseInt(subjectId));
       data.putInt("commentid", commentid);
       data.putInt("touserid", touserid);
       data.putString("tousername", tousername);
       data.putString("cid", cid);
       message1.setData(data);
       //			message1.obj = subjectId;
       //			message1.arg1 = isSubject;
       //			message1.arg2 = commentid;
       handler.sendMessage(message1);
       break;
     case 1: // 查看商品
       Message message2 = new Message();
       message2.what = MessageID.MESSAGE_MENUCLICK_COMMENTC_MSG_COMMODITY;
       Bundle data2 = new Bundle();
       data2.putInt("position", position);
       message2.setData(data2);
       handler.sendMessage(message2);
       break;
   }
 }
  @SmallTest
  @MediumTest
  @LargeTest
  public void testMultipleCaches() {
    Bundle bundle1 = new Bundle(), bundle2 = new Bundle();

    bundle1.putInt(INT_KEY, 10);
    bundle1.putString(STRING_KEY, "ABC");
    bundle2.putInt(INT_KEY, 100);
    bundle2.putString(STRING_KEY, "xyz");

    ensureApplicationContext();

    SharedPreferencesTokenCachingStrategy cache1 =
        new SharedPreferencesTokenCachingStrategy(getContext());
    SharedPreferencesTokenCachingStrategy cache2 =
        new SharedPreferencesTokenCachingStrategy(getContext(), "CustomCache");

    cache1.save(bundle1);
    cache2.save(bundle2);

    // Get new references to make sure we are getting persisted data.
    // Reverse the cache references for fun.
    cache1 = new SharedPreferencesTokenCachingStrategy(getContext(), "CustomCache");
    cache2 = new SharedPreferencesTokenCachingStrategy(getContext());

    Bundle newBundle1 = cache1.load(), newBundle2 = cache2.load();

    Assert.assertEquals(bundle2.getInt(INT_KEY), newBundle1.getInt(INT_KEY));
    Assert.assertEquals(bundle2.getString(STRING_KEY), newBundle1.getString(STRING_KEY));
    Assert.assertEquals(bundle1.getInt(INT_KEY), newBundle2.getInt(INT_KEY));
    Assert.assertEquals(bundle1.getString(STRING_KEY), newBundle2.getString(STRING_KEY));
  }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // if(Session.getActiveSession() != null) {
    // Session.getActiveSession().onActivityResult(this, requestCode,
    // resultCode, data);
    // }

    if (resultCode == RESULT_OK) {
      Bundle bundle;
      switch (requestCode) {
        case 4445:
          bundle = new Bundle();
          bundle.putString("photo", mSelectedImage);
          setupLayout(bundle);
          break;
        case 4444:
          bundle = new Bundle();
          Uri selectedImageUri = data.getData();
          if (Build.VERSION.SDK_INT < 19) {
            mSelectedImage = BeUtils.getPicturePathFromURI(this, selectedImageUri);
            bundle.putString("photo", mSelectedImage);
          } else {
            bundle.putParcelable("photo", selectedImageUri);
          }
          setupLayout(bundle);
          break;
      }
    }

    super.onActivityResult(requestCode, resultCode, data);
  }
示例#26
0
  @Override
  public Bundle getAuthToken(
      AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options)
      throws NetworkErrorException {
    Log.d(TAG, "getAuthToken(%s)", account.name);

    Bundle result = new Bundle();
    if (AccountData.get(account.name, mContext).isAuthenticated()) {
      Log.d(TAG, "getAuthToken(): Returning dummy SPNEGO auth token");
      result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
      result.putString(AccountManager.KEY_ACCOUNT_TYPE, account.type);
      result.putString(AccountManager.KEY_AUTHTOKEN, Constants.AUTH_TOKEN);
      result.putInt(HttpNegotiateConstants.KEY_SPNEGO_RESULT, 0);
    } else {
      Log.d(TAG, "getAuthToken(): Asking for credentials confirmation");
      Intent intent =
          SpnegoAuthenticatorActivity.getConfirmCredentialsIntent(mContext, account.name, response);
      result.putParcelable(AccountManager.KEY_INTENT, intent);

      // We need to show a notification in case the caller can't use the intent directly.
      showConfirmCredentialsNotification(mContext, intent);
    }

    return result;
  }
示例#27
0
  private void go2BootDefaultChannel(int serviceId) {
    ServiceInfoDao serInfoDao = new ServiceInfoDaoImpl(this);
    List<ServiceInfoBean> nBeans = serInfoDao.getChannelIdByLogicalNumber(serviceId);
    ServiceInfoBean nBean = null;
    if (nBeans.size() != 0) {
      nBean = nBeans.get(0);
    }
    if (null == nBean) {
      LogUtils.printLog(1, 5, TAG, "--->>> get boot default channel is null !");
      finish();
      return;
    }

    Bundle bundle = new Bundle();
    bundle.putInt("ServicePos", nBean.getChannelPosition());
    bundle.putInt("LogicalNumber", serviceId);
    bundle.putInt("ServiceId", serviceId);
    bundle.putString("ServiceName", nBean.getChannelName());
    bundle.putChar("ServiceType", nBean.getServiceType());
    bundle.putString("superPwd", superPwd);
    bundle.putInt("Grade", grade);
    bundle.putBoolean("RecStatus", recStatus);
    CommonUtils.skipActivity(
        SplashActivity.this, TVChannelPlay.class, bundle, Intent.FLAG_ACTIVITY_CLEAR_TOP);
  }
  /**
   * Displays the frame reader dialog
   *
   * @param p
   */
  protected void showFrameReaderDialog(Project p, FramesListAdapter.DisplayOption option) {
    if (p != null && p.getSelectedChapter() != null) {
      // move other dialogs to backstack
      FragmentTransaction ft = getFragmentManager().beginTransaction();
      Fragment prev = getFragmentManager().findFragmentByTag("dialog");
      if (prev != null) {
        ft.remove(prev);
      }
      ft.addToBackStack(null);

      // Create the dialog
      FramesReaderDialog newFragment = new FramesReaderDialog();
      Bundle args = new Bundle();
      args.putString(FramesReaderDialog.ARG_PROJECT_ID, p.getId());
      args.putString(FramesReaderDialog.ARG_CHAPTER_ID, p.getSelectedChapter().getId());
      args.putInt(
          FramesReaderDialog.ARG_SELECTED_FRAME_INDEX,
          p.getSelectedChapter().getFrameIndex(p.getSelectedChapter().getSelectedFrame()));

      // configure display option
      args.putInt(FramesReaderDialog.ARG_DISPLAY_OPTION_ORDINAL, option.ordinal());

      // display dialog
      newFragment.setArguments(args);
      newFragment.show(ft, "dialog");
    }
  }
  @Override
  public void onSaveInstanceState(Bundle savedInstanceState) {

    // Saving title field
    if (titleEditText != null) {
      savedInstanceState.putString(STATE_TITLE, titleEditText.getText().toString());
    }

    // Saving description field
    if (descriptionEditText != null) {
      savedInstanceState.putString(STATE_DESCRIPTION, descriptionEditText.getText().toString());
    }

    // Saving time field
    if (time != null) {
      savedInstanceState.putInt(STATE_TIME_HOUR, time.first);
      savedInstanceState.putInt(STATE_TIME_MINUTES, time.second);
    }

    // Saving week days field
    if (weekDays != null) {
      savedInstanceState.putBooleanArray(STATE_WEEK_DAYS, weekDays);
    }

    // The call to super method must be at the end here
    super.onSaveInstanceState(savedInstanceState);
  }
示例#30
0
 @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;
 }