示例#1
0
 /*
  * (non-Javadoc)
  * @see org.odk.collect.android.widgets.QuestionWidget#setOnLongClickListener(android.view.View.OnLongClickListener)
  */
 @Override
 public void setOnLongClickListener(OnLongClickListener l) {
   mViewButton.setOnLongClickListener(l);
   mGetLocationButton.setOnLongClickListener(l);
   mStringAnswer.setOnLongClickListener(l);
   mAnswerDisplay.setOnLongClickListener(l);
 }
示例#2
0
 @Override
 public void setOnLongClickListener(OnLongClickListener l) {
     mQuestionText.setOnLongClickListener(l);
     if (mMissingImage != null) {
         mMissingImage.setOnLongClickListener(l);
     }
     if (mImageView != null) {
         mImageView.setOnLongClickListener(l);
     }
     if (label != null) {
         label.setOnLongClickListener(l);
     }
 }
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
      View row = convertView;
      if (row == null) {
        LayoutInflater inflater = getLayoutInflater();
        row = inflater.inflate(R.layout.search_history_list_item, parent, false);
      }
      TextView label = (TextView) row.findViewById(R.id.label);
      TextView distanceLabel = (TextView) row.findViewById(R.id.distance_label);
      ImageButton icon = (ImageButton) row.findViewById(R.id.remove);
      final HistoryEntry model = getItem(position);
      if (location != null) {
        int dist = (int) (MapUtils.getDistance(location, model.lat, model.lon));
        distanceLabel.setText(
            OsmAndFormatter.getFormattedDistance(dist, SearchHistoryActivity.this));
      } else {
        distanceLabel.setText(""); // $NON-NLS-1$
      }
      label.setText(model.name);
      icon.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              helper.remove(model, SearchHistoryActivity.this);
              setListAdapter(
                  new HistoryAdapter(helper.getHistoryEntries(SearchHistoryActivity.this)));
            }
          });
      View.OnClickListener clickListener =
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              selectModel(model);
            }
          };

      View.OnLongClickListener longClickListener =
          new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
              return onItemLongClick(position);
            }
          };
      distanceLabel.setOnLongClickListener(longClickListener);
      label.setOnLongClickListener(longClickListener);
      distanceLabel.setOnClickListener(clickListener);
      label.setOnClickListener(clickListener);
      return row;
    }
    ViewHolder(View view) {
      super(view);
      addressView = view;
      addressLabel = (TextView) view.findViewById(R.id.address_label);
      address = (TextView) view.findViewById(R.id.address);

      addressView.setOnLongClickListener(this);
      addressView.setOnClickListener(this);

      addressLabel.setOnLongClickListener(this);
      addressLabel.setOnClickListener(this);

      address.setOnLongClickListener(this);
      address.setOnClickListener(this);
    }
示例#5
0
  private void init() {

    // enable or disable onscreen delta buttons based on whether we have
    // enough room onscreen or not
    deltaButtonsViewStub = view.findViewById(R.id.onscreen_delta_buttons_stub);
    int versionInt = VersionHelper.getVersionSdkIntCompat();
    if (versionInt > VersionHelper.VERSION_DONUT && versionInt < VersionHelper.VERSION_FROYO) {
      // in eclair, there's a bug where ViewStubs within ViewSubs do not
      // render correctly, so inflate the ViewStubs no matter what
      if (deltaButtonsViewStub instanceof ViewStub) {
        deltaButtonsViewStub = ((ViewStub) deltaButtonsViewStub).inflate();
      }
    }
    deltaButtonsViewStub.setVisibility(showOnscreenDeltaButtons ? View.VISIBLE : View.GONE);
    onscreenDeltaButtonsLayout =
        (LinearLayout) view.findViewById(R.id.onscreen_delta_buttons_table_layout);

    divider1 = view.findViewById(R.id.player_score_divider_1);
    divider2 = view.findViewById(R.id.player_score_divider_2);
    nameTextView = (TextView) view.findViewById(R.id.text_name);
    scoreTextView = (TextView) view.findViewById(R.id.text_score);
    historyTextView = (TextView) view.findViewById(R.id.text_history);
    badgeTextView = (TextView) view.findViewById(R.id.text_badge);
    badgeLinearLayout = (LinearLayout) view.findViewById(R.id.linear_layout_badge);

    minusButton = (Button) view.findViewById(R.id.button_minus);
    plusButton = (Button) view.findViewById(R.id.button_plus);
    deltaButton1 = (Button) view.findViewById(android.R.id.button1);
    deltaButton2 = (Button) view.findViewById(android.R.id.button2);
    deltaButton3 = (Button) view.findViewById(android.R.id.button3);
    deltaButton4 = (Button) view.findViewById(R.id.button4);

    minusButton.setOnClickListener(this);
    minusButton.setOnLongClickListener(this);
    plusButton.setOnClickListener(this);
    plusButton.setOnLongClickListener(this);
    nameTextView.setOnClickListener(this);
    nameTextView.setOnLongClickListener(this);
    historyTextView.setOnClickListener(this);
    historyTextView.setOnLongClickListener(this);

    ColorScheme colorScheme = PreferenceHelper.getColorScheme(context);
    setNewColorScheme(colorScheme);

    updateViews();

    log.d("history is: %s", playerScore.getHistory());
  }
    private void setLabel(String text) {
      label.setText(text);

      label.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              Toast.makeText(
                      context, "This is inside onclick " + getAdapterPosition(), Toast.LENGTH_SHORT)
                  .show();
            }
          });

      label.setOnLongClickListener(
          new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {

              Toast.makeText(
                      context, "This is inside long " + getAdapterPosition(), Toast.LENGTH_SHORT)
                  .show();

              return true;
            }
          });
    }
示例#7
0
  /** 向Folder添加ShortcutInfo */
  protected boolean createAndAddShortcut(ShortcutInfo item) {
    final TextView textView = (TextView) mInflater.inflate(R.layout.application, this, false);
    textView.setCompoundDrawablesWithIntrinsicBounds(
        null, new FastBitmapDrawable(item.getIcon(mIconCache)), null, null);
    textView.setText(item.title);
    textView.setTag(item);

    textView.setOnClickListener(this);
    textView.setOnLongClickListener(this);

    // 检查这个地方是否被其他item占据
    if (mContent.getChildAt(item.cellX, item.cellY) != null
        || item.cellX < 0
        || item.cellY < 0
        || item.cellX >= mContent.getCountX()
        || item.cellY >= mContent.getCountY()) {
      // 其实不应该发生
      Log.e(TAG, "Folder order not properly persisted during bind");
      if (!findAndSetEmptyCells(item)) {
        return false;
      }
    }

    CellLayout.LayoutParams lp =
        new CellLayout.LayoutParams(item.cellX, item.cellY, item.spanX, item.spanY);
    boolean insert = false;
    textView.setOnKeyListener(new FolderKeyEventListener());
    mContent.addViewToCellLayout(textView, insert ? 0 : -1, (int) item.id, lp, true);
    return true;
  }
示例#8
0
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   _this = inflater.inflate(R.layout.jobdetail_layout, container, false);
   initVariable();
   setStatusItems();
   setjobDetail();
   if (!jobStatus.getSelectedItem().toString().equals("pending")) {
     disableEdit();
   } else if (NonStoppable.startingJob != null && !NonStoppable.startingJob.equals("")) {
     if (NonStoppable.startingJob.equals(jobNo.getText().toString())) {
       btn_startTimer.setText("CLICK TO FINISH");
       btn_startTimer.setTextColor(Color.RED);
       btn_startTimer.setBackground(
           getActivity().getResources().getDrawable(R.drawable.styled_button_finish_job));
       setOnClickListenerForTimer();
     } else {
       disableEdit();
       btn_startTimer.setText("You started " + NonStoppable.startingJob);
       btn_startTimer.setVisibility(View.VISIBLE);
     }
   } else {
     setOnClickListenerForTimer();
   }
   image_preview = new ImageView(getActivity());
   btn_photo.setOnClickListener(this);
   btn_cancelJob.setOnClickListener(this);
   btn_postpone.setOnClickListener(this);
   btn_viewImage.setOnClickListener(this);
   btn_viewSign.setOnClickListener(this);
   editDialog = new AlertDialog.Builder(getActivity());
   editDialog.setTitle("Edit");
   editDialog.setNegativeButton(
       "Cancel",
       new DialogInterface.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialogInterface, int i) {}
       });
   jobProblem.setOnLongClickListener(this);
   jobRemark.setOnLongClickListener(this);
   jobStatus.setEnabled(false);
   return _this;
 }
  private void processControllers() {
    // 建立選單項目點擊監聽物件
    AdapterView.OnItemClickListener itemListener =
        new AdapterView.OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // 使用Action名稱建立啟動另一個Activity元件需要的Intent物件
            Intent intent = new Intent("net.macdidi.myandroidtutorial.EDIT_ITEM");

            // 設定記事編號與標題
            intent.putExtra("position", position);
            intent.putExtra("titleText", data.get(position));

            // 呼叫「startActivityForResult」,第二個參數「1」表示執行修改
            startActivityForResult(intent, 1);
          }
        };

    // 註冊選單項目點擊監聽物件
    item_list.setOnItemClickListener(itemListener);

    // 建立選單項目長按監聽物件
    AdapterView.OnItemLongClickListener itemLongListener =
        new AdapterView.OnItemLongClickListener() {

          @Override
          public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            // 換掉「data[position]」
            Toast.makeText(MainActivity.this, "Long: " + data.get(position), Toast.LENGTH_LONG)
                .show();
            return false;
          }
        };

    // 註冊選單項目長按監聽物件
    item_list.setOnItemLongClickListener(itemLongListener);

    // 建立長按監聽物件
    View.OnLongClickListener listener =
        new View.OnLongClickListener() {

          @Override
          public boolean onLongClick(View view) {
            AlertDialog.Builder dialog = new AlertDialog.Builder(MainActivity.this);
            dialog.setTitle(R.string.app_name).setMessage(R.string.about).show();
            return false;
          }
        };

    // 註冊長按監聽物件
    show_app_name.setOnLongClickListener(listener);
  }
  @Override
  public View getGroupView(
      final int groupPosition, boolean isLastChild, View view, ViewGroup parent) {

    Todo todo = (Todo) getGroup(groupPosition);
    if (view == null) {
      LayoutInflater inf =
          (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      view = inf.inflate(R.layout.todo_list_item, null);
    }

    CheckBox cb_done = (CheckBox) view.findViewById(R.id.cb_checked);
    TextView tv_title = (TextView) view.findViewById(R.id.tv_title);
    TextView tv_category = (TextView) view.findViewById(R.id.tv_category);
    tv_title.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Todo todo = todoList.get(groupPosition);
            expandOrCollapseListener.expandOrCollapseGroupOnClickEvent(
                groupPosition, todo.isExpanded());
            todo.setExpanded(!todo.isExpanded());
          }
        });
    tv_title.setOnLongClickListener(
        new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View v) {
            todoList.remove(groupPosition);
            notifyDataSetChanged();
            return false;
          }
        });
    cb_done.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            Log.v("EXP", "CHECKING");
            Todo todo = todoList.get(groupPosition);
            todo.setChecked(isChecked);
            notifyDataSetChanged();
          }
        });

    tv_title.setText(todo.getTitle());
    tv_category.setText(todo.getCategory().toString());
    cb_done.setChecked(todo.getChecked());
    onGroupExpanded(groupPosition);
    return view;
  }
  void initView(View rootView) {
    // chapterQuoteSpinnerView.initialize(getActivity(), rootView, this);
    Bundle b = getArguments();
    if (b.containsKey(Constants.Bundle_quote)) {
      quote = (Quote) b.get(Constants.Bundle_quote);
    } else {
      Utility.closeCurrentFragment(getActivity());
    }

    lastquoteOfChapter =
        GitaDBOperation.getLastQuoteTextChapter(getActivity(), quote.getChapterNo());
    parentView = (RelativeLayout) rootView.findViewById(R.id.qp_main_parent);
    tv_body = (TextView) rootView.findViewById(R.id.qp_body);
    tv_body.setOnLongClickListener(this);
    slokaTV = (TextView) rootView.findViewById(R.id.sloka);
    slokaTV.setOnLongClickListener(this);
    playPause = (ImageView) rootView.findViewById(R.id.playPause);
    playPause.setOnClickListener(this);
    slokaTV.setTypeface(
        Typeface.createFromAsset(getActivity().getAssets(), "NotoSansHindi-Regular.ttf"));
    translationTitleTV = (TextView) rootView.findViewById(R.id.translationTitle);
    slokaTitleTV = (TextView) rootView.findViewById(R.id.slokaTitle);
    slokaIndex = (TextView) rootView.findViewById(R.id.slokaIndex);
    slokaIndex.setText(quote.getTextId() + "/" + lastquoteOfChapter);

    mScrollView = (ScrollView) rootView.findViewById(R.id.qp_body_wrapper);
    mScrollView.setHorizontalFadingEdgeEnabled(false);
    mScrollView.setVerticalFadingEdgeEnabled(false);
    setQuoteContent();
    updateSlokaVisibility();
    // chapterQuoteSpinnerView.setQuoteSelection(quote.getTextId());

    Utility.updateBackgroundImage(parentView, getActivity());
    updateFontColor();
    updateFontSize();
  }
