Ejemplo n.º 1
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
    View vi = convertView;
    if (vi == null) {
      vi = inflater.inflate(R.layout.row_chat_box, null);
    }
    try {
      JSONObject json_data = new JSONObject(data.get(position));
      LinearLayout right_delete_box = (LinearLayout) vi.findViewById(R.id.right_delete_box);
      LinearLayout left_delete_box = (LinearLayout) vi.findViewById(R.id.left_delete_box);
      LinearLayout row_box = (LinearLayout) vi.findViewById(R.id.row_box);
      LinearLayout chat_box = (LinearLayout) vi.findViewById(R.id.chat_box);
      RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) chat_box.getLayoutParams();
      int left = Math.round(100 * this.context.getResources().getDisplayMetrics().density);
      int top = Math.round(5 * this.context.getResources().getDisplayMetrics().density);
      int right = Math.round(10 * this.context.getResources().getDisplayMetrics().density);
      if (json_data.getString("sender_id").equals(jsonuser.getString(TblUsers.USER_ID))) {
        params.setMargins(left, top, right, top);
        params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        row_box.setBackgroundResource(R.drawable.bg_chat_box);
        chat_box.findViewById(R.id.img_mark).setVisibility(View.VISIBLE);
        right_delete_box.setVisibility(View.GONE);
        left_delete_box.setVisibility(View.VISIBLE);

        if (json_data.getString("read").equals("0")) {
          chat_box.findViewById(R.id.img_mark).setVisibility(View.GONE);
        }
      } else {
        params.setMargins(right, top, left, top);
        params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0);
        row_box.setBackgroundResource(R.drawable.bg_button_deactive);
        chat_box.findViewById(R.id.img_mark).setVisibility(View.GONE);
        right_delete_box.setVisibility(View.VISIBLE);
        left_delete_box.setVisibility(View.GONE);
      }

      if (ChatBoxActivity.allow_edit == 0) {
        right_delete_box.setVisibility(View.GONE);
        left_delete_box.setVisibility(View.GONE);
      }
      chat_box.setLayoutParams(params);

      right_delete_box.setClickable(true);
      right_delete_box.setOnClickListener(deleteMessage(position, data.get(position)));

      left_delete_box.setClickable(true);
      left_delete_box.setOnClickListener(deleteMessage(position, data.get(position)));

      ((TextView) vi.findViewById(R.id.chat_text)).setText(json_data.getString("conversation"));
      ((TextView) vi.findViewById(R.id.chat_text)).setAutoLinkMask(1);

      String timing_send =
          FormatDateTime.formatAutoGetDateTimeForMessage(json_data.getString("timing_send"));
      ((TextView) vi.findViewById(R.id.message_time)).setText(timing_send);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return vi;
  }
 private void enableAll() {
   mDueDateLayout.setClickable(true);
   mDueHourLayout.setClickable(true);
   mStartDateLayout.setClickable(true);
   mStartHourLayout.setClickable(true);
   mSlaveTitle.setClickable(true);
   mSelectedSlaveView.setClickable(true);
   mPermissionTypeLayout.setClickable(true);
 }
Ejemplo n.º 3
0
 // 退出功能模块
 public void endModule() {
   mModuleView.removeAllViews();
   mModuleView.setVisibility(View.GONE);
   mResultView.setVisibility(View.GONE);
   mModuleListView.setVisibility(View.VISIBLE);
   resetMainView();
   // 设置actionbar
   // 隐藏后退按钮,并设置为不可点击
   LinearLayout llayout = (LinearLayout) findViewById(R.id.actionBarReturn);
   llayout.setFocusable(false);
   llayout.setClickable(false);
   llayout.setVisibility(View.GONE);
   TextView title = (TextView) findViewById(R.id.TactionBarTitle);
   EPlatform platform = getPlatform();
   title.setTextColor(Color.RED);
   if (platform == EPlatform.ePlatform_QQ) {
     title.setText("MSDKDemo QQ登录中");
   } else if (platform == EPlatform.ePlatform_Weixin) {
     title.setText("MSDKDemo 微信登录中");
   } else if (platform == EPlatform.ePlatform_QQHall) {
     title.setText("MSDKDemo 大厅登录中");
   } else {
     title.setText("MSDKDemo 未登录");
     title.setTextColor(Color.WHITE);
   }
 }
