Exemple #1
0
 public static void addBottomButton(RelativeLayout layout) {
   MyHippieButton myHippieButton = new MyHippieButton(layout.getContext());
   RelativeLayout.LayoutParams layoutParams =
       new RelativeLayout.LayoutParams(
           RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
   layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 1);
   myHippieButton.setLayoutParams(layoutParams);
   layout.addView(myHippieButton);
 }
Exemple #2
0
  private void bookmarkAdapter(
      FriendData friendData, ArrayList<FriendData> friendDataList, RelativeLayout recyclerLayout) {

    RecyclerView bookmarkRecyclerView =
        (RecyclerView) recyclerLayout.findViewById(R.id.friend_recycler_view);

    LinearLayoutManager bookmarkLayoutManager =
        new LinearLayoutManager(recyclerLayout.getContext());
    bookmarkLayoutManager.setOrientation(RecyclerView.VERTICAL);
    bookmarkRecyclerView.setLayoutManager(bookmarkLayoutManager);

    FriendListMain.getFriendListDB().updateFriendData(friendData);

    ArrayList<FriendData> tempList = friendDataList;
    ArrayList<FriendData> bookmarkedList = new ArrayList<>();

    Collections.sort(
        tempList,
        new Comparator<FriendData>() {
          @Override
          public int compare(FriendData lhs, FriendData rhs) {
            return (lhs.getName().compareToIgnoreCase(rhs.getName()));
          }
        });

    for (int i = 0; i < tempList.size(); i++)
      if (tempList.get(i).getBookMark() == 1) bookmarkedList.add(tempList.get(i));
      else if (i == tempList.size() - 1)
        for (int j = 0; j < tempList.size(); j++)
          if (tempList.get(j).getBookMark() == 0) bookmarkedList.add(tempList.get(j));

    FriendListAdapter friendListAdapter =
        new FriendListAdapter(bookmarkedList, recyclerLayout.getContext(), recyclerLayout, false);
    bookmarkRecyclerView.setAdapter(friendListAdapter);
    friendListAdapter.notifyDataSetChanged();
    FriendListMain.getFriendListDB().close();
  }
  protected void SetLoadingAnimation(boolean start) {
    if (rl != null) {
      RelativeLayout loadingRelativeLayout =
          (RelativeLayout) rl.findViewById(R.id.loadingRelativeLayout);
      ImageView imageViewLoadingIcon = (ImageView) rl.findViewById(R.id.imageViewLoadingIcon);

      if (start == true) {
        Animation rotate_continously =
            AnimationUtils.loadAnimation(rl.getContext(), R.anim.rotate_continously);
        imageViewLoadingIcon.startAnimation(rotate_continously);

        loadingRelativeLayout.setVisibility(View.VISIBLE);
      } else {
        loadingRelativeLayout.setVisibility(View.GONE);
      }
    }
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    RelativeLayout view =
        (RelativeLayout) inflater.inflate(R.layout.fragment_list, container, false);
    tvListEmptyNotifier = (TextView) view.findViewById(R.id.emptyLayout);

    RecyclerView rvContent = (RecyclerView) view.findViewById(R.id.rvContent);
    rvContent.setLayoutManager(new LinearLayoutManager(view.getContext()));
    mAdapter = new RemindAdapter(getActivity(), new ArrayList<Remind>());
    mAdapter.setOnListChangesListener(
        new RemindAdapter.ListChangesListener() {
          @Override
          public void onListSizeChanged() {
            if (mAdapter.getItemCount() == 0) {
              tvListEmptyNotifier.setVisibility(View.VISIBLE);
            } else {
              tvListEmptyNotifier.setVisibility(View.INVISIBLE);
            }
          }
        });
    switch (mFragmentType) {
      case FRAGMENT_TYPE_CURRENT:
        mAdapter.updateData(
            RemindDatabase.getInstance().getStoredData(DatabaseHelper.FILTER_WAITING_REMINDS));
        mAdapter.setItemEditable(true);
        rvContent.setItemAnimator(new FadeInRightAnimator());
        break;

      case FRAGMENT_TYPE_DONE:
        mAdapter.updateData(
            RemindDatabase.getInstance().getStoredData(DatabaseHelper.FILTER_DONE_REMINDS));
        mAdapter.setItemEditable(false);
        rvContent.setItemAnimator(new FadeInLeftAnimator());

        rvContent.setAlpha((float) FRAGMENT_DONE_ITEM_ALPHA);
        ((TextView) view.findViewById(R.id.emptyLayout))
            .setText(R.string.empty_layout_no_done_reminds);
        break;
    }
    rvContent.setAdapter(mAdapter);

    return view;
  }
        @SuppressLint("RtlHardcoded")
        @Override
        public View instantiateItem(ViewGroup container, final int position) {
          RelativeLayout rl = new RelativeLayout(container.getContext());
          rl.setGravity(Gravity.CENTER);
          TouchImageView img = new TouchImageView(container.getContext());
          img.setImageBitmap(browserDefaultBitmap);
          loadBrowserImageAsync(
              img,
              imageDetails[position].getPath(),
              displayMetrics.widthPixels,
              displayMetrics.heightPixels,
              imageDetails[position].getOrientation());

          rl.addView(
              img, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);

          final CheckBox cb = new CheckBox(rl.getContext());
          cb.setChecked(imageDetails[position].isSelected());
          cb.setGravity(Gravity.TOP | Gravity.RIGHT);
          cb.setOnClickListener(
              new android.view.View.OnClickListener() {
                public void onClick(View v) {
                  browserCheckboxChecked(position, cb);
                }
              });
          img.setOnClickListener(
              new android.view.View.OnClickListener() {
                public void onClick(View v) {
                  browserCheckboxChecked(position, cb);
                }
              });

          rl.addView(
              cb, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);

          container.addView(
              rl, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);

          return rl;
        }
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // prepare thread
    moredetail =
        new Runnable() {
          @Override
          public void run() {
            getMoreDetail();
          }
        };

    // prepare Channellogos
    setContentView(R.layout.infopage);

    // got selected item index from calling activity
    String idx = this.getIntent().getStringExtra("clientid");

    // get clientarray from global MainApp
    ArrayList<StatusClient> clients = MainApp.instance.getClients();
    Log.i("Details", "Array size " + clients.size() + " ID " + idx);

    if (!(clients.size() == 0)) {

      for (int i = 0; i < clients.size(); i++) {
        if (clients.get(i).name.equals(idx)) {
          _client = clients.get(i);
          break;
        }
      }

      Boolean isServer = false;

      // identify the server types
      if (_client.type.equals("s")
          || _client.type.equals("h")
          || _client.type.equals("m")
          || _client.type.equals("a")) {
        isServer = true;
      }

      ImageView icon = (ImageView) findViewById(R.id.infopage_icon);
      if (_client.type.equals("r")) {
        icon.setImageResource(R.drawable.readericon);
      } else if (_client.type.equals("p")) {
        icon.setImageResource(R.drawable.proxyicon);
      } else if (_client.type.equals("s")) {
        icon.setImageResource(R.drawable.servericon);
      } else if (_client.type.equals("h")) {
        icon.setImageResource(R.drawable.servericon);
      } else if (_client.type.equals("m")) {
        icon.setImageResource(R.drawable.servericon);
      } else if (_client.type.equals("a")) {
        icon.setImageResource(R.drawable.servericon);
      } else if (_client.type.equals("c")) {
        icon.setImageResource(R.drawable.clienticon);
      }

      TextView headline = (TextView) findViewById(R.id.infopage_headline);
      headline.setText("Details for " + _client.name);

      TableLayout table = (TableLayout) findViewById(R.id.infopage_table);

      addTableRow(table, "Name:", _client.name);
      addTableRow(table, "Protocol:", _client.protocol);
      if (!isServer) {
        addTableRow(table, "Request:", _client.request_caid + ":" + _client.request_srvid);
        addTableRow(table, "Channel:", _client.request);
      }
      addTableRow(table, "Login:"******"Online:", MainApp.sec2time(_client.times_online));
      addTableRow(table, "Idle:", MainApp.sec2time(_client.times_idle));
      addTableRow(table, "Connect:", _client.connection_ip);
      addTableRow(table, "Status:", _client.connection);

      String caidsrvid[] = new String[2];
      caidsrvid[0] = _client.request_caid;
      caidsrvid[1] = _client.request_srvid;
      Bitmap logo = MainApp.instance.getLogos().getLogo(caidsrvid, 0);

      if (_client.request_ecmhistory.length() > 0) {
        String ecmvalues[] = _client.request_ecmhistory.split(",");
        if (ecmvalues.length > 0) {
          Integer arr[] = new Integer[ecmvalues.length];
          int total = 0;
          int numvalues = 0;
          for (int i = 0; i < ecmvalues.length; i++) {
            arr[i] = Integer.parseInt(ecmvalues[i]);
            total += arr[i];
            if (arr[i] > 0) numvalues++;
          }

          if (numvalues > 0 && total > 0) {
            Integer average = total / numvalues;
            addTableRow(table, "Average:", average.toString() + " ms");
          }

          View chart = null;
          RelativeLayout container = (RelativeLayout) findViewById(R.id.infopage_chartlayout);
          if (!isServer && !_client.request_srvid.equals("0000")) {
            chart = new ChartView(container.getContext(), arr, logo);
          } else {
            chart = new ChartView(container.getContext(), arr, null);
          }
          container.addView(chart);
        }
      }

      // Request more details in thread to avoid blocking UI
      if (MainApp.instance.getServerInfo().getRevision() >= 4835
          && (_client.type.equals("c") || _client.type.equals("r") || _client.type.equals("p"))) {
        thread = new Thread(null, moredetail, "MagentoBackground");
        thread.start();
      }
    }
  }