Пример #1
5
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      LayoutInflater inflater =
          (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      View rowView = inflater.inflate(R.layout.list_item_icon, parent, false);
      TextView textView = (TextView) rowView.findViewById(R.id.label);

      ImageView imageView = (ImageView) rowView.findViewById(R.id.icon);
      textView.setText(mValues[position]);

      // Set icons
      String s = mValues[position];
      if (s.equals("CPU")) {
        imageView.setImageResource(R.drawable.ic_drawer_cpu);
      } else if (s.equals("System")) {
        imageView.setImageResource(R.drawable.ic_drawer_system);
      } else if (s.equals("Disks")) {
        imageView.setImageResource(R.drawable.ic_drawer_disks);
      } else if (s.equals("Processes")) {
        imageView.setImageResource(R.drawable.ic_drawer_processes);
      } else if (s.equals("GPU")) {
        imageView.setImageResource(R.drawable.ic_drawer_gpu);
      } else if (s.equals("Overview")) {
        imageView.setImageResource(R.drawable.ic_drawer_overview);
      } else if (s.equals("History")) {
        imageView.setImageResource(R.drawable.ic_drawer_history);
      } else if (s.equals("Notifications")) {
        imageView.setImageResource(R.drawable.ic_drawer_notifications);
      }
      imageView.setContentDescription(s + " icon");

      return rowView;
    }
Пример #2
0
    public View getView(int position, View convertView, ViewGroup parent) {
      final View view =
          (convertView != null)
              ? convertView
              : LayoutInflater.from(parent.getContext())
                  .inflate(R.layout.bookmark_item, parent, false);
      final ImageView imageView = (ImageView) view.findViewById(R.id.bookmark_item_icon);
      final TextView textView = (TextView) view.findViewById(R.id.bookmark_item_text);
      final TextView bookTitleView = (TextView) view.findViewById(R.id.bookmark_item_booktitle);

      final Bookmark bookmark = getItem(position);
      if (bookmark == null) {
        imageView.setVisibility(View.VISIBLE);
        imageView.setImageResource(R.drawable.ic_list_plus);
        textView.setText(ZLResource.resource("bookmarksView").getResource("new").getValue());
        bookTitleView.setVisibility(View.GONE);
      } else {
        imageView.setVisibility(View.GONE);
        textView.setText(bookmark.getText());
        if (myCurrentBook) {
          bookTitleView.setVisibility(View.GONE);
        } else {
          bookTitleView.setVisibility(View.VISIBLE);
          bookTitleView.setText(bookmark.getBookTitle());
        }
      }
      return view;
    }
Пример #3
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      ViewHolder holder;
      if (convertView == null) {
        holder = new ViewHolder();
        convertView = LayoutInflater.from(getActivity()).inflate(R.layout.item_song, null);
        holder.mTvName = (TextView) convertView.findViewById(R.id.tv_name);
        holder.mTvArtist = (TextView) convertView.findViewById(R.id.tv_artist);
        holder.mTvDuration = (TextView) convertView.findViewById(R.id.tv_duration);
        holder.aboveView = convertView.findViewById(R.id.item_root);
        holder.behindView = convertView.findViewById(R.id.behind);
        convertView.setTag(holder);
        convertViewList.add((PullRightLayout) convertView);
      } else {
        holder = (ViewHolder) convertView.getTag();
      }
      if (HideApplication.showListAnim) {
        startAnim(convertView);
      }

      SongInfo info = SongManager.with(getActivity()).getSongByIndex(position);
      holder.mTvName.setText(info.getTitle());
      holder.mTvArtist.setText(info.getArtist() + " - " + info.getAlbum());
      holder.mTvDuration.setText(
          CommonUtils.durationToString(info.getDuration())
              + " - "
              + CommonUtils.getFileSize(info.getPath()));

      setItemSelected(holder, info.getId() == playingId);

      convertView.setOnClickListener(new OnItemClick(position));
      holder.behindView.setOnClickListener(new OnBehindClick(position));

      return convertView;
    }
Пример #4
0
  private void initViews(Context context, int customLeftMenuId, int customRightMenuId) {
    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.residemenu_custom, this);

    if (customLeftMenuId >= 0) {
      scrollViewLeftMenu = inflater.inflate(customLeftMenuId, this, false);
    } else {
      scrollViewLeftMenu =
          inflater.inflate(R.layout.residemenu_custom_left_scrollview, this, false);
      layoutLeftMenu = (LinearLayout) scrollViewLeftMenu.findViewById(R.id.layout_left_menu);
    }

    if (customRightMenuId >= 0) {
      scrollViewRightMenu = inflater.inflate(customRightMenuId, this, false);
    } else {
      scrollViewRightMenu =
          inflater.inflate(R.layout.residemenu_custom_right_scrollview, this, false);
      layoutRightMenu = (LinearLayout) scrollViewRightMenu.findViewById(R.id.layout_right_menu);
    }

    imageViewShadow = (ImageView) findViewById(R.id.iv_shadow);
    imageViewBackground = (ImageView) findViewById(R.id.iv_background);

    RelativeLayout menuHolder = (RelativeLayout) findViewById(R.id.sv_menu_holder);
    menuHolder.addView(scrollViewLeftMenu);
    menuHolder.addView(scrollViewRightMenu);
  }
 public void bindView(View view, Context context, Cursor cursor)
 {
     Log.d("smali", "Lcom/samsung/sec/mtv/ui/channelguide/MtvUiFragReservationList$ReservationAdapter;->bindView(Landroid/view/View;Landroid/content/Context;Landroid/database/Cursor;)V");
     MtvReservation mtvreservation = MtvReservationManager.builder(cursor);
     view.setTag(mtvreservation);
     String s;
     String s1;
     if(DateFormat.is24HourFormat(Log.d(MtvUiFragReservationList.this).getApplicationContext()))
         s = (new SimpleDateFormat("M/d (EEE) H:mm")).format(new Date(mtvreservation.mTimeStart));
     else
         s = (new SimpleDateFormat("M/d (EEE) h:mm a")).format(new Date(mtvreservation.mTimeStart));
     if(mtvreservation.mTimeEnd > 0L)
     {
         if(DateFormat.is24HourFormat(Log.d(MtvUiFragReservationList.this).getApplicationContext()))
             s1 = (new StringBuilder()).append(s).append(" - ").append((new SimpleDateFormat("H:mm")).format(new Date(mtvreservation.mTimeEnd))).toString();
         else
             s1 = (new StringBuilder()).append(s).append(" - ").append((new SimpleDateFormat("h:mm a")).format(new Date(mtvreservation.mTimeEnd))).toString();
     } else
     {
         s1 = (new StringBuilder()).append(s).append(" -            ").toString();
     }
     ((ImageView)view.findViewById(0x7f0a0053)).setImageDrawable(mIcon[mtvreservation.mPgmType][selectStatusIconIndex(mtvreservation)]);
     ((TextView)view.findViewById(0x7f0a0113)).setText((new StringBuilder()).append(s1).append(" ").append("Ch ").append(mtvreservation.mPch).append(" ").toString());
     ((TextView)view.findViewById(0x7f0a0112)).setText(mtvreservation.mPgmName);
     view.findViewById(0x7f0a0048).setVisibility(8);
 }