Ejemplo n.º 4
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // 添加百度地图SDK
    SDKInitializer.initialize(getApplicationContext());
    // setContentView(R.layout.activity_main);

    setContentView(R.layout.layout_login);
    application = (MyApplication) this.getApplication();
    context = LoginActivity.this;
    AbTitleBar mAbTitleBar = this.getTitleBar();
    mAbTitleBar.setVisibility(View.GONE);

    String username = application.getProperty(Constants.USER_NAME);
    if (null != username && username.length() > 0) {
      inputUsername.setText(username);
    }

    Button button = (Button) findViewById(R.id.login_button);

    button.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View arg0) {
            login();
          }
        });

    inputPassword.setOnEditorActionListener(
        new OnEditorActionListener() {

          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
              // 隐藏软键盘
              InputMethodManager imm =
                  (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
              imm.hideSoftInputFromWindow(inputPassword.getWindowToken(), 0);
              login();
              return true;
            }
            return false;
          }
        });

    OnClickListener keyboard_hide =
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            InputMethodManager imm =
                (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
          }
        };
    full_screen_layout.setClickable(true);
    full_screen_layout.setOnClickListener(keyboard_hide);
  }
        @Override
        public void handleMessage(Message msg) {
          switch (msg.what) {
            case 2:
              if (mAppInfoForManage == null) {
                return;
              }
              String packageName = mAppInfoForManage.getPackageName();
              int size = DownloadService.downtask.size();

              boolean found = false;
              for (int i = 0; i < size; i++) {
                DownloadTask task = DownloadService.downtask.get(i);
                if (task.getPackageName().equals(packageName)) {
                  found = true;
                  int percent = 0;

                  int totalSize = task.getTotalSize();
                  int currentSize = task.getCurrentSize();

                  mProgressBar.setMax(totalSize);
                  mProgressBar.setProgress(currentSize);

                  if (totalSize > 0) {
                    percent = currentSize * 100 / totalSize;
                  }

                  String text =
                      String.format(
                          "%d%% %dKB/%dKB", percent, currentSize / 1000, totalSize / 1000);
                  mDownloadingText.setText(text);

                  break;
                }
              }

              if (found) {
                this.sendEmptyMessageDelayed(2, 500);
              } else {
                tempCount += 1;
                this.sendEmptyMessage(7);
              }
              break;
            case 7:
              mInstallApk.setClickable(true);
              mDownloadingText.setVisibility(View.GONE);
              mProgressBar.setVisibility(View.GONE);
              TextView textDesc = (TextView) findViewById(R.id.textDesc);
              textDesc.setText(R.string.softmanage_install_now_text);
              isDownloading = false;
              updateButton();
              break;
          }
        }
 private void updateButton() {
   if (isDownloading) {
     TextView textDesc = (TextView) findViewById(R.id.textDesc);
     textDesc.setText(R.string.softcenter_install_cancel_text);
     return;
   }
   int isInstalled = isInstalled();
   if (isInstalled == 0) {
     shotCut.setImageBitmap(null);
     mInstallApk.setClickable(false);
     textDesc.setText(R.string.had_install);
   } else if (isInstalled == 1) {
     shotCut.setImageResource(R.drawable.icon_anzhuang);
     mInstallApk.setClickable(true);
     textDesc.setText(R.string.softcenter_search_my_upgrade);
   } else {
     shotCut.setImageResource(R.drawable.icon_anzhuang);
     mInstallApk.setClickable(true);
     textDesc.setText(R.string.softmanage_install_now_text);
   }
 }
 @Override
 public View getSectionHeaderView(int section, View convertView, ViewGroup parent) {
   LinearLayout layout = null;
   if (convertView == null) {
     LayoutInflater inflator =
         (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     layout = (LinearLayout) inflator.inflate(R.layout.header_item, null);
   } else {
     layout = (LinearLayout) convertView;
   }
   layout.setClickable(false);
   ((TextView) layout.findViewById(R.id.textItem)).setText(leftStr[section]);
   return layout;
 }
Ejemplo n.º 8
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_layout);
    /** Layout init * */
    sliding_lyt = (LinearLayout) findViewById(R.id.sliding_lyt);
    sliding_lyt.setClickable(true);

    /** Animator create * */
    float start = -200 * Propose.getDensity(this);
    float end = 0;
    sliding_lyt.setX(start);
    ObjectAnimator rightAnimator =
        ObjectAnimator.ofFloat(sliding_lyt, View.TRANSLATION_X, start, end);
    rightAnimator.setDuration(500);
    /** "duration" use to onClick * */

    /** Propose create * */
    Propose propose = new Propose(this);
    propose.motionRight.play(rightAnimator);
    /** set right move Animator * */
    sliding_lyt.setOnTouchListener(propose);
    /** set touch listener * */
    propose.motionRight.setMotionDistance(-start);
    /** set Drag Distance * */

    /** set MotionListener for black Alpha* */
    propose.motionRight.setOnMotionListener(
        new MotionListener() {
          @Override
          public void onStart(boolean isForward) {}

          @Override
          public void onScroll(long currDuration, long totalDuration, boolean isForward) {
            float alpha = (float) currDuration / totalDuration / 2; // max 0.5
            findViewById(R.id.alpha_lyt).setAlpha(alpha);
          }

          @Override
          public void onEnd(boolean isForward) {}
        });
  }
  private void findViews() {
    mAppIcon = (ImageView) findViewById(R.id.appIcon);
    mAppName = (TextView) findViewById(R.id.appName);
    mAppVersion = (TextView) findViewById(R.id.appVersion);
    mAppSizeNum = (TextView) findViewById(R.id.appSizeNum);
    mAppSizeUnit = (TextView) findViewById(R.id.appSizeUnit);
    mAppDescription = (TextView) findViewById(R.id.appDescription);

    mScreenshotOne = (ImageView) findViewById(R.id.appScreenshotOne);
    mScreenshotTwo = (ImageView) findViewById(R.id.appScreenshotTwo);

    mInstallApk = (LinearLayout) findViewById(R.id.installApk);
    mInstallApk.setClickable(true);
    mInstallApk.setOnClickListener(this);

    mProgressBar = (ProgressBar) findViewById(R.id.downloadingBar);
    mDownloadingText = (TextView) findViewById(R.id.downloadingText);

    shotCut = (ImageView) findViewById(R.id.installShotcut);
    textDesc = (TextView) findViewById(R.id.textDesc);
  }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      // TODO Auto-generated method stub

      if (position + 1 <= views.size()) {
        return views.get(position);
      }

      float density = mContext.getResources().getDisplayMetrics().density;
      int item_height = (int) (48.0f * density);
      int padding = (int) (24.0f * density);

      AbsListView.LayoutParams params =
          new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, item_height);
      LinearLayout item = new LinearLayout(mContext);
      item.setPadding(padding, 0, padding, 0);
      item.setOrientation(LinearLayout.HORIZONTAL);
      item.setLayoutParams(params);
      item.setClickable(false);
      item.setGravity(Gravity.CENTER);

      TextView text = new TextView(mContext);
      LinearLayout.LayoutParams tp =
          new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
      tp.gravity = Gravity.CENTER;
      text.setTextSize(18);
      text.setTextColor(mContext.getResources().getColor(R.color.text_color_dark));
      text.setLayoutParams(tp);
      text.setId(android.R.id.text1);
      text.setText(mListData[position]);
      text.setGravity(Gravity.CENTER);
      text.setClickable(false);

      item.addView(text);

      views.add(item);

      return item;
    }
        @Override
        public void handleMessage(Message msg) {
          if (!possibleLogTypes.contains(typeSelected)) {
            typeSelected = possibleLogTypes.get(0);
            setType(typeSelected);

            showToast(res.getString(R.string.info_log_type_changed));
          }

          if (cgBase.isEmpty(viewstates) && attempts < 2) {
            final LoadDataThread thread;
            thread = new LoadDataThread();
            thread.start();

            return;
          } else if (cgBase.isEmpty(viewstates) && attempts >= 2) {
            showToast(res.getString(R.string.err_log_load_data));
            showProgress(false);

            return;
          }

          gettingViewstate = false; // we're done, user can post log

          enablePostButton(true);

          // add trackables
          if (CollectionUtils.isNotEmpty(trackables)) {
            if (inflater == null) {
              inflater = getLayoutInflater();
            }

            final LinearLayout inventoryView = (LinearLayout) findViewById(R.id.inventory);
            inventoryView.removeAllViews();

            for (cgTrackableLog tb : trackables) {
              LinearLayout inventoryItem =
                  (LinearLayout) inflater.inflate(R.layout.visit_trackable, null);

              ((TextView) inventoryItem.findViewById(R.id.trackcode)).setText(tb.trackCode);
              ((TextView) inventoryItem.findViewById(R.id.name)).setText(tb.name);
              ((TextView) inventoryItem.findViewById(R.id.action))
                  .setText(
                      res.getString(
                              Settings.isTrackableAutoVisit()
                                  ? LogTypeTrackable.VISITED.resourceId
                                  : LogTypeTrackable.DO_NOTHING.resourceId)
                          + " ▼");

              inventoryItem.setId(tb.id);
              final String tbCode = tb.trackCode;
              inventoryItem.setClickable(true);
              registerForContextMenu(inventoryItem);
              inventoryItem
                  .findViewById(R.id.info)
                  .setOnClickListener(
                      new View.OnClickListener() {

                        public void onClick(View view) {
                          final Intent trackablesIntent =
                              new Intent(VisitCacheActivity.this, cgeotrackable.class);
                          trackablesIntent.putExtra(EXTRAS_GEOCODE, tbCode);
                          startActivity(trackablesIntent);
                        }
                      });
              inventoryItem
                  .findViewById(R.id.action)
                  .setOnClickListener(
                      new View.OnClickListener() {

                        public void onClick(View view) {
                          openContextMenu(view);
                        }
                      });

              inventoryView.addView(inventoryItem);

              if (Settings.isTrackableAutoVisit()) {
                tb.action = LogTypeTrackable.VISITED;
                tbChanged = true;
              }
            }

            if (inventoryView.getChildCount() > 0) {
              ((LinearLayout) findViewById(R.id.inventory_box)).setVisibility(View.VISIBLE);
            }
            if (inventoryView.getChildCount() > 1) {
              final LinearLayout inventoryChangeAllView =
                  (LinearLayout) findViewById(R.id.inventory_changeall);

              final Button changeButton =
                  (Button) inventoryChangeAllView.findViewById(R.id.changebutton);
              registerForContextMenu(changeButton);
              changeButton.setOnClickListener(
                  new View.OnClickListener() {

                    public void onClick(View view) {
                      openContextMenu(view);
                    }
                  });

              inventoryChangeAllView.setVisibility(View.VISIBLE);
            }
          }

          showProgress(false);
        }
