コード例 #1
0
  public void reconfigureViewHierarchy() {
    final DisplayMetrics dm = getResources().getDisplayMetrics();
    final int widthPixels = dm.widthPixels;

    if (mDecorView == null) {
      return;
    }
    if (mDrawerContent != null) {
      removeView(mDrawerContent);
    }
    if (mDecorContent != null) {
      /*
       * Add the window/content (whatever it is at the time) back to its original parent.
       */
      removeView(mDecorContent);
      mDecorContentParent.addView(mDecorContent);

      /*
       * Reset the window/content's OnClickListener/background color to default values as well
       */
      mDecorContent.setOnClickListener(null);
      mDecorContent.setBackgroundColor(Color.TRANSPARENT);
    }
    if (mAdded) {
      mDecorContentParent.removeView(this);
    }
    if (mSlideTarget == SLIDE_TARGET_CONTENT) {
      mDecorContent = mContentTarget;
      mDecorContentParent = mContentTargetParent;
    } else if (mSlideTarget == SLIDE_TARGET_WINDOW) {
      mDecorContent = mWindowTarget;
      mDecorContentParent = mWindowTargetParent;
    } else {
      throw new IllegalArgumentException(
          "Slide target must be one of SLIDE_TARGET_CONTENT or SLIDE_TARGET_WINDOW.");
    }
    ((ViewGroup) mDecorContent.getParent()).removeView(mDecorContent);
    addView(mDrawerContent, new ViewGroup.LayoutParams(mDrawerMaxWidth, MATCH_PARENT));
    addView(mDecorContent, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
    mDecorContentParent.addView(this);
    mAdded = true;

    /* Set background color of the content view (it shouldn't be transparent) */
    mDecorContent.setBackgroundColor(mDecorContentBackgroundColor);

    /* Reset shadow bounds */
    mShadowDrawable.setBounds(-mTouchTargetWidth / 6, 0, 0, dm.heightPixels);

    /*
     * Set an empty onClickListener on the Decor content parent to prevent any touch events
     * from escaping and passing through to the drawer even while it's closed.
     */
    mDecorContent.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View view) {}
        });
  }
コード例 #2
0
  private void rebuildComplicationsList() {
    ViewGroup complicationsContainer = (ViewGroup) mRootView.findViewById(R.id.complications_list);
    complicationsContainer.removeAllViews();

    LayoutInflater inflater = LayoutInflater.from(getActivity());

    for (int i = 0; i < PREF_KEYS.length; i++) {
      final String prefKey = PREF_KEYS[i];

      ViewGroup itemContainer =
          (ViewGroup)
              inflater.inflate(R.layout.config_complications_item, complicationsContainer, false);
      final CheckedTextView titleView =
          (CheckedTextView) itemContainer.findViewById(android.R.id.text1);
      final View checkmarkView = itemContainer.findViewById(R.id.checkmark);

      titleView.setText(PREF_TITLE_IDS[i]);
      boolean isPrefOn = mSharedPreferences.getBoolean(prefKey, false);

      checkmarkView.setVisibility(isPrefOn ? View.VISIBLE : View.INVISIBLE);
      titleView.setChecked(isPrefOn);

      itemContainer.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              boolean isPrefOn = mSharedPreferences.getBoolean(prefKey, false);
              mSharedPreferences.edit().putBoolean(prefKey, !isPrefOn).apply();
              rebuildComplicationsList();
            }
          });

      complicationsContainer.addView(itemContainer);
    }
  }
コード例 #3
0
ファイル: SixFragment.java プロジェクト: cuishenghu/hewuzhe
  private void setItemData(ViewGroup child, final StudyOnlineCatItem item) {

    ImageView imageView = (ImageView) child.getChildAt(0);
    TextView textView = (TextView) child.getChildAt(1);
    textView.setText(item.Name);
    //        textView.setText(item.Name);

    Glide.with(getContext())
        .load(C.BASE_URL + item.ImagePath)
        .crossFade()
        .placeholder(R.mipmap.img_bg_videio)
        .into(imageView);

    child.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(getActivity(), Videos_2Activity.class);
            intent.putExtra("title", item.Name);
            intent.putExtra("id", item.Id);
            intent.putExtra("where", "six");
            getActivity().startActivity(intent);
          }
        });
  }
コード例 #4
0
ファイル: GeneralHelper.java プロジェクト: sovranliu/pretty
 /**
  * 打开单选框
  *
  * @param context 上下文
  */
 public static AlertDialog showWaiting(Context context) {
   final AlertDialog alertDialog = new AlertDialog.Builder(context).create();
   alertDialog.show();
   Window window = alertDialog.getWindow();
   WindowManager.LayoutParams layoutParams = window.getAttributes();
   layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
   layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
   window.setGravity(Gravity.CENTER);
   window.setAttributes(layoutParams);
   window.setContentView(R.layout.dialog_waiting);
   ViewGroup background = (ViewGroup) window.findViewById(R.id.waiting_layout_background);
   background.setOnClickListener(
       new OnClickListener() {
         @Override
         public void onClick(View v) {
           // alertDialog.cancel();
         }
       });
   ImageView icon = (ImageView) window.findViewById(R.id.waiting_image_icon);
   final RotateAnimation animation =
       new RotateAnimation(
           0f, 720f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
   animation.setDuration(2000);
   animation.setRepeatCount(Animation.INFINITE);
   icon.startAnimation(animation);
   return alertDialog;
 }
コード例 #5
0
 public static void setActionButton(
     Activity activity, int id, int icon, View.OnClickListener listener) {
   ViewGroup button = (ViewGroup) activity.findViewById(id);
   button.setOnClickListener(listener);
   ((ImageView) button.findViewById(R.id.icon)).setImageResource(icon);
   button.setVisibility(View.VISIBLE);
 }
コード例 #6
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.feedback);
   // TravelApplication.getInstance().addActivity(this);
   ActivityMange.getInstance().addActivity(this);
   contentEditText = (EditText) findViewById(R.id.feedback_content);
   contactEditText = (EditText) findViewById(R.id.feedback_contact);
   contactTipsTextView = (TextView) findViewById(R.id.feedback_contact_tips);
   ViewGroup feedbackGroup = (ViewGroup) findViewById(R.id.feedback_group);
   ImageButton submit = (ImageButton) findViewById(R.id.submit);
   submit.setOnClickListener(submitOnClickListener);
   feedbackGroup.setOnClickListener(feedbackGroupOnClickListener);
   InputMethodManager imm =
       (InputMethodManager)
           feedbackGroup.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
   if (imm.isActive()) {
     imm.hideSoftInputFromWindow(feedbackGroup.getApplicationWindowToken(), 0);
   }
   token = TravelApplication.getInstance().getToken();
   if (token != null && !token.equals("")) {
     contactEditText.setVisibility(View.GONE);
     contactTipsTextView.setVisibility(View.GONE);
   }
 }
コード例 #7
0
  private void setupTitleView() {
    ViewGroup titleLayout = (ViewGroup) findViewById(R.id.title_layout);
    titleLayout.setOnClickListener(navBarActionsHandler);

    titleLabelView = (TextView) findViewById(R.id.txt_title_label);

    TextView reportMonthStartView = (TextView) findViewById(R.id.btn_report_month);
    setReportDates(reportMonthStartView);
  }
コード例 #8
0
ファイル: MainActivity.java プロジェクト: eyeshims/kon
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mRootView = (ViewGroup) findViewById(R.id.layout_root_view);
    mRootView.setOnClickListener(this);

    mRedBox = findViewById(R.id.red_box);
    mGreenBox = findViewById(R.id.green_box);
    mBlueBox = findViewById(R.id.blue_box);
    mBlackBox = findViewById(R.id.black_box);
  }
コード例 #9
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.layout_condition_query, null);
    mContainer = (ViewGroup) view.findViewById(R.id.id_llayout_item_container);
    view.findViewById(R.id.id_btn_condition_query_addition).setOnClickListener(this);
    view.findViewById(R.id.id_btn_condition_query_subtraction).setOnClickListener(this);
    view.findViewById(R.id.id_btn_condition_query_confirm).setOnClickListener(this);
    mContainer.setClickable(true);

    mContainer.setOnClickListener(this);
    slog.p("ConditionQuery  onCreateView");
    return view;
  }