Пример #6
0
 public ViewHolder(View itemView) {
   super(itemView);
   cv = (CardView) itemView.findViewById(R.id.card_view);
   tittle = (TextView) itemView.findViewById(R.id.titletxt);
   description = (TextView) itemView.findViewById(R.id.descriptiontext);
   background = (RelativeLayout) itemView.findViewById(R.id.relativelayouthome);
   itemView.setOnClickListener(this);
 }
 private void initPagerItems() {
   for (int i = 0; i < bitmapList.size(); i++) {
     View v = LayoutInflater.from(this).inflate(R.layout.call_activity_itempage, null);
     ImageView imageView = (ImageView) v.findViewById(R.id.contactIv);
     TextView textView = (TextView) v.findViewById(R.id.contactTv);
     imageView.setImageBitmap(bitmapList.get(i));
     textView.setText(nameList.get(i));
     viewArrayList.add(v);
   }
 }
Пример #8
0
    @Override
    public View getView(int position, View convertView, final ViewGroup parent) {
      final Item item = getItem(position);

      final View view;
      if (convertView != null && item.getClass().equals(convertView.getTag())) {
        view = convertView;
      } else {
        view =
            getLayoutInflater()
                .inflate(
                    item instanceof SectionItem
                        ? R.layout.catalog_manager_section_head
                        : R.layout.catalog_manager_item,
                    null);
        view.setTag(item.getClass());
      }

      if (item instanceof SectionItem) {
        ((TextView) view.findViewById(R.id.catalog_manager_section_head_title))
            .setText(((SectionItem) item).Title);
      } else /* if (item instanceof CatalogItem) */ {
        final CatalogItem catalogItem = (CatalogItem) item;

        if (myCoverManager == null) {
          view.measure(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
          final int coverHeight = view.getMeasuredHeight();
          myCoverManager =
              new CoverManager(CatalogManagerActivity.this, coverHeight * 15 / 22, coverHeight);
          view.requestLayout();
        }

        final INetworkLink link = catalogItem.Tree.getLink();
        ((TextView) view.findViewById(R.id.catalog_manager_item_title)).setText(link.getTitle());
        ((TextView) view.findViewById(R.id.catalog_manager_item_subtitle))
            .setText(link.getSummary());

        final ImageView coverView = (ImageView) view.findViewById(R.id.catalog_manager_item_icon);
        if (!myCoverManager.trySetCoverImage(coverView, catalogItem.Tree)) {
          coverView.setImageResource(R.drawable.ic_list_library_books);
        }

        final CheckBox checkBox = (CheckBox) view.findViewById(R.id.catalog_manager_item_checkbox);
        checkBox.setChecked(catalogItem.IsChecked);
        checkBox.setOnClickListener(
            new View.OnClickListener() {
              public void onClick(View v) {
                catalogItem.IsChecked = checkBox.isChecked();
                setResultIds(catalogItem, 0);
              }
            });
      }
      return view;
    }
Пример #9
0
  private void showUserHashDialog() {
    String userHash = NavigineApp.Settings.getString("user_hash", "");

    LayoutInflater inflater = getLayoutInflater();
    View view = inflater.inflate(R.layout.user_hash_dialog, null);
    _userEdit = (EditText) view.findViewById(R.id.user_hash_edit);
    _userEdit.setText(userHash);
    _userEdit.setTypeface(Typeface.MONOSPACE);
    // _userEdit.addTextChangedListener(new TextWatcher()
    //  {
    //    public void afterTextChanged(Editable s) { }
    //    public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
    //    public void onTextChanged(CharSequence s, int start, int before, int count)
    //    {
    //      String text = _userEdit.getText().toString();
    //      int length  = _userEdit.getText().length();
    //
    //      if (text.endsWith("-"))
    //        return;
    //
    //      if (count <= before)
    //        return;
    //
    //      if (length == 4 || length == 9 || length == 14)
    //      {
    //        _userEdit.setText((text + "-"));
    //        _userEdit.setSelection(length + 1);
    //      }
    //    }
    //  });

    AlertDialog.Builder alertBuilder = new AlertDialog.Builder(mContext);
    alertBuilder.setView(view);
    alertBuilder.setTitle("Enter user ID");
    alertBuilder.setNegativeButton(
        getString(R.string.cancel_button),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dlg, int id) {}
        });

    alertBuilder.setPositiveButton(
        getString(R.string.ok_button),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dlg, int id) {
            String userHash = _userEdit.getText().toString();
            SharedPreferences.Editor editor = NavigineApp.Settings.edit();
            editor.putString("user_hash", userHash);
            editor.commit();
            NavigineApp.applySettings();
            refreshMapList();
          }
        });

    AlertDialog dialog = alertBuilder.create();
    dialog.setCanceledOnTouchOutside(false);
    dialog.show();
  }
 @Override
 public void onFinishInflate() {
   super.onFinishInflate();
   View view = inflate(getContext(), R.layout.cover_anim_view, (ViewGroup) this);
   Arpan_ßløødy_CoverImages = new ImageView[2];
   Arpan_ßløødy_CoverImages[0] = (ImageView) view.findViewById(R.id.image0);
   Arpan_ßløødy_CoverImages[1] = (ImageView) view.findViewById(R.id.image1);
 }
Пример #11
0
  protected View getView(int position, View convertView, ViewGroup parent) {
    AccountHolder holder;
    if (convertView == null) {
      convertView = layoutInflater.inflate(layoutResourceId, parent, false);
      holder = new AccountHolder();
      holder.accountRow1 = (TextView) convertView.findViewById(R.id.accountRow1);
      holder.accountRow1.setTypeface(GothamFont.BOLD);
      holder.accountRow2 = (TextView) convertView.findViewById(R.id.accountRow2);
      convertView.setTag(holder);

    } else holder = (AccountHolder) convertView.getTag();

    Account account = getItem(position);

    holder.accountRow2.setText(getAccountRow2(account));
    holder.accountRow1.setText(getAccountRow1(account));

    return convertView;
  }