Ejemplo n.º 12
0
  private void updateTrackablesList() {
    if (CollectionUtils.isEmpty(trackables)) {
      return;
    }
    if (inflater == null) {
      inflater = getLayoutInflater();
    }
    actionButtons = new SparseArray<TrackableLog>();

    final LinearLayout inventoryView = (LinearLayout) findViewById(R.id.inventory);
    inventoryView.removeAllViews();

    for (TrackableLog tb : trackables) {
      LinearLayout inventoryItem =
          (LinearLayout) inflater.inflate(R.layout.logcache_trackable_item, null);

      ((TextView) inventoryItem.findViewById(R.id.trackcode)).setText(tb.trackCode);
      ((TextView) inventoryItem.findViewById(R.id.name)).setText(tb.name);
      final TextView actionButton = (TextView) inventoryItem.findViewById(R.id.action);
      actionButton.setId(tb.id);
      actionButtons.put(actionButton.getId(), tb);
      actionButton.setText(res.getString(tb.action.resourceId) + " ▼");
      actionButton.setOnClickListener(
          new View.OnClickListener() {

            @Override
            public void onClick(View view) {
              selectTrackableAction(view);
            }
          });

      final String tbCode = tb.trackCode;
      inventoryItem.setClickable(true);
      inventoryItem
          .findViewById(R.id.info)
          .setOnClickListener(
              new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                  final Intent trackablesIntent =
                      new Intent(LogCacheActivity.this, TrackableActivity.class);
                  trackablesIntent.putExtra(Intents.EXTRA_GEOCODE, tbCode);
                  startActivity(trackablesIntent);
                }
              });

      inventoryView.addView(inventoryItem);
    }

    if (inventoryView.getChildCount() > 0) {
      findViewById(R.id.inventory_box).setVisibility(View.VISIBLE);
    }
    if (inventoryView.getChildCount() > 1) {
      final LinearLayout inventoryChangeAllView =
          (LinearLayout) findViewById(R.id.inventory_changeall);

      final Button changeButton = (Button) inventoryChangeAllView.findViewById(R.id.changebutton);
      changeButton.setOnClickListener(
          new View.OnClickListener() {

            @Override
            public void onClick(View view) {
              selectAllTrackablesAction();
            }
          });

      inventoryChangeAllView.setVisibility(View.VISIBLE);
    }
  }