コード例 #10
0
  // 当保存资料时操作
  private void afterToUpdateUserInfo() {
    FragmentChangeActivity.slideMenu.setSlidingEnabled(true);

    headLayout.setVisibility(View.VISIBLE);
    middleLayout.setVisibility(View.VISIBLE);
    sexGroup.setOnClickListener(null);
    birthdayGroup.setOnClickListener(null);
    etEmail.setEnabled(isUpdate);
    etEmail.setHint(null);
    etRealName.setEnabled(isUpdate);
    etRealName.setHint(null);
    etMsn.setEnabled(isUpdate);
    etMsn.setHint(null);
    etQQ.setEnabled(isUpdate);
    etQQ.setHint(null);
    etOfficePhone.setEnabled(isUpdate);
    etOfficePhone.setHint(null);
    etMobilePhone.setEnabled(isUpdate);
    etMobilePhone.setHint(null);
    etHomePhone.setEnabled(isUpdate);
    etHomePhone.setHint(null);
    // 保存用户信息
    reayToSaveUserInfo();
  }
コード例 #11
0
 private void createBottomMenuItem(
     LinearLayout menu,
     BottomMenuClickListener listener,
     AtomicInteger counter,
     Fragment f,
     int itemId,
     int textId,
     int imageId) {
   ViewGroup group = get(menu, itemId, ViewGroup.class);
   get(group, R.id.bottom_menu_text, TextView.class).setText(textId);
   get(group, R.id.bottom_menu_image, ImageView.class).setImageResource(imageId);
   if (Build.VERSION.SDK_INT >= 11) {
     get(group, R.id.bottom_menu_image, ImageView.class).setAlpha(0.7f);
   }
   group.setTag(BottomMenuClickListener.TAG_FRAGMENT, f);
   group.setTag(BottomMenuClickListener.TAG_IDX, counter.getAndIncrement());
   group.setOnClickListener(listener);
 }
コード例 #12
0
 public View getView(int paramInt, View paramView, ViewGroup paramViewGroup) {
   paramViewGroup = paramView;
   if (paramView == null) {
     paramViewGroup = g.a(b).inflate(2130903179, null);
   }
   paramViewGroup.setBackgroundDrawable(b(paramInt));
   ((ImageView) paramViewGroup.findViewById(2131362458)).setImageDrawable(a(paramInt));
   paramView = (TextView) paramViewGroup.findViewById(2131362459);
   paramView.setTextColor(-16777216);
   paramView.setText(d[paramInt]);
   paramView = (RadioButton) paramViewGroup.findViewById(2131362460);
   if (e == paramInt) {}
   for (boolean bool = true; ; bool = false) {
     paramView.setChecked(bool);
     paramView.setClickable(false);
     paramViewGroup.setOnClickListener(new ag(this, paramInt));
     paramViewGroup.setOnTouchListener(new ah(this, paramInt));
     return paramViewGroup;
   }
 }
コード例 #13
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRootView = (ViewGroup) inflater.inflate(R.layout.fragment_tracks_dropdown, null);
    mTitle = (TextView) mRootView.findViewById(R.id.track_title);
    mAbstract = (TextView) mRootView.findViewById(R.id.track_abstract);

    mRootView.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View view) {
            mListPopupWindow = new ListPopupWindow(getActivity());
            mListPopupWindow.setAdapter(mAdapter);
            mListPopupWindow.setModal(true);
            mListPopupWindow.setContentWidth(400);
            mListPopupWindow.setAnchorView(mRootView);
            mListPopupWindow.setOnItemClickListener(TracksDropdownFragment.this);
            mListPopupWindow.show();
            mListPopupWindow.setOnDismissListener(TracksDropdownFragment.this);
          }
        });
    return mRootView;
  }
コード例 #14
0
 private void a(User paramUser, ViewGroup paramViewGroup)
 {
   List localList = paramUser.getYearsElite();
   Collections.sort(localList, Collections.reverseOrder());
   int m = localList.size();
   LinearLayout.LayoutParams localLayoutParams = cp.b();
   int k = ao.m;
   rightMargin = k;
   leftMargin = k;
   if (m > 3)
   {
     rightMargin = 0;
     leftMargin = -1;
   }
   k = 0;
   if (k < m)
   {
     User.EliteYear localEliteYear = (User.EliteYear)localList.get(k);
     Object localObject = getContext();
     User.EliteYear.TYPE localTYPE = type;
     if ((k != 0) && (m > 3)) {}
     for (boolean bool = true;; bool = false)
     {
       localObject = new EliteBadge((Context)localObject, null, localTYPE.getBadge(bool));
       paramViewGroup.addView((View)localObject, localLayoutParams);
       if (k >= 5) {
         break label164;
       }
       ((EliteBadge)localObject).setYear(year);
       k += 1;
       break;
     }
   }
   label164:
   paramUser = WhatsAnElite.a(getContext(), paramUser);
   paramViewGroup.setOnClickListener(new by(EventIri.ProfileEliteBanner, paramUser));
 }
コード例 #15
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    if (draggedBrick != null && dragTargetPosition == position) {
      return insertionView;
    }
    listItemCount = position + 1;

    Object item = getItem(position);

    if (item instanceof ScriptBrick
        && (!initInsertedBrick || position != positionOfInsertedBrick)) {
      View scriptBrickView = ((Brick) item).getView(context, position, this);
      if (draggedBrick == null) {
        scriptBrickView.setOnClickListener(this);
      }
      return scriptBrickView;
    }

    View currentBrickView;
    // dirty HACK
    // without the footer, position can be 0, and list.get(-1) caused an Indexoutofboundsexception
    // no clean solution was found
    if (position == 0) {
      if (item instanceof AllowedAfterDeadEndBrick
          && brickList.get(position) instanceof DeadEndBrick) {
        currentBrickView =
            ((AllowedAfterDeadEndBrick) item).getNoPuzzleView(context, position, this);
      } else {
        currentBrickView = ((Brick) item).getView(context, position, this);
      }
    } else {
      if (item instanceof AllowedAfterDeadEndBrick
          && brickList.get(position - 1) instanceof DeadEndBrick) {
        currentBrickView =
            ((AllowedAfterDeadEndBrick) item).getNoPuzzleView(context, position, this);
      } else {
        currentBrickView = ((Brick) item).getView(context, position, this);
      }
    }

    // this one is working but causes null pointer exceptions on movement and control bricks?!
    //		currentBrickView.setOnLongClickListener(longClickListener);

    // Hack!!!
    // if wrapper isn't used the longClick event won't be triggered
    @SuppressLint("ViewHolder")
    ViewGroup wrapper = (ViewGroup) View.inflate(context, R.layout.brick_wrapper, null);
    if (currentBrickView.getParent() != null) {
      ((ViewGroup) currentBrickView.getParent()).removeView(currentBrickView);
    }

    LinearLayout brickElement = (LinearLayout) currentBrickView;
    final CheckBox checkbox = ((Brick) getItem(position)).getCheckBox();

    wrapper.addView(currentBrickView);
    if (draggedBrick == null) {
      if ((selectMode == ListView.CHOICE_MODE_NONE)) {
        wrapper.setOnClickListener(this);
        if (!(item instanceof DeadEndBrick)) {
          wrapper.setOnLongClickListener(dragAndDropListView);
        }
      } else {
        brickElement.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                checkbox.setChecked(!checkbox.isChecked());
              }
            });
      }
    }

    if (position == positionOfInsertedBrick
        && initInsertedBrick
        && (selectMode == ListView.CHOICE_MODE_NONE)) {
      initInsertedBrick = false;
      addingNewBrick = true;
      dragAndDropListView.setInsertedBrick(position);

      dragAndDropListView.setDraggingNewBrick();
      dragAndDropListView.onLongClick(currentBrickView);

      return insertionView;
    }

    if (animatedBricks.contains(brickList.get(position))) {
      Animation animation = AnimationUtils.loadAnimation(context, R.anim.blink);
      wrapper.startAnimation(animation);
      animatedBricks.remove(brickList.get(position));
    }
    return wrapper;
  }
