zoukankan      html  css  js  c++  java
  • 团队冲刺第八天

    1、今天自己完成了运动时候的运动距离以及运动速度的还有运动消耗的能量,进行了成果测试。具体的布局代码如下,然后就是实验运动截图,明天准备弄一下数据库净这些内容存放到数据库中,以方便后续的内容展示:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/layout_bg"
        android:id="@+id/sport_content"
        tools:context=".DynamicDemo">
        <RelativeLayout
            android:id="@+id/rlMap"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    
            <com.baidu.mapapi.map.MapView
                android:id="@+id/bmapView"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
        </RelativeLayout>
    
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/sport_change_bg">
    
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="@dimen/title_height"
                android:layout_marginTop="@dimen/spacing_normal"
                android:orientation="horizontal">
    
                <TextView
                    android:id="@+id/startguiji"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical"
                    android:layout_marginStart="@dimen/margin_edge"
                    android:drawableStart="@mipmap/run_mode"
                    android:drawablePadding="5dp"
                    android:gravity="center_vertical"
    
                    android:text="开始运动"
                    android:textColor="@color/red"
                    android:textColorLink="@color/red"
                    android:textSize="@dimen/textsize_8"
                    android:layout_marginLeft="@dimen/margin_edge"
                    android:drawableLeft="@mipmap/map_mode" />
                <TextView
                    android:id="@+id/textView1"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="30px"
                    android:layout_weight="3"
                    android:gravity="center"
                    android:text="时间提醒" />
                <EditText
                    android:id="@+id/setTimeEdit"
                    android:layout_width="500px"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:layout_marginRight="10px"
    
                    android:width="2dp"
                    android:maxLength="4"
                    android:text="1"
                    android:ems="3"
                    android:inputType="number" >
                    <requestFocus />
                </EditText>
    
                <TextView
                    android:id="@+id/textView2"
                    android:layout_width="fill_parent"
                    android:layout_height="match_parent"
                    android:layout_marginLeft="0px"
                    android:layout_weight="3"
                    android:gravity="center"
                    android:text="分钟" />
            </LinearLayout>
        </RelativeLayout>
    
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/margin_edge_20"
            android:layout_marginTop="110dp"
            android:orientation="vertical"
            android:layout_marginLeft="@dimen/margin_edge_20">
            <Chronometer
                android:id="@+id/cm_passtime"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:ellipsize="end"
                android:format="00:00:00"
                android:gravity="center"
                android:textColor="@color/text_color_white"
                android:textSize="65sp"
                android:textStyle="bold" />
    
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/margin_edge_20"
                android:orientation="horizontal">
    
                <TextView
                    android:id="@+id/tvMileage"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:ellipsize="end"
                    android:maxLength="8"
                    android:text="00.00"
                    android:textColor="@color/text_color_white"
                    android:textSize="26sp"
                    android:textStyle="bold" />
    
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="bottom"
                    android:layout_marginStart="6dp"
                    android:layout_marginBottom="2.5dp"
                    android:text="千米"
                    android:textColor="@color/text_color_white"
                    android:textSize="@dimen/textsize_2"
                    android:layout_marginLeft="6dp" />
    
                <TextView
                    android:id="@+id/tvSpeed"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="@dimen/margin_edge_20"
                    android:ellipsize="end"
                    android:maxLength="8"
                    android:text="0.00"
                    android:textColor="@color/text_color_white"
                    android:textSize="26sp"
                    android:textStyle="bold"
                    android:layout_marginLeft="@dimen/margin_edge_20" />
    
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="bottom"
                    android:layout_marginStart="6dp"
                    android:layout_marginBottom="2.5dp"
                    android:text="均速(米/秒)"
                    android:textColor="@color/text_color_white"
                    android:textSize="@dimen/textsize_2"
                    android:layout_marginLeft="6dp" />
                <TextView
                    android:id="@+id/tvcalor"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="@dimen/margin_edge_20"
                    android:ellipsize="end"
                    android:maxLength="8"
                    android:text="00.00"
                    android:textColor="@color/text_color_white"
                    android:textSize="26sp"
                    android:textStyle="bold"
                    android:layout_marginLeft="@dimen/margin_edge_20" />
    
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="bottom"
                    android:layout_marginStart="6dp"
                    android:layout_marginBottom="2.5dp"
                    android:text=""
                    android:textColor="@color/text_color_white"
                    android:textSize="@dimen/textsize_2"
                    android:layout_marginLeft="6dp" />
            </LinearLayout>
    
        </LinearLayout>
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_marginTop="80dip"
            android:background="@color/baise"
            android:minWidth="100dip"
            android:orientation="vertical"
            android:padding="2dp" >
    
            <ToggleButton android:id="@+id/togglebutton"
                android:layout_width="140dip"
                android:layout_height="wrap_content"
                android:textOn="普通地图"
                android:textOff="热力地图"
                android:textColor="@color/darkmagenta"
                android:background="@color/baise"
                android:layout_gravity="center_horizontal" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_marginTop="130dip"
            android:background="@color/baise"
            android:minWidth="100dip"
            android:orientation="vertical"
            android:padding="2dp" >
    
            <Button
                android:id="@+id/button1"
                android:text="罗盘"
                android:layout_width="140dip"
                android:layout_height="wrap_content"
                android:textColor="@color/orangered"
                android:background="@color/baise"
                android:layout_gravity="center_horizontal"/>
        </LinearLayout>
    
    </RelativeLayout>

     2、今天主要是对昨天的问题进行了修复以及完善,解决了activity不能跳转到fragment的问题,解决方式是在点击添加后跳出弹出框,用户可以设置闹钟时间以及标签内容,这样就避免了添加闹钟跳转到activity成功后再回到fragment。第二个问题是用户进入闹钟界面显示闹钟开关状态的问题,解决办法对开关加一个监听事件,通过和对数据库的存储的闹钟状态做匹配,让其显示开关状态。今天就完成了这么多,明天计划完成闹钟的触发事件。下面是今天的主要代码和效果图。

    package com.alarm;
    
    import android.content.Context;
    import android.util.Log;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.BaseAdapter;
    import android.widget.CompoundButton;
    import android.widget.Switch;
    import android.widget.TextView;
    import android.widget.Toast;
    
    import com.example.keeprunning1.R;
    
    import java.util.List;
    
    public class AlarmAdapter extends BaseAdapter {
        private List<Alarm> mlist;
        private Context mContext;
        private LayoutInflater mlayoutInflater;
        private AlarmOperator malarmOperator;;
        public AlarmAdapter(Context context,List<Alarm> list){
            mContext=context;
            mlist=list;
            mlayoutInflater=LayoutInflater.from(context);
            malarmOperator=new AlarmOperator(context);
        }
    
        @Override
        public int getCount() {
            return mlist.size();
        }
    
        @Override
        public Object getItem(int position) {
            return position;
        }
    
        @Override
        public long getItemId(int position) {
            return position;
        }
    
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            final ViewHolder viewHolder;
            if(convertView==null){
                viewHolder=new ViewHolder();
                convertView=mlayoutInflater.inflate(R.layout.alarmitem,null);
                viewHolder.mHour=convertView.findViewById(R.id.hour);
                viewHolder.mMinute=convertView.findViewById(R.id.minute);
                viewHolder.mContent=convertView.findViewById(R.id.content_item);
                viewHolder.mClockType=convertView.findViewById(R.id.switch_control);
                convertView.setTag(viewHolder);
            }else{
                viewHolder=(ViewHolder)convertView.getTag();
            }
    
            final Alarm bean=mlist.get(position);
            final String name=bean.getUsername();
            final String hour=bean.getHour();
            final String minute=bean.getMinute();
            Log.i("name", name);
            viewHolder.mClockType.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    if(isChecked) {
                        malarmOperator.updateswitch(name,hour,minute);
                    }else{
                        malarmOperator.updateswitch1(name,hour,minute);
    
                    }
                }
            });
            int clockType=bean.getClockType();
            Log.d("volley", String.valueOf(clockType));
            if(clockType==0){
                viewHolder.mClockType.setChecked(false);
            }else {
                viewHolder.mClockType.setChecked(true);
            }
            viewHolder.mContent.setText(bean.content);
            viewHolder.mHour.setText(bean.hour);
            viewHolder.mMinute.setText(bean.minute);
            return convertView;
        }
        public class ViewHolder{
            public TextView mHour;
            public TextView mMinute;
            public TextView mContent;
            public Switch mClockType;
            //public CheckBox mCheckBox;
        }
    }

     

     3、今天编写了日历的显示,用了自定义控件,中途遇到的问题,一直显示Binary XML file line #9: Error inflating class错误,晚上查阅资料http://blog.csdn.net/huangxiaohu_coder/article/details/8497286,根据上面的原因,排除了出错原因。但是依旧没有发现自己的问题所在,这个bug弄的好心累呀。明天继续加油。

    package com.example.keeprunning7;
    
    import android.content.Context;
    import android.graphics.Color;
    import android.text.format.DateUtils;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.BaseAdapter;
    import android.widget.ImageView;
    import android.widget.RelativeLayout;
    import android.widget.TextView;
    import android.widget.Toast;
    
    import java.util.ArrayList;
    import java.util.List;
    
    public class AdapterDate extends BaseAdapter {
    
        private Context context;
        private List<Integer> days=new ArrayList<>();
    
        public void setOnSignedSuccess(OnSignedSuccess onSignedSuccess){
            this.onSignedSuccess=onSignedSuccess;
        }
    
        //日历数据
        private List<Boolean> status=new ArrayList<>();
        //签到状态,实际应用中初始化签到状态可通过改字段传递
        private OnSignedSuccess onSignedSuccess;
        //签到成功的回调方法,相应的可自行添加签到始白时的回调函数
        public AdapterDate(Context context){
            this.context=context;
            ///获取当月天数
            int maxDay= DateUtil.getCurrentMonthLastDay();
            for(int i=0;i<DateUtil.getFirstDayOfMonth()-1;i++){
                days.add(0);//0代表需要隐藏的item
                status.add(false);//false为签到状态
            }
    
            for(int i=0;i<maxDay;i++){
                //初始化日历数据
                days.add(i+1);
                //初始化日历签到状态
                status.add(false);
            }
        }
    
        @Override
        public int getCount() {
            return days.size();
        }
    
        @Override
        public Object getItem(int position) {
            return days.get(position);
        }
    
        @Override
        public long getItemId(int position) {
            return position;
        }
    
        class ViewHolder{
            RelativeLayout rlItem;
            TextView tv;
            ImageView ivStatus;
        }
        @Override
        public View getView(final int position, View view, ViewGroup viewGroup) {
            ViewHolder viewHolder = null;
            if (view == null) {
                view = LayoutInflater.from(context).inflate(R.layout.item_gv, null);
                viewHolder = new ViewHolder();
                view.setTag(viewHolder);
            } else {
                viewHolder = (ViewHolder) view.getTag();
            }
            viewHolder.tv = view.findViewById(R.id.tvWeek);
            viewHolder.rlItem=view.findViewById(R.id.rlItem);
            viewHolder.ivStatus=view.findViewById(R.id.ivStatus);
            viewHolder.tv.setText(days.get(position)+"");
            if(days.get(position)==0){
                viewHolder.rlItem.setVisibility(View.GONE);
            }
            if(status.get(position)){
                viewHolder.tv.setTextColor(Color.parseColor("#DF0000"));
                viewHolder.ivStatus.setVisibility(View.VISIBLE);
            }else{
                viewHolder.tv.setTextColor(Color.parseColor("#666666"));
                viewHolder.ivStatus.setVisibility(View.GONE);
            }
            view.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if(status.get(position)){
                        Toast.makeText(context,"Already sign in!",Toast.LENGTH_SHORT).show();
                    }else{
                        Toast.makeText(context,"Sign in success!",Toast.LENGTH_SHORT).show();
                        status.set(position,true);
                        notifyDataSetChanged();
                        if(onSignedSuccess!=null){
                            onSignedSuccess.OnSignedSuccess();
                        }
                    }
                }
            });
            return view;
        }
    
    }
    package com.example.keeprunning7;
    
    import android.content.Context;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.BaseAdapter;
    import android.widget.TextView;
    
    public class AdapterWeek extends BaseAdapter {
    
        private String[] week={"日","一","二","三","四","五","六"};
        private Context context;
    
        public AdapterWeek(Context context){
            this.context=context;
        }
        @Override
        public int getCount() {
            return week.length;
        }
    
        @Override
        public Object getItem(int position) {
            return week[position];
        }
    
        @Override
        public long getItemId(int position) {
            return position;
        }
    
        class ViewHolder{
            TextView tv;
        }
        @Override
        public View getView(final int position, View view, ViewGroup viewGroup) {
            ViewHolder viewHolder=null;
            if(view==null){
                view= LayoutInflater.from(context).inflate(R.layout.item_gv,null);
                viewHolder=new ViewHolder();
                view.setTag(viewHolder);
            }else{
                viewHolder=(ViewHolder)view.getTag();
            }
            viewHolder.tv=view.findViewById(R.id.tvWeek);
            viewHolder.tv.setText(week[position]);
            return view;
        }
    }
    package com.example.keeprunning7;
    
    import java.util.Calendar;
    import java.util.concurrent.CancellationException;
    
    public class DateUtil {
        public static int getCurrentMonthLastDay(){
            Calendar a=Calendar.getInstance();
            //把日期设置为当月第一天
            a.set(Calendar.DATE,1);
            //把日期回滚一天,也就是最后一天
            a.roll(Calendar.DATE,-1);
    
            int maxDate=a.get(Calendar.DATE);
            return maxDate;
    
        }
    
        public static String getCurrentYearAndMonth(){
            Calendar a=Calendar.getInstance();
            int year=a.get(Calendar.YEAR);
            int month=a.get(Calendar.MONTH)+1;
            return year+"年"+month+"月";
        }
    
        //获取当月第一天是星期几,星期日是第一天
        public static int getFirstDayOfMonth(){
            Calendar a=Calendar.getInstance();
            a.set(Calendar.DAY_OF_MONTH,1);
            int i=a.get(Calendar.DAY_OF_WEEK);
            return i;
        }
    }

    团队会议截图:

  • 相关阅读:
    正确使用日志的10个技巧
    为什么使用 SLF4J 而不是 Log4J 来做 Java 日志
    将 MyBatis3 的支持添加到 Spring
    Gson 解析教程
    JSON解析工具比较,主要GSON和FastJSON
    高性能JSON框架之FastJson的简单使用
    Overriding managed version XX for YY
    Access restriction 问题解决
    delphi 判断MDI窗体的子窗体是否存在
    delphi 解决RichViewEdit乱码问题
  • 原文地址:https://www.cnblogs.com/yumazemadui/p/12757282.html
Copyright © 2011-2022 走看看