-
Notifications
You must be signed in to change notification settings - Fork 1
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
61 changed files
with
1,293 additions
and
0 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
/build |
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 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 26 | ||
defaultConfig { | ||
applicationId "com.cleven.clchat.clchat" | ||
minSdkVersion 15 | ||
targetSdkVersion 26 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation 'com.android.support:appcompat-v7:26.1.0' | ||
implementation 'com.android.support.constraint:constraint-layout:1.1.3' | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation 'com.android.support.test:runner:1.0.2' | ||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' | ||
} |
Binary file not shown.
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,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
26 changes: 26 additions & 0 deletions
26
app/src/androidTest/java/com/cleven/clchat/clchat/ExampleInstrumentedTest.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,26 @@ | ||
package com.cleven.clchat.clchat; | ||
|
||
import android.content.Context; | ||
import android.support.test.InstrumentationRegistry; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() throws Exception { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getTargetContext(); | ||
|
||
assertEquals("com.cleven.clchat.clchat", appContext.getPackageName()); | ||
} | ||
} |
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,22 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.cleven.clchat.clchat"> | ||
|
||
<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=".activity.SplashActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name=".activity.MainActivity"></activity> | ||
</application> | ||
|
||
</manifest> |
123 changes: 123 additions & 0 deletions
123
app/src/main/java/com/cleven/clchat/clchat/activity/MainActivity.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,123 @@ | ||
package com.cleven.clchat.clchat.activity; | ||
|
||
import android.os.Bundle; | ||
import android.support.v4.app.Fragment; | ||
import android.support.v4.app.FragmentActivity; | ||
import android.support.v4.app.FragmentTransaction; | ||
import android.view.Window; | ||
import android.widget.FrameLayout; | ||
import android.widget.RadioGroup; | ||
|
||
import com.cleven.clchat.clchat.R; | ||
import com.cleven.clchat.clchat.base.CLBaseFragment; | ||
import com.cleven.clchat.clchat.fragment.CLContactFragment; | ||
import com.cleven.clchat.clchat.fragment.CLDiscoverFragment; | ||
import com.cleven.clchat.clchat.fragment.CLHomeFragment; | ||
import com.cleven.clchat.clchat.fragment.CLProfileFragment; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class MainActivity extends FragmentActivity { | ||
|
||
private FrameLayout frameLayout; | ||
private RadioGroup radioGroup; | ||
|
||
private int currentSelectIndex = 0; | ||
/// 记录当前显示的fragment | ||
private CLBaseFragment preFragment; | ||
private List<CLBaseFragment> fragments; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
/// 取消标题 | ||
requestWindowFeature(Window.FEATURE_NO_TITLE); | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
|
||
initFragments(); | ||
|
||
findViews(); | ||
|
||
} | ||
|
||
private void findViews() { | ||
frameLayout = (FrameLayout)findViewById( R.id.frameLayout ); | ||
radioGroup = (RadioGroup)findViewById( R.id.radioGroup ); | ||
/// 设置监听事件 | ||
radioGroup.setOnCheckedChangeListener(new MyOnClickListener()); | ||
/// 默认选中第一个 | ||
radioGroup.check(R.id.rb_main_home); | ||
} | ||
|
||
private class MyOnClickListener implements RadioGroup.OnCheckedChangeListener { | ||
|
||
@Override | ||
public void onCheckedChanged(RadioGroup group, int checkedId) { | ||
switch (checkedId){ | ||
case R.id.rb_main_home: | ||
currentSelectIndex = 0; | ||
break; | ||
case R.id.rb_main_contact: | ||
currentSelectIndex = 1; | ||
break; | ||
case R.id.rb_main_discover: | ||
currentSelectIndex = 2; | ||
break; | ||
case R.id.rb_main_profile: | ||
currentSelectIndex = 3; | ||
break; | ||
} | ||
/// 获取Fragment | ||
CLBaseFragment fragment = getFragment(currentSelectIndex); | ||
/// 切换 | ||
switchFragment(preFragment,fragment); | ||
} | ||
|
||
} | ||
|
||
/// 根据下标获取fragment | ||
private CLBaseFragment getFragment(int index){ | ||
if (fragments != null && fragments.size() > 0){ | ||
return fragments.get(index); | ||
} | ||
return null; | ||
} | ||
|
||
/// 切换Fragment | ||
private void switchFragment(Fragment fromFragment, CLBaseFragment nextFragment){ | ||
if (preFragment != nextFragment){ | ||
preFragment = nextFragment; | ||
if (nextFragment != null){ | ||
/// 获取Fragment管理器 | ||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); | ||
// 判断nextFragment是否添加 | ||
if (!nextFragment.isAdded()){ | ||
//隐藏当前Fragment | ||
if (fromFragment != null){ | ||
transaction.hide(fromFragment); | ||
} | ||
// 添加下一个Fragment | ||
transaction.add(R.id.frameLayout,nextFragment).commit(); | ||
}else { | ||
//隐藏当前Fragment | ||
if (fromFragment != null){ | ||
transaction.hide(fromFragment); | ||
} | ||
/// 如果已经添加过,直接显示 | ||
transaction.show(nextFragment).commit(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
private void initFragments() { | ||
fragments = new ArrayList<>(); | ||
fragments.add(new CLHomeFragment()); | ||
fragments.add(new CLContactFragment()); | ||
fragments.add(new CLDiscoverFragment()); | ||
fragments.add(new CLProfileFragment()); | ||
} | ||
|
||
|
||
} |
61 changes: 61 additions & 0 deletions
61
app/src/main/java/com/cleven/clchat/clchat/activity/SplashActivity.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,61 @@ | ||
package com.cleven.clchat.clchat.activity; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.animation.AlphaAnimation; | ||
import android.view.animation.Animation; | ||
import android.view.animation.AnimationSet; | ||
import android.view.animation.ScaleAnimation; | ||
import android.widget.TextView; | ||
|
||
import com.cleven.clchat.clchat.R; | ||
|
||
public class SplashActivity extends AppCompatActivity { | ||
|
||
private TextView tv_text; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_splash); | ||
|
||
tv_text = (TextView) findViewById(R.id.tv_text); | ||
|
||
ScaleAnimation scaleAnimation = new ScaleAnimation(0.5f, 1.0f, 0.5f, 1.0f); | ||
scaleAnimation.setDuration(1500); | ||
scaleAnimation.setFillAfter(true); | ||
|
||
AlphaAnimation alphaAnimation = new AlphaAnimation(0.5f, 1.0f); | ||
alphaAnimation.setFillAfter(true); | ||
alphaAnimation.setDuration(1500); | ||
|
||
AnimationSet set = new AnimationSet(this, null); | ||
set.addAnimation(scaleAnimation); | ||
set.addAnimation(alphaAnimation); | ||
set.setDuration(1500); | ||
set.setFillAfter(true); | ||
tv_text.setAnimation(set); | ||
|
||
set.setAnimationListener(new Animation.AnimationListener() { | ||
@Override | ||
public void onAnimationStart(Animation animation) { | ||
|
||
} | ||
|
||
@Override | ||
public void onAnimationEnd(Animation animation) { | ||
Intent intent = new Intent(SplashActivity.this,MainActivity.class); | ||
startActivity(intent); | ||
|
||
finish(); | ||
} | ||
|
||
@Override | ||
public void onAnimationRepeat(Animation animation) { | ||
|
||
} | ||
}); | ||
|
||
} | ||
} |
Oops, something went wrong.