示例#12
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mScope = new Scope(SHORTENER_SCOPE);
    mGoogleSignInOptions =
        new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestScopes(mScope)
            .requestEmail()
            .build();

    mGoogleApiClient =
        new GoogleApiClient.Builder(this)
            .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
            .addApi(Auth.GOOGLE_SIGN_IN_API, mGoogleSignInOptions)
            .addScope(mScope)
            .build();
    mGoogleApiClient.connect();

    SignInButton signInButton = (SignInButton) findViewById(R.id.sign_in_button);
    signInButton.setScopes(mGoogleSignInOptions.getScopeArray());
    signInButton.setOnClickListener(this);
    findViewById(R.id.sign_out_button).setOnClickListener(this);
    mStatusTextView = (TextView) findViewById(R.id.status);
    findViewById(R.id.btn_shorten).setOnClickListener(this);
    findViewById(R.id.long_uri)
        .setOnKeyListener(
            new View.OnKeyListener() {
              public boolean onKey(View v, int keyCode, KeyEvent event) {
                if ((event.getAction() == KeyEvent.ACTION_DOWN)
                    && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                  shorten(((EditText) findViewById(R.id.long_uri)).getText().toString());
                  return true;
                }
                return false;
              }
            });
    mStatusTextView.setOnLongClickListener(
        new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View v) {
            ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
            cm.setPrimaryClip(ClipData.newPlainText("", ((TextView) v).getText()));
            showClipboardSnackBar(((TextView) v).getText().toString());
            return true;
          }
        });
  }
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   View view = inflater.inflate(R.layout.fragment_customer, container, false);
   mCustomerChat = (TextView) view.findViewById(R.id.customer_chat);
   mCustomerChat.setOnClickListener(this);
   mCustomerChat.setOnLongClickListener(
       new View.OnLongClickListener() {
         @Override
         public boolean onLongClick(View v) {
           startDoubleChatroom(getActivity(), "OIBbeKlkx", "675NdFjkx");
           return true;
         }
       });
   return view;
 }
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    Log.i(TAG, "onActivityCreated()");
    initUI();
    applyFonts();

    if (!mMenuWasCreated) {
      setHasOptionsMenu(true);
      mMenuWasCreated = true;
    }

    mPassword.setOnLongClickListener(longClickListener);
    mPassword.setOnClickListener(shortClickListener);

    applyFonts();
    showTip();
  }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      View itemView = convertView;
      if (itemView == null) {
        itemView = getLayoutInflater().inflate(R.layout.tracks_item_view, parent, false);
      }

      // Find the album to work with
      final TrackItem currentTrack = data.getCurrentAlbum().getTracksList().get(position);

      // Make
      final TextView sizeText = (TextView) itemView.findViewById(R.id.size);
      sizeText.setText(currentTrack.getTrackSize());
      final TextView makeText = (TextView) itemView.findViewById(R.id.trackTextView);
      final TextView makeDescription = (TextView) itemView.findViewById(R.id.track_description);
      final ImageView makeimage = (ImageView) itemView.findViewById(R.id.imageView);
      makeText.setText(currentTrack.getTrackName());
      makeText.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              stopPlayer();
              selected = currentTrack;
              track_text.setText(currentTrack.getTrackName());
              startPlayer(selected);
            }
          });
      makeText.setOnLongClickListener(
          new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
              selected = currentTrack;
              return false;
            }
          });

      // Make Description

      makeDescription.setText(currentTrack.getTrackDescription());
      makeDescription.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              stopPlayer();
              selected = currentTrack;
              track_text.setText(currentTrack.getTrackName());
              startPlayer(selected);
            }
          });
      makeDescription.setOnLongClickListener(
          new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
              selected = currentTrack;
              return false;
            }
          });

      makeDescription.setText(currentTrack.getTrackDescription());
      makeimage.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              stopPlayer();
              selected = currentTrack;
              track_text.setText(currentTrack.getTrackName());
              startPlayer(selected);
            }
          });
      makeimage.setOnLongClickListener(
          new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
              selected = currentTrack;
              return false;
            }
          });

      play_button.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              if (mediaPlayer != null) mediaPlayer.start();
              else if (selected != null) startPlayer(selected);
            }
          });

      pause_button.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              if (mediaPlayer != null) {
                mediaPlayer.pause();
              }
            }
          });

      stop_button.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              stopPlayer();
              trackSeekBar.setProgress(0);
              current_duration.setText("00:00");
            }
          });

      trackSeekBar.setOnSeekBarChangeListener(
          new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

              if (fromUser && seekBar.isInTouchMode()) {
                progressValue = progress;
              }
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {}

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
              if (mediaPlayer != null) {
                mediaPlayer.seekTo(progressValue);
              } else {
                trackSeekBar.setProgress(progressValue);
              }
            }
          });

      return itemView;
    }
示例#16
0
  public void createScrollView() {
    // LayoutParams (Reuseable)
    LinearLayout.LayoutParams lparams_text =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
    LinearLayout.LayoutParams lparams_img =
        new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1000);

    RelativeLayout.LayoutParams rparams_text =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    RelativeLayout.LayoutParams rparams_img =
        new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1000);

    lparams_text.gravity = Gravity.CENTER_HORIZONTAL;
    lparams_img.gravity = Gravity.CENTER_HORIZONTAL;

    if (questionDataLayout.getChildCount() != 0) {
      questionDataLayout.removeAllViewsInLayout();
    }
    QData data;
    for (int position = 0; position < elements.size(); position++) {
      data = elements.get(position);
      RelativeLayout rl = new RelativeLayout(getApplicationContext());

      if (data.isText()) {
        TextView tv = new TextView(this);
        tv.setLayoutParams(lparams_text);
        tv.setText(data.getText());
        tv.setTextSize(20);
        tv.setTextColor(Color.DKGRAY);
        tv.setOnClickListener(questionItemClickListener);
        tv.setOnLongClickListener(questionItemLongClickListener);
        rl.addView(tv, rparams_text);
        questionDataLayout.addView(rl, lparams_text);
      } else if (!data.isText()) {
        // ADD IMAGEVIEW
        ImageKeepAspectRatio iv = new ImageKeepAspectRatio(this);
        iv.setLayoutParams(lparams_img);
        iv.setImageBitmap(data.getImageBitmap());

        PhotoViewAttacher photoViewAttacher = new PhotoViewAttacher(iv);
        photoViewAttacher.setOnLongClickListener(questionItemLongClickListener);
        photoViewAttacher.setOnViewTapListener(
            new PhotoViewAttacher.OnViewTapListener() {
              @Override
              public void onViewTap(View view, float x, float y) {
                int index = questionDataLayout.indexOfChild(view);
                //                           scrollView.scrollTo(0,
                // questionDataLayout.getChildAt(index).getTop());

                // reset colors/boxes
                for (int i = 0; i < elements.size(); i++) {
                  circleIndex.get(i).setBorderColor(getResources().getColor(R.color.blue));
                  questionDataLayout.getChildAt(i).setBackground(null);
                }
                //                        circleIndex.get(index).setBorderColor(Color.WHITE);
                // TODO: WORKAROUND FOR API 16 CALL BELOW
                view.setBackground(rectShapeDrawable);
                selectedIndex = index;
              }
            });
        photoViewAttacher.update();

        rl.addView(iv, rparams_img);
        questionDataLayout.addView(rl, lparams_img);
      }
    }
  }