Ejemplo n.º 13
0
  private void ensureUiListView() {

    // if(mListAdapter == null){
    mListAdapter = new SeparatedListAdapter(this);
    // }

    if (mStateHolder.getSortMethod() == SORT_METHOD_RECENT) {
      sortRecommendsRecent(mStateHolder.getRecommends(), mListAdapter);
    } else {
      sortRecommendsDistance(mStateHolder.getRecommends(), mListAdapter);
    }
    listView = getListView();
    listView.setAdapter(mListAdapter);
    listView.setDividerHeight(0);

    listView.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            RecommendMsg recommend = (RecommendMsg) parent.getAdapter().getItem(position);
            if (recommend != null) {
              Intent intent = new Intent(FriendsActivity.this, RecommendDetailsActivity.class);
              intent.putExtra(RecommendDetailsActivity.EXTRA_RecommendMsg_PARCEL, recommend);
              startActivity(intent);
            }
          }
        });

    footerview =
        (LinearLayout)
            LayoutInflater.from(listView.getContext())
                .inflate(R.layout.recommend_list_footer, null);

    footerview.setClickable(true);
    footerview.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            mStateHolder.setCurrentListItem(listView.getCount());

            mStateHolder.startTask(FriendsActivity.this);
          }
        });
    footerview.setVisibility(View.VISIBLE);
    if (!mStateHolder.getRanOnce()) {
      listView.addFooterView(footerview);
    }

    // Prepare our no-results view. Something odd is going on with the layout parameters though.
    // If we don't explicitly set the layout to be fill/fill after inflating, the layout jumps
    // to a wrap/wrap layout. Furthermore, sdk 3 crashes with the original layout using two
    // buttons in a horizontal LinearLayout.
    LayoutInflater inflater = LayoutInflater.from(this);

    if (UiUtil.sdkVersion() > 3) {
      mLayoutEmpty = (ScrollView) inflater.inflate(R.layout.friends_activity_empty, null);

      Button btnAddFriends =
          (Button) mLayoutEmpty.findViewById(R.id.friendsActivityEmptyBtnAddFriends);
      btnAddFriends.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              /*
              Intent intent = new Intent(FriendsActivity.this, AddFriendsActivity.class);
              startActivity(intent);*/
            }
          });

      Button btnFriendRequests =
          (Button) mLayoutEmpty.findViewById(R.id.friendsActivityEmptyBtnFriendRequests);
      btnFriendRequests.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              /*
              Intent intent = new Intent(FriendsActivity.this, FriendRequestsActivity.class);
              startActivity(intent);*/
            }
          });

    } else {
      // Inflation on 1.5 is causing a lot of issues, dropping full layout.
      mLayoutEmpty = (ScrollView) inflater.inflate(R.layout.friends_activity_empty_sdk3, null);
    }

    mLayoutEmpty.setLayoutParams(
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT));

    if (mListAdapter.getCount() == 0) {
      setEmptyView(mLayoutEmpty);
    }

    if (mStateHolder.getIsRunningTask()) {
      setProgressBarIndeterminateVisibility(true);
      if (!mStateHolder.getRanOnce()) {
        setLoadingView();
      }
    } else {
      setProgressBarIndeterminateVisibility(false);
    }
  }
