zoukankan      html  css  js  c++  java
  • 结对编码(柳祎、张许君)

    倾城日记
    倾城日记(Allure)
    功能介绍:这是一款日记app,用于写日记,记事。
    外观:采用文艺型,原因,因为一般经常性写日记的都是属于文艺类型的,所以采用这种这种风格。
    编写测试:柳祎、张许君。

    主界面的列表布局

    <TextView
        android:id="@+id/tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="从前车马很慢,
            书信很远, 一生只够爱一个人"
        android:textColor="#FFF"
        android:textSize="25px"
        android:fontFamily="monospace"
        android:layout_weight="0"
        android:layout_marginTop="35dp"/>
    
    
    <RadioButton
        android:id="@+id/rb1"
        android:layout_width="50dp"
        android:layout_height="wrap_content"
        android:button="null"
        android:layout_marginTop="400dp"
        android:layout_marginLeft="255dp"
        android:drawableTop="@drawable/plane"/>
    
    主界面编码 package com.example.liuy.liuyi;

    import android.content.Intent;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.RadioButton;

    public class MainActivity extends AppCompatActivity {
    private RadioButton rb1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        rb1=(RadioButton)findViewById(R.id.rb1);
        rb1.setOnClickListener(new View.OnClickListener() {
    
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, Login.class);
                startActivity(intent);
            }
        });
    }
    

    }
    实现的界面

    注册界面布局

    <TextView
        android:id="@+id/tv2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="Welcome to Allure !"
        android:textSize="55px"
        android:textColor="#fff"
        android:fontFamily="monospace"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    
        <TextView
            android:id="@+id/tv3"
            android:layout_width="88dp"
            android:layout_height="36dp"
            android:text="Admin:"
            android:textSize="45px"
            android:textColor="#AAAAFF"
            android:layout_marginLeft="45dp"
            android:layout_marginTop="55dp"/>
    
        <EditText
            android:id="@+id/et_password"
            android:layout_width="wrap_content"
            android:layout_height="match_parent" />
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    
        <TextView
            android:id="@+id/tv4"
            android:layout_width="88dp"
            android:layout_height="36dp"
            android:text="Password:"
            android:textSize="45px"
            android:textColor="#AAAAFF"
            android:layout_marginLeft="45dp"
            android:layout_marginTop="55dp"/>
    
        <EditText
            android:id="@+id/et_username"
            android:layout_width="wrap_content"
            android:layout_height="match_parent" />
    </LinearLayout>
    <Button
        android:id="@+id/btn1"
        android:layout_width="155dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="125dp"
        android:text="注册"
        android:textSize="35px"
        android:textColor="#fff"
        android:fontFamily="monospace"
        android:layout_marginTop="100dp"/>
    
    注册界面代码 package com.example.liuy.liuyi;

    import android.content.Intent;
    import android.os.Bundle;
    import android.os.PersistableBundle;
    import android.support.v7.app.AppCompatActivity;
    import android.view.View;
    import android.widget.Button;

    /**

    • Created by liuY on 2017/3/28.
      */

    public class Login extends AppCompatActivity {
    private Button btn1;

    @Override
    public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login);
        btn1 = (Button) findViewById(R.id.btn1);
        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Login.this, Page.class);
            }
        });
    }
    

    }

    跳转界面

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/welcome" />
    
    <RadioButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:button="null"
        android:background="@drawable/add1"/>
    
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="350dp">
    
        <RadioButton
            android:id="@+id/search"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:drawableTop="@drawable/search"
            android:button="null"/>
    
        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:drawableTop="@drawable/notebook"
            android:button="null"
            android:id="@+id/radioButton" />
    
        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:drawableTop="@drawable/camera"
            android:button="null"/>
    
    </LinearLayout>
    
    跳转界面代码 package com.example.liuy.liuyi;

    /**

    • Created by liuY on 2017/3/28.
      */

    import android.app.ProgressDialog;
    import android.graphics.Bitmap;
    import android.graphics.BitmapFactory;
    import android.os.AsyncTask;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.ImageView;
    import android.widget.RadioButton;

    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.net.HttpURLConnection;
    import java.net.MalformedURLException;
    import java.net.URL;

    public class Page extends AppCompatActivity{
    private RadioButton search;
    private ProgressDialog progressDialog;
    private final String IMAGE_PATH = "http://www.baidu.com/img/bd_logo1.png";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        search = (RadioButton) findViewById(R.id.search);
        progressDialog = new ProgressDialog(Page.this);
        progressDialog.setTitle("提示信息");
        progressDialog.setCancelable(false);
        progressDialog.setMessage("正在下载,请稍候。。。");
    

    // progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);

        search.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new MyAsyncTask().execute(IMAGE_PATH);
            }
        });
    
    }
    
    public class MyAsyncTask extends AsyncTask<String, Integer, byte[]> {
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            progressDialog.show();
        }
    
        @Override
        protected byte[] doInBackground(String... strings) {
            byte[] image = new byte[] {};
            HttpURLConnection conn = null;
            InputStream inputStream = null;
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    
            try {
                URL url = new URL(strings[0]);
                conn = (HttpURLConnection)url.openConnection();
                if (conn.getResponseCode() == 200) {
                    long file_length = conn.getContentLength();
                    long total_length = 0;
                    int length = 0;
                    byte[] data = new byte[1024];
                    inputStream = conn.getInputStream();
                    while (-1 != (length = inputStream.read(data))) {
                        total_length += length;
                        byteArrayOutputStream.write(data, 0, length);
                        int progress = ((int) (total_length*100/(float)file_length));
                        publishProgress(progress);
    
                        try {
                            Thread.sleep(1000);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                    //image = byteArrayOutputStream.toByteArray();
                    inputStream.close();
                    byteArrayOutputStream.close();
                }
            } catch (MalformedURLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }finally {
                conn.disconnect();
            }
            return image;
        }
    
        @Override
        protected void onProgressUpdate(Integer... values) {
            super.onProgressUpdate(values);
            progressDialog.setProgress(values[0]);
        }
    
        @Override
        protected void onPostExecute(byte[] bytes) {
            super.onPostExecute(bytes);
            Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
            progressDialog.dismiss();
        }
    }
    

    }

    测试用例1:
    用户名输入特殊字符,检测是否能识别到
    结果:都能准确的反映出来
    测试用例2:
    点击按钮,检测是否可以跳转页面
    结果:跳转页面稍有延迟(可能是电脑内存小的原因)
    测试用例3:
    点击按钮,检测是否能够跳转到网页
    结果:失败

  • 相关阅读:
    C++ std::map::erase用法及其陷阱
    写在分类之首-----to do list!
    Gradle系列教材(译)
    Android进阶-UIL分析
    ArrayList源码解析
    Android进阶-MVP
    高质量代码-树的子结构
    高质量代码-并和链表
    高质量代码-翻转链表
    高质量代码-链表中倒数第k个结点
  • 原文地址:https://www.cnblogs.com/u1118746/p/6637474.html
Copyright © 2011-2022 走看看