示例#17
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // .
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
      Mode = extras.getInt("Mode");
      String _IDs = extras.getString("IDs");
      if (_IDs != null) IDs = _IDs.split(",");
    }
    // .
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    // .
    setContentView(R.layout.sensorsmodule_meters_panel);
    // .
    lvMeters = (ListView) findViewById(R.id.lvMeters);
    lvMeters.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    lvMeters.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            boolean flChecked = lvMeters.isItemChecked(arg2);
            if (flChecked) { // . clear checking for all items with the same LocationID
              TSensorMeterInfo CheckedMeter = MetersInfo[arg2];
              if (CheckedMeter.Descriptor.LocationID.length() > 0) {
                int Cnt = MetersInfo.length;
                for (int I = 0; I < Cnt; I++)
                  if (I != arg2) {
                    TSensorMeterInfo Meter = MetersInfo[I];
                    if (Meter.Descriptor.LocationID.equals(CheckedMeter.Descriptor.LocationID))
                      lvMeters.setItemChecked(I, false);
                  }
              }
            }
          }
        });
    lvMeters.setOnItemLongClickListener(
        new OnItemLongClickListener() {

          @Override
          public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            if (MetersInfo == null) return false; // . ->
            Intent intent =
                new Intent(
                    TSensorsMetersPanel.this,
                    com.geoscope.GeoLog.DEVICE.SensorsModule.Meter.TSensorsMeterPanel.class);
            intent.putExtra("MeterID", MetersInfo[arg2].Descriptor.ID);
            intent.putExtra("MeterName", MetersInfo[arg2].Descriptor.Name);
            startActivity(intent);
            return true;
          }
        });
    // .
    btnUpdate = (Button) findViewById(R.id.btnUpdate);
    btnUpdate.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            StartUpdating();
          }
        });
    btnUpdate.setVisibility((Mode == MODE_NORMAL) ? View.VISIBLE : View.GONE);
    // .
    btnApplyChanges = (Button) findViewById(R.id.btnApplyChanges);
    btnApplyChanges.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            try {
              switch (Mode) {
                case MODE_NORMAL:
                  ApplyChanges();
                  break; // . >

                case MODE_SELECTOR:
                  String IDs = GetCheckItemsString();
                  if (IDs != null) {
                    Intent intent = getIntent();
                    // .
                    intent.putExtra("IDs", IDs);
                    // .
                    setResult(Activity.RESULT_OK, intent);
                    // .
                    finish();
                  }
                  break; // . >
              }
            } catch (Exception E) {
              Toast.makeText(TSensorsMetersPanel.this, E.getMessage(), Toast.LENGTH_LONG).show();
            }
          }
        });
    btnApplyChanges.setText((Mode == MODE_NORMAL) ? R.string.SApplyChanges : R.string.SSelect);
    // .
    final int HintID = THintManager.HINT__Long_click_to_edit_item_properties;
    final TextView lbListHint = (TextView) findViewById(R.id.lbListHint);
    String Hint = THintManager.GetHint(HintID, this);
    if (Hint != null) {
      lbListHint.setText(Hint);
      lbListHint.setOnLongClickListener(
          new OnLongClickListener() {

            @Override
            public boolean onLongClick(View v) {
              THintManager.SetHintAsDisabled(HintID);
              lbListHint.setVisibility(View.GONE);
              // .
              return true;
            }
          });
      // .
      lbListHint.setVisibility(View.VISIBLE);
    } else lbListHint.setVisibility(View.GONE);
    // .
    setResult(Activity.RESULT_CANCELED);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.emprunt_xml);
    String user = this.getIntent().getStringExtra("USER");
    TextView textUser = (TextView) findViewById(R.id.textViewEmprunts);

    textUser.setText("Emprunts de " + user);
    XMLParser XMl = new XMLParser();
    Livre livre = new Livre();
    InputStream inputStream = getResources().openRawResource(R.raw.livre);
    // InputStreamReader ipsr = new InputStreamReader(inputStream);
    // BufferedReader br = new BufferedReader(ipsr);
    try {
      livre = XMl.parse(inputStream);
    } catch (XmlPullParserException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }

    TextView livreUser = (TextView) findViewById(R.id.Livre);
    livreUser.setText(livre.toString());

    livreUser.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            AlertDialog.Builder builder = new AlertDialog.Builder(EmpruntsXML.this);
            builder.setMessage("Saisir la durée avant déclenchement (en sec)");
            builder.setTitle("PARAMETRER UNE ALERTE");

            final EditText dureeChoisie = new EditText(EmpruntsXML.this);
            LinearLayout.LayoutParams lp =
                new LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
            dureeChoisie.setLayoutParams(lp);
            builder.setView(dureeChoisie);

            builder.setPositiveButton(
                "Valider l'alerte",
                new DialogInterface.OnClickListener() {

                  public void onClick(DialogInterface dialog, int whichButton) {
                    String dureeAlerte = dureeChoisie.getText().toString();
                    int duree = Integer.parseInt(dureeAlerte);
                    Intent intent = new Intent(EmpruntsXML.this, TimerNotif.class);

                    PendingIntent pendingIntent =
                        PendingIntent.getBroadcast(
                            getApplicationContext(), 1, intent, PendingIntent.FLAG_ONE_SHOT);

                    AlarmManager alarmManager =
                        (AlarmManager) getSystemService(Context.ALARM_SERVICE);
                    alarmManager.set(
                        AlarmManager.RTC_WAKEUP,
                        System.currentTimeMillis() + (1000 * duree),
                        pendingIntent);
                  }
                });
            builder.show();
          }
        });

    livreUser.setOnLongClickListener(
        new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View v) {
            AlertDialog.Builder builderPenalite = new AlertDialog.Builder(EmpruntsXML.this);
            builderPenalite.setMessage("Pénalités sur les emprunts en retard");
            builderPenalite.setTitle("VOIR MES PENALITES");

            builderPenalite.setPositiveButton(
                "OK",
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int whichButton) {
                    Intent intent = new Intent(EmpruntsXML.this, Penalites.class);
                    startActivity(intent);
                  }
                });

            builderPenalite.setNegativeButton(
                "Annuler",
                new DialogInterface.OnClickListener() {

                  public void onClick(DialogInterface dialog, int whichButton) {}
                });

            builderPenalite.show();
            return false;
          }
        });
  }