コード例 #16
0
  @Override
  public View getView(int position, View reuse, ViewGroup parent) {
    if (reuse != null) {
      eventType = (ImageView) reuse.findViewById(R.id.capture_list_cell_image_type);
      fileName = (TextView) reuse.findViewById(R.id.capture_list_cell_name);
      location = (ImageView) reuse.findViewById(R.id.capture_list_cell_image_location);
      checkMark = (ImageView) reuse.findViewById(R.id.capture_list_cell_image_checkmark);
      holder = (ViewGroup) reuse.findViewById(R.id.capture_list_cell_holder);
      final SavedCaptures obj = list.get(position);
      eventType.setBackgroundResource(setEventType(obj.getCaptureType()));
      fileName.setText(getFileName(obj.getFileName()));

      holder.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              SavedCaptures savedCap = obj;

              File file = new File(savedCap.getFileName());
              if (file.exists()) {
                Intent intent = new Intent();
                intent.setAction(Intent.ACTION_VIEW);
                if (savedCap.getCaptureType().equals("image/jpeg"))
                  intent.setDataAndType(Uri.parse("file://" + savedCap.getFileName()), "image/*");
                else if (savedCap.getCaptureType().equals("audio/x-caf"))
                  intent.setDataAndType(Uri.parse("file://" + savedCap.getFileName()), "audio/*");
                else if (savedCap.getCaptureType().equals("video/quicktime"))
                  intent.setDataAndType(Uri.parse("file://" + savedCap.getFileName()), "video/*");
                context.startActivity(intent);
              } else {
                Intent intentDownload = new Intent(context, AssetDownloadingProgressActivity.class);
                Bundle b = new Bundle();
                b.putString("eventserverid", savedCap.getEventServerId());
                b.putString("assetserverid", savedCap.getAssetServerId());
                b.putString("filepath", file.getAbsolutePath());

                intentDownload.putExtras(b);
                context.startActivity(intentDownload);
              }
            }
          });
      if (obj.getLatitude() > 0) location.setImageResource(R.drawable.location_green);
      else {
        location.setOnClickListener(
            new OnClickListener() {
              @Override
              public void onClick(View v) {
                SavedCaptures savedCap = obj;

                Intent intent = new Intent(context, MapActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                intent.putExtra("file_id", savedCap.getID());
                context.startActivity(intent);
              }
            });
      }

      if (obj.getUploadStatus()) checkMark.setImageResource(R.drawable.checkmark_green);

      return reuse;
    } else {
      ViewGroup item = getViewGroup(reuse, parent);

      eventType = (ImageView) item.findViewById(R.id.capture_list_cell_image_type);
      fileName = (TextView) item.findViewById(R.id.capture_list_cell_name);
      location = (ImageView) item.findViewById(R.id.capture_list_cell_image_location);
      checkMark = (ImageView) item.findViewById(R.id.capture_list_cell_image_checkmark);
      holder = (ViewGroup) item.findViewById(R.id.capture_list_cell_holder);
      final SavedCaptures obj = list.get(position);
      eventType.setBackgroundResource(setEventType(obj.getCaptureType()));
      fileName.setText(getFileName(obj.getFileName()));

      holder.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              SavedCaptures savedCap = obj;

              File file = new File(savedCap.getFileName());

              if (file.exists()) {
                Intent intent = new Intent();
                intent.setAction(Intent.ACTION_VIEW);
                if (savedCap.getCaptureType().equals("image/jpeg"))
                  intent.setDataAndType(Uri.parse("file://" + savedCap.getFileName()), "image/*");
                else if (savedCap.getCaptureType().equals("audio/x-caf"))
                  intent.setDataAndType(Uri.parse("file://" + savedCap.getFileName()), "audio/*");
                else if (savedCap.getCaptureType().equals("video/quicktime"))
                  intent.setDataAndType(Uri.parse("file://" + savedCap.getFileName()), "video/*");
                context.startActivity(intent);
              } else {
                Intent intentDownload = new Intent(context, AssetDownloadingProgressActivity.class);
                Bundle b = new Bundle();
                b.putString("eventserverid", savedCap.getEventServerId());
                b.putString("assetserverid", savedCap.getAssetServerId());
                b.putString("filepath", file.getAbsolutePath());

                intentDownload.putExtras(b);
                context.startActivity(intentDownload);
              }
            }
          });

      if (obj.getLatitude() > 0) location.setImageResource(R.drawable.location_green);
      else {
        location.setOnClickListener(
            new OnClickListener() {
              @Override
              public void onClick(View v) {
                SavedCaptures savedCap = obj;

                Intent intent = new Intent(context, MapActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                intent.putExtra("file_id", savedCap.getID());
                context.startActivity(intent);
              }
            });
      }
      if (obj.getUploadStatus()) checkMark.setImageResource(R.drawable.checkmark_green);
      return item;
    }
  }
コード例 #17
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_lobby);

    Bundle extras = getIntent().getExtras();
    playerName = extras.getString("name");
    if (playerName.isEmpty()) playerName = "guest" + (int) (Math.random() * 100000);
    playerAvatar = playerName.substring(0, 1);

    layoutCreateLobby = (ViewGroup) findViewById(R.id.layoutCreateLobby);
    layoutCreateLobby.setVisibility(View.GONE);
    editLobbyName = (EditText) findViewById(R.id.editText);
    listView = (ListView) findViewById(R.id.listView);
    mAdapter = new ArrayAdapter<NetAddress>(this, R.layout.lobby_list_item, R.id.textView);
    listView.setAdapter(mAdapter);
    findViewById(R.id.buttonRefresh)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                lobbyManager.listLobbies(listLobbiesListener);
              }
            });

    findViewById(R.id.buttonCreate)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                layoutCreateLobby.setVisibility(View.VISIBLE);
              }
            });
    layoutCreateLobby.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            layoutCreateLobby.setVisibility(View.GONE);
          }
        });

    findViewById(R.id.buttonCreateLobby)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                String name = editLobbyName.getText().toString();
                Intent i = new Intent(LobbyBrowserActivity.this, GameActivity.class);
                i.putExtra("action", "host");
                i.putExtra("lobbyName", name);
                i.putExtra("sessionId", mSessionId);
                i.putExtra("playerName", playerName);
                i.putExtra("playerAvatar", playerAvatar);
                startActivity(i);
              }
            });

    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> adapterView, View view, int pos, long l) {
            NetAddress netAddress = mAdapter.getItem(pos);
            Intent i = new Intent(LobbyBrowserActivity.this, GameActivity.class);
            i.putExtra("action", "join");
            i.putExtra("lobby", new Lobby(netAddress.srcAddress, netAddress.srcPort));
            i.putExtra("sessionId", mSessionId);
            i.putExtra("playerName", playerName);
            i.putExtra("playerAvatar", playerAvatar);
            startActivity(i);
          }
        });
  }
