parent
9c7b29c63b
commit
d12f84d4f5
@ -0,0 +1,28 @@ |
||||
package com.community.pocket.data.model; |
||||
|
||||
/** |
||||
* 访客信息 |
||||
*/ |
||||
public class Visitor { |
||||
private String name; |
||||
private long time; |
||||
private String notes; |
||||
|
||||
public Visitor(String name, long time, String notes) { |
||||
this.name = name; |
||||
this.time = time; |
||||
this.notes = notes; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public long getTime() { |
||||
return time; |
||||
} |
||||
|
||||
public String getNotes() { |
||||
return notes; |
||||
} |
||||
} |
@ -1,18 +1,35 @@ |
||||
package com.community.pocket.ui.main.ui.visitor; |
||||
|
||||
import android.os.Bundle; |
||||
import android.view.View; |
||||
import android.widget.Toast; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.annotation.Nullable; |
||||
|
||||
import com.community.pocket.R; |
||||
import com.community.pocket.ui.main.TestMainFragment; |
||||
|
||||
import org.xutils.view.annotation.ContentView; |
||||
import org.xutils.view.annotation.Event; |
||||
|
||||
/** |
||||
* 我的访客界面 |
||||
*/ |
||||
@ContentView(R.layout.visitor_my_fragment) |
||||
public class VisitorMyFragment extends TestMainFragment { |
||||
public class VisitorMyFragment extends VisitorMyVisitor { |
||||
|
||||
@Override |
||||
protected int viewId() { |
||||
return R.id.text_visitor; |
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
||||
super.onViewCreated(view, savedInstanceState); |
||||
name.setText(R.string.visitor_name); |
||||
time.setText(R.string.visitor_time); |
||||
} |
||||
|
||||
/** |
||||
* 查询访客数据 |
||||
*/ |
||||
@Event(R.id.query) |
||||
private void query(View view) { |
||||
Toast.makeText(getContext(), "访客数据查询" + startTime.getText() + "|" + endTime.getText(), Toast.LENGTH_SHORT).show(); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,128 @@ |
||||
package com.community.pocket.ui.main.ui.visitor; |
||||
|
||||
import android.os.Build; |
||||
import android.os.Bundle; |
||||
import android.text.format.DateFormat; |
||||
import android.view.Gravity; |
||||
import android.view.View; |
||||
import android.widget.Button; |
||||
import android.widget.EditText; |
||||
import android.widget.TextView; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.annotation.Nullable; |
||||
import androidx.annotation.RequiresApi; |
||||
import androidx.appcompat.app.AlertDialog; |
||||
import androidx.gridlayout.widget.GridLayout; |
||||
|
||||
import com.community.pocket.R; |
||||
import com.community.pocket.data.model.Visitor; |
||||
import com.community.pocket.ui.BaseFragment; |
||||
|
||||
import org.xutils.view.annotation.ViewInject; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.Objects; |
||||
|
||||
public abstract class VisitorMyVisitor extends BaseFragment { |
||||
//表格布局
|
||||
@ViewInject(R.id.table) |
||||
private GridLayout gridLayout; |
||||
|
||||
//查询开始时间
|
||||
@ViewInject(R.id.start_time) |
||||
protected EditText startTime; |
||||
|
||||
//查询结束时间
|
||||
@ViewInject(R.id.end_time) |
||||
protected EditText endTime; |
||||
|
||||
//表格列
|
||||
@ViewInject(R.id.name) |
||||
protected TextView name; |
||||
|
||||
@ViewInject(R.id.time) |
||||
protected TextView time; |
||||
|
||||
/** |
||||
* 显示备注最大长度 |
||||
*/ |
||||
private static final int maxLength = 5; |
||||
|
||||
@Override |
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
||||
super.onViewCreated(view, savedInstanceState); |
||||
initDataList(); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 初始化数据 |
||||
* TODO 测试数据 |
||||
*/ |
||||
private void initDataList() { |
||||
List<Visitor> visitors = new ArrayList<>(); |
||||
for (int i = 0; i < 30; i++) { |
||||
Visitor visitor = new Visitor("1231", System.currentTimeMillis(), "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"); |
||||
visitors.add(visitor); |
||||
} |
||||
|
||||
for (final Visitor visitor : visitors) { |
||||
createTextView(visitor.getName()); |
||||
createTextView(DateFormat.format(getString(R.string.dateformat), visitor.getTime())); |
||||
createTextView(visitor.getNotes().length() <= maxLength ? visitor.getNotes() : visitor.getNotes().substring(0, maxLength)); |
||||
|
||||
Button button = new Button(getContext()); |
||||
button.setText(getString(R.string.show_notes)); |
||||
GridLayout.LayoutParams layoutParams = new GridLayout.LayoutParams(); |
||||
layoutParams.columnSpec = GridLayout.spec(GridLayout.UNDEFINED, 1f); |
||||
button.setLayoutParams(layoutParams); |
||||
button.setOnClickListener(new View.OnClickListener() { |
||||
@RequiresApi(api = Build.VERSION_CODES.KITKAT) |
||||
@Override |
||||
public void onClick(View v) { |
||||
createAlertNotes(visitor.getNotes()); |
||||
} |
||||
}); |
||||
gridLayout.addView(button); |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 创建单元格 |
||||
*/ |
||||
private void createTextView(CharSequence text) { |
||||
TextView textView = new TextView(getContext()); |
||||
textView.setGravity(Gravity.CENTER | Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); |
||||
textView.setText(text); |
||||
textView.setBackground(getResources().getDrawable(R.drawable.border)); |
||||
GridLayout.LayoutParams layoutParams = new GridLayout.LayoutParams(); |
||||
layoutParams.columnSpec = GridLayout.spec(GridLayout.UNDEFINED, 1f); |
||||
textView.setLayoutParams(layoutParams); |
||||
gridLayout.addView(textView); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 创建显示备注信息弹窗 |
||||
*/ |
||||
@RequiresApi(api = Build.VERSION_CODES.KITKAT) |
||||
private void createAlertNotes(String text) { |
||||
View view = View.inflate(getContext(), R.layout.visitor_info, null); |
||||
EditText editText = view.findViewById(R.id.content); |
||||
editText.setText(text); |
||||
editText.setTextColor(getResources().getColor(R.color.colorPrimaryDark)); |
||||
Button button = view.findViewById(R.id.close); |
||||
AlertDialog.Builder alert = new AlertDialog.Builder(Objects.requireNonNull(getContext())); |
||||
final AlertDialog alertDialog = alert.setTitle(R.string.notes).setView(view).create(); |
||||
button.setOnClickListener(new View.OnClickListener() { |
||||
@Override |
||||
public void onClick(View v) { |
||||
alertDialog.dismiss(); |
||||
} |
||||
}); |
||||
alertDialog.show(); |
||||
} |
||||
} |
@ -1,18 +1,36 @@ |
||||
package com.community.pocket.ui.main.ui.visitor; |
||||
|
||||
import android.os.Bundle; |
||||
import android.view.View; |
||||
import android.widget.Toast; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.annotation.Nullable; |
||||
|
||||
import com.community.pocket.R; |
||||
import com.community.pocket.ui.main.TestMainFragment; |
||||
|
||||
import org.xutils.view.annotation.ContentView; |
||||
import org.xutils.view.annotation.Event; |
||||
|
||||
/** |
||||
* 我的预约界面 |
||||
*/ |
||||
@ContentView(R.layout.visitor_reservation_fragment) |
||||
public class VisitorReservationFragment extends TestMainFragment { |
||||
@ContentView(R.layout.visitor_my_fragment) |
||||
public class VisitorReservationFragment extends VisitorMyVisitor { |
||||
|
||||
@Override |
||||
protected int viewId() { |
||||
return R.id.text_reservation; |
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
||||
super.onViewCreated(view, savedInstanceState); |
||||
name.setText(R.string.appointment_name); |
||||
time.setText(R.string.appointment_time); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 查询预约数据 |
||||
*/ |
||||
@Event(value = R.id.query) |
||||
private void query(View view) { |
||||
Toast.makeText(getContext(), "预约数据查询" + startTime.getText() + "|" + endTime.getText(), Toast.LENGTH_SHORT).show(); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,30 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent"> |
||||
|
||||
<EditText |
||||
android:id="@+id/content" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
android:ems="10" |
||||
android:enabled="false" |
||||
android:gravity="start|top" |
||||
android:importantForAutofill="no" |
||||
android:inputType="textMultiLine" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintTop_toTopOf="parent" |
||||
tools:ignore="LabelFor" /> |
||||
|
||||
<Button |
||||
android:id="@+id/close" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
android:text="@string/action_close" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintTop_toBottomOf="@id/content" /> |
||||
</androidx.constraintlayout.widget.ConstraintLayout> |
@ -1,13 +1,108 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
tools:context=".ui.main.ui.visitor.VisitorMyFragment"> |
||||
|
||||
<TextView |
||||
android:id="@+id/text_visitor" |
||||
<androidx.constraintlayout.widget.ConstraintLayout |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" /> |
||||
android:layout_height="match_parent"> |
||||
|
||||
<LinearLayout |
||||
android:id="@+id/query_layout" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="horizontal" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintTop_toTopOf="parent"> |
||||
|
||||
<EditText |
||||
android:id="@+id/start_time" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
android:ems="10" |
||||
android:hint="@string/start_time" |
||||
android:inputType="textPersonName" |
||||
android:importantForAutofill="no" /> |
||||
|
||||
<EditText |
||||
android:id="@+id/end_time" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
android:ems="10" |
||||
android:hint="@string/end_time" |
||||
android:inputType="textPersonName" |
||||
android:importantForAutofill="no" /> |
||||
|
||||
</LinearLayout> |
||||
|
||||
<Button |
||||
android:id="@+id/query" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
android:text="@string/query" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintTop_toBottomOf="@id/query_layout" /> |
||||
|
||||
<androidx.core.widget.NestedScrollView |
||||
android:layout_width="match_parent" |
||||
android:layout_height="0dp" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintTop_toBottomOf="@id/query"> |
||||
|
||||
<LinearLayout |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="vertical"> |
||||
|
||||
<androidx.gridlayout.widget.GridLayout |
||||
android:id="@+id/table" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
app:columnCount="4"> |
||||
|
||||
<TextView |
||||
android:id="@+id/name" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:gravity="center" |
||||
android:textSize="18sp" |
||||
app:layout_columnWeight="1" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/time" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:gravity="center" |
||||
android:textSize="18sp" |
||||
app:layout_columnWeight="1" /> |
||||
|
||||
<TextView |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:gravity="center" |
||||
android:text="@string/notes" |
||||
android:textSize="18sp" |
||||
app:layout_columnWeight="1" /> |
||||
|
||||
<TextView |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:gravity="center" |
||||
android:text="@string/action" |
||||
android:textSize="18sp" |
||||
app:layout_columnWeight="1" /> |
||||
|
||||
</androidx.gridlayout.widget.GridLayout> |
||||
</LinearLayout> |
||||
</androidx.core.widget.NestedScrollView> |
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout> |
||||
</FrameLayout> |
@ -1,13 +0,0 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<FrameLayout 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" |
||||
tools:context=".ui.main.ui.visitor.VisitorReservationFragment"> |
||||
|
||||
<TextView |
||||
android:id="@+id/text_reservation" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" /> |
||||
|
||||
</FrameLayout> |
Loading…
Reference in new issue