Пример #12
0
  private ViewHolder getViewHolder(final View workingView) {
    final Object tag = workingView.getTag();
    ViewHolder viewHolder = null;

    if (null == tag || !(tag instanceof ViewHolder)) {
      viewHolder = new ViewHolder();

      viewHolder.nameView = (TextView) workingView.findViewById(R.id.name);
      viewHolder.dateView = (TextView) workingView.findViewById(R.id.date);
      viewHolder.sizeView = (TextView) workingView.findViewById(R.id.size);
      viewHolder.imageView = (ImageView) workingView.findViewById(R.id.image);

      workingView.setTag(viewHolder);

    } else {
      viewHolder = (ViewHolder) tag;
    }

    return viewHolder;
  }
Пример #13
0
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   ViewHodler holder = null;
   if (null == convertView) {
     convertView = View.inflate(context, R.layout.li_child_click_item, null);
     holder = new ViewHodler();
     holder.mCountry = (Button) convertView.findViewById(R.id.licc_btn_country);
     holder.mName = (TextView) convertView.findViewById(R.id.licc_tv_name);
     convertView.setTag(holder);
   } else {
     holder = (ViewHodler) convertView.getTag();
   }
   LiData data = list.get(position);
   holder.mCountry.setText(data.country);
   holder.mCountry.setOnClickListener(new OnItemChildClickListener(CLICK_INDEX_COUNTRY, position));
   holder.mName.setText(data.name);
   holder.mName.setOnClickListener(new OnItemChildClickListener(CLICK_INDEX_NAME, position));
   convertView.setOnClickListener(new OnItemChildClickListener(CLICK_INDEX_ITEM, position));
   return convertView;
 }
Пример #14
0
  private void initView() {
    context = (BaseActivity) getActivity();
    imgLeftCorner = (ImageView) ret.findViewById(R.id.img_left_corner);
    et_searchkey = (MaterialEditText) ret.findViewById(R.id.et_searchkey);
    mListView = (XListView) ret.findViewById(R.id.list_search_fans);
    mListView.setPullRefreshEnable(false);
    mListView.setPullLoadEnable(false);
    mNoContentHint = (TextView) ret.findViewById(R.id.no_content_hint);

    imgLeftCorner.setOnClickListener(this);
    mListView.setOnItemClickListener(this);
    et_searchkey.addTextChangedListener(this);

    et_searchkey.setFocusable(true);
    et_searchkey.setFocusableInTouchMode(true);
    et_searchkey.requestFocus();

    adapter = new SearchAdapter(context, R.layout.item_group_member2, cursor);
    mListView.setAdapter(adapter);
  }
Пример #15
0
  public void showDetails(Equipment equipment) {
    equip = equipment;
    View view;
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
      view = getActivity().findViewById(R.id.detail_frag);
    } else {
      view = getActivity().findViewById(R.id.main_frame);
      Button button = (Button) view.findViewById(R.id.closeButton);
      button.setVisibility(View.VISIBLE);
    }

    TextView textIt_no = (TextView) view.findViewById(R.id.it_no2);
    TextView textType = (TextView) view.findViewById(R.id.type2);
    TextView textBrand = (TextView) view.findViewById(R.id.brand2);
    TextView textModel = (TextView) view.findViewById(R.id.model2);
    TextView textE_id = (TextView) view.findViewById(R.id.e_id);
    TextView textDescription = (TextView) view.findViewById(R.id.description);
    TextView textAquired = (TextView) view.findViewById(R.id.aquired);

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
      textIt_no.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape);
      textType.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape);
      textBrand.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape);
      textAquired.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape);
      textModel.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape);
      textDescription.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape);
      textE_id.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape);
    } else {
      textIt_no.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait);
      textType.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait);
      textBrand.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait);
      textAquired.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait);
      textModel.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait);
      textDescription.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait);
      textE_id.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait);
    }
    textIt_no.setText("Item nr: \t\t\t\t" + equipment.getIt_no());
    textType.setText("Type: \t\t\t\t\t" + equipment.getType());
    textBrand.setText("Brand: \t\t\t\t" + equipment.getBrand());
    textModel.setText("Model: \t\t\t\t" + equipment.getModel());
    textE_id.setText("Equipment ID: \t" + equipment.getE_id());
    textDescription.setText("Description: \t" + equipment.getDescription());
    textAquired.setText("Aquired: \t\t\t" + equipment.getAquired());

    downloadImageThread();

    ImageView image = (ImageView) view.findViewById(R.id.equipment_image);
    image.setImageBitmap(bitmap);
  }
Пример #16
0
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   View v = convertView;
   if (v == null) {
     LayoutInflater vi =
         (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     v = vi.inflate(R.layout.row, null);
   }
   Message m = items.get(position);
   // if (m != null) {
   m.createColorFromString(m.from);
   TextView tt = (TextView) v.findViewById(R.id.username);
   TextView bt = (TextView) v.findViewById(R.id.message);
   if (isMonospaced) {
     tt.setTypeface(Typeface.MONOSPACE);
     bt.setTypeface(Typeface.MONOSPACE);
   }
   tt.setText(m.getFrom());
   tt.setTextColor(m.color);
   bt.setText(m.getMessage());
   // }
   return v;
 }
Пример #17
0
 @Override
 public boolean onContextItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case CONTEXT_DELETE_TAG:
       AdapterView.AdapterContextMenuInfo menuInfo =
           (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
       db.deleteTag(menuInfo.id);
       ListView lv = (ListView) viewTagList.findViewById(R.id.item_list);
       Cursor listItem = (Cursor) lv.getItemAtPosition(menuInfo.position);
       String tagName = listItem.getString(1);
       ((TagViewListAdaptor) lv.getAdapter()).refreshData();
       Toast.makeText(SBActivity.this, "Tag '" + tagName + "' deleted.", Toast.LENGTH_SHORT)
           .show();
       return true;
     case CONTEXT_VIEW_NOTES:
       AdapterView.AdapterContextMenuInfo menuInfo2 =
           (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
       Gallery g = (Gallery) viewNoteGallery.findViewById(R.id.note_gallery);
       g.setAdapter(new NoteGalleryImageAdaptor(SBActivity.this, db.findNotesByTag(menuInfo2.id)));
       setContentView(viewNoteGallery);
     default:
       return super.onContextItemSelected(item);
   }
 }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      View row = convertView;
      PhotoGridHolder holder = null;

      if (row == null) {
        LayoutInflater inflater = ((Activity) context).getLayoutInflater();
        row = inflater.inflate(layoutResourceId, parent, false);
        holder = new PhotoGridHolder();
        holder.itemImageView = (ImageView) row.findViewById(R.id.galleryGridImage);
        row.setTag(holder);
      } else {
        holder = (PhotoGridHolder) row.getTag();
      }
      String filename = getItem(position);
      String path = context.getFilesDir().getAbsolutePath() + "/images/" + filename;

      holder.itemImageView.setImageURI(Uri.parse(path));
      return row;
    }