コード例 #18
0
  private ViewGroup getViewForMessage(int num, boolean applyOffset) {
    if (NotificationsController.getInstance().popupMessages.size() == 1
        && (num < 0 || num >= NotificationsController.getInstance().popupMessages.size())) {
      return null;
    }
    if (num == -1) {
      num = NotificationsController.getInstance().popupMessages.size() - 1;
    } else if (num == NotificationsController.getInstance().popupMessages.size()) {
      num = 0;
    }
    ViewGroup view;
    MessageObject messageObject = NotificationsController.getInstance().popupMessages.get(num);
    if (messageObject.type == 1 || messageObject.type == 4) {
      if (imageViews.size() > 0) {
        view = imageViews.get(0);
        imageViews.remove(0);
      } else {
        view = new FrameLayoutAnimationListener(this);
        view.addView(getLayoutInflater().inflate(R.layout.popup_image_layout, null));
        view.setTag(2);

        view.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                openCurrentMessage();
              }
            });
      }

      TextView messageText = (TextView) view.findViewById(R.id.message_text);
      BackupImageView imageView = (BackupImageView) view.findViewById(R.id.message_image);
      imageView.setAspectFit(true);

      if (messageObject.type == 1) {
        TLRPC.PhotoSize currentPhotoObject =
            FileLoader.getClosestPhotoSizeWithSize(
                messageObject.photoThumbs, AndroidUtilities.getPhotoSize());
        TLRPC.PhotoSize thumb =
            FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 100);
        boolean photoSet = false;
        if (currentPhotoObject != null) {
          boolean photoExist = true;
          if (messageObject.type == 1) {
            File cacheFile = FileLoader.getPathToMessage(messageObject.messageOwner);
            if (!cacheFile.exists()) {
              photoExist = false;
            }
          }
          if (photoExist
              || MediaController.getInstance()
                  .canDownloadMedia(MediaController.AUTODOWNLOAD_MASK_PHOTO)) {
            imageView.setImage(
                currentPhotoObject.location, "100_100", thumb.location, currentPhotoObject.size);
            photoSet = true;
          } else {
            if (thumb != null) {
              imageView.setImage(thumb.location, null, (Drawable) null);
              photoSet = true;
            }
          }
        }
        if (!photoSet) {
          imageView.setVisibility(View.GONE);
          messageText.setVisibility(View.VISIBLE);
          messageText.setTextSize(
              TypedValue.COMPLEX_UNIT_SP, MessagesController.getInstance().fontSize);
          messageText.setText(messageObject.messageText);
        } else {
          imageView.setVisibility(View.VISIBLE);
          messageText.setVisibility(View.GONE);
        }
      } else if (messageObject.type == 4) {
        messageText.setVisibility(View.GONE);
        messageText.setText(messageObject.messageText);
        imageView.setVisibility(View.VISIBLE);
        double lat = messageObject.messageOwner.media.geo.lat;
        double lon = messageObject.messageOwner.media.geo._long;
        String currentUrl =
            String.format(
                Locale.US,
                "https://maps.googleapis.com/maps/api/staticmap?center=%f,%f&zoom=13&size=100x100&maptype=roadmap&scale=%d&markers=color:red|size:big|%f,%f&sensor=false",
                lat,
                lon,
                Math.min(2, (int) Math.ceil(AndroidUtilities.density)),
                lat,
                lon);
        imageView.setImage(currentUrl, null, null);
      }
    } else if (messageObject.type == 2) {
      PopupAudioView cell;
      if (audioViews.size() > 0) {
        view = audioViews.get(0);
        audioViews.remove(0);
        cell = (PopupAudioView) view.findViewWithTag(300);
      } else {
        view = new FrameLayoutAnimationListener(this);
        view.addView(getLayoutInflater().inflate(R.layout.popup_audio_layout, null));
        view.setTag(3);

        view.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                openCurrentMessage();
              }
            });

        ViewGroup audioContainer = (ViewGroup) view.findViewById(R.id.audio_container);
        cell = new PopupAudioView(this);
        cell.setTag(300);
        audioContainer.addView(cell);
      }

      cell.setMessageObject(messageObject);
      if (MediaController.getInstance().canDownloadMedia(MediaController.AUTODOWNLOAD_MASK_AUDIO)) {
        cell.downloadAudioIfNeed();
      }
    } else {
      if (textViews.size() > 0) {
        view = textViews.get(0);
        textViews.remove(0);
      } else {
        view = new FrameLayoutAnimationListener(this);
        view.addView(getLayoutInflater().inflate(R.layout.popup_text_layout, null));
        view.setTag(1);

        View textContainer = view.findViewById(R.id.text_container);
        textContainer.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                openCurrentMessage();
              }
            });
      }
      TextView messageText = (TextView) view.findViewById(R.id.message_text);
      messageText.setTag(301);
      messageText.setTextSize(
          TypedValue.COMPLEX_UNIT_SP, MessagesController.getInstance().fontSize);
      messageText.setText(messageObject.messageText);
    }
    if (view.getParent() == null) {
      messageContainer.addView(view);
    }
    view.setVisibility(View.VISIBLE);

    if (applyOffset) {
      int widht = AndroidUtilities.displaySize.x - AndroidUtilities.dp(24);
      FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams();
      layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
      layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT;
      layoutParams.width = widht;
      if (num == currentMessageNum) {
        layoutParams.leftMargin = 0;
      } else if (num == currentMessageNum - 1) {
        layoutParams.leftMargin = -widht;
      } else if (num == currentMessageNum + 1) {
        layoutParams.leftMargin = widht;
      }
      view.setLayoutParams(layoutParams);
      view.invalidate();
    }

    return view;
  }
コード例 #19
0
  // 当按下编辑资料按钮时操作
  private void reayToUpdateUserInfo() {
    String flag = "updating";
    FragmentChangeActivity.slideMenu.setTag(flag);
    FragmentChangeActivity.slideMenu.setSlidingEnabled(false);
    headLayout.setVisibility(View.GONE);
    middleLayout.setVisibility(View.GONE);
    sexGroup.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            if (!v.isEnabled()) return;
            v.setEnabled(false);
            if (isLogin) {
              // 更改性别
              showSexSettingRem();
              v.setEnabled(true);
            }
          }
        });
    // 更改生日
    birthdayGroup.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            if (!v.isEnabled()) return;
            v.setEnabled(false);
            if (isLogin) {
              // 更改生日
              showBirthdaySettingRem();
              v.setEnabled(true);
            }
          }
        });

    // 更改邮箱
    etEmail.setEnabled(isUpdate);
    if (etEmail.getText() != null) {
      etEmail.setHint(R.string.email_hint_text);
    }
    String email = etEmail.getText().toString();
    String regMacth = "[\\w]+@[\\w]+.[\\w]+";
    if (email.matches(regMacth)) {
      rec.setEmail(email);
    }

    // 更改真实姓名
    etRealName.setEnabled(isUpdate);
    if (etRealName.getText() != null) {
      etRealName.setHint(R.string.real_name_hint_text);
    }
    String RealName = etRealName.getText().toString();
    rec.setRealName(RealName);

    // 更改MSN
    etMsn.setEnabled(isUpdate);
    if (etMsn.getText() != null) {
      etMsn.setHint(R.string.msn_hint_text);
    }
    String Msn = etMsn.getText().toString();
    rec.setMsn(Msn);

    // 更改qq
    etQQ.setEnabled(isUpdate);
    if (etQQ.getText() != null) {
      etQQ.setHint(R.string.qq_hint_text);
    }
    String QQ = etQQ.getText().toString();
    rec.setQq(QQ);

    // 更改工作电话
    etOfficePhone.setEnabled(isUpdate);
    if (etOfficePhone.getText() != null) {
      etOfficePhone.setHint(R.string.office_phone_hint_text);
    }
    String OfficePhone = etOfficePhone.getText().toString();
    rec.setOfficePhone(OfficePhone);

    // 更改手机
    etMobilePhone.setEnabled(isUpdate);
    if (etMobilePhone.getText() != null) {
      etMobilePhone.setHint(R.string.mobile_phone_hint_text);
    }
    String MobilePhone = etMobilePhone.getText().toString();
    rec.setMobilePhone(MobilePhone);

    // 更改座机
    etHomePhone.setEnabled(isUpdate);
    if (etHomePhone.getText() != null) {
      etHomePhone.setHint(R.string.home_phone_hint_text);
    }
    String HomePhone = etHomePhone.getText().toString();
    rec.setHomePhone(HomePhone);
  }
