Пример #1
0
  @Override
  protected void update() {
    starButton.setVisibility(
        (Util.isOffline(getContext()) || !song.isStarred()) ? View.GONE : View.VISIBLE);
    DownloadService downloadService = DownloadServiceImpl.getInstance();
    if (downloadService == null) {
      return;
    }

    DownloadFile downloadFile = downloadService.forSong(song);
    File partialFile = downloadFile.getPartialFile();

    int leftImage = 0;
    int rightImage = 0;

    if (downloadFile.isWorkDone()) {
      leftImage = downloadFile.shouldSave() ? R.drawable.saved : R.drawable.downloaded;
    }

    if (downloadFile.isDownloading()
        && !downloadFile.isDownloadCancelled()
        && partialFile.exists()) {
      statusTextView.setText(Util.formatLocalizedBytes(partialFile.length(), getContext()));
      rightImage = R.drawable.downloading;
    } else {
      statusTextView.setText(null);
    }
    statusTextView.setCompoundDrawablesWithIntrinsicBounds(leftImage, 0, rightImage, 0);

    boolean playing = downloadService.getCurrentPlaying() == downloadFile;
    if (playing) {
      titleTextView.setCompoundDrawablesWithIntrinsicBounds(
          R.drawable.stat_notify_playing, 0, 0, 0);
    } else {
      titleTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
    }
  }
Пример #2
0
  private void SetBackGroundforList() {
    // TODO Auto-generated method stub
    mDownView_parent_txt1 = new TextView(activity.getApplicationContext());
    RelativeLayout.LayoutParams lp1 =
        new RelativeLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    lp1.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    mDownView_parent_txt1.setId(Integer.parseInt("111111"));
    mDownView_parent_txt1.setLayoutParams(lp1);
    mDownView_parent_txt1.setGravity(Gravity.CENTER_HORIZONTAL);
    mDownView_parent_txt1.setText(HalfText);
    mDownView_parent_txt1.setWidth(textwidth2);
    mDownView_parent_txt1.setPadding(0, textheight / 4, 0, 0);
    mDownView_parent_txt1.setHeight(textheight);
    mDownView_parent_txt1.setBackgroundColor(Color.parseColor(FullColor));
    mDownView_parent_txt1.setTextColor(Color.parseColor(TextColor));
    mDownView_parent_txt1.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
    mDownView_parent.addView(mDownView_parent_txt1, 0);

    //         if(SwipeType==Double){
    //             mDownView_parent_txt2 = new TextView(activity.getApplicationContext());
    //             mDownView_parent_txt2.setId(222222);
    //             RelativeLayout.LayoutParams lp2 =new
    // RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT);
    //             lp2.addRule(RelativeLayout.LEFT_OF,mDownView_parent_txt1.getId());
    //             mDownView_parent_txt2.setLayoutParams(lp2);
    //             mDownView_parent_txt2.setGravity(Gravity.CENTER_HORIZONTAL);
    //             mDownView_parent_txt2.setText(FullText);
    //             mDownView_parent_txt2.setWidth(textwidth);
    //             mDownView_parent_txt2.setPadding(0, textheight/4, 0, 0);
    //             mDownView_parent_txt2.setHeight(textheight);
    //             mDownView_parent_txt2.setBackgroundColor(Color.parseColor(FullColor));
    //             mDownView_parent_txt2.setTextColor(Color.parseColor(TextColor));
    //             mDownView_parent_txt2.setCompoundDrawablesWithIntrinsicBounds(null ,
    // FullDrawable, null, null );
    //             mDownView_parent.addView(mDownView_parent_txt2, 1);
    //         }
  }