Пример #19
0
  protected Dialog onCreateDialog(int id) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    switch (id) {
      case PROMPT_OAUTH:
        builder
            .setMessage(R.string.commentneedsinaoauth)
            .setCancelable(false)
            .setPositiveButton(
                R.string.ok,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int id) {
                    FlipdroidApplications application = (FlipdroidApplications) getApplication();
                    OAuth oauth = new OAuth();
                    application.setOauth(oauth);
                    //// System.out.println("OAuthHolder.oauth" + application + oauth);
                    oauth.RequestAccessToken(PageActivity.this, "flipdroid://SinaAccountSaver");
                  }
                })
            .setNegativeButton(
                R.string.cancel,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int id) {}
                });
        this.dialog = builder.create();
        break;
      case NAVIGATION:
        LayoutInflater li = LayoutInflater.from(this);
        View v = li.inflate(R.layout.dialog_nav_title_view, null);

        // builder.setView(v);
        builder.setCustomTitle(v);

        builder.setAdapter(
            sourceAdapter,
            new DialogInterface.OnClickListener() {

              public void onClick(DialogInterface dialogInterface, int i) {
                Intent intent = new Intent(PageActivity.this, PageActivity.class);
                SourceItem cursor = sourceAdapter.getItem(i);
                intent.putExtra("type", cursor.getSourceType());
                intent.putExtra("sourceId", cursor.getSourceId());
                intent.putExtra("sourceImage", cursor.getSourceImage());
                intent.putExtra("sourceName", cursor.getSourceName());
                intent.putExtra("contentUrl", cursor.getSourceURL());
                if (dialog != null) dialog.dismiss();
                startActivity(intent);
                finishActivity();
              }
            });

        this.dialog = builder.create();
        Button btn_addshortcut = (Button) v.findViewById(R.id.btnaddshortcut);
        btn_addshortcut.setText("add shortcut");

        btn_addshortcut.setOnClickListener(
            new Button.OnClickListener() {
              public void onClick(View v) {
                addShortcut();
                dialog.cancel();
              }
            });

        dialog.setOnKeyListener(
            new DialogInterface.OnKeyListener() {
              public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
                if (keyEvent.getKeyCode() == KeyEvent.KEYCODE_MENU) {
                  if (dialog != null) {
                    dialog.dismiss();
                    return true;
                  }
                }

                return false;
              }
            });
        break;
      default:
        this.dialog = null;
    }
    if (dialog != null) {
      dialog.setOnDismissListener(
          new DialogInterface.OnDismissListener() {
            public void onDismiss(DialogInterface dialogInterface) {
              dialog = null;
            }
          });
    }
    return this.dialog;
  }
Пример #20
0
  @Override
  public View GetView(
      LayoutInflater inflater,
      ViewGroup container,
      SurveyActivity activityRef,
      SurveyAdapter surveyAdapter,
      int parentId) {

    View view = inflater.inflate(R.layout.gps_question, container, false);
    TextView label = (TextView) view.findViewById(R.id.description);
    label.setText(this.label);
    label.setTextSize(fontSize);

    Typeface tf = Typeface.createFromAsset(activityRef.getAssets(), "fonts/OpenSans-Regular.ttf");
    label.setTypeface(tf);

    try {
      label.setTextColor(Color.parseColor(color));
    } catch (Exception e) {
    }

    // SET LABELS
    TextView textlatlabel = (TextView) view.findViewById(R.id.lattext);
    textlatlabel.setText(latLabel);
    textlatlabel.setTypeface(tf);

    TextView textLonlabel = (TextView) view.findViewById(R.id.lontext);
    textLonlabel.setText(lonLabel);
    textLonlabel.setTypeface(tf);

    // GET GPS POSITION
    textLat = (TextView) view.findViewById(R.id.latitude);
    textLon = (TextView) view.findViewById(R.id.longitude);
    textLat.setTypeface(tf);
    textLon.setTypeface(tf);

    if (locationManager == null) {
      // Acquire a reference to the system Location Manager
      locationManager =
          (LocationManager) view.getContext().getSystemService(Context.LOCATION_SERVICE);

      // Define a listener that responds to location updates
      LocationListener locationListener =
          new LocationListener() {
            public void onLocationChanged(Location location) {

              if (LocationUtil.isBetterLocation(location, currentBestLocation)) {
                // Called when a new location is found by the network location provider.
                textLat.setText(String.valueOf(location.getLatitude()));
                textLon.setText(String.valueOf(location.getLongitude()));
                answer =
                    String.valueOf(location.getLatitude())
                        + "/"
                        + String.valueOf(location.getLongitude());

                // Remove the listener you previously added
                locationManager.removeUpdates(this);
              }
            }

            public void onProviderEnabled(String provider) {}

            public void onProviderDisabled(String provider) {}

            @Override
            public void onStatusChanged(String provider, int status, Bundle extras) {
              // TODO Auto-generated method stub

            }
          };

      // Register the listener with the Location Manager to receive location updates
      locationManager.requestLocationUpdates(
          LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
      locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);

      Criteria criteria = new Criteria();
      String provider = locationManager.getBestProvider(criteria, false);
      currentBestLocation = locationManager.getLastKnownLocation(provider);
    }

    // SET ORIENTATION
    LinearLayout layout = (LinearLayout) view.findViewById(R.id.layout);
    if (orientation.equals("horizontal")) layout.setOrientation(LinearLayout.HORIZONTAL);
    else layout.setOrientation(LinearLayout.VERTICAL);

    // SET ANSWER
    if (!answer.equals("")) {
      String[] parts = answer.split("/");
      textLat.setText(parts[0]);
      textLon.setText(parts[1]);
    }
    return view;
  }