コード例 #20
0
    @Override
    protected void onPostExecute(Boolean result) {
      mIsPostTaskRunning = false;

      if (!result) {
        /*
         * post couldn't be loaded (?)
         */
        txtTitle.setText(R.string.reader_title_err_unable_to_load_post);
        txtSource.setVisibility(View.GONE);
        imgAvatar.setImageResource(R.drawable.ic_error);
        return;
      }

      // likes appears above the webView so force the like layout to take up space before loading
      // them in refreshLikes() - this way the webView won't appear and then be pushed down the
      // page once likes are loaded
      if (mPost.numLikes > 0 && mLayoutLikes.getVisibility() == View.GONE)
        mLayoutLikes.setVisibility(View.INVISIBLE);

      if (mPost.hasTitle()) {
        txtTitle.setText(mPost.getTitle());
      } else {
        txtTitle.setText(R.string.reader_untitled_post);
      }

      // tapping title layout opens post in browser
      layoutTitle.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              ReaderActivityLauncher.openUrl(ReaderPostDetailActivity.this, mPost.getUrl());
            }
          });

      // blog name / author name / date
      txtSource.setText(mPost.getSource());

      if (mPost.hasPostAvatar()) {
        int avatarSz = getResources().getDimensionPixelSize(R.dimen.reader_avatar_sz_medium);
        imgAvatar.setImageUrl(
            mPost.getPostAvatarForDisplay(avatarSz), WPNetworkImageView.ImageType.AVATAR);
        imgAvatar.setVisibility(View.VISIBLE);
      } else {
        imgAvatar.setVisibility(View.GONE);
      }

      // enable reblogging wp posts
      btnReblog.setVisibility(mPost.isWP() ? View.VISIBLE : View.GONE);
      btnReblog.setSelected(mPost.isRebloggedByCurrentUser);
      if (mPost.isWP()) {
        btnReblog.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                doPostReblog(btnReblog, mPost);
              }
            });
      }

      // enable adding a comment if comments are open on this post
      if (mPost.isWP() && mPost.isCommentsOpen) {
        btnComment.setVisibility(View.VISIBLE);
        btnComment.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                toggleShowAddCommentBox();
              }
            });
      } else {
        btnComment.setVisibility(View.GONE);
      }

      // webView settings must be configured on main thread - note that while JavaScript is
      // required for embedded videos, it's disabled since it's a security risk:
      //    http://developer.android.com/training/articles/security-tips.html#WebView
      // note: even with JavaScript enabled video embeds are unreliable (some work, some don't)
      webView.getSettings().setJavaScriptEnabled(false);
      webView.getSettings().setUserAgentString(Constants.USER_AGENT);
      webView
          .getSettings()
          .setLayoutAlgorithm(
              WebSettings.LayoutAlgorithm.NARROW_COLUMNS); // <-- not sure this is necessary

      // webView is hidden at design time, don't show it until the page finishes loading so it
      // has time to layout the post before it appears...
      webView.setWebViewClient(
          new WebViewClient() {
            @Override
            public void onPageFinished(WebView view, String url) {
              if (webView.getVisibility() != View.VISIBLE) webView.setVisibility(View.VISIBLE);
            }

            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
              // open clicked urls in default browser or else urls will open in this webView,
              // but only do this when webView has loaded (is visible) - have seen some posts
              // containing iframes automatically try to open urls (without being clicked)
              // before the page has loaded
              if (view.getVisibility() == View.VISIBLE) {
                ReaderActivityLauncher.openUrl(ReaderPostDetailActivity.this, url);
                return true;
              } else {
                return false;
              }
            }
          });

      // ...but force it to appear after a few seconds to ensure user never has to be faced
      // with a blank post for too long (very important on slow connections)
      new Handler()
          .postDelayed(
              new Runnable() {
                @Override
                public void run() {
                  if (webView.getVisibility() != View.VISIBLE) {
                    webView.setVisibility(View.VISIBLE);
                    ReaderLog.w("forced webView to appear before page finished");
                  }
                }
              },
              2500);

      // detect image taps so we can open images in the photo viewer activity
      webView.setOnTouchListener(
          new View.OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
              if (event.getAction() == MotionEvent.ACTION_UP) {
                HitTestResult hr = ((WebView) v).getHitTestResult();
                if (hr != null
                    && (hr.getType() == HitTestResult.IMAGE_TYPE
                        || hr.getType() == HitTestResult.SRC_IMAGE_ANCHOR_TYPE)) {
                  String imageUrl = hr.getExtra();
                  if (imageUrl == null) return false;
                  // skip if image is a file: reference - this will be the video overlay, ie:
                  // file:///android_res/drawable/ic_reader_video_overlay.png
                  if (imageUrl.startsWith("file:")) return false;
                  // skip if image is a video thumbnail (see processVideos)
                  if (mVideoThumbnailUrls.contains(imageUrl)) return false;
                  // skip if image is a VideoPress thumbnail (anchor around thumbnail will
                  // take user to actual video - see ReaderPost.cleanupVideoPress)
                  if (imageUrl.contains("videos.files.")) return false;
                  showPhotoViewer(imageUrl);
                  return true;
                }
              }
              return false;
            }
          });

      // IMPORTANT: must use loadDataWithBaseURL() rather than loadData() since the latter often
      // fails
      // https://code.google.com/p/android/issues/detail?id=4401
      webView.loadDataWithBaseURL(null, postHtml, "text/html", "UTF-8", null);

      // only show action buttons for WP posts
      mLayoutActions.setVisibility(mPost.isWP() ? View.VISIBLE : View.GONE);

      // make sure the adapter is assigned now that we've retrieved the post and updated views
      if (!hasCommentAdapter()) getListView().setAdapter(getCommentAdapter());

      refreshFollowed();
      refreshLikes();
      refreshComments();

      // get the latest info for this post if we haven't updated it already
      if (!mHasAlreadyUpdatedPost) {
        updatePost();
        mHasAlreadyUpdatedPost = true;
      }

      // show the listView now that post has loaded and views have been updated
      getListView().setVisibility(View.VISIBLE);
    }