Ejemplo n.º 14
0
  @SuppressWarnings("deprecation")
  private void readAttrs(Context context, AttributeSet attrs) {
    if (null != attrs) {
      TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SettingViewItem);
      if (a.hasValue(R.styleable.SettingViewItem_arrow)) {
        Drawable drawable = a.getDrawable(R.styleable.SettingViewItem_arrow);
        if (null != drawable) {
          mArrow.setImageDrawable(drawable);
        } else {
          mArrow.setImageResource(R.drawable.setting_view_arrow);
        }
      }

      if (a.hasValue(R.styleable.SettingViewItem_background)) {
        Drawable drawable = a.getDrawable(R.styleable.SettingViewItem_background);
        if (null != drawable) {
          mItemViewContainer.setBackgroundDrawable(drawable);
        } else {
          mItemViewContainer.setBackgroundResource(R.drawable.setting_view_item_selector);
        }
      } else {
        mItemViewContainer.setBackgroundResource(R.drawable.setting_view_item_selector);
      }

      if (a.hasValue(R.styleable.SettingViewItem_drawable)) {
        Drawable drawable = a.getDrawable(R.styleable.SettingViewItem_drawable);
        if (null != drawable) {
          mDrawable.setImageDrawable(drawable);
        } else {
          mDrawable.setVisibility(View.GONE);
        }
      } else {
        mDrawable.setVisibility(View.GONE);
      }

      if (a.hasValue(R.styleable.SettingViewItem_subTitle)) {
        String subTitle = a.getString(R.styleable.SettingViewItem_subTitle);
        if (!TextUtils.isEmpty(subTitle)) {
          mSubTitle.setText(subTitle);
        }
      }

      if (a.hasValue(R.styleable.SettingViewItem_subTitleColor)) {
        ColorStateList colors = a.getColorStateList(R.styleable.SettingViewItem_subTitleColor);
        if (null != colors) {
          mSubTitle.setTextColor(colors);
        }
      }

      if (a.hasValue(R.styleable.SettingViewItem_subTitleSize)) {
        int textSize =
            (int)
                TypedValue.applyDimension(
                    TypedValue.COMPLEX_UNIT_PX,
                    a.getDimensionPixelSize(R.styleable.SettingViewItem_subTitleSize, 14),
                    getResources().getDisplayMetrics());
        mSubTitle.setTextSize(textSize);
      }

      if (a.hasValue(R.styleable.SettingViewItem_title)) {
        String title = a.getString(R.styleable.SettingViewItem_title);
        if (!TextUtils.isEmpty(title)) {
          mTitle.setText(title);
        }
      }

      if (a.hasValue(R.styleable.SettingViewItem_titleColor)) {
        ColorStateList colors = a.getColorStateList(R.styleable.SettingViewItem_titleColor);
        if (null != colors) {
          mTitle.setTextColor(colors);
        }
      }

      if (a.hasValue(R.styleable.SettingViewItem_titleSize)) {
        int textSize =
            (int)
                TypedValue.applyDimension(
                    TypedValue.COMPLEX_UNIT_PX,
                    a.getDimensionPixelSize(R.styleable.SettingViewItem_titleSize, 16),
                    getResources().getDisplayMetrics());
        mTitle.setTextSize(textSize);
      }

      if (a.hasValue(R.styleable.SettingViewItem_clickable)) {
        mItemViewContainer.setClickable(a.getBoolean(R.styleable.SettingViewItem_clickable, true));
      } else {
        mItemViewContainer.setClickable(true);
      }

      a.recycle();
    }
  }
  public void addEntity(String elementName, String filename) {
    final String filenameFinal = filename;

    // Create a TableLayout object associated with the TableLayout in the .xml file
    TableLayout tl = (TableLayout) findViewById(R.id.loads_container);
    // Create a LinearLayout to contain our element_row
    buttonContainer = new LinearLayout(this);
    // Set some properties
    // tr.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    buttonContainer.setBackgroundResource(R.drawable.load_state_tr_bg);
    buttonContainer.setLongClickable(true);
    buttonContainer.setClickable(true);
    buttonContainer.setPadding(25, 10, 25, 10);
    buttonContainer.setGravity(Gravity.RIGHT);

    // Create a TextView to hold the element name
    TextView nameTextView = new TextView(this);
    nameTextView.setText(elementName);
    nameTextView.setLayoutParams(
        new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1));
    // filename.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
    // LayoutParams.WRAP_CONTENT));

    // Makes use of DisplayMetrics to create an automatic dip unit :)
    // filename.setPadding((int)(16 * SCALE + 0.5f), 0, 0, 0);
    // Add the TextView to the TableRow
    buttonContainer.addView(nameTextView);

    // Set buttonContainer's gravity to right with a 16dip right padding
    // buttonContainer.setPadding(0, 0, (int)(16 * SCALE + 0.5f), 0);
    // buttonContainer.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 50));

    // Edit element button
    actionButton = new ImageButton(this);
    actionButton.setBackgroundResource(R.drawable.load_state_select);
    actionButton.setLayoutParams(
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    actionButton.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            Intent i = new Intent(CustomElementManagerActivity.this, CustomElementActivity.class);
            i.putExtra("filename", filenameFinal);
            startActivity(i);
          }
        });
    buttonContainer.addView(actionButton);

    // Delete button
    actionButton = new ImageButton(this);
    actionButton.setBackgroundResource(R.drawable.load_state_delete);
    actionButton.setLayoutParams(
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    actionButton.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            // Delete the custom element file
            Log.i("TheElements", "Deleting " + filenameFinal);
            new File(filenameFinal).delete();

            // Update the view accordingly
            ViewGroup parent = (ViewGroup) v.getParent().getParent();
            parent.removeView((View) v.getParent());
            TableLayout tl = (TableLayout) findViewById(R.id.loads_container);
            if (tl.getChildCount() == 0) {
              tr = new TableRow(getBaseContext());
              tr.setLayoutParams(
                  new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
              tr.setGravity(Gravity.CENTER);

              TextView tv = new TextView(getBaseContext());
              tv.setText(res.getText(R.string.no_elements));

              tr.addView(tv);
              tl.addView(tr);
            }
          }
        });
    buttonContainer.addView(actionButton);

    // Click on the entire element_row
    buttonContainer.setOnClickListener(
        new OnClickListener() {
          public void onClick(View viewParam) {
            Intent i = new Intent(CustomElementManagerActivity.this, CustomElementActivity.class);
            i.putExtra("filename", filenameFinal);
            startActivity(i);
          }
        });

    // Add the created element_row to our TableLayout
    tl.addView(
        buttonContainer, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
  }
