endian11
2019-09-11 ae292cb4f4a67e16465b732e26b408955b4407f5
隐藏“查看地图”;  自定义ArrowView的Text属性
6个文件已修改
44 ■■■■ 已修改文件
app/src/main/java/safeluck/drive/evaluation/MainActivity.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/customview/ArrowView.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/viewmodels/MainViewModel.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/layout_net_train_item.xml 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/profile_layout.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/values/attrs.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/MainActivity.java
@@ -9,6 +9,7 @@
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;
import android.widget.Toast;
@@ -63,14 +64,14 @@
        MyLog.i(TAG,"onCreate");
        MainViewModel mainViewModel = ViewModelProviders.of(this).get(MainViewModel.class);
        mainViewModel.getJson().observe(this, new Observer<String>() {
            @Override
            public void onChanged(@Nullable String json) {
                Toast.makeText(MainActivity.this, json, Toast.LENGTH_SHORT).show();
                MyLog.i(TAG,"json=========="+json);
                MyLog.i(TAG,"json=========="+Thread.currentThread().getName());
                MyLog.i(TAG,"json=========="+json+" ThreadName:"+Thread.currentThread().getName());
            }
        });
@@ -81,6 +82,11 @@
        }
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.i(TAG, "onDestroy: ");
    }
    @Override
    protected void onResume() {
app/src/main/java/safeluck/drive/evaluation/customview/ArrowView.java
@@ -1,6 +1,7 @@
package safeluck.drive.evaluation.customview;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
@@ -10,8 +11,10 @@
import android.text.StaticLayout;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
import safeluck.drive.evaluation.R;
import safeluck.drive.evaluation.util.Utils;
/**
@@ -31,15 +34,18 @@
    private Path textPath = new Path();
    public ArrowView(Context context) {
        super(context);
        this(context,null);
    }
    public ArrowView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        this(context, attrs,0);
    }
    public ArrowView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ArrowView,defStyleAttr,0);
        text = a.getString(R.styleable.ArrowView_text);
        a.recycle();
    }
    @Override
app/src/main/java/safeluck/drive/evaluation/viewmodels/MainViewModel.java
@@ -4,10 +4,15 @@
import android.arch.lifecycle.LiveData;
import android.arch.lifecycle.MutableLiveData;
import android.arch.lifecycle.ViewModel;
import android.util.Log;
import java.util.concurrent.atomic.AtomicInteger;
import safeluck.drive.evaluation.util.MyLog;
public class MainViewModel extends ViewModel {
    private static final String TAG = "MainViewModel";
    AtomicInteger atomicInteger = new AtomicInteger(0);
    private MutableLiveData<String> json = new MutableLiveData<>();
    public LiveData<String> getJson(){
        //往json字符串写入数据
@@ -25,7 +30,9 @@
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                json.postValue("我爱你JetPack!!");
                Log.i(TAG, "run: "+   atomicInteger.incrementAndGet());
                json.postValue("我爱你JetPack!!"+atomicInteger.get());
            }
        }).start();
    }
app/src/main/res/layout/layout_net_train_item.xml
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="5dp"
    android:background="@color/train_item_bg"
@@ -17,11 +19,13 @@
        android:layout_height="80dp"
        android:layout_toRightOf="@+id/hv"
        android:id="@+id/av1"
        app:text="直角转弯"
        android:layout_marginLeft="-15dp"
        />
    <safeluck.drive.evaluation.customview.ArrowView
        android:layout_width="80dp"
        android:layout_height="80dp"
        app:text="曲线行驶"
        android:layout_marginLeft="-15dp"
        android:layout_toRightOf="@+id/av1"
        android:id="@+id/av2"
@@ -30,6 +34,7 @@
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:id="@+id/av3"
        app:text="侧方停车"
        android:layout_marginLeft="-15dp"
        android:layout_toRightOf="@id/av2"
        />
@@ -39,6 +44,7 @@
        android:layout_marginLeft="-15dp"
        android:layout_toRightOf="@+id/av3"
        android:id="@+id/av4"
        app:text="坡道定点"
        />
</RelativeLayout>
app/src/main/res/layout/profile_layout.xml
@@ -116,6 +116,7 @@
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="查看地图"
                android:visibility="gone"
                android:textColor="@android:color/white"/>
        </LinearLayout>
app/src/main/res/values/attrs.xml
@@ -6,4 +6,8 @@
        <attr name="civ_border_overlay" format="boolean" />
        <attr name="civ_fill_color" format="color" />
    </declare-styleable>
    <declare-styleable name="ArrowView">
        <attr name="text" format="string" />
    </declare-styleable>
</resources>