Search in sources :

Example 6 with HttpTransaction

use of lib.data.HttpTransaction in project LibTest by liudao01.

the class ListHttpAdapter method baseGetView.

@Override
public void baseGetView(final int position, View v, ViewHolder vh) {
    if (list == null || list.size() <= 0) {
        return;
    }
    HttpTransaction transaction = (HttpTransaction) list.get(position);
    // Logger.d(" 每个item 的值 = "+transaction.toString());
    TextView code;
    TextView path;
    TextView host;
    TextView start;
    TextView duration;
    TextView size;
    ImageView ssl;
    code = (TextView) vh.getTextView(R.id.code);
    path = (TextView) vh.getTextView(R.id.path);
    host = (TextView) vh.getTextView(R.id.host);
    start = (TextView) vh.getTextView(R.id.start);
    duration = (TextView) vh.getTextView(R.id.duration);
    size = (TextView) vh.getTextView(R.id.size);
    ssl = (ImageView) vh.getImageView(R.id.ssl);
    Button mBtCopyData;
    mBtCopyData = vh.getButton(R.id.bt_copy_data);
    path.setText(transaction.getMethod() + " " + transaction.getPath());
    host.setText(transaction.getHost());
    start.setText(transaction.getRequestStartTimeString());
    ssl.setVisibility(transaction.isSsl() ? View.VISIBLE : View.GONE);
    if (transaction.getStatus() == HttpTransaction.Status.Complete) {
        code.setText(String.valueOf(transaction.getResponseCode()));
        duration.setText(transaction.getDurationString());
        size.setText(transaction.getTotalSizeString());
    } else {
        code.setText(null);
        duration.setText(null);
        size.setText(null);
    }
    if (transaction.getStatus() == HttpTransaction.Status.Failed) {
        code.setText("!!!");
    }
    mBtCopyData.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            HttpTransaction httpTransaction = (HttpTransaction) TestLibUtil.httpMoudleList.get(position);
            Utils.copy(context, "请求方式: " + httpTransaction.getMethod() + "\n" + "请求地址: " + httpTransaction.getUrl() + "\n" + "请求参数: " + httpTransaction.getRequestBody() + "\n请求结果:" + httpTransaction.getFormattedResponseBody());
        }
    });
    setStatusColor(vh, transaction);
}
Also used : HttpTransaction(lib.data.HttpTransaction) Button(android.widget.Button) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Example 7 with HttpTransaction

use of lib.data.HttpTransaction in project LibTest by liudao01.

the class NetHoverMenuScreen method initView.

// //    private View createScreenView() {
// //        TextView wholeScreen = new TextView(mContext);
// //        wholeScreen.setText("Screen: " + mPageTitle);
// //        wholeScreen.setGravity(Gravity.CENTER);
// //        return wholeScreen;
// //    }    @NonNull
private View initView() {
    view = LayoutInflater.from(mContext).inflate(R.layout.result_list, null);
    httpResult = (LinearLayout) view.findViewById(R.id.http_result);
    httpResultList = (LinearLayout) view.findViewById(R.id.http_result_list);
    btCopy = (Button) view.findViewById(R.id.bt_copy);
    btClear = (Button) view.findViewById(R.id.bt_clear);
    listview = (ListView) view.findViewById(R.id.listview);
    listview.setOnItemClickListener(this);
    listview.setOnItemLongClickListener(this);
    httpTransactionList = TestLibUtil.httpMoudleList;
    if (httpTransactionList != null && httpTransactionList.size() > 0) {
        // 倒序刚发的在最前面
        Collections.reverse(httpTransactionList);
    }
    listHttpAdapter = new ListHttpAdapter(mContext, httpTransactionList);
    listview.setAdapter(listHttpAdapter);
    btClear.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            TestLibUtil.httpMoudleList.clear();
            httpTransactionList.clear();
            listHttpAdapter.setList(httpTransactionList);
        }
    });
    // 拷贝返回的数据
    btCopy.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            HttpTransaction httpTransaction = httpTransactionList.get(clickPosition);
            Utils.copy(mContext, "返回数据: " + httpTransaction.getFormattedResponseBody());
        }
    });
    return view;
}
Also used : HttpTransaction(lib.data.HttpTransaction) ListHttpAdapter(lib.net.ListHttpAdapter) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Example 8 with HttpTransaction

use of lib.data.HttpTransaction in project LibTest by liudao01.

the class HttpNavigatorContent method onItemLongClick.

@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
    HttpTransaction httpTransaction = getHttpTransactionList().get(position);
    Utils.copy(context, "请求方式: " + httpTransaction.getMethod() + "\n" + "请求地址: " + httpTransaction.getUrl() + "\n" + "请求参数: " + httpTransaction.getRequestBody());
    return true;
}
Also used : HttpTransaction(lib.data.HttpTransaction)

Example 9 with HttpTransaction

use of lib.data.HttpTransaction in project LibTest by liudao01.

the class HttpNavigatorContent method setList.

public static void setList() {
    if (TestLibUtil.httpMoudleList != null) {
        if (listHttpAdapter != null) {
            List<HttpTransaction> httpMoudleList = TestLibUtil.httpMoudleList;
            Message message = Message.obtain();
            message.obj = httpMoudleList;
            handler.sendMessage(message);
        }
    }
}
Also used : HttpTransaction(lib.data.HttpTransaction) Message(android.os.Message)

Aggregations

HttpTransaction (lib.data.HttpTransaction)9 View (android.view.View)3 TextView (android.widget.TextView)3 Intent (android.content.Intent)2 Message (android.os.Message)2 AdapterView (android.widget.AdapterView)1 Button (android.widget.Button)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 IpConfigBeen (httploglib.lib.been.IpConfigBeen)1 EOFException (java.io.EOFException)1 IOException (java.io.IOException)1 Charset (java.nio.charset.Charset)1 UnsupportedCharsetException (java.nio.charset.UnsupportedCharsetException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 ListHttpAdapter (lib.net.ListHttpAdapter)1 MediaType (okhttp3.MediaType)1 Request (okhttp3.Request)1 RequestBody (okhttp3.RequestBody)1