Ejemplo n.º 16
0
        @Override
        public void handleMessage(Message msg) {
          if (types.contains(typeSelected) == false) {
            typeSelected = types.get(0);
            setType(typeSelected);

            showToast(res.getString(R.string.info_log_type_changed));
          }

          if ((viewstate == null || viewstate.length() == 0) && attempts < 2) {
            showToast(res.getString(R.string.err_log_load_data_again));

            loadData thread;
            thread = new loadData(cacheid);
            thread.start();

            return;
          } else if ((viewstate == null || viewstate.length() == 0) && attempts >= 2) {
            showToast(res.getString(R.string.err_log_load_data));
            showProgress(false);

            return;
          }

          gettingViewstate = false; // we're done, user can post log

          if (post == null) {
            post = (Button) findViewById(R.id.post);
          }
          post.setEnabled(true);
          post.setOnClickListener(new postListener());

          // add trackables
          if (trackables != null && trackables.isEmpty() == false) {
            if (inflater == null) {
              inflater = getLayoutInflater();
            }

            final LinearLayout inventoryView = (LinearLayout) findViewById(R.id.inventory);
            inventoryView.removeAllViews();

            for (cgTrackableLog tb : trackables) {
              LinearLayout inventoryItem =
                  (LinearLayout) inflater.inflate(R.layout.visit_trackable, null);

              ((TextView) inventoryItem.findViewById(R.id.trackcode)).setText(tb.trackCode);
              ((TextView) inventoryItem.findViewById(R.id.name)).setText(tb.name);
              ((TextView) inventoryItem.findViewById(R.id.action))
                  .setText(cgBase.logTypesTrackable.get(settings.trackableAutovisit ? 1 : 0));

              inventoryItem.setId(tb.id);
              final String tbCode = tb.trackCode;
              inventoryItem.setClickable(true);
              registerForContextMenu(inventoryItem);
              inventoryItem
                  .findViewById(R.id.info)
                  .setOnClickListener(
                      new View.OnClickListener() {

                        public void onClick(View view) {
                          final Intent trackablesIntent =
                              new Intent(cgeovisit.this, cgeotrackable.class);
                          trackablesIntent.putExtra("geocode", tbCode);
                          startActivity(trackablesIntent);
                        }
                      });
              inventoryItem
                  .findViewById(R.id.action)
                  .setOnClickListener(
                      new View.OnClickListener() {

                        public void onClick(View view) {
                          openContextMenu(view);
                        }
                      });

              inventoryView.addView(inventoryItem);

              if (settings.trackableAutovisit) {
                tb.action = 1;
                tbChanged = true;
              }
            }

            if (inventoryView.getChildCount() > 0) {
              ((LinearLayout) findViewById(R.id.inventory_box)).setVisibility(View.VISIBLE);
            }
            if (inventoryView.getChildCount() > 1) {
              final LinearLayout inventoryChangeAllView =
                  (LinearLayout) findViewById(R.id.inventory_changeall);

              Button changeButton = (Button) inventoryChangeAllView.findViewById(R.id.changebutton);
              registerForContextMenu(changeButton);
              changeButton.setOnClickListener(
                  new View.OnClickListener() {

                    public void onClick(View view) {
                      openContextMenu(view);
                    }
                  });

              ((LinearLayout) findViewById(R.id.inventory_changeall)).setVisibility(View.VISIBLE);
            }
          }

          showProgress(false);
        }