示例#19
0
 private void initNumericCell(TextView numericCell) {
   numericCell.setGravity(Gravity.CENTER);
   numericCell.setTextColor(getResources().getColor(R.color.numeric_tile_text));
   numericCell.setOnClickListener(this);
   numericCell.setOnLongClickListener(this);
 }
  protected boolean addFingerprintRowWithListeners(
      LinearLayout keys,
      final Account account,
      final String fingerprint,
      boolean highlight,
      XmppAxolotlSession.Trust trust,
      boolean showTag,
      CompoundButton.OnCheckedChangeListener onCheckedChangeListener,
      View.OnClickListener onClickListener,
      View.OnClickListener onKeyClickedListener) {
    if (trust == XmppAxolotlSession.Trust.COMPROMISED) {
      return false;
    }
    View view = getLayoutInflater().inflate(R.layout.contact_key, keys, false);
    TextView key = (TextView) view.findViewById(R.id.key);
    key.setOnClickListener(onKeyClickedListener);
    TextView keyType = (TextView) view.findViewById(R.id.key_type);
    keyType.setOnClickListener(onKeyClickedListener);
    Switch trustToggle = (Switch) view.findViewById(R.id.tgl_trust);
    trustToggle.setVisibility(View.VISIBLE);
    trustToggle.setOnCheckedChangeListener(onCheckedChangeListener);
    trustToggle.setOnClickListener(onClickListener);
    final View.OnLongClickListener purge =
        new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View v) {
            showPurgeKeyDialog(account, fingerprint);
            return true;
          }
        };
    view.setOnLongClickListener(purge);
    key.setOnLongClickListener(purge);
    keyType.setOnLongClickListener(purge);
    boolean x509 =
        trust == XmppAxolotlSession.Trust.TRUSTED_X509
            || trust == XmppAxolotlSession.Trust.INACTIVE_TRUSTED_X509;
    switch (trust) {
      case UNTRUSTED:
      case TRUSTED:
      case TRUSTED_X509:
        trustToggle.setChecked(trust.trusted(), false);
        trustToggle.setEnabled(trust != XmppAxolotlSession.Trust.TRUSTED_X509);
        if (trust == XmppAxolotlSession.Trust.TRUSTED_X509) {
          trustToggle.setOnClickListener(null);
        }
        key.setTextColor(getPrimaryTextColor());
        keyType.setTextColor(getSecondaryTextColor());
        break;
      case UNDECIDED:
        trustToggle.setChecked(false, false);
        trustToggle.setEnabled(false);
        key.setTextColor(getPrimaryTextColor());
        keyType.setTextColor(getSecondaryTextColor());
        break;
      case INACTIVE_UNTRUSTED:
      case INACTIVE_UNDECIDED:
        trustToggle.setOnClickListener(null);
        trustToggle.setChecked(false, false);
        trustToggle.setEnabled(false);
        key.setTextColor(getTertiaryTextColor());
        keyType.setTextColor(getTertiaryTextColor());
        break;
      case INACTIVE_TRUSTED:
      case INACTIVE_TRUSTED_X509:
        trustToggle.setOnClickListener(null);
        trustToggle.setChecked(true, false);
        trustToggle.setEnabled(false);
        key.setTextColor(getTertiaryTextColor());
        keyType.setTextColor(getTertiaryTextColor());
        break;
    }

    if (showTag) {
      keyType.setText(
          getString(x509 ? R.string.omemo_fingerprint_x509 : R.string.omemo_fingerprint));
    } else {
      keyType.setVisibility(View.GONE);
    }
    if (highlight) {
      keyType.setTextColor(getResources().getColor(R.color.accent));
      keyType.setText(
          getString(
              x509
                  ? R.string.omemo_fingerprint_x509_selected_message
                  : R.string.omemo_fingerprint_selected_message));
    } else {
      keyType.setText(
          getString(x509 ? R.string.omemo_fingerprint_x509 : R.string.omemo_fingerprint));
    }

    key.setText(CryptoHelper.prettifyFingerprint(fingerprint.substring(2)));
    keys.addView(view);
    return true;
  }
  @Override
  public void bindView(View view, Context context, Cursor cursor) {
    if (cursor == null) {
      return;
    }
    // set the Item's ID so it can be retrieved latter in the onClick callbacks
    long itemID = cursor.getLong(cursor.getColumnIndex(ItemsTable.COL_ID));
    view.setTag(itemID);

    TextView tvItemName = (TextView) view.findViewById(R.id.tvItemName);
    tvItemsSeparator = (TextView) view.findViewById(R.id.tvItemsSeparator);
    if (tvItemName == null || tvItemsSeparator == null) {
      return;
    }

    // set the tvItemName text to the item's name and add the note if it's avaiable.
    String itemName = cursor.getString(cursor.getColumnIndex(ItemsTable.COL_ITEM_NAME));
    String itemNote = cursor.getString(cursor.getColumnIndex(ItemsTable.COL_ITEM_NOTE));

    if (!itemNote.isEmpty()) {
      itemName = itemName + " (" + itemNote + ")";
    }
    tvItemName.setText(itemName);

    // set tvItemName typeface
    boolean isStruckOut = cursor.getInt(cursor.getColumnIndex(ItemsTable.COL_STRUCK_OUT)) > 0;
    if (isStruckOut) {
      // item has been struck out
      tvItemName.setTypeface(null, Typeface.ITALIC);
      // tvItemName.setTextColor(this.mListSettings.getItemStrikeoutTextColor());
      tvItemName.setPaintFlags(tvItemName.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
    } else {
      // item is NOT struck out
      tvItemName.setTypeface(null, Typeface.NORMAL);
      // tvItemName.setTextColor(this.mListSettings.getItemNormalTextColor());
      tvItemName.setPaintFlags(tvItemName.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
    }

    // show separator header as appropriate
    switch (mStoreItemsSortingOrder) {
      case MySettings.SORT_ALPHABETICAL:
        tvItemsSeparator.setVisibility(View.GONE);
        break;

      case MySettings.SORT_BY_GROUP:
        if (showGroupSeparator(cursor)) {
          String separatorText =
              cursor.getString(cursor.getColumnIndex(GroupsTable.COL_GROUP_NAME));
          long groupID = cursor.getLong(cursor.getColumnIndex(StoreMapsTable.COL_GROUP_ID));
          long locationID = cursor.getLong(cursor.getColumnIndex(StoreMapsTable.COL_LOCATION_ID));
          String locationName =
              cursor.getString(cursor.getColumnIndex(LocationsTable.COL_LOCATION_NAME));
          if (!locationName.isEmpty() && groupID > 1) {
            if (locationID > 1) {
              separatorText = separatorText + " (" + locationName + ")";
            } else {
              separatorText = separatorText + " " + locationName;
            }
            tvItemsSeparator.setText(separatorText);
          }
        }
        break;

      case MySettings.SORT_BY_AISLE:
        if (showAisleSeparator(cursor)) {
          String separatorText =
              cursor.getString(cursor.getColumnIndex(LocationsTable.COL_LOCATION_NAME));
          tvItemsSeparator.setText(separatorText);
        }
        break;

      case MySettings.SORT_MANUALLY:
        break;
    }

    tvItemName.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            LinearLayout viewParent = (LinearLayout) v.getParent();
            long itemID = (long) viewParent.getTag();
            EventBus.getDefault().post(new MyEvents.toggleItemStrikeOut(itemID));
          }
        });

    tvItemName.setOnLongClickListener(
        new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View v) {
            LinearLayout viewParent = (LinearLayout) v.getParent();
            long itemID = (long) viewParent.getTag();
            EventBus.getDefault().post(new MyEvents.showEditItemDialog(itemID));
            return true;
          }
        });

    tvItemsSeparator.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            LinearLayout viewParent = (LinearLayout) v.getParent();
            long itemID = (long) viewParent.getTag();
            long groupID;
            long currentLocationID;
            Cursor cursor = ItemsTable.getItemCursor(mContext, itemID);
            if (cursor != null && cursor.getCount() > 0) {
              cursor.moveToFirst();
              groupID = cursor.getLong(cursor.getColumnIndex(ItemsTable.COL_GROUP));
              if (groupID > 1) {
                currentLocationID = StoreMapsTable.getLocationID(mContext, groupID, mStoreID);
                switch (mStoreItemsSortingOrder) {
                  case MySettings.SORT_ALPHABETICAL:
                    // do nothing
                    break;

                  case MySettings.SORT_BY_GROUP:
                    EventBus.getDefault()
                        .post(
                            new MyEvents.showSelectGroupLocationDialog(
                                itemID, groupID, currentLocationID, mStoreID));
                    break;

                  case MySettings.SORT_BY_AISLE:
                    // TODO: Show select location for sort by aisle
                    break;

                  case MySettings.SORT_MANUALLY:
                    // TODO: Show select location for manual sort
                    break;
                }
              }
            }
          }
        });
  }
    private void addItem(final Reminder reminder) {
      final int reminderID = reminder.getId();
      String title = reminder.getTitle();
      String billedAmt = String.valueOf(reminder.getBilledAmount());
      String paidAmt = String.valueOf(reminder.getPaidAmount());
      String unpaidAmt = String.valueOf(Double.valueOf(billedAmt) - Double.valueOf(paidAmt));
      String dueDate = reminder.getDueDate();

      int days = Integer.parseInt(TimeUtils.getDateDiffStr(dueDate));

      // Instantiate a new "row" view.
      final ViewGroup newView =
          (ViewGroup)
              LayoutInflater.from(context)
                  .inflate(R.layout.layoutchange_list_item, mContainerView, false);

      newView.setOnLongClickListener(
          new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
              flipCard(reminder);
              return true;
            }
          });

      // Set the text in the new row to a random country.
      TextView reminderTitleView = (TextView) newView.findViewById(R.id.reminderTitle);
      reminderTitleView.setText(title);
      reminderTitleView.setOnLongClickListener(
          new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
              flipCard(reminder);
              return true;
            }
          });

      TextView reminderAmtView = (TextView) newView.findViewById(R.id.reminderAmtInfo);
      reminderAmtView.setText("$" + unpaidAmt + " out of " + billedAmt + " unpaid");
      reminderAmtView.setOnLongClickListener(
          new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
              flipCard(reminder);
              return true;
            }
          });

      TextView reminderDateView = (TextView) newView.findViewById(R.id.reminderDateInfo);
      if (days <= 1) reminderDateView.setText(days + " day unitl " + dueDate);
      else reminderDateView.setText(days + " days unitl " + dueDate);
      reminderDateView.setOnLongClickListener(
          new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
              flipCard(reminder);
              return true;
            }
          });

      // Set a click listener for the "X" button in the row that will remove the row.
      newView
          .findViewById(R.id.delete_button)
          .setOnClickListener(
              new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                  AlarmManagerBroadcastReceiver alarm = new AlarmManagerBroadcastReceiver();
                  alarm.cancelAlarm(context, reminderID);

                  dbManager.deleteReminder(reminderID);

                  // Remove the row from its parent (the container view).
                  // Because mContainerView has android:animateLayoutChanges set to true,
                  // this removal is automatically animated.
                  mContainerView.removeView(newView);

                  // If there are no rows remaining, show the empty view.
                  if (mContainerView.getChildCount() == 0) emptyText.setVisibility(View.VISIBLE);
                }
              });

      // Because mContainerView has android:animateLayoutChanges set to true,
      // adding this view is automatically animated.
      mContainerView.addView(newView, 0);
    }
 public void onCreate(Bundle paramBundle)
 {
   Cursor localCursor = null;
   super.onCreate(paramBundle);
   fv = ViewConfiguration.get(kNN.kOg).getScaledTouchSlop();
   hMi = ((ClipboardManager)getSystemService("clipboard"));
   deK = findViewById(2131759452);
   hLQ = findViewById(2131759457);
   hLR = findViewById(2131759459);
   hLT = ((TextView)findViewById(2131759456));
   hLU = ((Button)findViewById(2131759454));
   hLS = ((LinearLayout)findViewById(2131759453));
   dEQ = ((ScrollView)findViewById(2131756093));
   hMg = new View.OnTouchListener()
   {
     public final boolean onTouch(View paramAnonymousView, MotionEvent paramAnonymousMotionEvent)
     {
       switch (paramAnonymousMotionEvent.getAction())
       {
       case 2: 
       default: 
       case 0: 
         do
         {
           return false;
           VoiceTransTextUI.c(VoiceTransTextUI.this);
           VoiceTransTextUI.a(VoiceTransTextUI.this, paramAnonymousView.getScrollY());
           VoiceTransTextUI.b(VoiceTransTextUI.this, VoiceTransTextUI.d(VoiceTransTextUI.this));
           VoiceTransTextUI.e(VoiceTransTextUI.this).removeMessages(0);
         } while (!VoiceTransTextUI.f(VoiceTransTextUI.this));
         VoiceTransTextUI.g(VoiceTransTextUI.this);
         VoiceTransTextUI.a(VoiceTransTextUI.this, true);
         return false;
       }
       if (Math.abs(VoiceTransTextUI.h(VoiceTransTextUI.this) - paramAnonymousView.getScrollY()) > VoiceTransTextUI.i(VoiceTransTextUI.this)) {
         VoiceTransTextUI.e(VoiceTransTextUI.this).sendMessage(VoiceTransTextUI.e(VoiceTransTextUI.this).obtainMessage(0, paramAnonymousView));
       }
       if ((VoiceTransTextUI.j(VoiceTransTextUI.this) < 800L) && (Math.abs(VoiceTransTextUI.h(VoiceTransTextUI.this) - paramAnonymousView.getScrollY()) <= VoiceTransTextUI.i(VoiceTransTextUI.this)) && (!VoiceTransTextUI.k(VoiceTransTextUI.this)))
       {
         VoiceTransTextUI.e(VoiceTransTextUI.this).removeMessages(0);
         VoiceTransTextUI.l(VoiceTransTextUI.this);
         finish();
       }
       VoiceTransTextUI.a(VoiceTransTextUI.this, false);
       return false;
     }
   };
   hLT.setOnLongClickListener(hMj);
   hLT.setOnClickListener(hMh);
   bbT = getIntent().getExtras().getLong("voice_trans_text_msg_id", -1L);
   int i;
   if (bbT < 0L) {
     i = 0;
   }
   for (;;)
   {
     if (i == 0)
     {
       v.d("MicroMsg.VoiceTransTextUI", "error invalid msgId");
       return;
       v.i("MicroMsg.VoiceTransTextUI", "msg Id:%d", new Object[] { Long.valueOf(bbT) });
       au localau = com.tencent.mm.modelvoice.m.ER();
       long l = bbT;
       if (l < 0L) {
         paramBundle = localCursor;
       }
       for (;;)
       {
         hLY = paramBundle;
         if ((hLY == null) || (be.kf(hLY.field_content))) {
           break label360;
         }
         v.i("MicroMsg.VoiceTransTextUI", "get voiceTransText");
         i = 1;
         break;
         paramBundle = new at();
         localCursor = bkP.query("VoiceTransText", null, "msgId=?", new String[] { String.valueOf(l) }, null, null, null);
         if (localCursor.getCount() > 0)
         {
           localCursor.moveToFirst();
           paramBundle.b(localCursor);
         }
         localCursor.close();
       }
       label360:
       paramBundle = getIntent().getExtras().getString("voice_trans_text_img_path");
       if (be.kf(paramBundle))
       {
         i = 0;
         continue;
       }
       hLX = com.tencent.mm.modelvoice.m.EQ().kS(paramBundle);
       if (hLX != null)
       {
         v.i("MicroMsg.VoiceTransTextUI", "get voiceInfo");
         i = 1;
         continue;
       }
       hLZ = com.tencent.mm.model.ah.tE().rt().dQ(bbT);
       if (hLZ != null)
       {
         v.i("MicroMsg.VoiceTransTextUI", "get MsgInfo");
         i = 1;
       }
     }
     else
     {
       paramBundle = iW.aP();
       if (paramBundle != null) {
         paramBundle.hide();
       }
       Gy();
       return;
     }
     i = 0;
   }
 }
  @Override
  public View getItemView(Item item, View view, ViewGroup parent) {
    ShoppingListViewHolder holder;

    if (view == null) {
      view = mInflater.inflate(R.layout.row_shopping_list, parent, false);
      holder = new ShoppingListViewHolder();
      holder.tvSelectedItem = (TextView) view.findViewById(R.id.tvSelectedItem);
      view.setTag(holder);
    } else {
      holder = (ShoppingListViewHolder) view.getTag();
    }

    TextView tvSelectedItem = holder.tvSelectedItem;
    String selectedItemText = item.getItemName();
    if (!item.getItemNote().isEmpty()) {
      selectedItemText = selectedItemText + " (" + item.getItemNote() + ")";
    }
    tvSelectedItem.setText(selectedItemText);

    if (item.isStruckOut()) {
      setStrikeOut(tvSelectedItem);
    } else {
      setNoStrikeOut(tvSelectedItem);
    }

    // save the item so it can be retrieved later
    tvSelectedItem.setTag(item);

    tvSelectedItem.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            TextView tv = (TextView) v;
            final Item item = (Item) v.getTag();

            // toggle the item's struckOut attribute
            Item.setStruckOut(mContext, item, !item.isStruckOut());

            // save the now dirty item to the local datastore
            // item.pinInBackground();

            // set the TextView's attributes to either strikeout or normal as appropriate
            if (item.isStruckOut()) {
              setStrikeOut(tv);
            } else {
              setNoStrikeOut(tv);
            }
          }
        });

    tvSelectedItem.setOnLongClickListener(
        new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View v) {
            Item item = (Item) v.getTag();
            MyLog.i(
                "ShoppingListAdapter", "tvSelectedItem OnLongClick: Item " + item.getItemName());
            EventBus.getDefault().post(new MyEvents.showEditItemDialog(item.getItemID()));
            return true;
          }
        });

    return view;
  }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    // Look up the AdView as a resource and load a request.
    AdView adView = (AdView) this.findViewById(R.id.adView);
    adView.loadAd(new AdRequest());

    // delete button listener
    OnClickListener DeleteButtonListner =
        new OnClickListener() {
          public void onClick(View v) {
            yesnoDeleteHandler("Are you sure?", "Are you sure you want to delete?");
          }
        };
    Button deleteButton = (Button) findViewById(R.id.delete);
    deleteButton.setOnClickListener(DeleteButtonListner);

    // save button listener
    OnClickListener SaveButtonListner =
        new OnClickListener() {
          public void onClick(View v) {
            saveCurrentPyramid(v.getContext());
          }
        };
    Button saveButton = (Button) findViewById(R.id.save);
    saveButton.setOnClickListener(SaveButtonListner);

    // new button listener
    OnClickListener newButtonListner =
        new OnClickListener() {
          public void onClick(View v) {
            newPyramid();
          }
        };
    Button newPButton = (Button) findViewById(R.id.newrow);
    newPButton.setOnClickListener(newButtonListner);

    // dots button listener
    OnClickListener topDotsListner =
        new OnClickListener() {
          public void onClick(View v) {
            TextView topCheckBox = (TextView) findViewById(R.id.TopItemCheckBox);
            String blockname = topCheckBox.getText().toString();
            switchToTextView(v.getContext(), blockname);
          }
        };
    OnClickListener dotsOneListner =
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox cb = (CheckBox) findViewById(R.id.itemOneCheckBox);
            String blockname = cb.getText().toString();
            switchToTextView(v.getContext(), blockname);
          }
        };
    OnClickListener dotsTwoListner =
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox cb = (CheckBox) findViewById(R.id.itemTwoCheckBox);
            String blockname = cb.getText().toString();
            switchToTextView(v.getContext(), blockname);
          }
        };
    OnClickListener dotsThreeListner =
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox cb = (CheckBox) findViewById(R.id.itemThreeCheckBox);
            String blockname = cb.getText().toString();
            switchToTextView(v.getContext(), blockname);
          }
        };
    OnClickListener dotsFourListner =
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox cb = (CheckBox) findViewById(R.id.itemFourCheckBox);
            String blockname = cb.getText().toString();
            switchToTextView(v.getContext(), blockname);
          }
        };
    OnClickListener dotsFiveListner =
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox cb = (CheckBox) findViewById(R.id.itemFiveCheckBox);
            String blockname = cb.getText().toString();
            switchToTextView(v.getContext(), blockname);
          }
        };
    OnClickListener dotsSixListner =
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox cb = (CheckBox) findViewById(R.id.itemSixCheckBox);
            String blockname = cb.getText().toString();
            switchToTextView(v.getContext(), blockname);
          }
        };

    Button topDotsButton = (Button) findViewById(R.id.topdots);
    Button DotsOneButton = (Button) findViewById(R.id.dotsOne);
    Button DotsTwoButton = (Button) findViewById(R.id.dotsTwo);
    Button DotsThreeButton = (Button) findViewById(R.id.dotsThree);
    Button DotsFourButton = (Button) findViewById(R.id.dotsFour);
    Button DotsFiveButton = (Button) findViewById(R.id.dotsFive);
    Button DotsSixButton = (Button) findViewById(R.id.dotsSix);

    topDotsButton.setOnClickListener(topDotsListner);
    DotsOneButton.setOnClickListener(dotsOneListner);
    DotsTwoButton.setOnClickListener(dotsTwoListner);
    DotsThreeButton.setOnClickListener(dotsThreeListner);
    DotsFourButton.setOnClickListener(dotsFourListner);
    DotsFiveButton.setOnClickListener(dotsFiveListner);
    DotsSixButton.setOnClickListener(dotsSixListner);

    // image listeners
    // photo on click listener
    ImageView imageOne = (ImageView) findViewById(R.id.ImageViewOne);
    ImageView imageTwo = (ImageView) findViewById(R.id.ImageViewTwo);
    ImageView imageThree = (ImageView) findViewById(R.id.ImageViewThree);
    ImageView imageFour = (ImageView) findViewById(R.id.ImageViewFour);
    ImageView imageFive = (ImageView) findViewById(R.id.ImageViewFive);
    ImageView imageSix = (ImageView) findViewById(R.id.ImageViewSix);
    ImageView imageTop = (ImageView) findViewById(R.id.TopBlockImage);

    // Create an anonymous implementation of OnClickListener
    OnLongClickListener TopNameListner =
        new OnLongClickListener() {
          public boolean onLongClick(View v) {
            // do something when the button is clicked

            // in onCreate or any event where your want the user to

            AlertDialog.Builder alert = new AlertDialog.Builder(v.getContext());

            alert.setTitle("Block Name?");
            alert.setMessage("Please Enter A Name For The Block");

            // Set an EditText view to get user input
            final EditText input = new EditText(v.getContext());
            alert.setView(input);

            alert.setPositiveButton(
                "Ok",
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int whichButton) {
                    tempName = input.getText().toString();

                    Cursor tempCursor = getPyramidCursorByName(tempName);
                    if (tempCursor.getCount() > 0) {
                      Toast.makeText(
                              getBaseContext(), "That Name is Already In Use!", Toast.LENGTH_LONG)
                          .show();
                    } else {
                      // Do something with value!
                      if (tempName.length() > 1) {
                        // select a file
                        TextView topCheckBox = (TextView) findViewById(R.id.TopItemCheckBox);
                        topCheckBox.setText(tempName);
                      } else {
                        Toast.makeText(getBaseContext(), "Invalid Name!", Toast.LENGTH_LONG).show();
                      }
                    }
                  }
                });

            alert.setNegativeButton(
                "Cancel",
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int whichButton) {
                    // Canceled.
                  }
                });

            alert.show();
            return true;
          }
        };
    TextView topCheckBox = (TextView) findViewById(R.id.TopItemCheckBox);
    topCheckBox.setOnLongClickListener(TopNameListner);

    // checkbox listeners
    // Create an anonymous implementation of OnClickListener
    OnLongClickListener otherNameListener =
        new OnLongClickListener() {
          public boolean onLongClick(final View v) {
            // do something when the button is clicked

            // in onCreate or any event where your want the user to

            AlertDialog.Builder alert = new AlertDialog.Builder(v.getContext());

            alert.setTitle("Block Name?");
            alert.setMessage("Please Enter A Name For The Block");

            // Set an EditText view to get user input
            final EditText input = new EditText(v.getContext());
            alert.setView(input);

            alert.setPositiveButton(
                "Ok",
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int whichButton) {
                    tempName = input.getText().toString();

                    // Do something with value!
                    if (tempName.length() > 1) {
                      // select a file
                    } else {
                      tempName = "Unnamed";
                    }

                    // set the correct view name
                    final CheckBox checkBoxOne = (CheckBox) findViewById(R.id.itemOneCheckBox);
                    final CheckBox checkBoxTwo = (CheckBox) findViewById(R.id.itemTwoCheckBox);
                    final CheckBox checkBoxThree = (CheckBox) findViewById(R.id.itemThreeCheckBox);
                    final CheckBox checkBoxFour = (CheckBox) findViewById(R.id.itemFourCheckBox);
                    final CheckBox checkBoxFive = (CheckBox) findViewById(R.id.itemFiveCheckBox);
                    final CheckBox checkBoxSix = (CheckBox) findViewById(R.id.itemSixCheckBox);

                    if (tempName != null) {
                      if (v.equals(checkBoxOne)) {
                        checkBoxOne.setText(tempName);
                      } else if (v.equals(checkBoxTwo)) {
                        checkBoxTwo.setText(tempName);
                      } else if (v.equals(checkBoxThree)) {
                        checkBoxThree.setText(tempName);
                      } else if (v.equals(checkBoxFour)) {
                        checkBoxFour.setText(tempName);
                      } else if (v.equals(checkBoxFive)) {
                        checkBoxFive.setText(tempName);
                      } else if (v.equals(checkBoxSix)) {
                        checkBoxSix.setText(tempName);
                      }
                    }
                  }
                });

            alert.setNegativeButton(
                "Cancel",
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int whichButton) {
                    // Canceled.
                    tempName = null;
                  }
                });

            alert.show();

            return true;
          }
        };

    CheckBox checkBoxOne = (CheckBox) findViewById(R.id.itemOneCheckBox);
    checkBoxOne.setOnLongClickListener(otherNameListener);
    CheckBox checkBoxTwo = (CheckBox) findViewById(R.id.itemTwoCheckBox);
    checkBoxTwo.setOnLongClickListener(otherNameListener);
    CheckBox checkBoxThree = (CheckBox) findViewById(R.id.itemThreeCheckBox);
    checkBoxThree.setOnLongClickListener(otherNameListener);
    CheckBox checkBoxFour = (CheckBox) findViewById(R.id.itemFourCheckBox);
    checkBoxFour.setOnLongClickListener(otherNameListener);
    CheckBox checkBoxFive = (CheckBox) findViewById(R.id.itemFiveCheckBox);
    checkBoxFive.setOnLongClickListener(otherNameListener);
    CheckBox checkBoxSix = (CheckBox) findViewById(R.id.itemSixCheckBox);
    checkBoxSix.setOnLongClickListener(otherNameListener);

    checkBoxOne.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox checkBoxOne = (CheckBox) findViewById(R.id.itemOneCheckBox);
            if (checkBoxOne.isChecked()) {
              checkBoxOne.setPaintFlags(checkBoxOne.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
            } else {
              checkBoxOne.setPaintFlags(checkBoxOne.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
            }
          }
        });

    checkBoxTwo.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox checkBoxTwo = (CheckBox) findViewById(R.id.itemTwoCheckBox);
            if (checkBoxTwo.isChecked()) {
              checkBoxTwo.setPaintFlags(checkBoxTwo.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
            } else {
              checkBoxTwo.setPaintFlags(checkBoxTwo.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
            }
          }
        });

    checkBoxThree.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox checkBoxThree = (CheckBox) findViewById(R.id.itemThreeCheckBox);
            if (checkBoxThree.isChecked()) {
              checkBoxThree.setPaintFlags(
                  checkBoxThree.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
            } else {
              checkBoxThree.setPaintFlags(
                  checkBoxThree.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
            }
          }
        });

    checkBoxFour.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox checkBoxFour = (CheckBox) findViewById(R.id.itemFourCheckBox);
            if (checkBoxFour.isChecked()) {
              checkBoxFour.setPaintFlags(
                  checkBoxFour.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
            } else {
              checkBoxFour.setPaintFlags(
                  checkBoxFour.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
            }
          }
        });

    checkBoxFive.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox checkBoxFive = (CheckBox) findViewById(R.id.itemFiveCheckBox);
            if (checkBoxFive.isChecked()) {
              checkBoxFive.setPaintFlags(
                  checkBoxFive.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
            } else {
              checkBoxFive.setPaintFlags(
                  checkBoxFive.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
            }
          }
        });

    checkBoxSix.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox checkBoxSix = (CheckBox) findViewById(R.id.itemSixCheckBox);
            if (checkBoxSix.isChecked()) {
              checkBoxSix.setPaintFlags(checkBoxSix.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
            } else {
              checkBoxSix.setPaintFlags(checkBoxSix.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
            }
          }
        });

    // image onlongclick listeners
    imageOne.setOnLongClickListener(
        new OnLongClickListener() {
          public boolean onLongClick(View v) {
            ImageView imageOne = (ImageView) findViewById(R.id.ImageViewOne);
            colorPicker(imageOne, v.getContext());
            return true;
          }
        });

    imageTwo.setOnLongClickListener(
        new OnLongClickListener() {
          public boolean onLongClick(View v) {
            ImageView imageOne = (ImageView) findViewById(R.id.ImageViewTwo);
            colorPicker(imageOne, v.getContext());
            return true;
          }
        });

    imageThree.setOnLongClickListener(
        new OnLongClickListener() {
          public boolean onLongClick(View v) {
            ImageView imageOne = (ImageView) findViewById(R.id.ImageViewThree);
            colorPicker(imageOne, v.getContext());
            return true;
          }
        });

    imageFour.setOnLongClickListener(
        new OnLongClickListener() {
          public boolean onLongClick(View v) {
            ImageView imageOne = (ImageView) findViewById(R.id.ImageViewFour);
            colorPicker(imageOne, v.getContext());
            return true;
          }
        });

    imageFive.setOnLongClickListener(
        new OnLongClickListener() {
          public boolean onLongClick(View v) {
            ImageView imageOne = (ImageView) findViewById(R.id.ImageViewFive);
            colorPicker(imageOne, v.getContext());
            return true;
          }
        });

    imageSix.setOnLongClickListener(
        new OnLongClickListener() {
          public boolean onLongClick(View v) {
            ImageView imageOne = (ImageView) findViewById(R.id.ImageViewSix);
            colorPicker(imageOne, v.getContext());
            return true;
          }
        });

    imageTop.setOnLongClickListener(
        new OnLongClickListener() {
          public boolean onLongClick(View v) {
            ImageView imageOne = (ImageView) findViewById(R.id.TopBlockImage);
            colorPicker(imageOne, v.getContext());
            return true;
          }
        });

    // set regular click listeners for the bottom 6 items
    imageOne.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox checkBoxOne = (CheckBox) findViewById(R.id.itemOneCheckBox);
            saveAndCreateNewFromName(v.getContext(), checkBoxOne.getText().toString());
          }
        });

    // set regular click listeners for the bottom 6 items
    imageTwo.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox checkBoxOne = (CheckBox) findViewById(R.id.itemTwoCheckBox);
            saveAndCreateNewFromName(v.getContext(), checkBoxOne.getText().toString());
          }
        });

    // set regular click listeners for the bottom 6 items
    imageThree.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox checkBoxOne = (CheckBox) findViewById(R.id.itemThreeCheckBox);
            saveAndCreateNewFromName(v.getContext(), checkBoxOne.getText().toString());
          }
        });

    // set regular click listeners for the bottom 6 items
    imageFour.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox checkBoxOne = (CheckBox) findViewById(R.id.itemFourCheckBox);
            saveAndCreateNewFromName(v.getContext(), checkBoxOne.getText().toString());
          }
        });

    // set regular click listeners for the bottom 6 items
    imageFive.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox checkBoxOne = (CheckBox) findViewById(R.id.itemFiveCheckBox);
            saveAndCreateNewFromName(v.getContext(), checkBoxOne.getText().toString());
          }
        });

    // set regular click listeners for the bottom 6 items
    imageSix.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            CheckBox checkBoxOne = (CheckBox) findViewById(R.id.itemSixCheckBox);
            saveAndCreateNewFromName(v.getContext(), checkBoxOne.getText().toString());
          }
        });

    fillImagesRandomly();

    // set an adapter for our spinner
    m_adapterForSpinner =
        new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_spinner_item);
    m_adapterForSpinner.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    Spinner spinner = (Spinner) findViewById(R.id.oldpyramids);
    spinner.setAdapter(m_adapterForSpinner);
    m_adapterForSpinner.add("*New Pyramid");

    spinner.setOnItemSelectedListener(new MyUnitsOnItemSelectedListener());

    // fill up our spinner item
    Cursor cursor = getPyramidssCursor();
    if (cursor.getCount() > 0) {
      deleteButton.setEnabled(true);
      while (cursor.moveToNext()) {
        String singlecardName = cursor.getString(1);
        m_adapterForSpinner.add(singlecardName);
      }
    } else {
      spinner.setEnabled(false);
    }
  }
