forked from hzuapps/android-labs-2020
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
851 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
students/net1814080903118/Net1814080903118LendAckActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package edu.hzuapps.androidlabs; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.SharedPreferences; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
|
||
public class Net1814080903118LendAckActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_net_1814080903118_lend_ack); | ||
|
||
SharedPreferences sharedPreferences = getSharedPreferences("status", Context.MODE_PRIVATE); | ||
String lendid=sharedPreferences.getString("lendid","111111"); | ||
EditText cdbId2=(EditText)findViewById(R.id.cdbId2); | ||
cdbId2.setText(lendid); | ||
Button lendAckBtn=(Button)findViewById(R.id.lendAckBtn); | ||
lendAckBtn.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
|
||
SharedPreferences sharedPreferences = getSharedPreferences("status", Context.MODE_PRIVATE); | ||
SharedPreferences.Editor editor = sharedPreferences.edit();//获取编辑器 | ||
//修改lendable标志 | ||
editor.putString("lendable", "true"); | ||
|
||
//修改lend开始时间 | ||
SimpleDateFormat df = new SimpleDateFormat("HH:mm");//设置日期格式 | ||
editor.putString("lendopentime",df.format(new Date())); | ||
editor.commit();//提交修改 | ||
|
||
//跳转页面到Net1814080903118WorkLendActivity | ||
Intent intent=new Intent(); | ||
intent.setClass(Net1814080903118LendAckActivity.this,Net1814080903118WorkLendActivity.class); | ||
startActivity(intent); | ||
} | ||
}); | ||
|
||
|
||
|
||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
students/net1814080903118/Net1814080903118PayAckActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package edu.hzuapps.androidlabs; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.SharedPreferences; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.TextView; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import edu.hzuapps.androidlabs.util.LendFunction; | ||
|
||
public class Net1814080903118PayAckActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_net_1814080903118_pay_ack); | ||
|
||
//获取充电宝编号 | ||
SharedPreferences sharedPreferences = getSharedPreferences("status", Context.MODE_PRIVATE); | ||
String lendid=sharedPreferences.getString("lendid","111111"); | ||
TextView cdbId3=(TextView)findViewById(R.id.cdbId3); | ||
cdbId3.setText(lendid);//设置充电宝编号 | ||
new Thread(){ | ||
@Override | ||
public void run(){ | ||
while(true){ | ||
SharedPreferences sharedPreferences = getSharedPreferences("status", Context.MODE_PRIVATE); | ||
String opendate=sharedPreferences.getString("lendopentime","12:00");//Hour-Minter | ||
String usedate=LendFunction.usetime(opendate);//函数返回以及使用了多少时间 | ||
String []use_hour_minter=usedate.split(":"); | ||
String usehour=use_hour_minter[0];//已经使用的小时 | ||
String useminter=use_hour_minter[1];//已经使用的分钟 | ||
TextView userTimeHour=(TextView)findViewById(R.id.userTimeHour); | ||
userTimeHour.setText(usehour);//设置使用小时 | ||
TextView userTimeMinter=(TextView)findViewById(R.id.userTimeMinter); | ||
userTimeMinter.setText(useminter);//设置使用分钟 | ||
|
||
double muchPayMoney= LendFunction.muchPayMoney(usedate);//函数返回应该缴费金额数 | ||
TextView muchSpyMoney=(TextView)findViewById(R.id.muchSpyMoney); | ||
muchSpyMoney.setText(String.format("%.1f",muchPayMoney)); | ||
try { | ||
Thread.sleep(50000); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
}.start(); | ||
|
||
Button spyAckBtn=(Button)findViewById(R.id.spyAckBtn); | ||
spyAckBtn.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
//1. | ||
//跳出付款小窗口---相关操作在小窗口中进行 | ||
|
||
//2. | ||
//直接在当前页面进行简单处理 | ||
SharedPreferences sharedPreferences = getSharedPreferences("status", Context.MODE_PRIVATE); | ||
SharedPreferences.Editor editor = sharedPreferences.edit();//获取编辑器 | ||
editor.putString("lendable", "false"); | ||
editor.commit();//提交修改 | ||
Intent intent =new Intent(); | ||
intent.setClass(Net1814080903118PayAckActivity.this,Net1814080903118WorkUnLendActivity.class); | ||
startActivity(intent); | ||
} | ||
}); | ||
|
||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
students/net1814080903118/Net1814080903118PersonalActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package edu.hzuapps.androidlabs; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.SharedPreferences; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.Button; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
public class Net1814080903118PersonalActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_net_1814080903118_personal); | ||
Button navLendBtn3=(Button) findViewById(R.id.navLendBtn3); | ||
navLendBtn3.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
SharedPreferences sharedPreferences = getSharedPreferences("status", Context.MODE_PRIVATE); | ||
String lendable=sharedPreferences.getString("lendable","false"); | ||
Intent intent=new Intent(); | ||
if(lendable.equals("false")) | ||
intent.setClass(Net1814080903118PersonalActivity.this,Net1814080903118WorkUnLendActivity.class); | ||
else | ||
intent.setClass(Net1814080903118PersonalActivity.this,Net1814080903118WorkLendActivity.class); | ||
startActivity(intent); | ||
} | ||
}); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
students/net1814080903118/Net1814080903118WorkLendActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package edu.hzuapps.androidlabs; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.SharedPreferences; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import edu.hzuapps.androidlabs.util.LendFunction; | ||
|
||
public class Net1814080903118WorkLendActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_net_1814080903118_work_lend); | ||
|
||
//获取充电宝编号 | ||
SharedPreferences sharedPreferences = getSharedPreferences("status", Context.MODE_PRIVATE); | ||
String lendid=sharedPreferences.getString("lendid","111111"); | ||
TextView cdbId2=(TextView)findViewById(R.id.cdbId2); | ||
//设置充电宝编号 | ||
cdbId2.setText(lendid); | ||
|
||
//及时更新已使用时间与需要缴费金额 | ||
new Thread(){ | ||
@Override | ||
public void run(){ | ||
while(true){ | ||
//获取lend开始时间 | ||
SharedPreferences sharedPreferences = getSharedPreferences("status", Context.MODE_PRIVATE); | ||
String opendate=sharedPreferences.getString("lendopentime","12:00");//Hour-Minter | ||
String usedate= LendFunction.usetime(opendate);//函数返回以及使用了多少时间 | ||
TextView usehour=(TextView)findViewById(R.id.usehour); | ||
usehour.setText(usedate.split(":")[0].trim()); | ||
TextView useminter=(TextView)findViewById(R.id.useminter); | ||
useminter.setText(usedate.split(":")[1].trim()); | ||
double muchPayMoney=LendFunction.muchPayMoney(usedate);//函数返回应该缴费金额数 | ||
TextView muchMoney=(TextView)findViewById(R.id.muchMoney); | ||
muchMoney.setText(String.format("%.1f",muchPayMoney)); | ||
try { | ||
Thread.sleep(50000); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
}.start(); | ||
|
||
|
||
|
||
Button navPersonalBtn2=(Button)findViewById(R.id.navPersonalBtn2); | ||
navPersonalBtn2.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
Intent intent=new Intent(); | ||
intent.setClass(Net1814080903118WorkLendActivity.this,Net1814080903118PersonalActivity.class); | ||
startActivity(intent); | ||
} | ||
}); | ||
|
||
ImageView lendMap=(ImageView)findViewById(R.id.lendMap2); | ||
lendMap.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
Intent intent=new Intent(); | ||
intent.setClass(Net1814080903118WorkLendActivity.this,Net1814080903118PayAckActivity.class); | ||
startActivity(intent); | ||
} | ||
}); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
students/net1814080903118/Net1814080903118WorkUnLendActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package edu.hzuapps.androidlabs; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.SharedPreferences; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.ImageView; | ||
|
||
import edu.hzuapps.androidlabs.util.LendFunction; | ||
|
||
public class Net1814080903118WorkUnLendActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_net_1814080903118_work_un_lend); | ||
|
||
SharedPreferences sharedPreferences = getSharedPreferences("status", Context.MODE_PRIVATE); | ||
String lendable=sharedPreferences.getString("lendable","false"); | ||
if(lendable.equals("false")){ | ||
SharedPreferences.Editor editor = sharedPreferences.edit();//获取编辑器 | ||
editor.putString("lendable", "false"); | ||
editor.commit();//提交修改 | ||
}else{ | ||
Intent intent=new Intent(); | ||
intent.setClass(Net1814080903118WorkUnLendActivity.this,Net1814080903118WorkLendActivity.class); | ||
startActivity(intent); | ||
} | ||
|
||
Button navPersonalBtn1=(Button)findViewById(R.id.navPersonalBtn1); | ||
navPersonalBtn1.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
Intent intent=new Intent(); | ||
intent.setClass(Net1814080903118WorkUnLendActivity.this,Net1814080903118PersonalActivity.class); | ||
startActivity(intent); | ||
} | ||
}); | ||
|
||
ImageView lendMap=(ImageView)findViewById(R.id.scanWin); | ||
lendMap.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
String lendid= LendFunction.getbinarynumber();//扫描二维码的函数,返回二维码中存储的充电宝编号 | ||
//初始化Lend标志 | ||
SharedPreferences sharedPreferences = getSharedPreferences("status", Context.MODE_PRIVATE); | ||
SharedPreferences.Editor editor = sharedPreferences.edit();//获取编辑器 | ||
editor.putString("lendid", lendid); | ||
editor.commit();//提交修改 | ||
|
||
Intent intent=new Intent(); | ||
intent.setClass(Net1814080903118WorkUnLendActivity.this,Net1814080903118LendAckActivity.class); | ||
startActivity(intent); | ||
} | ||
}); | ||
|
||
|
||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
students/net1814080903118/activity_net_1814080903118_lend_ack.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?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" | ||
android:background="@drawable/login_bg" | ||
tools:context=".Net1814080903118LendAckActivity"> | ||
|
||
<ImageView | ||
android:id="@+id/imageView6" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:srcCompat="@drawable/lend_icon" /> | ||
|
||
<TextView | ||
android:id="@+id/textView7" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="16dp" | ||
android:layout_marginLeft="16dp" | ||
android:layout_marginTop="188dp" | ||
android:text="充电宝编号:" | ||
android:textSize="24sp" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/imageView6" /> | ||
|
||
<EditText | ||
android:id="@+id/cdbId2" | ||
android:layout_width="240dp" | ||
android:layout_height="40dp" | ||
android:layout_marginStart="2dp" | ||
android:layout_marginLeft="2dp" | ||
android:background="@color/colorWhite" | ||
app:layout_constraintBaseline_toBaselineOf="@+id/textView7" | ||
app:layout_constraintStart_toEndOf="@+id/textView7" /> | ||
|
||
<Button | ||
android:id="@+id/lendAckBtn" | ||
android:layout_width="250dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="288dp" | ||
android:background="@drawable/button_circle_shape" | ||
android:text="确定" | ||
android:textSize="24sp" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintHorizontal_bias="0.496" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/imageView6" /> | ||
</androidx.constraintlayout.widget.ConstraintLayout> |
Oops, something went wrong.