コード例 #21
0
  private void init() {
    place = getPlaceById();
    if (place != null) {
      currentCityId = place.getCityId();
      nearbyPlaceList = new ArrayList<Place>();
      List<String> imagePath = place.getImagesList();
      LayoutInflater inflater = getLayoutInflater();
      ArrayList<View> imageViewlist = new ArrayList<View>();
      imageLoader = ImageLoader.getInstance();
      int size = imagePath.size();
      String url = "";
      View view = null;
      ImageView imageView = null;
      for (int i = 0; i < size; i++) {
        view = inflater.inflate(R.layout.place_detail_image, null);
        imageView = (ImageView) view.findViewById(R.id.place_image_item);
        url = imagePath.get(i);
        url = TravelUtil.getImageUrl(currentCityId, url);
        imageLoader.displayImage(url, imageView);
        imageViewlist.add(view);
      }
      imageViews = new ImageView[size];
      main = (ViewGroup) inflater.inflate(R.layout.common_place_detail, null);
      ViewGroup group = (ViewGroup) main.findViewById(R.id.place_images_group);
      ViewPager placeImage = (ViewPager) main.findViewById(R.id.place_images);
      LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(10, 10);
      params.setMargins(
          (int) getResources().getDimension(R.dimen.image_margin),
          0,
          (int) getResources().getDimension(R.dimen.image_margin),
          0);
      for (int i = 0; i < size; i++) {
        imageView = new ImageView(CommonPlaceDetailActivity.this);
        imageView.setLayoutParams(params);
        imageViews[i] = imageView;
        if (i == 0) {
          imageViews[i].setBackgroundResource(R.drawable.guide_dot_white);
        } else {
          imageViews[i].setBackgroundResource(R.drawable.guide_dot_black);
        }
        group.addView(imageView);
      }
      PlaceImageAdapter sceneryAdapter = new PlaceImageAdapter(imageViewlist);
      if (isSupportService()) {
        ViewGroup serviceGroup = (ViewGroup) main.findViewById(R.id.proServiceGroup);
        serviceGroup.setVisibility(View.VISIBLE);
        ImageView serviceImageView = null;
        LayoutParams layoutParams =
            new LayoutParams(
                (int) this.getResources().getDimension(R.dimen.service_icon2),
                LayoutParams.WRAP_CONTENT);
        for (int id : place.getProvidedServiceIdList()) {

          serviceImageView = new ImageView(CommonPlaceDetailActivity.this);
          serviceImageView.setLayoutParams(layoutParams);
          serviceImageView.setScaleType(ScaleType.FIT_CENTER);
          serviceImageView.setImageResource(TravelUtil.getServiceImage(id));
          serviceGroup.addView(serviceImageView);
        }
      }

      placeImage.setAdapter(sceneryAdapter);
      placeImage.setOnPageChangeListener(placeImageOnPageChangeListener);
      setContentView(main);

      if (isSupportSpecialTrafficStyle()) {
        main.findViewById(R.id.special_trans_group).setVisibility(View.VISIBLE);
        String trafficInfos = place.getTransportation();
        trafficInfos = trafficInfos.replaceAll(":;", "").trim();
        String[] traffic = trafficInfos.split(";");
        specialTrans = (ViewGroup) main.findViewById(R.id.special_trans);
        if (traffic.length > 0) {
          int i = 1;
          String[] trafficDetail = null;
          RelativeLayout.LayoutParams params1 =
              new RelativeLayout.LayoutParams(
                  (int) getResources().getDimension(R.dimen.special_traffic_loaction),
                  LayoutParams.WRAP_CONTENT);
          RelativeLayout.LayoutParams params2 =
              new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
          LayoutParams params3 =
              new LayoutParams(
                  (int) getResources().getDimension(R.dimen.transport_width),
                  (int) getResources().getDimension(R.dimen.transport_height));
          for (String trafficInfo : traffic) {
            row = new RelativeLayout(CommonPlaceDetailActivity.this);
            row.setLayoutParams(params3);
            if (i == traffic.length) {
              row.setBackgroundDrawable(getResources().getDrawable(R.drawable.table5_down));
            } else {
              row.setBackgroundDrawable(getResources().getDrawable(R.drawable.table5_center));
            }

            trafficDetail = trafficInfo.split(":");
            if (trafficDetail.length == 2) {
              locationTextView = new TextView(CommonPlaceDetailActivity.this);
              distanceTextView = new TextView(CommonPlaceDetailActivity.this);
              params1.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
              params1.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
              params1.setMargins(
                  (int) getResources().getDimension(R.dimen.transport_margin_left), 0, 0, 0);
              params2.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
              params2.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
              params2.setMargins(
                  (int) getResources().getDimension(R.dimen.transport_margin_right), 0, 0, 0);
              locationTextView.setLayoutParams(params1);
              distanceTextView.setLayoutParams(params2);
              locationTextView.setTextColor(getResources().getColor(R.color.place_price_color));
              locationTextView.setTextSize(
                  getResources().getDimension(R.dimen.transport_text_size));
              locationTextView.setSingleLine(true);
              locationTextView.setMarqueeRepeatLimit(-1);
              locationTextView.setEllipsize(TruncateAt.MARQUEE);
              locationTextView.setHorizontallyScrolling(true);
              locationTextView.setSelected(true);
              distanceTextView.setTextColor(getResources().getColor(R.color.place_price_color));
              distanceTextView.setTextSize(
                  getResources().getDimension(R.dimen.transport_location_text_size));
              locationTextView.setText(trafficDetail[0]);
              distanceTextView.setText(trafficDetail[1]);
              row.addView(locationTextView);
              row.addView(distanceTextView);
              specialTrans.addView(row, i);
            }
            i++;
          }
        }

      } else {
        main.findViewById(R.id.transport_group).setVisibility(View.VISIBLE);
        TextView transport = (TextView) main.findViewById(R.id.transport);
        transport.setSelected(true);
        transport.setText(place.getTransportation());
      }

      // ticket
      if (isSupportTicket()) {
        String priceDescription = place.getPriceDescription();
        if (priceDescription != null && !priceDescription.equals("")) {
          findViewById(R.id.ticket_group).setVisibility(View.VISIBLE);
          TextView ticket = (TextView) findViewById(R.id.ticket);
          ticket.setText(priceDescription);
        }
      }

      // food
      if (isSupportFood()) {
        String footCate = AppManager.getInstance().getAllSubCatMap().get(place.getSubCategoryId());
        if (footCate != null && !footCate.equals("")) {
          findViewById(R.id.food_group).setVisibility(View.VISIBLE);
          TextView food = (TextView) findViewById(R.id.food);
          food.setText(footCate);
        }
      }

      // openTime
      if (isSupportOpenTime()) {
        String openTimeString = place.getOpenTime();
        if (openTimeString != null && !openTimeString.equals("")) {
          findViewById(R.id.open_time_group).setVisibility(View.VISIBLE);
          if (place.getCategoryId() != PlaceCategoryType.PLACE_SPOT_VALUE) {
            TextView openTimeTitle = (TextView) findViewById(R.id.open_time_title);
            openTimeTitle.setText(getString(R.string.open_time1));
          }

          TextView openTime = (TextView) findViewById(R.id.open_time);
          openTime.setText(openTimeString);
        }
      }

      // avgPrice
      if (isSupportAvgPrice()) {
        String avePriceString = place.getAvgPrice();
        if (avePriceString != null && !avePriceString.equals("")) {
          findViewById(R.id.avg_price_group).setVisibility(View.VISIBLE);
          TextView avgPrice = (TextView) findViewById(R.id.avg_price);
          HashMap<Integer, String> symbolHashMap = AppManager.getInstance().getSymbolMap();
          StringBuffer symbol = new StringBuffer();
          if (symbolHashMap.containsKey(currentCityId)) {
            String symbolStr = symbolHashMap.get(currentCityId);
            symbol.append(symbolStr);
          }
          avgPrice.setText(symbol + avePriceString);
        }
      }

      // specialFood
      if (isSupportSpecialFood()) {
        List<String> typcialDisList = place.getTypicalDishesList();
        if (typcialDisList != null && typcialDisList.size() > 0) {
          findViewById(R.id.special_food_group).setVisibility(View.VISIBLE);
          TextView specialFood = (TextView) findViewById(R.id.special_food);
          StringBuffer typicalDishes = new StringBuffer();
          for (String typcial : typcialDisList) {
            typicalDishes.append(typcial);
            typicalDishes.append("  ");
          }
          specialFood.setText(typicalDishes);
        }
      }

      // tips
      if (isSupportTips()) {
        String tipsString = place.getTips();
        if (tipsString != null && !tipsString.equals("")) {
          findViewById(R.id.tips_group).setVisibility(View.VISIBLE);
          TextView tipsTitles = (TextView) findViewById(R.id.tips_title);
          TextView tips = (TextView) findViewById(R.id.tips);
          tipsTitles.setText(tipsTitle);
          tips.setText(tipsString);
        }
      }

      // park
      if (isSupportPark()) {
        String parkGuideString = place.getParkingGuide();
        if (parkGuideString != null && !parkGuideString.equals("")) {
          findViewById(R.id.park_group).setVisibility(View.VISIBLE);
          TextView park = (TextView) findViewById(R.id.park);
          park.setText(place.getParkingGuide());
        }
      }

      // hotelStart
      if (isSupportHotelStart()) {
        int hotelStartLevel = place.getHotelStar();
        if (hotelStartLevel > 0) {
          findViewById(R.id.hotel_start_group).setVisibility(View.VISIBLE);
          TextView hotelStart = (TextView) findViewById(R.id.hotel_start);
          hotelStart.setText(TravelUtil.getHotelStar(this, hotelStartLevel));
          ViewGroup hotelStartImageGroup = (ViewGroup) findViewById(R.id.hotel_start_image);
          ImageView hotelStartImage;
          LayoutParams layoutParams =
              new LayoutParams(
                  (int) this.getResources().getDimension(R.dimen.hotel_start_icon),
                  LayoutParams.WRAP_CONTENT);
          for (int i = 0; i < place.getHotelStar(); i++) {

            hotelStartImage = new ImageView(CommonPlaceDetailActivity.this);
            hotelStartImage.setLayoutParams(layoutParams);
            hotelStartImage.setPadding(0, 0, 5, 0);
            hotelStartImage.setScaleType(ScaleType.FIT_CENTER);
            hotelStartImage.setImageResource(R.drawable.star_ico);
            hotelStartImageGroup.addView(hotelStartImage);
          }
        }
      }

      // keyword
      if (isSupportKeyWords()) {
        List<String> keyList = place.getKeywordsList();
        if (keyList != null && keyList.size() > 0) {
          findViewById(R.id.keyword_group).setVisibility(View.VISIBLE);
          TextView keyword = (TextView) findViewById(R.id.place_keyword);
          StringBuffer keywordStr = new StringBuffer();
          for (String key : keyList) {
            keywordStr.append(key);
            keywordStr.append("、");
          }
          if (keywordStr.length() > 1) {
            keyword.setText(keywordStr.substring(0, keywordStr.length() - 1));
          }
        }
      }

      // roomprice
      if (isSupportRoomPrice()) {
        String priceString = place.getPrice();
        if (priceString != null && !priceString.equals("")) {
          findViewById(R.id.room_price_group).setVisibility(View.VISIBLE);
          TextView roomPrice = (TextView) findViewById(R.id.room_price);
          HashMap<Integer, String> symbolHashMap = AppManager.getInstance().getSymbolMap();
          StringBuffer symbol = new StringBuffer();
          if (symbolHashMap.containsKey(currentCityId)) {
            String symbolStr = symbolHashMap.get(currentCityId);
            symbol.append(symbolStr);
          }
          symbol.append(priceString);
          symbol.append("起");
          roomPrice.setText(symbol);
        }
      }

      ImageView recommendImage1 = (ImageView) findViewById(R.id.place_detail_recommend_image1);
      ImageView recommendImage2 = (ImageView) findViewById(R.id.place_detail_recommend_image2);
      ImageView recommendImage3 = (ImageView) findViewById(R.id.place_detail_recommend_image3);

      TextView placeDetailTitle = (TextView) findViewById(R.id.place_detail_title);
      TextView placeIntroTitle = (TextView) findViewById(R.id.place_intro_title);
      TextView placeIntro = (TextView) findViewById(R.id.place_intro);
      placeDetailTitle.setText(place.getName());
      placeIntroTitle.setText(getPlaceIntroTitle());
      String introduction = place.getIntroduction();
      introduction = TravelUtil.handlerString(introduction);
      placeIntro.setText("		" + introduction);

      int rank = place.getRank();
      switch (rank) {
        case 1:
          {
            recommendImage1.setImageDrawable(this.getResources().getDrawable(R.drawable.good));
            recommendImage2.setImageDrawable(this.getResources().getDrawable(R.drawable.good2));
            recommendImage3.setImageDrawable(this.getResources().getDrawable(R.drawable.good2));
          }
          break;
        case 2:
          {
            recommendImage1.setImageDrawable(this.getResources().getDrawable(R.drawable.good));
            recommendImage2.setImageDrawable(this.getResources().getDrawable(R.drawable.good));
            recommendImage3.setImageDrawable(this.getResources().getDrawable(R.drawable.good2));
          }
          break;
        case 3:
          {
            recommendImage1.setImageDrawable(this.getResources().getDrawable(R.drawable.good));
            recommendImage2.setImageDrawable(this.getResources().getDrawable(R.drawable.good));
            recommendImage3.setImageDrawable(this.getResources().getDrawable(R.drawable.good));
          }
          break;
        default:
          break;
      }

      if (place.getTelephoneList().size() > 0) {
        ViewGroup phoneGroup = (ViewGroup) findViewById(R.id.phone_group);
        phoneNum = (TextView) findViewById(R.id.phone_num);
        phoneNum.setSelected(true);
        ImageView phoneCall = (ImageView) findViewById(R.id.phone_call);
        phoneGroup.setVisibility(View.VISIBLE);
        StringBuffer phoneNumber = new StringBuffer();
        for (String telephone : place.getTelephoneList()) {
          phoneNumber.append(telephone);
          phoneNumber.append(" ");
        }
        phoneNum.setText(getString(R.string.phone_number) + " " + phoneNumber);
        phoneCall.setOnClickListener(phoneCallOnClickListener);
        phoneGroup.setOnClickListener(phoneCallOnClickListener);
      }

      if (place.getAddressList().size() > 0) {
        ViewGroup addressGroup = (ViewGroup) findViewById(R.id.address_group);
        TextView address = (TextView) findViewById(R.id.address);
        address.setSelected(true);
        ImageView addressMapView = (ImageView) findViewById(R.id.address_map_view);
        addressGroup.setVisibility(View.VISIBLE);
        StringBuffer addressStr = new StringBuffer();
        for (String addres : place.getAddressList()) {
          addressStr.append(addres);
          addressStr.append(" ");
        }
        address.setText(getString(R.string.address) + " " + addressStr);
        addressMapView.setOnClickListener(addressLocateOnClickListener);
        addressGroup.setOnClickListener(addressLocateOnClickListener);
      }

      if (place.getWebsite() != null && !place.getWebsite().equals("")) {
        ViewGroup websiteGroup = (ViewGroup) findViewById(R.id.website_group);
        websiteGroup.setVisibility(View.VISIBLE);
        TextView website = (TextView) findViewById(R.id.website);
        website.setText(place.getWebsite());
      }
      nearbyListGroup = (ViewGroup) findViewById(R.id.nearby_list_group);
      favoriteCount = (TextView) findViewById(R.id.favorite_count);
      collect = (TextView) findViewById(R.id.collect);
      collectBtn = (ImageView) findViewById(R.id.collect_btn);
      collectBtn.setOnClickListener(addFavoriteOnClickListener);
      ImageButton locationButton = (ImageButton) findViewById(R.id.location_button);
      Button indexButton = (Button) findViewById(R.id.index_button);
      indexButton.setOnClickListener(indexOnClickListener);
      ImageView help2Button = (ImageView) findViewById(R.id.help2);
      locationButton.setOnClickListener(locationOnClickListener);
      help2Button.setOnClickListener(helpOnClickListener);
    }
  }