Ejemplo n.º 17
0
  // ***********************界面布局相关*************************
  // 初始化界面
  private void initView() {
    Util.init(getApplicationContext()); // 初始化Demo需要的工具类
    ModuleManager.LANG = LANG;
    nameList = ModuleManager.getInstance().modules;

    mModuleListView = (GridView) findViewById(R.id.gridview);
    mModuleView = (LinearLayout) findViewById(R.id.module);
    mResultView = (LinearLayout) findViewById(R.id.result);

    // 设置actionbar
    // 隐藏后退按钮,并设置为不可点击
    LinearLayout llayout = (LinearLayout) findViewById(R.id.actionBarReturn);
    llayout.setFocusable(false);
    llayout.setClickable(false);
    llayout.setVisibility(View.GONE);

    TextView title = (TextView) findViewById(R.id.TactionBarTitle);
    LinearLayout.LayoutParams textParams = (LayoutParams) title.getLayoutParams();
    textParams.leftMargin = Util.dp(9);
    title.setLayoutParams(textParams);
    title.setText("MSDKDemo 未登录");

    // 设置局部广播,处理回调信息
    lbm = LocalBroadcastManager.getInstance(this.getApplicationContext());
    mReceiver =
        new BroadcastReceiver() {

          @Override
          public void onReceive(Context context, Intent intent) {
            String result = intent.getExtras().getString("Result");
            Logger.d(result);
            displayResult(result);
          }
        };
    lbm.registerReceiver(mReceiver, new IntentFilter(MsdkCallback.LOCAL_ACTION));

    // 初始化下载进度条
    mProgressDialog = new ProgressDialog(this);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mProgressDialog.setTitle("更新中");
    mProgressDialog.setMessage("下载进度");
    resetMainView();

    mModuleListView.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            seletedModule = nameList.get(position);
            if ("QQ登录".equals(seletedModule.name)) {
              if (getPlatform() == EPlatform.ePlatform_QQ) {
                // 如已登录直接进入相应模块视图
                startModule();
              } else if (getPlatform() == EPlatform.ePlatform_None) {
                WGPlatform.WGLogin(EPlatform.ePlatform_QQ);
              } else {

              }
              //                    WGPlatform.WGOpenUrl("http://www.baidu.com");
            } else if ("微信登录".equals(seletedModule.name)) {
              if (getPlatform() == EPlatform.ePlatform_Weixin) {
                // 如已登录直接进入相应模块视图
                startModule();
              } else if (getPlatform() == EPlatform.ePlatform_None) {
                WGPlatform.WGLogin(EPlatform.ePlatform_Weixin);
              } else {

              }
            } else {
              // 进行其它功能模块
              startModule();
            }
          }
        });
  }