Пример #21
0
    public View getItemView(int itemPosition, View convertView, ViewGroup parent) {
      FolderInfoHolder folder = (FolderInfoHolder) getItem(itemPosition);
      View view;
      if (convertView != null) {
        view = convertView;
      } else {
        view = mInflater.inflate(R.layout.folder_list_item, parent, false);
      }

      FolderViewHolder holder = (FolderViewHolder) view.getTag();

      if (holder == null) {
        holder = new FolderViewHolder();
        holder.folderName = (TextView) view.findViewById(R.id.folder_name);
        holder.newMessageCount = (TextView) view.findViewById(R.id.folder_unread_message_count);
        holder.flaggedMessageCount =
            (TextView) view.findViewById(R.id.folder_flagged_message_count);
        holder.folderStatus = (TextView) view.findViewById(R.id.folder_status);
        holder.activeIcons = (RelativeLayout) view.findViewById(R.id.active_icons);
        holder.chip = view.findViewById(R.id.chip);
        holder.folderListItemLayout =
            (LinearLayout) view.findViewById(R.id.folder_list_item_layout);
        holder.rawFolderName = folder.name;

        view.setTag(holder);
      }

      if (folder == null) {
        return view;
      }

      holder.folderName.setText(folder.displayName);
      String statusText = "";

      if (folder.loading) {
        statusText = getString(R.string.status_loading);
      } else if (folder.status != null) {
        statusText = folder.status;
      } else if (folder.lastChecked != 0) {
        Date lastCheckedDate = new Date(folder.lastChecked);

        statusText =
            getTimeFormat().format(lastCheckedDate) + " " + getDateFormat().format(lastCheckedDate);
      }

      if (folder.pushActive) {
        statusText = getString(R.string.folder_push_active_symbol) + " " + statusText;
      }

      if (statusText != null) {
        holder.folderStatus.setText(statusText);
        holder.folderStatus.setVisibility(View.VISIBLE);
      } else {
        holder.folderStatus.setText(null);
        holder.folderStatus.setVisibility(View.GONE);
      }

      if (folder.unreadMessageCount != 0) {
        holder.newMessageCount.setText(Integer.toString(folder.unreadMessageCount));
        holder.newMessageCount.setOnClickListener(
            new FolderClickListener(
                mAccount, folder.name, folder.displayName, SearchModifier.UNREAD));
        holder.newMessageCount.setVisibility(View.VISIBLE);
      } else {
        holder.newMessageCount.setVisibility(View.GONE);
      }

      if (K9.messageListStars() && folder.flaggedMessageCount > 0) {
        holder.flaggedMessageCount.setText(Integer.toString(folder.flaggedMessageCount));
        holder.flaggedMessageCount.setOnClickListener(
            new FolderClickListener(
                mAccount, folder.name, folder.displayName, SearchModifier.FLAGGED));
        holder.flaggedMessageCount.setVisibility(View.VISIBLE);
      } else {
        holder.flaggedMessageCount.setVisibility(View.GONE);
      }
      if (K9.useCompactLayouts() && holder.folderListItemLayout != null) {
        holder.folderListItemLayout.setMinimumHeight(0);
      }
      holder.activeIcons.setOnClickListener(
          new OnClickListener() {
            public void onClick(View v) {
              Toast toast =
                  Toast.makeText(
                      getApplication(), getString(R.string.tap_hint), Toast.LENGTH_SHORT);
              toast.show();
            }
          });

      holder.chip.setBackgroundDrawable(mAccount.generateColorChip().drawable());
      holder.chip.getBackground().setAlpha(folder.unreadMessageCount == 0 ? 127 : 255);

      holder.folderName.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mFontSizes.getFolderName());
      holder.folderStatus.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mFontSizes.getFolderStatus());

      return view;
    }
    @Override
    public View onCreateView(
        LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      View rootView = inflater.inflate(R.layout.fragment_user_crud, container, false);

      editTextUserName = (EditText) rootView.findViewById(R.id.editTextUserName);
      editTextEmail = (EditText) rootView.findViewById(R.id.editTextEmail);
      editTextLogin = (EditText) rootView.findViewById(R.id.editTextLogin);
      editTextPassword = (EditText) rootView.findViewById(R.id.editTextPassword);
      editTextConfirmPassword = (EditText) rootView.findViewById(R.id.editTextConfirmPassword);
      editTextZipCode = (EditText) rootView.findViewById(R.id.editTextZipCode);
      editTextAddress = (EditText) rootView.findViewById(R.id.editTextAddress);
      editTextNumberAddress = (EditText) rootView.findViewById(R.id.editTextNumberAddress);
      editTextComplement = (EditText) rootView.findViewById(R.id.editTextComplement);
      editTextNeighborhood = (EditText) rootView.findViewById(R.id.editTextNeighborhood);
      editTextCity = (EditText) rootView.findViewById(R.id.editTextCity);
      txtLatitude = (TextView) rootView.findViewById(R.id.txtLatitude);
      txtLongitude = (TextView) rootView.findViewById(R.id.txtLongitude);
      radioGroupGender = (RadioGroup) rootView.findViewById(R.id.radioGender);
      spinnerStates = (Spinner) rootView.findViewById(R.id.spinnerStates);
      btnSearchZipCode = (Button) rootView.findViewById(R.id.btnSearchZipCode);
      btnSaveUser = (Button) rootView.findViewById(R.id.btnSaveUser);

      ArrayAdapter arrayAdapterStates =
          new ArrayAdapter(getActivity(), R.layout.support_simple_spinner_dropdown_item, states);
      spinnerStates.setPrompt("Estados");
      spinnerStates.setAdapter(arrayAdapterStates);
      spinnerStates.setOnItemSelectedListener(
          new AdapterView.OnItemSelectedListener() {

            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
              if (position > 0) {
                String state = (String) spinnerStates.getItemAtPosition(position);
                spinnerStates.setSelection(states.indexOf(state));
              }
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {
              Toast.makeText(
                      getActivity(), "É necessário selecionar uma Categoria", Toast.LENGTH_SHORT)
                  .show();
            }
          });

      if (getActivity().getIntent().getSerializableExtra("user") != null) {
        UserBean userBeanLoad = (UserBean) getActivity().getIntent().getSerializableExtra("user");
        editTextUserName.setText(userBeanLoad.getUserName());
        editTextEmail.setText(userBeanLoad.getEmail());
        editTextLogin.setText(userBeanLoad.getLogin());
        editTextPassword.setVisibility(View.INVISIBLE);
        editTextConfirmPassword.setVisibility(View.INVISIBLE);
        editTextZipCode.setText(userBeanLoad.getZipCode());
        editTextAddress.setText(userBeanLoad.getAddress());
        editTextNumberAddress.setText(userBeanLoad.getNumberAddress());
        editTextComplement.setText(userBeanLoad.getComplement());
        editTextNeighborhood.setText(userBeanLoad.getNeighborhood());
        editTextCity.setText(userBeanLoad.getCity());
        if (userBeanLoad.getGender().equals(UserBean.Gender.MALE.getSex())) {
          radioButtonGender = (RadioButton) rootView.findViewById(R.id.radioMale);
          radioButtonGender.setChecked(true);
        } else {
          radioButtonGender = (RadioButton) rootView.findViewById(R.id.radioFemale);
          radioButtonGender.setChecked(true);
        }

        spinnerStates.setSelection(states.indexOf(userBeanLoad.getState()));
        getActivity()
            .getWindow()
            .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
        btnSaveUser.setTag(userBeanLoad);
      }

      btnSaveUser.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              progressDialog =
                  ProgressDialog.show(getActivity(), "Processando", "Salvando usuário...");

              if (view.getTag() != null) {
                userBean = (UserBean) view.getTag();
              } else {
                userBean = new UserBean();
              }

              int selectedId = radioGroupGender.getCheckedRadioButtonId();
              switch (selectedId) {
                case R.id.radioFemale:
                  userBean.setGender(UserBean.Gender.FEMALE.getSex());
                  break;
                case R.id.radioMale:
                  userBean.setGender(UserBean.Gender.MALE.getSex());
                  break;
              }

              userBean.setUserName(editTextUserName.getText().toString());
              userBean.setEmail(editTextEmail.getText().toString());
              userBean.setLogin(editTextLogin.getText().toString());
              userBean.setPassword(editTextPassword.getText().toString());
              userBean.setZipCode(editTextZipCode.getText().toString());
              userBean.setAddress(editTextAddress.getText().toString());
              userBean.setNumberAddress(editTextNumberAddress.getText().toString());
              userBean.setComplement(editTextComplement.getText().toString());
              userBean.setNeighborhood(editTextNeighborhood.getText().toString());
              userBean.setCity(editTextCity.getText().toString());

              userBean.setState(spinnerStates.getSelectedItem().toString());

              AsyncTask<Void, Void, JSONObject> task =
                  new AsyncTask<Void, Void, JSONObject>() {

                    @Override
                    protected JSONObject doInBackground(Void... voids) {
                      Http http = new Http();
                      try {
                        StringBuilder strAddress = new StringBuilder();
                        strAddress.append(editTextAddress.getText().toString()).append(" ");
                        strAddress.append(editTextNumberAddress.getText().toString()).append(" ");
                        strAddress.append(editTextCity.getText().toString()).append(" ");
                        strAddress.append(spinnerStates.getSelectedItem().toString());

                        String result =
                            http.doGet(
                                PAGE_MAPS
                                    + URLEncoder.encode(strAddress.toString(), "UTF-8")
                                    + "&sensor=true");

                        JSONObject jsonObject = new JSONObject(result);

                        if (jsonObject.getString("status").equals("OK")) {
                          JSONArray jsonArrayResults = jsonObject.getJSONArray("results");
                          for (int i = 0; i < jsonArrayResults.length(); i++) {
                            JSONObject jsonObjectResults = jsonArrayResults.getJSONObject(i);
                            if (jsonObjectResults.get("geometry") != null) {
                              JSONObject jsonObjectGeometry =
                                  jsonObjectResults.getJSONObject("geometry");
                              return (JSONObject) jsonObjectGeometry.get("location");
                            }
                          }
                        }

                      } catch (IOException e1) {
                        Log.e(AppHelper.getClassError(UserCrudActivity.class), e1.getMessage());
                      } catch (JSONException e2) {
                        Log.e(AppHelper.getClassError(UserCrudActivity.class), e2.getMessage());
                      }

                      return null;
                    }

                    @Override
                    protected void onPostExecute(JSONObject jsonObject) {
                      super.onPostExecute(jsonObject);

                      boolean cepOK = true;
                      if (jsonObject == null || jsonObject.isNull("lng")) {
                        cepOK = false;
                        Toast.makeText(getActivity(), "CEP inexistente.", Toast.LENGTH_SHORT)
                            .show();
                      } else {
                        try {
                          userBean.setLatitude(jsonObject.get("lat").toString());
                          userBean.setLongitude(jsonObject.get("lng").toString());

                          boolean create = userBean.getId() == null ? true : false;

                          UserDB userDB = new UserDB(getActivity());
                          userBean = userDB.salvar(userBean);

                          if (userBean != null) {
                            Intent it = new Intent();
                            it.putExtra(
                                "msg",
                                create
                                    ? "Usuário salvo com sucesso!"
                                    : "Usuário atualizado com sucesso!");
                            it.putExtra("user", userBean);
                            getActivity().setResult(RESULT_OK, it);
                            getActivity().finish();
                          } else {
                            Intent it = new Intent();
                            it.putExtra(
                                "msg",
                                create
                                    ? "Falha ao cadastrar o Usuário!"
                                    : "Falha ao atualizar Usuário!");
                            getActivity().setResult(RESULT_CANCELED, it);
                            getActivity().finish();
                          }

                        } catch (JSONException e3) {
                          Log.e(AppHelper.getClassError(UserCrudActivity.class), e3.getMessage());
                        }
                      }

                      if (cepOK) {
                        UserDB userDB = new UserDB(getActivity());
                        userBean = userDB.salvar(userBean);
                        if (userBean != null) {
                          Intent it = new Intent();
                          it.putExtra(
                              "msg",
                              userBean.getId() == null
                                  ? "Usuário salvo com sucesso!"
                                  : "Usuário atualizado com sucesso!");
                          it.putExtra("user", userBean);
                          getActivity().setResult(RESULT_OK, it);
                          getActivity().finish();
                        } else {
                          Intent it = new Intent();
                          it.putExtra(
                              "msg",
                              userBean.getId() == null
                                  ? "Falha ao cadastrar o Usuário!"
                                  : "Falha ao atualizar Usuário!");
                          getActivity().setResult(RESULT_CANCELED, it);
                          getActivity().finish();
                        }
                      }
                    }
                  };

              if (validateFields(userBean)) {
                task.execute();
              }

              progressDialog.dismiss();
            }
          });

      btnSearchZipCode.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              progressDialog = ProgressDialog.show(getActivity(), "Pesquisando", "Carregando...");
              AsyncTask<Void, Void, JSONObject> task =
                  new AsyncTask<Void, Void, JSONObject>() {
                    @Override
                    protected JSONObject doInBackground(Void... params) {

                      Http http = new Http();
                      try {
                        String result =
                            http.doGet(PAGE_CORREIOS + editTextZipCode.getText().toString());
                        JSONObject jsonObject = new JSONObject(result);
                        if (!jsonObject.has("message")) {
                          return jsonObject;
                        }

                      } catch (IOException e1) {
                        Log.e(AppHelper.getClassError(UserCrudActivity.class), e1.getMessage());
                      } catch (JSONException e2) {
                        Log.e(AppHelper.getClassError(UserCrudActivity.class), e2.getMessage());
                      }

                      return null;
                    }

                    @Override
                    protected void onPostExecute(JSONObject jsonObject) {
                      if (jsonObject == null) {
                        Toast.makeText(getActivity(), "CEP inexistente.", Toast.LENGTH_SHORT)
                            .show();
                      } else {
                        try {
                          editTextAddress.setText(
                              jsonObject.get("tipoDeLogradouro")
                                  + " "
                                  + jsonObject.get("logradouro"));
                          editTextNeighborhood.setText(jsonObject.get("bairro").toString());
                          editTextCity.setText(jsonObject.get("cidade").toString());
                          spinnerStates.setSelection(
                              states.indexOf(jsonObject.get("estado").toString()));
                        } catch (JSONException e3) {
                          Log.e(AppHelper.getClassError(UserCrudActivity.class), e3.getMessage());
                        }
                      }
                      progressDialog.dismiss();
                    }
                  };
              task.execute();
            }
          });

      return rootView;
    }