Пример #3
0
    /** Create the custom dialog */
    @SuppressLint("Override")
    public ArkBaseDialog create() {
      LayoutInflater inflater =
          (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      // instantiate the dialog with the custom Theme
      final ArkBaseDialog dialog = new ArkBaseDialog(context, R.style.alertdialog);

      View layout = inflater.inflate(R.layout.alert_dialog, null);
      dialog.addContentView(
          layout, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
      // set the dialog title
      TextView titleView = ((TextView) layout.findViewById(R.id.dialog_title_show));
      titleView.setText(title);

      // set the dialog title icon
      if (0 != title_background) {
        layout.findViewById(R.id.dialog_title_layout).setBackgroundResource(title_background);
      }

      if (0 != title_icon) {
        titleView.setCompoundDrawablesWithIntrinsicBounds(
            context.getResources().getDrawable(title_icon), null, null, null);
        /*ImageView ico = (ImageView) layout.findViewById(R.id.dialog_title_icon);
        ico.setImageResource(title_icon);*/
        if (null != icoClickListener) {
          titleView.setClickable(true);
          titleView.setOnClickListener(icoClickListener);
        }
      }

      ListView dialogListView = (ListView) layout.findViewById(R.id.dialog_list);
      // set the dialog list adpter
      if (adapter != null) {
        dialogListView.setAdapter(adapter);
        // set the dialog list width
        if (listAutoHeight) {
          // setListViewHeightBasedOnChildren(dialogListView);
        }
      } else {
        dialogListView.setVisibility(View.GONE);
      }

      // set the close button
      if (closeButtonClickListener != null) {
        ImageButton imageClose = ((ImageButton) layout.findViewById(R.id.dialog_close));
        imageClose.setBackgroundResource(closeButtonRes);
        TouchHelper.setOnTouchListener(imageClose, 0.85f, 0.85f);
        imageClose.setOnClickListener(
            new View.OnClickListener() {
              public void onClick(View v) {
                closeButtonClickListener.onClick(dialog, DialogInterface.BUTTON_NEGATIVE);
              }
            });
      } else {
        // if no confirm button just set the visibility to GONE
        layout.findViewById(R.id.dialog_close).setVisibility(View.GONE);
      }

      // set the confirm button
      if (positiveButtonText != null) {
        // int positiveTextLenght = positiveButtonText.length();
        ((Button) layout.findViewById(R.id.dialog_confirm_btn)).setText(positiveButtonText);
        /*  ((Button) layout.findViewById(R.id.dialog_confirm_btn))
        .setWidth(104 + (positiveTextLenght - 2) * 15);*/
        layout.findViewById(R.id.dialog_confirm_btn).setBackgroundResource(positiveButtonRes);
        if (positiveButtonClickListener != null) {
          (layout.findViewById(R.id.dialog_confirm_btn))
              .setOnClickListener(
                  new View.OnClickListener() {
                    public void onClick(View v) {
                      positiveButtonClickListener.onClick(dialog, DialogInterface.BUTTON_POSITIVE);
                    }
                  });
        }
      } else {
        // if no confirm button just set the visibility to GONE
        layout.findViewById(R.id.dialog_confirm_btn).setVisibility(View.GONE);
      }
      // set the cancel button
      if (negativeButtonText != null) {
        //   int negativeTextLenght = negativeButtonText.length();
        Button btnCancel = (Button) layout.findViewById(R.id.dialog_cancel_btn);
        //   btnCancel.setWidth(104 + (negativeTextLenght - 2) * 15);
        btnCancel.setText(negativeButtonText);
        btnCancel.setBackgroundResource(negativeButtonRes);
        if (negativeButtonClickListener != null) {
          btnCancel.setOnClickListener(
              new View.OnClickListener() {
                public void onClick(View v) {
                  negativeButtonClickListener.onClick(dialog, DialogInterface.BUTTON_NEGATIVE);
                }
              });
        }
      } else {
        // if no confirm button just set the visibility to GONE
        layout.findViewById(R.id.dialog_cancel_btn).setVisibility(View.GONE);
      }
      // set the content message
      if (message != null) {
        ((TextView) layout.findViewById(R.id.dialog_content_show)).setText(message);
      } else if (contentView != null) {
        // if no message set
        // add the contentView to the dialog body
        ((LinearLayout) layout.findViewById(R.id.dialog_content_layout)).removeAllViews();
        ((LinearLayout) layout.findViewById(R.id.dialog_content_layout))
            .addView(
                contentView,
                new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
      } else if (null != listView) {
        ((LinearLayout) layout.findViewById(R.id.dialog_content_layout)).removeAllViews();
        ((LinearLayout) layout.findViewById(R.id.dialog_content_layout))
            .addView(
                listView, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        // setListViewHeightBasedOnChildren(listView);
      } else {
        (layout.findViewById(R.id.dialog_content_show)).setVisibility(View.GONE);
      }
      dialog.setContentView(layout);
      dialog.setCanceledOnTouchOutside(true);
      return dialog;
    }