-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1400 from cyh1069247088/master
- Loading branch information
Showing
10 changed files
with
208 additions
and
9 deletions.
There are no files selected for viewing
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,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="edu.hzuapps.androidlabs.com1714080901141"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity | ||
android:name=".Com1714080901141DialogActivity" | ||
android:theme="@style/Theme.AppCompat.Dialog"> | ||
|
||
</activity> | ||
<activity | ||
android:name=".Com1714080901141MainActivity" | ||
android:label="@string/app_name"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
25 changes: 25 additions & 0 deletions
25
...main/java/edu/hzuapps/androidlabs/com1714080901141/Com1714080901141ActivityCollector.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,25 @@ | ||
package edu.hzuapps.androidlabs.com1714080901141; | ||
|
||
import android.app.Activity; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class Com1714080901141ActivityCollector { | ||
public static List<Activity> activities=new ArrayList<>(); | ||
public static void addActivity(Activity activity){ | ||
activities.add(activity); | ||
} | ||
public static void removeActivity(Activity activity){ | ||
activities.remove(activity); | ||
} | ||
public static void finishAll(){ | ||
for(Activity activity:activities){ | ||
if(!activity.isFinishing()){ | ||
activity.finish(); | ||
} | ||
} | ||
activities.clear(); | ||
//android.os.Process.killProcess(android.os.Process.myPid());//kill all processes,exit without heritage | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
.../src/main/java/edu/hzuapps/androidlabs/com1714080901141/Com1714080901141BaseActivity.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,20 @@ | ||
package edu.hzuapps.androidlabs.com1714080901141; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.util.Log; | ||
|
||
public class Com1714080901141BaseActivity extends AppCompatActivity { | ||
private int TAG; //Com1714080901141 is too long,not better for log.d() function. | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState){ | ||
super.onCreate(savedInstanceState); | ||
Log.d("TAG",getClass().getSimpleName());//to know exactly wher you are | ||
Com1714080901141ActivityCollector.addActivity(this);//static class is share with all | ||
} | ||
@Override | ||
protected void onDestroy(){ | ||
super.onDestroy(); | ||
Com1714080901141ActivityCollector.removeActivity(this); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...rc/main/java/edu/hzuapps/androidlabs/com1714080901141/Com1714080901141DialogActivity.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.com1714080901141; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.View; | ||
import android.widget.Button; | ||
|
||
public class Com1714080901141DialogActivity extends Com1714080901141BaseActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_dialog); | ||
Button select_yes=(Button) findViewById(R.id.hope_to_exit); | ||
Button select_no=(Button) findViewById(R.id.regret_to_exit); | ||
select_no.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
finish();//exit dialog activity | ||
|
||
} | ||
}); | ||
select_yes.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
Com1714080901141MainActivity.exit=true; | ||
Com1714080901141ActivityCollector.finishAll();//exit all activity | ||
} | ||
}); | ||
|
||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
.../src/main/java/edu/hzuapps/androidlabs/com1714080901141/Com1714080901141MainActivity.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,55 @@ | ||
package edu.hzuapps.androidlabs.com1714080901141; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.annotation.NonNull; | ||
import android.support.design.widget.BottomNavigationView; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.MenuItem; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.TextView; | ||
|
||
public class Com1714080901141MainActivity extends Com1714080901141BaseActivity { | ||
|
||
private TextView mTextMessage; | ||
public static boolean exit; | ||
|
||
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener | ||
= new BottomNavigationView.OnNavigationItemSelectedListener() { | ||
|
||
@Override | ||
public boolean onNavigationItemSelected(@NonNull MenuItem item) { | ||
switch (item.getItemId()) { | ||
case R.id.navigation_first: | ||
mTextMessage.setText(R.string.title_first); | ||
return true; | ||
case R.id.navigation_second: | ||
mTextMessage.setText(R.string.title_second); | ||
return true; | ||
case R.id.navigation_third: | ||
mTextMessage.setText(R.string.title_third); | ||
return true; | ||
case R.id.navigation_forth: | ||
mTextMessage.setText(R.string.title_forth); | ||
return true; | ||
} | ||
return false; | ||
} | ||
}; | ||
|
||
@Override | ||
public void onBackPressed() { | ||
Intent intent=new Intent(Com1714080901141MainActivity.this,Com1714080901141DialogActivity.class); | ||
startActivity(intent); | ||
} | ||
|
||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
exit=false; | ||
setContentView(R.layout.activity_main); | ||
mTextMessage = (TextView) findViewById(R.id.message); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
students/com171408901141/app/src/main/res/layout/activity_dialog.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,27 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout 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="wrap_content" | ||
android:layout_height="wrap_content" | ||
tools:context=".Com1714080901141MainActivity"> | ||
|
||
<Button | ||
android:id="@+id/regret_to_exit" | ||
android:layout_width="51dp" | ||
android:layout_height="35dp" | ||
android:text="No" | ||
android:textAllCaps="false" /> | ||
|
||
<TextView | ||
android:layout_width="158dp" | ||
android:layout_height="wrap_content" | ||
android:text="Are you sure to exit?" /> | ||
|
||
<Button | ||
android:id="@+id/hope_to_exit" | ||
android:layout_width="58dp" | ||
android:layout_height="35dp" | ||
android:text="Yes" | ||
android:textAllCaps="false" /> | ||
</LinearLayout> |
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
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
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
11 changes: 11 additions & 0 deletions
11
students/com171408901141/app/src/main/res/values/styles.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,11 @@ | ||
<resources> | ||
|
||
<!-- Base application theme. --> | ||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> | ||
<!-- Customize your theme here. --> | ||
<item name="colorPrimary">@color/colorPrimary</item> | ||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> | ||
<item name="colorAccent">@color/colorAccent</item> | ||
</style> | ||
|
||
</resources> |