Ejemplo n.º 18
0
  private void updateTrackablesList() {
    if (CollectionUtils.isEmpty(trackables)) {
      return;
    }
    if (inflater == null) {
      inflater = getLayoutInflater();
    }
    actionButtons = new SparseArray<>();

    final LinearLayout inventoryView = ButterKnife.findById(this, R.id.inventory);
    inventoryView.removeAllViews();

    for (final TrackableLog tb : getSortedTrackables()) {
      final LinearLayout inventoryItem =
          (LinearLayout) inflater.inflate(R.layout.logcache_trackable_item, inventoryView, false);

      final ImageView brandView = ButterKnife.findById(inventoryItem, R.id.trackable_image_brand);
      brandView.setImageResource(tb.brand.getIconResource());
      final TextView codeView = ButterKnife.findById(inventoryItem, R.id.trackcode);
      codeView.setText(tb.trackCode);
      final TextView nameView = ButterKnife.findById(inventoryItem, R.id.name);
      nameView.setText(tb.name);
      final TextView actionButton = ButterKnife.findById(inventoryItem, R.id.action);
      actionButton.setId(tb.id);
      actionButtons.put(actionButton.getId(), tb);
      actionButton.setText(tb.action.getLabel() + " ▼");
      actionButton.setOnClickListener(
          new View.OnClickListener() {

            @Override
            public void onClick(final View view) {
              selectTrackableAction(view);
            }
          });

      inventoryItem.setClickable(true);
      ButterKnife.findById(inventoryItem, R.id.info)
          .setOnClickListener(
              new View.OnClickListener() {

                @Override
                public void onClick(final View view) {
                  final Intent trackablesIntent =
                      new Intent(LogCacheActivity.this, TrackableActivity.class);
                  final String tbCode =
                      StringUtils.isNotEmpty(tb.geocode) ? tb.geocode : tb.trackCode;
                  trackablesIntent.putExtra(Intents.EXTRA_GEOCODE, tbCode);
                  trackablesIntent.putExtra(Intents.EXTRA_BRAND, tb.brand.getId());
                  trackablesIntent.putExtra(Intents.EXTRA_TRACKING_CODE, tb.trackCode);
                  startActivity(trackablesIntent);
                }
              });

      inventoryView.addView(inventoryItem);
    }

    if (inventoryView.getChildCount() > 0) {
      ButterKnife.findById(this, R.id.inventory_box).setVisibility(View.VISIBLE);
    }
    if (inventoryView.getChildCount() > 1) {
      final LinearLayout inventoryChangeAllView =
          ButterKnife.findById(this, R.id.inventory_changeall);

      final Button changeButton = ButterKnife.findById(inventoryChangeAllView, R.id.changebutton);
      changeButton.setOnClickListener(
          new View.OnClickListener() {

            @Override
            public void onClick(final View view) {
              selectAllTrackablesAction();
            }
          });

      inventoryChangeAllView.setVisibility(View.VISIBLE);
    }
  }