コード例 #22
0
ファイル: SearchBox.java プロジェクト: shenm233/Mmaps
  @Override
  protected void onCreateView(LayoutInflater inflater, ViewGroup container) {
    super.onCreateView(inflater, container);
    ViewGroup searchBox = (ViewGroup) inflater.inflate(R.layout.search_box, container, false);
    mSearchBox = searchBox;

    ImageButton btn = (ImageButton) searchBox.findViewById(R.id.opendrawer_or_back);
    mBackBtn = btn;
    btn.setOnClickListener(this);

    final ImageButton editTextClearBtn = (ImageButton) searchBox.findViewById(R.id.edit_text_clear);
    editTextClearBtn.setOnClickListener(this);

    EditText searchEditText = (EditText) searchBox.findViewById(R.id.search_edittext);
    mSearchEditText = searchEditText;
    searchEditText.setCursorVisible(false);
    searchEditText.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {}

          @Override
          public void afterTextChanged(Editable s) {
            if (s.length() > 0) {
              editTextClearBtn.setVisibility(View.VISIBLE);
            } else {
              editTextClearBtn.setVisibility(View.INVISIBLE);
            }
            if (enableTextTip) {
              String str = s.toString().trim();
              mSearchBoxPresenter.requestInputTips(str, "");
            }
          }
        });
    searchEditText.setOnClickListener(this);
    searchEditText.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            String s = v.getText().toString();
            if (CommonUtils.isStringEmpty(s)) {
              return false;
            }
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
              Tip tip = getTipFromKeyword(s);
              tip.setID(""); // prevent null value
              returnResult(tip);
              return true;
            }
            return false;
          }
        });

    ViewGroup searchResultContainer =
        (ViewGroup) inflater.inflate(R.layout.search_result, container, false);
    mSearchResultContainer = searchResultContainer;

    ViewGroup chooseOnMapBtn =
        (ViewGroup) searchResultContainer.findViewById(R.id.search_choose_on_map);
    mChooseOnMapBtn = chooseOnMapBtn;
    chooseOnMapBtn.setOnClickListener(this);
    ViewGroup chooseFromFavBtn =
        (ViewGroup) searchResultContainer.findViewById(R.id.choose_from_favorites);
    mChooseFromFavBtn = chooseFromFavBtn;
    chooseFromFavBtn.setOnClickListener(this);

    RecyclerView resultListView =
        (RecyclerView) searchResultContainer.findViewById(R.id.result_listview);
    SearchTipsAdapter searchTipsAdapter = new SearchTipsAdapter(getContext());
    mResultAdapter = searchTipsAdapter;
    resultListView.setAdapter(searchTipsAdapter);
    searchTipsAdapter.setOnViewClickListener(
        new OnViewClickListener() {
          @Override
          public void onClick(View v, Object data) {
            final Tip tip = (Tip) data;
            if (getOnlySearchBox()) {
              enableTextTip = false;
              mSearchEditText.setText(tip.getName());
              enableTextTip = true;
            }
            returnResult(tip);
          }
        });
    setOnStartAnimation(R.animator.slide_in_top);
    setOnStopAnimation(R.animator.slide_out_top);
    setViewToAnimate(searchBox);
  }
