public void UpdateToast(String str) {
    if (str.contains("o")) {
      // rotation code to go here
      rotations = mComponent.rotation.split(",");
      if (rotations.length > currentComponent) {
        Activity activity123 = getActivity();
        if (activity123 instanceof ItemListActivity) {

          try {
            if (!rotations[currentComponent].equals("0")) {
              ((ItemListActivity) activity123)
                  .sendData(String.valueOf(rotations[currentComponent]));
            }
          } catch (IOException e) {
            e.printStackTrace();
          }
        }
        // set value for next component
        currentComponent++;
        NextComponent();
      }
    }
    Toast.makeText(this.getActivity(), str, Toast.LENGTH_SHORT).show();
    // currentComponent
  }
  public void LoadComponent(int activecomponent) {
    items = mComponent.content.split(",");
    tvSubTitle.setText(items[currentComponent]);
    imageView.setImageDrawable(null);

    // int currentcomponentimage = items[currentComponent]);
    String imagename = imagenameprefix + items[currentComponent] + ".png";

    try {
      // get input stream
      InputStream ims = ((ContextWrapper) getActivity()).getAssets().open(imagename);
      // load image as Drawable
      Drawable d = Drawable.createFromStream(ims, null);
      // set image to ImageView
      imageView.setImageDrawable(d);
    } catch (IOException ex) {

    }

    // imageView.setImageResource(resID);

    // imageView.setBackgroundResource(feederList.get(currentcomponentimage-1));

    Activity activity123 = getActivity();
    if (activity123 instanceof ItemListActivity) {
      try {
        ((ItemListActivity) activity123).sendData(items[currentComponent]);
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  }
Пример #3
0
  @Override
  protected void onResume() {
    super.onResume();

    Log.d(TAG, "Selected item is going to be displayed: " + uriToDisplay);

    if (uriToDisplay == null) {
      final Intent intent = getIntent();

      if (intent != null && Intent.ACTION_VIEW.equals(intent.getAction())) {
        uriToDisplay = intent.getData();
      } else {
        Log.w(TAG, "No data or invalid intent is received:" + intent);
        return;
      }
    }

    // create cursor for the view
    final Cursor cursor =
        getContentResolver()
            .query(
                uriToDisplay,
                new String[] {
                  RSSObject.F__ID,
                  RSSObject.F_TITLE,
                  RSSObject.F_DESCRIPTION,
                  RSSItem.F_AUTHOR,
                  RSSItem.F_PUBDATE,
                  RSSObject.F_LINK
                },
                null,
                null,
                RSSItem.DEFAULT_SORT_ORDER);

    if (cursor.moveToFirst()) {
      final String description = cursor.getString(cursor.getColumnIndex(RSSItem.F_DESCRIPTION));
      ((WebView) findViewById(R.id.webView))
          .loadDataWithBaseURL(
              "http://androidportal.hu",
              description,
              "text/html",
              "utf-8",
              "http://androidportal.hu");
      ((TextView) findViewById(R.id.titleText))
          .setText(cursor.getString(cursor.getColumnIndex(RSSItem.F_TITLE)));
      ((TextView) findViewById(R.id.author))
          .setText(
              ItemListActivity.getAuthorText(
                  cursor.getString(cursor.getColumnIndex(RSSItem.F_AUTHOR)),
                  cursor.getString(cursor.getColumnIndex(RSSItem.F_PUBDATE))));

      url = cursor.getString(cursor.getColumnIndex(RSSObject.F_LINK));
    } else {
      Log.w(TAG, "Item is not found in DB: " + uriToDisplay);
    }

    cursor.close();
  }