Пример #23
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // open up the DbAdaptor
    db.open();

    // gives us more screen space
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    // need to do this because the camera doesn't do portrait mode
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    // initialize all our views.
    LayoutInflater inflater = getLayoutInflater();
    viewCaptureNote = inflater.inflate(R.layout.view_capture_note, null);
    viewNote = inflater.inflate(R.layout.view_note, null);
    viewTagList = inflater.inflate(R.layout.view_tag_list, null);
    viewNoteGallery = inflater.inflate(R.layout.view_note_gallery, null);

    // set the content view initially to save notes
    setContentView(viewCaptureNote);

    // set up the click listeners for the camera preview screen
    CameraPreview cameraPreview = (CameraPreview) findViewById(R.id.surface);
    findViewById(R.id.discard).setOnClickListener(cameraPreview);
    findViewById(R.id.take).setOnClickListener(cameraPreview);
    findViewById(R.id.save_untagged).setOnClickListener(cameraPreview);
    findViewById(R.id.save_and_tag).setOnClickListener(cameraPreview);

    // set up the 'view untagged' option in the list menu
    View someView = viewTagList.findViewById(R.id.tag_list_untagged);
    someView.findViewById(R.id.tag_subtags).setVisibility(View.GONE);
    ((TextView) someView.findViewById(R.id.tag_name)).setText("Click to view untagged notes");
    someView.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Gallery g = (Gallery) viewNoteGallery.findViewById(R.id.note_gallery);
            g.setAdapter(new NoteGalleryImageAdaptor(SBActivity.this, db.getUntaggedNotes()));
            setContentView(viewNoteGallery);
          }
        });

    // set the list adaptor for our tag list
    final ListView lv = (ListView) viewTagList.findViewById(R.id.item_list);
    lv.setAdapter(new TagViewListAdaptor(this, db.getTagList()));
    registerForContextMenu(lv);
    lv.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            TextView v = (TextView) view.findViewById(R.id.tag_subtags);
            v.setVisibility(v.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
            long tagId = (Long) view.findViewById(R.id.tag_name).getTag();
            if (v.getVisibility() == View.VISIBLE) {
              int subtagCount = 0;
              StringBuilder subTags = new StringBuilder("Sub-tags: ");
              Cursor c = db.getSubTags(tagId);
              while (c.moveToNext()) {
                subTags.append(c.getString(1) + " ");
                subtagCount++;
              }
              if (subtagCount > 0) v.setText(subTags);
              else v.setText("No sub-tags.");
            }
          }
        });
    lv.setOnCreateContextMenuListener(
        new View.OnCreateContextMenuListener() {
          public void onCreateContextMenu(
              ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
            menu.setHeaderIcon(android.R.drawable.ic_menu_info_details);
            ListView lv = (ListView) viewTagList.findViewById(R.id.item_list);
            Cursor listItem =
                (Cursor)
                    lv.getItemAtPosition(((AdapterView.AdapterContextMenuInfo) menuInfo).position);
            String tagName = listItem.getString(1);
            menu.setHeaderTitle("Tag '" + tagName + "'");
            menu.add(0, CONTEXT_VIEW_NOTES, 0, "View notes tagged with '" + tagName + "'");
            menu.add(0, CONTEXT_DELETE_TAG, 0, "Delete tag");
          }
        });

    // set up click listeners for add tag
    viewTagList
        .findViewById(R.id.save_tag)
        .setOnClickListener(
            new View.OnClickListener() {
              public void onClick(View view) {
                EditText editText = (EditText) viewTagList.findViewById(R.id.tag_id);
                if (editText.getText().length() == 0) return;
                db.addNewTag(editText.getText());
                ((TagViewListAdaptor) lv.getAdapter()).refreshData();
                Toast.makeText(
                        SBActivity.this,
                        "Tag '" + editText.getText() + "' added.",
                        Toast.LENGTH_SHORT)
                    .show();
                editText.setText("");
              }
            });
    viewTagList.setOnFocusChangeListener(
        new View.OnFocusChangeListener() {
          @Override
          public void onFocusChange(View view, boolean b) {
            Log.i(TAG, "Focus changed innit: " + b);
            if (b) ((TagViewListAdaptor) lv.getAdapter()).refreshData();
          }
        });

    // set up our note viewing gallery
    final Gallery g = (Gallery) viewNoteGallery.findViewById(R.id.note_gallery);
    g.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            // set the note number i.e. 1/3
            ((TextView) viewNoteGallery.findViewById(R.id.gallery_note_number))
                .setText((i + 1) + " / " + g.getCount());

            // set the date field
            Date d = new Date(((Note) view.getTag()).getSaveTime());
            ((TextView) viewNoteGallery.findViewById(R.id.gallery_note_date))
                .setText(DateFormat.getDateTimeInstance().format(d));

            // set the tag field
            Cursor c = db.getTagListForImg(l);
            StringBuilder sb = new StringBuilder();
            while (c.moveToNext()) {
              if (c.getInt(2) == 0) continue;
              sb.append(c.getString(1));
              sb.append(", ");
            }
            // delete the last 2 chars: ", "
            if (sb.length() > 0) sb.delete(sb.length() - 2, sb.length());
            else sb.append("none");
            ((TextView) viewNoteGallery.findViewById(R.id.gallery_note_tags))
                .setText(sb.toString());
          }

          @Override
          public void onNothingSelected(AdapterView<?> adapterView) {}
        });
    g.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {

            return true;
          }
        });
    viewNoteGallery
        .findViewById(R.id.note_gallery_examine)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                Note n = (Note) ((View) g.getSelectedView()).getTag();
                setViewSingleNote(n.getFileName());
              }
            });

    Handler btProgressHandler =
        new Handler() {
          public void handleMessage(Message msg) {
            if (btProgressDialog == null) return;
            switch (msg.what) {
              case BluetoothService.MSG_CONNECTED:
                btProgressDialog.setMessage("Bluetooth connected! Sending updates...");
                break;
              case BluetoothService.MSG_RECEIVING:
                btProgressDialog.setMessage("Receiving updates from computer..");
                break;
              case BluetoothService.MSG_PROGRESS:
                int cur = msg.arg1;
                int max = msg.arg2;
                btProgressDialog.setProgress(cur);
                btProgressDialog.setMax(max);
                break;
              case BluetoothService.MSG_DONE:
                btProgressDialog.dismiss();
                break;
            }
          }
        };
    bService.setProgressHandler(btProgressHandler);
  }