コード例 #23
0
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    list = finder.find(android.R.id.list);
    progress = finder.find(R.id.pb_loading);

    LayoutInflater inflater = getLayoutInflater(savedInstanceState);

    headerView = inflater.inflate(R.layout.issue_header, null);

    stateText = (TextView) headerView.findViewById(R.id.tv_state);
    titleText = (TextView) headerView.findViewById(R.id.tv_issue_title);
    authorText = (TextView) headerView.findViewById(R.id.tv_issue_author);
    createdDateText = (TextView) headerView.findViewById(R.id.tv_issue_creation_date);
    creatorAvatar = (ImageView) headerView.findViewById(R.id.iv_avatar);
    commitsView = (ViewGroup) headerView.findViewById(R.id.ll_issue_commits);
    assigneeText = (TextView) headerView.findViewById(R.id.tv_assignee_name);
    assigneeAvatar = (ImageView) headerView.findViewById(R.id.iv_assignee_avatar);
    labelsArea = (TextView) headerView.findViewById(R.id.tv_labels);
    milestoneArea = headerView.findViewById(R.id.ll_milestone);
    milestoneText = (TextView) headerView.findViewById(R.id.tv_milestone);
    milestoneProgressArea = headerView.findViewById(R.id.v_closed);
    bodyText = (TextView) headerView.findViewById(R.id.tv_issue_body);
    bodyText.setMovementMethod(LinkMovementMethod.getInstance());

    loadingView = inflater.inflate(R.layout.loading_item, null);

    footerView = inflater.inflate(R.layout.footer_separator, null);

    commitsView.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (IssueUtils.isPullRequest(issue)) openPullRequestCommits();
          }
        });

    stateText.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (issue != null) stateTask.confirm(STATE_OPEN.equals(issue.getState()));
          }
        });

    milestoneArea.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (issue != null && isCollaborator) milestoneTask.prompt(issue.getMilestone());
          }
        });

    headerView
        .findViewById(R.id.ll_assignee)
        .setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View v) {
                if (issue != null && isCollaborator) assigneeTask.prompt(issue.getAssignee());
              }
            });

    labelsArea.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (issue != null && isCollaborator) labelsTask.prompt(issue.getLabels());
          }
        });

    Activity activity = getActivity();
    loggedUser = AccountUtils.getLogin(activity);
    adapter =
        new HeaderFooterListAdapter<CommentListAdapter>(
            list,
            new CommentListAdapter(
                activity, avatars, commentImageGetter, this, isCollaborator, loggedUser));
    list.setAdapter(adapter);
  }
コード例 #24
0
    @Override
    protected void onPostExecute(Boolean result) {
      mIsPostTaskRunning = false;

      if (!isAdded()) {
        return;
      }

      if (!result) {
        // post couldn't be loaded which means it doesn't exist in db, so request it from
        // the server if it hasn't already been requested
        if (!mHasAlreadyRequestedPost) {
          mHasAlreadyRequestedPost = true;
          AppLog.i(T.READER, "reader post detail > post not found, requesting it");
          requestPost();
        }
        return;
      }

      if (!canShowFooter()) {
        mLayoutFooter.setVisibility(View.GONE);
      }

      // add padding to the scrollView to make room for the top and bottom toolbars - this also
      // ensures the scrollbar matches the content so it doesn't disappear behind the toolbars
      int topPadding = (mAutoHideToolbarListener != null ? mToolbarHeight : 0);
      int bottomPadding = (canShowFooter() ? mLayoutFooter.getHeight() : 0);
      mScrollView.setPadding(0, topPadding, 0, bottomPadding);

      // scrollView was hidden in onCreateView, show it now that we have the post
      mScrollView.setVisibility(View.VISIBLE);

      // render the post in the webView
      mRenderer = new ReaderPostRenderer(mReaderWebView, mPost);
      mRenderer.beginRender();

      txtTitle.setText(
          mPost.hasTitle() ? mPost.getTitle() : getString(R.string.reader_untitled_post));

      followButton.setVisibility(mIsLoggedOutReader ? View.GONE : View.VISIBLE);
      if (!mIsLoggedOutReader) {
        followButton.setIsFollowed(mPost.isFollowedByCurrentUser);
        followButton.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                togglePostFollowed();
              }
            });
      }

      // clicking the header shows blog preview
      if (getPostListType() != ReaderPostListType.BLOG_PREVIEW) {
        layoutHeader.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                ReaderActivityLauncher.showReaderBlogPreview(v.getContext(), mPost);
              }
            });
      }

      if (mPost.hasBlogName()) {
        txtBlogName.setText(mPost.getBlogName());
        txtBlogName.setVisibility(View.VISIBLE);
      } else if (mPost.hasBlogUrl()) {
        txtBlogName.setText(UrlUtils.getDomainFromUrl(mPost.getBlogUrl()));
        txtBlogName.setVisibility(View.VISIBLE);
      } else {
        txtBlogName.setVisibility(View.GONE);
      }

      int avatarSz = getResources().getDimensionPixelSize(R.dimen.avatar_sz_medium);
      if (mPost.hasBlogUrl()) {
        String imageUrl = GravatarUtils.blavatarFromUrl(mPost.getBlogUrl(), avatarSz);
        imgAvatar.setImageUrl(imageUrl, WPNetworkImageView.ImageType.BLAVATAR);
      } else {
        imgAvatar.setImageUrl(
            mPost.getPostAvatarForDisplay(avatarSz), WPNetworkImageView.ImageType.AVATAR);
      }

      if (mPost.hasAuthorName()) {
        txtAuthor.setText(mPost.getAuthorName());
        txtAuthor.setVisibility(View.VISIBLE);
      } else {
        txtAuthor.setVisibility(View.GONE);
      }

      String dateLine;
      if (mPost.hasBlogUrl()) {
        dateLine =
            UrlUtils.getDomainFromUrl(mPost.getBlogUrl())
                + " \u2022 "
                + DateTimeUtils.javaDateToTimeSpan(mPost.getDatePublished());
      } else {
        dateLine = DateTimeUtils.javaDateToTimeSpan(mPost.getDatePublished());
      }
      txtDateLine.setText(dateLine);

      final String tagToDisplay = mPost.getTagForDisplay(null);
      if (!TextUtils.isEmpty(tagToDisplay)) {
        txtTag.setText(ReaderUtils.makeHashTag(tagToDisplay));
        txtTag.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                ReaderTag tag = new ReaderTag(tagToDisplay, ReaderTagType.FOLLOWED);
                ReaderActivityLauncher.showReaderTagPreview(v.getContext(), tag);
              }
            });
      }

      if (canShowFooter() && mLayoutFooter.getVisibility() != View.VISIBLE) {
        AniUtils.fadeIn(mLayoutFooter, AniUtils.Duration.LONG);
      }

      refreshIconCounts();
    }