示例#26
0
  /**
   * text类型的: 1. 设定内容Emoparser 2. 点击事件 单击跳转、 双击方法、长按pop menu 点击头像的事件 跳转
   *
   * @param position
   * @param convertView
   * @param viewGroup
   * @param isMine
   * @return
   */
  private View textMsgRender(
      final int position, View convertView, final ViewGroup viewGroup, final boolean isMine) {
    TextRenderView textRenderView;
    final TextMessage textMessage = (TextMessage) msgObjectList.get(position);
    UserEntity userEntity = imService.getContactManager().findContact(textMessage.getFromId());

    if (null == convertView) {
      textRenderView =
          TextRenderView.inflater(
              ctx, viewGroup, isMine); // new TextRenderView(ctx,viewGroup,isMine);
    } else {
      textRenderView = (TextRenderView) convertView;
    }

    final TextView textView = textRenderView.getMessageContent();

    // 失败事件添加
    textRenderView
        .getMessageFailed()
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View arg0) {
                MessageOperatePopup popup =
                    getPopMenu(viewGroup, new OperateItemClickListener(textMessage, position));
                popup.show(textView, DBConstant.SHOW_ORIGIN_TEXT_TYPE, true, isMine);
              }
            });

    textView.setOnLongClickListener(
        new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View v) {
            // 弹窗类型
            MessageOperatePopup popup =
                getPopMenu(viewGroup, new OperateItemClickListener(textMessage, position));
            boolean bResend = textMessage.getStatus() == MessageConstant.MSG_FAILURE;
            popup.show(textView, DBConstant.SHOW_ORIGIN_TEXT_TYPE, bResend, isMine);
            return true;
          }
        });

    // url 路径可以设定 跳转哦哦
    final String content = textMessage.getContent();
    textView.setOnTouchListener(
        new OnDoubleClickListener() {
          @Override
          public void onClick(View view) {
            // todo
          }

          @Override
          public void onDoubleClick(View view) {
            Intent intent = new Intent(ctx, PreviewTextActivity.class);
            intent.putExtra(IntentConstant.PREVIEW_TEXT_CONTENT, content);
            ctx.startActivity(intent);
          }
        });
    textRenderView.render(textMessage, userEntity, ctx);
    return textRenderView;
  }
  private void initView() {
    getTitleFragment();

    info = getIntent().getParcelableExtra("notice_info");
    if (info != null) {
      if (info.getIsRead() == 0) {
        info.setIsRead(1);
        uploadReadStatue(info);
      }
    }
    TextView timeTv = (TextView) findViewById(R.id.time);
    final TextView titleTv = (TextView) findViewById(R.id.title);
    final TextView contentTv = (TextView) findViewById(R.id.detail_content);
    TextView fromUserTv = (TextView) findViewById(R.id.from_user);
    iconIv = (ImageView) findViewById(R.id.icon);
    progressView = (ProgressView) findViewById(R.id.progressView);
    progressView.setVisibility(View.GONE);
    if (!TextUtils.isEmpty(info.getImage())) {
      // AsyncRequest.getBitmap(info.getImage(), new Listener<Bitmap>() {
      //
      // @Override
      // public void onResponse(Bitmap arg0) {
      // int oldWidth = arg0.getWidth();
      // int oldHeight = arg0.getHeight();
      // float f = ((float)width)/oldWidth;
      // int dheight = (int)(f*oldHeight);
      // Bitmap bm = Bitmap.createScaledBitmap(arg0, width, dheight,
      // false);
      // iconIv.setImageBitmap(bm);
      // }
      //
      // @Override
      // public void onErrorResponse(InvocationError arg0) {
      //
      // }
      // });

      MainApplication.getImageLoader().get(info.getImage(), imageWidth, 1, this, false);
    } else {
      iconIv.setVisibility(View.GONE);
    }
    String time = info.getCreateTime();
    try {
      Date date = BusinessConstants.parseTime(info.getCreateTime());
      SimpleDateFormat formart = new SimpleDateFormat("yy-MM-dd HH:mm");
      time = formart.format(date);
    } catch (ParseException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    timeTv.setText(time);
    titleTv.setText(info.getTitle());
    contentTv.setText(info.getContent());
    fromUserTv.setText(info.getFromUser());
    iconIv.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            if (!TextUtils.isEmpty(info.getImage())) {
              String[] url = info.getImage().split(",");
              ImageBrowser.launch(NotificationDetailActivity.this, url, 0);

              /*记录操作 0903*/
              OperaEventUtils.recordOperation(OperaEvent.OPERA_WATCH_NOTIFICATION_BIGIMAGE);
            }
          }
        });
    titleTv.setOnLongClickListener(
        new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View v) {
            CopyPopupWindow copyWindow = new CopyPopupWindow(NotificationDetailActivity.this);
            copyWindow.showAsDropDown(v, 0, dp2px(-5));
            copyWindow.setOnCopyListener(
                new CopyPopupWindow.OnCopyClickListener() {
                  @Override
                  public void onCopyClick() {
                    ClipboardUtils.copyToClipboard(titleTv.getText().toString());
                  }
                });
            return true;
          }
        });
    contentTv.setOnLongClickListener(
        new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View v) {
            CopyPopupWindow copyWindow = new CopyPopupWindow(NotificationDetailActivity.this);
            copyWindow.showAsDropDown(v, 0, dp2px(-20));
            copyWindow.setOnCopyListener(
                new CopyPopupWindow.OnCopyClickListener() {
                  @Override
                  public void onCopyClick() {
                    ClipboardUtils.copyToClipboard(contentTv.getText().toString());
                  }
                });
            return true;
          }
        });
  }
  @Override
  public View bindView(final int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
    final ChatMsg item = list.get(position);
    if (convertView == null) {
      convertView = createViewByType(item, position);
    }
    // 文本类型
    RoundImageView iv_avatar = ViewHolder.get(convertView, R.id.iv_avatar); // 圆形头像
    final ImageView iv_fail_resend = ViewHolder.get(convertView, R.id.iv_fail_resend); // 失败重发
    final TextView tv_send_status = ViewHolder.get(convertView, R.id.tv_send_status); // 发送状态
    TextView tv_time = ViewHolder.get(convertView, R.id.tv_time); // 发送时间
    TextView tv_message = ViewHolder.get(convertView, R.id.tv_message); // 文本内容
    // 图片
    ImageView iv_picture = ViewHolder.get(convertView, R.id.iv_picture);
    final ProgressBar progress_load = ViewHolder.get(convertView, R.id.progress_load); // 进度条
    // 语音
    final ImageView iv_voice = ViewHolder.get(convertView, R.id.iv_voice);
    final TextView tv_voice_length = ViewHolder.get(convertView, R.id.tv_voice_length); // 语音长度

    final ImageView iv_voice_tips = ViewHolder.get(convertView, R.id.iv_voice_tips);

    final boolean isTeamExist =
        DBUtil.isTeamExitByUuid(
            item.getBelongId().replace("@team", ""),
            UserManager.getInstance(mContext).getCurrentUser().getPlayer().getUuid());
    String avatar = item.getBelongAvatar();
    if (avatar != null && !avatar.equals("")) { // 加载头像-为了不每次都加载头像
      if (item.getBelongId().equals("System")) { // 云球团队
        ImageLoader.getInstance()
            .displayImage(
                avatar.trim(),
                iv_avatar,
                new DisplayImageOptions.Builder()
                    .showImageOnLoading(R.drawable.ic_launcher)
                    .showImageForEmptyUri(R.drawable.ic_launcher)
                    .showImageOnFail(R.drawable.ic_launcher)
                    .cacheInMemory(true)
                    .cacheOnDisk(true)
                    .build(),
                animateFirstListener);
      } else if (isTeamExist) {
        ImageLoader.getInstance()
            .displayImage(
                avatar.trim(),
                iv_avatar,
                new DisplayImageOptions.Builder()
                    .showImageOnLoading(R.drawable.team_bage_default)
                    .showImageForEmptyUri(R.drawable.team_bage_default)
                    .showImageOnFail(R.drawable.team_bage_default)
                    .cacheInMemory(true)
                    .cacheOnDisk(true)
                    .build(),
                animateFirstListener);
      } else {
        ImageLoader.getInstance()
            .displayImage(
                avatar.trim(),
                iv_avatar,
                new DisplayImageOptions.Builder()
                    .showImageOnLoading(R.drawable.icon_default_head)
                    .showImageForEmptyUri(R.drawable.icon_default_head)
                    .showImageOnFail(R.drawable.icon_default_head)
                    .cacheInMemory(true)
                    .cacheOnDisk(true)
                    .build(),
                animateFirstListener);
      }
    } else {
      iv_avatar.setImageResource(R.drawable.head);
    }

    // 点击头像进入个人资料("球员信息")
    iv_avatar.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View arg0) {
            Intent intent = new Intent();
            if (getItemViewType(position) == TYPE_RECEIVER_TXT
                || getItemViewType(position) == TYPE_RECEIVER_IMAGE
                || getItemViewType(position) == TYPE_RECEIVER_VOICE) {
              if (item.getBelongId().equals("System")) { // 云球团队
                // 不处理
              } else if (isTeamExist) { // 球队,不能用tag=group判断,因为球员的普通群聊消息的tag也是group
                intent.setClass(mContext, TeamInfoActivity.class);
                QueryBuilder<Team> teamQB =
                    CustomApplcation.getDaoSession(mContext).getTeamDao().queryBuilder();
                teamQB.where(TeamDao.Properties.Uuid.eq(item.getBelongId().replace("@team", "")));
                Team team = teamQB.unique();
                if (team == null || TextUtils.isEmpty(team.getUuid())) {
                  return;
                }
                intent.putExtra(TeamInfoActivity.INTENT_TEAM_INFO_BEAN, team);
                mContext.startActivity(intent);
              } else { // 球员
                String accountName = item.getConversationId().split("&")[0];
                // 先根据accountName获取得到用户的UUID
                getPlayerUidByAccountName(accountName);
              }
            } else {
              intent.setClass(mContext, SetMyInfoActivity.class);
              mContext.startActivity(intent);
            }
          }
        });

    // 以时间差显示
    if (position > 0) { // 从第二条消息开始显示时间差
      long preMsgTime = Long.parseLong(list.get(position - 1).getMsgTime()); // 前一条消息时间
      long currentMsgTime = Long.parseLong(list.get(position).getMsgTime()); // 当前消息时间
      if ((currentMsgTime - preMsgTime) / 1000 < 120) { // 计算两条消息时间间隔,小于两分钟则不显示时间
        tv_time.setVisibility(View.GONE);
      } else {
        tv_time.setVisibility(View.VISIBLE);
        tv_time.setText(TimeUtil.getChatTime(currentMsgTime));
      }
    } else { // 第一条消息直接显示时间
      tv_time.setText(TimeUtil.getChatTime(Long.parseLong(item.getMsgTime())));
    }

    int itemViewType = getItemViewType(position);
    if (itemViewType == TYPE_SEND_TXT
        // ||getItemViewType(position)==TYPE_SEND_IMAGE//图片单独处理
        || getItemViewType(position) == TYPE_SEND_VOICE) { // 只有自己发送的消息才有重发机制
      // 状态描述
      if (item.getStatus() == ChatConstants.STATUS_SEND_SUCCESS) { // 发送成功
        progress_load.setVisibility(View.INVISIBLE);
        iv_fail_resend.setVisibility(View.INVISIBLE);
        if (item.getMsgType().equals(ChatConstants.MSG_TYPE_AUDIO)) { // 如果是语音消息的话,显示语音长度
          tv_send_status.setVisibility(View.GONE);
          tv_voice_length.setVisibility(View.VISIBLE);
        } else { // 如果是文字消息的话则显示发送状态
          tv_send_status.setVisibility(View.VISIBLE);
          tv_send_status.setText("已发送");
        }
      } else if (item.getStatus()
          == ChatConstants.STATUS_SEND_FAIL) { // 服务器无响应或者查询失败等原因造成的发送失败,均需要重发
        progress_load.setVisibility(View.INVISIBLE);
        iv_fail_resend.setVisibility(View.VISIBLE); // 显示重发按钮
        iv_fail_resend.setOnClickListener(new OnResendClickListener(item, position));
        tv_send_status.setVisibility(View.INVISIBLE);
        if (item.getMsgType().equals(ChatConstants.MSG_TYPE_AUDIO)) {
          tv_voice_length.setVisibility(View.GONE);
        }
      } else if (item.getStatus() == ChatConstants.STATUS_SEND_START) { // 开始上传
        progress_load.setVisibility(View.VISIBLE); // 显示发送进度
        iv_fail_resend.setVisibility(View.INVISIBLE);
        tv_send_status.setVisibility(View.INVISIBLE);
        if (item.getMsgType().equals(ChatConstants.MSG_TYPE_AUDIO)) {
          tv_voice_length.setVisibility(View.GONE);
        }
      }
    }

    // 根据类型显示内容
    final String text = item.getContent();

    int msgTypeInt = getMsgTypeIntValue(item.getMsgType());

    switch (msgTypeInt) {
      case ChatConstants.TYPE_TEXT:
        try {
          SpannableString spannableString =
              FaceTextUtils.toSpannableString(mContext, text); // 转为可显示表情的字符串
          tv_message.setText(spannableString);
          tv_message.setOnClickListener(
              new OnClickListener() {

                @Override
                public void onClick(View v) {
                  // TODO 自动生成的方法存根
                  Intent intent = new Intent(mContext, BiggerTextSizeActivity.class);
                  intent.putExtra(ChatConstants.INTENT_TEXT_MESSAGE, text);
                  mContext.startActivity(intent);
                }
              });
          tv_message.setOnLongClickListener(new OnChatItemLongClickListener(item, position));
        } catch (Exception e) {
        }
        break;

      case ChatConstants.TYPE_IMAGE: // 图片类
        try {
          if (text != null && !text.equals("")) { // 发送成功之后存储的图片类型的content和接收到的是不一样的
            dealWithImage(
                position, progress_load, iv_fail_resend, tv_send_status, iv_picture, item);
          }
          iv_picture.setOnClickListener(
              new OnClickListener() { // 浏览大图

                @Override
                public void onClick(View arg0) {
                  Intent intent = new Intent(mContext, ImageBrowserActivity.class);
                  ArrayList<String> list = new ArrayList<String>();
                  for (int i = 0; i < ChatActivity.picUrls.size(); i++) {
                    list.add(ChatActivity.picUrls.valueAt(i));
                  }
                  intent.putStringArrayListExtra("photos", list);
                  intent.putExtra("position", ChatActivity.picUrls.indexOfValue(item.getContent()));
                  mContext.startActivity(intent);
                }
              });
          iv_picture.setOnLongClickListener(new OnChatItemLongClickListener(item, position));

        } catch (Exception e) {
        }
        break;

      case ChatConstants.TYPE_VOICE: // 语音消息
        try {
          if (text != null && !text.equals("")) {
            tv_voice_length.setVisibility(View.VISIBLE);
            final String localFilePath = Config.VOICE_DIR + MD5Util.getMD5(text.trim()) + ".amr";
            if (item.getBelongId().equals(currentUserAccountName)) { // 发送的消息
              if (item.getStatus() == ChatConstants.STATUS_SEND_RECEIVERED
                  || item.getStatus()
                      == ChatConstants.STATUS_SEND_SUCCESS) { // 当发送成功或者发送已阅读的时候,则显示语音长度
                tv_voice_length.setVisibility(View.VISIBLE);
                long duration = VoiceRecorder.getAmrDuration(new File(localFilePath));
                tv_voice_length.setText(duration + "\''");

              } else {
                tv_voice_length.setVisibility(View.INVISIBLE);
              }

            } else { // 收到的消息,则先下载下来
              iv_voice_tips.setVisibility(View.GONE); // 有出现一个Bug,就是有未读消息时,上下滑动消息记录,上方已读的语音消息又会出现红点
              if (!(new File(localFilePath).exists())) {
                final String netUrl = text.trim();
                DownloadManager downloadTask =
                    new DownloadManager(
                        new DownloadListener() {

                          @Override
                          public void onStart() {
                            // TODO Auto-generated method stub
                            progress_load.setVisibility(View.VISIBLE);
                            tv_voice_length.setVisibility(View.GONE);
                            iv_voice.setVisibility(View.INVISIBLE); // 只有下载完成才显示播放的按钮
                          }

                          @Override
                          public void onSuccess() {
                            // TODO Auto-generated method stub
                            try {
                              long duration = 0;
                              while (true) { // 取到真正语音长度为止,不能为0
                                duration = VoiceRecorder.getAmrDuration(new File(localFilePath));
                                if (duration != 0) break;
                              }
                              progress_load.setVisibility(View.GONE);
                              tv_voice_length.setVisibility(View.VISIBLE);
                              tv_voice_length.setText(duration + "\''");
                              iv_voice.setVisibility(View.VISIBLE);
                              iv_voice_tips.setVisibility(View.VISIBLE);
                            } catch (IOException e) {
                              // TODO 自动生成的 catch 块
                              e.printStackTrace();
                            }
                          }

                          @Override
                          public void onError(String error) {
                            // TODO Auto-generated method stub
                            progress_load.setVisibility(View.GONE);
                            tv_voice_length.setVisibility(View.GONE);
                            iv_voice.setVisibility(View.INVISIBLE);
                          }
                        });
                downloadTask.execute(netUrl, localFilePath);
              } else {
                long duration = VoiceRecorder.getAmrDuration(new File(localFilePath));
                tv_voice_length.setText(duration + "\''");
                if (item.getStatus() == ChatConstants.STATUS_UNPLAY) {
                  iv_voice_tips.setVisibility(View.VISIBLE);
                }
              }
            }
          }
          // 播放语音文件
          convertView.setOnClickListener(
              new NewRecordPlayClickListener(
                  mContext,
                  item,
                  iv_voice,
                  iv_voice_tips,
                  new OnPlayChangeListener() {

                    @Override
                    public void onPlayStop() {
                      // TODO 自动生成的方法存根
                      Intent intent = new Intent();
                      intent.setAction("chat.msg.playrecord");
                      mContext.sendBroadcast(intent);
                    }

                    @Override
                    public void onPlayStart() {
                      // TODO 自动生成的方法存根

                    }
                  }));
          convertView.setOnLongClickListener(new OnChatItemLongClickListener(item, position));
        } catch (Exception e) {

        }
        break;
      default:
        break;
    }
    return convertView;
  }
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
      View view =
          LayoutInflater.from(BookDescriptionActivity.this).inflate(R.layout.book_desc_data, null);
      // initiate widgets
      TextView description = (TextView) view.findViewById(R.id.book_desc_txt);
      TextView verseNo = (TextView) view.findViewById(R.id.book_desc_verseno_txt);
      // set the verse string to show
      verseNo.setText(EBibleConstants.verseListToHighlight.get(position));
      description.setText(
          EBibleConstants.contentListToHighlight.get(position), BufferType.SPANNABLE);

      /*Log.i("vesre contains in adapter",""+highlightedMatchedVerseArr.contains(EBibleConstants.verseListToHighlight.get(position)));
      Log.i("db saved verse at position",""+highlightedMatchedVerseArr.get(position));
      Log.i("saved verse at position",""+EBibleConstants.verseListToHighlight.get(position));
      Log.i("verse position matched",""+(highlightedMatchedVerseArr.get(position).equalsIgnoreCase((EBibleConstants.verseListToHighlight.get(position)))));*/
      // highlight functionality if found
      Spannable textToSpan = (Spannable) description.getText();
      if ((highlightedMatchedDescriptionArr.size() > 0)) {
        for (int count = 0; count < highlightedMatchedDescriptionArr.size(); count++) {
          if (highlightedMatchedDescriptionArr.get(count) != null /*&&
					(highlightedMatchedVerseArr.get(position).equalsIgnoreCase(
							(EBibleConstants.verseListToHighlight.get(position))))*/) {
            /*Log.i("verse matched desc in loop",""+highlightedMatchedDescriptionArr.get(count).equalsIgnoreCase
            			(highlightedMatchedVerseArr.get(position)));
            if(highlightedMatchedDescriptionArr.get(count).equalsIgnoreCase
            		(highlightedMatchedVerseArr.get(position)))
            {*/
            int index =
                EBibleConstants.contentListToHighlight
                    .get(position)
                    .indexOf(highlightedMatchedDescriptionArr.get(count), 0);
            // .indexOf(highlightedMatchedDescriptionArr.get(count));
            Log.i("index", "" + index);
            if (index > -1
                && (highlightedMatchedVerseArr
                    .get(count)
                    .equalsIgnoreCase(EBibleConstants.verseListToHighlight.get(position)))) {
              textToSpan.setSpan(
                  new BackgroundColorSpan(
                      Integer.parseInt(highlightedMatchedColorCodeArr.get(count))),
                  index,
                  (index + highlightedMatchedDescriptionArr.get(count).length()),
                  Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

              // check for underline
              if (highlightedMatchedUnderlineArr.get(count).equalsIgnoreCase("1")) {
                textToSpan.setSpan(
                    new UnderlineSpan(),
                    index,
                    (index + highlightedMatchedDescriptionArr.get(count).length()),
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
              }
            }
          }
          // }
        }
        description.setText(textToSpan);
      }

      // set the buttons state as enable or disable respect to data fetched from file
      if (EBibleConstants.pageNumber < (EBibleConstants.lastParaValue)) {
        next.setEnabled(true);
      } else {
        next.setEnabled(false);
      }
      if (EBibleConstants.pageNumber == (EBibleConstants.startParaNumber)) {
        previous.setEnabled(false);
      } else {
        previous.setEnabled(true);
      }

      description.setOnLongClickListener(
          new View.OnLongClickListener() {

            @Override
            public boolean onLongClick(View v) {
              Log.i("", "selected chapter " + selectedChapterName);
              versePositionToHighlighten = position;
              verseHighlightedPositionToStore = EBibleConstants.verseListToHighlight.get(position);
              // start the highlight view dialog
              new HighlightDialog(
                  BookDescriptionActivity.this,
                  selectedBookName,
                  selectedChapterPosition,
                  position);
              return false;
            }
          });

      return view;
    }
示例#30
0
 @Override
 public void setOnLongClickListener(OnLongClickListener l) {
   mTriggerButton.setOnLongClickListener(l);
   mStringAnswer.setOnLongClickListener(l);
 }