Пример #24
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.menu_view_tags:
        // little hack to refresh the data in our tag list view when we open it
        ListView lv = (ListView) viewTagList.findViewById(R.id.item_list);
        ((TagViewListAdaptor) lv.getAdapter()).refreshData();
        setContentView(viewTagList);
        return true;
      case R.id.menu_delete_note:
        Note n = ((NoteView) viewNote).getNote();
        db.deleteTag(n.getId());
        Toast.makeText(SBActivity.this, "Note " + n.getId() + " deleted.", Toast.LENGTH_SHORT)
            .show();
        goBack();
        return true;
      case R.id.menu_save_note:
        setContentView(viewCaptureNote);
        return true;
      case R.id.menu_tag_note:
        final Note curNote = ((NoteView) viewNote).getNote();
        final Cursor c = db.getTagListForImg(curNote.getId());
        CharSequence[] items = new CharSequence[c.getCount()];
        for (int i = 0; i < items.length; i++) {
          c.moveToNext();
          items[i] = c.getString(1);
        }

        final boolean[] checked = new boolean[c.getCount()];
        c.moveToFirst();
        for (int i = 0; i < items.length; i++) {
          checked[i] = c.getInt(2) == 1;
          c.moveToNext();
        }

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder
            .setTitle("Set tags for note " + curNote.getId())
            .setIcon(android.R.drawable.ic_menu_edit)
            .setMultiChoiceItems(
                items,
                checked,
                new DialogInterface.OnMultiChoiceClickListener() {
                  @Override
                  public void onClick(DialogInterface dialogInterface, int i, boolean b) {
                    c.moveToPosition(i);
                    db.setTagForNote(curNote.getId(), c.getLong(0), b);
                  }
                });
        builder.show();
        return true;
      case R.id.menu_bluetooth_sync:
        Cursor c1 = getDbAdaptor().getUpdateList(null);
        int idxId = c1.getColumnIndex("_id");
        int idxTable = c1.getColumnIndex("table_name");
        int idxTarget = c1.getColumnIndex("target_id");
        int idxTarget2 = c1.getColumnIndex("target2_id");
        int idxType = c1.getColumnIndex("update_type");
        int idxTime = c1.getColumnIndex("update_time");
        Log.i(getClass().getName(), "Update list:");
        while (c1.moveToNext()) {
          Log.i(
              getClass().getName(),
              " [_id="
                  + c1.getInt(idxId)
                  + "] "
                  + (c1.getInt(idxType) == DbAdaptor.UPDATE_TYPE_ADD ? "Added" : "Deleted")
                  + " "
                  + "id "
                  + c1.getInt(idxTarget)
                  + (!c1.isNull(idxTarget2) ? " (id2 " + c1.getInt(idxTarget2) + ")" : "")
                  + " in table "
                  + c1.getString(idxTable)
                  + " (@ "
                  + new Date(c1.getInt(idxTime))
                  + ")");
        }

        if (bService.requestEnableBluetooth()) bService.bluetoothDiscoverable();
        return true;
    }
    return false;
  }
Пример #25
0
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
      View view = convertView;
      if (view == null) {
        LayoutInflater inflater =
            (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = inflater.inflate(R.layout.content_list_item, null);
      }
      TextView titleTextView = (TextView) view.findViewById(R.id.list_item_title);
      TextView stateTextView = (TextView) view.findViewById(R.id.list_item_state);
      TextView downTextView = (TextView) view.findViewById(R.id.list_item_downbar);
      Button downloadButton = (Button) view.findViewById(R.id.list_item_download_button);
      Button uploadButton = (Button) view.findViewById(R.id.list_item_upload_button);

      LocationInfo info = mInfoList.get(position);
      String titleText = info.title;
      String stateText = "";

      if (titleText.length() > 30) titleText = titleText.substring(0, 28) + "...";

      synchronized (mLoaderMap) {
        if (mLoaderMap.containsKey(info.title)) {
          LoaderState loader = mLoaderMap.get(info.title);
          if (loader.state < 100) stateText = String.format(Locale.ENGLISH, "%d%%", loader.state);
          else if (loader.state == 100) stateText = String.format(Locale.ENGLISH, "Done!");
          else stateText = String.format(Locale.ENGLISH, "Failed!");
        }
      }

      if (info.localVersion < 0) titleText += " (?)";
      else {
        if (info.localModified)
          titleText += String.format(Locale.ENGLISH, " (v. %d+)", info.localVersion);
        else titleText += String.format(Locale.ENGLISH, " (v. %d)", info.localVersion);
      }

      String mapFile = NavigineApp.Settings.getString("map_file", "");
      if (mapFile.equals(info.archiveFile)) {
        titleTextView.setTypeface(null, Typeface.BOLD);
        view.setBackgroundColor(Color.parseColor("#590E0E"));
      } else {
        titleTextView.setTypeface(null, Typeface.NORMAL);
        view.setBackgroundColor(Color.BLACK);
      }

      titleTextView.setText(titleText);
      stateTextView.setText(stateText);

      if (info.localModified) {
        downloadButton.setVisibility(View.GONE);
        uploadButton.setVisibility(View.VISIBLE);
        downTextView.setText("Version is modified. Upload?");
      } else if (info.serverVersion > info.localVersion) {
        downloadButton.setVisibility(View.VISIBLE);
        uploadButton.setVisibility(View.GONE);
        String downText =
            String.format(Locale.ENGLISH, "Version available: %d", info.serverVersion);
        downTextView.setText(downText);
      } else {
        downloadButton.setVisibility(View.INVISIBLE);
        uploadButton.setVisibility(View.GONE);
        downTextView.setText("Version is up to date");
      }

      downloadButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              startDownload(position);
            }
          });

      uploadButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              startUpload(position);
            }
          });

      return view;
    }