Skip to content

Commit

Permalink
搭建基于Mars的IM框架
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengjy committed Jul 16, 2020
1 parent 2f99719 commit 4ba217d
Show file tree
Hide file tree
Showing 50 changed files with 1,801 additions and 28 deletions.
1 change: 0 additions & 1 deletion .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 44 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.protobuf'
apply from: versions

android {
Expand All @@ -17,6 +18,17 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

sourceSets {
main {
java {
srcDirs 'src/main/java'
}
proto {
srcDirs 'src/main/proto'
}
}
}

buildTypes {
release {
minifyEnabled false
Expand All @@ -34,15 +46,45 @@ android {

}

protobuf {
protoc {
// You still need protoc like in the non-Android case
artifact = deps.protoc
}
plugins {
javalite {
// The codegen for lite comes as a separate artifact
artifact = deps.protoc_gen
}
}
generateProtoTasks {
all().each { task ->
task.builtins {
// In most cases you don't need the full Java output
// if you use the lite output.
remove java
}
task.plugins {
javalite {}
}
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation deps.androidx.constraint_layout
implementation project(':lib-architecture')
implementation project(':chat')

implementation deps.androidx.constraint_layout
implementation deps.navigation.runtime_ktx
implementation deps.navigation.fragment_ktx
implementation deps.navigation.ui_ktx
implementation deps.retrofit.runtime
implementation deps.retrofit.gson
implementation deps.proto

implementation "com.github.PhilJay:MPAndroidChart:v3.1.0"
implementation "com.qmuiteam:qmui:2.0.0-alpha10"
implementation "com.zhy:base-rvadapter:3.0.3"
}
8 changes: 6 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zjy.arch">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNET" />

<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">
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<activity android:name=".WidgetActivity"/>
<activity android:name=".WebViewActivity" />

<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/java/com/zjy/arch/AppPreference.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.zjy.arch

import com.tencent.mmkv.MMKV
import com.zjy.architecture.util.preference.IStorage
import com.zjy.architecture.util.preference.Preference
import com.zjy.architecture.util.preference.PreferenceDelegate
import com.zjy.architecture.util.preference.PreferenceStorage

/**
* @author zhengjy
* @since 2020/07/15
* Description:
*/
object AppPreference : Preference {
override val sp: IStorage = PreferenceStorage(MMKV.defaultMMKV())

val isLogin by PreferenceDelegate("IS_LOGIN", false, sp)

}
19 changes: 17 additions & 2 deletions app/src/main/java/com/zjy/arch/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.zjy.arch

import androidx.appcompat.app.AppCompatActivity
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.liveData
import com.bumptech.glide.request.RequestOptions
import com.google.gson.Gson
Expand All @@ -17,18 +19,31 @@ class MainActivity : AppCompatActivity() {
"N5FKueEq4oT4VxcqjELLtBaqkMMdh6Fkiaya1uLfD0clTbjocU5pvZo7VK2ak3A/640?wx_fmt=png&" +
"tp=webp&wxfrom=5&wx_lazy=1&wx_co=1"

private val viewModel by lazy { ViewModelProvider(this).get(MainViewModel::class.java) }

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

val isEdit = AppPreference["app", true]
AppPreference["IS_LOGIN"] = "zhengjy"
AppPreference["IS_LOGIN"] = 128
val login = AppPreference.isLogin
if (AppPreference["IS_LOGIN", false] == AppPreference.isLogin) {
println("succeed!")
}

imageView?.apply {
load(imageUrl) {
apply(RequestOptions().placeholder(R.mipmap.ic_launcher))
}
setOnClickListener {

startActivity(Intent(this@MainActivity, WebViewActivity::class.java))
}
}
textView.setOnClickListener {
startActivity(Intent(this@MainActivity, WidgetActivity::class.java))
}
liveData(Dispatchers.IO) {
emit("")
}
Expand Down
68 changes: 68 additions & 0 deletions app/src/main/java/com/zjy/arch/WebViewActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.zjy.arch

import android.os.Bundle
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.recyclerview.widget.LinearLayoutManager
import com.qmuiteam.qmui.nestedScroll.QMUIContinuousNestedBottomAreaBehavior
import com.qmuiteam.qmui.nestedScroll.QMUIContinuousNestedBottomRecyclerView
import com.qmuiteam.qmui.nestedScroll.QMUIContinuousNestedTopAreaBehavior
import com.qmuiteam.qmui.nestedScroll.QMUIContinuousNestedTopWebView
import com.zhy.adapter.recyclerview.CommonAdapter
import com.zhy.adapter.recyclerview.base.ViewHolder
import kotlinx.android.synthetic.main.activity_web_view.*


class WebViewActivity : AppCompatActivity() {

private var mNestedWebView: QMUIContinuousNestedTopWebView? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_web_view)

mNestedWebView = QMUIContinuousNestedTopWebView(this)
val matchParent = ViewGroup.LayoutParams.MATCH_PARENT
val webViewLp = CoordinatorLayout.LayoutParams(
matchParent, matchParent
)
webViewLp.behavior = QMUIContinuousNestedTopAreaBehavior(this)
mCoordinatorLayout.setTopAreaView(mNestedWebView, webViewLp)

val mRecyclerView = QMUIContinuousNestedBottomRecyclerView(this)
val recyclerViewLp = CoordinatorLayout.LayoutParams(
matchParent, matchParent
)
recyclerViewLp.behavior = QMUIContinuousNestedBottomAreaBehavior()
mCoordinatorLayout.setBottomAreaView(mRecyclerView, recyclerViewLp)

mRecyclerView.layoutManager = LinearLayoutManager(this)
mRecyclerView.adapter = object : CommonAdapter<String>(this, android.R.layout.activity_list_item, listOf("a", "b", "c", "d", "e")) {
override fun convert(holder: ViewHolder, t: String, position: Int) {
holder.setText(android.R.id.text1, t)
}
}

mNestedWebView?.settings?.apply {
javaScriptEnabled = true
domStorageEnabled = true
blockNetworkImage = false
}
mNestedWebView?.loadUrl(
// "https://api.xiaoheihe.cn/v3/bbs/app/api/web/share?link_id=42234008"
// "http://fd.33.cn:1230/#/detail?id=40"
// "https://www.baidu.com"
"https://server.chain199.com/#/detail?id=23"
)
}

override fun onDestroy() {
super.onDestroy();
if (mNestedWebView != null) {
mCoordinatorLayout.removeView(mNestedWebView);
mNestedWebView?.destroy()
mNestedWebView = null
}
}
}
19 changes: 19 additions & 0 deletions app/src/main/java/com/zjy/arch/WidgetActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.zjy.arch

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.fragment.app.commit
import com.zjy.arch.fragment.ChartFragment
import com.zjy.arch.fragment.PullLayoutFragment

class WidgetActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_widget)

supportFragmentManager.commit {
// add(R.id.fcv_container, PullLayoutFragment(R.layout.fragment_pull_layout))
add(R.id.fcv_container, ChartFragment(R.layout.fragment_chart))
}
}
}
Loading

0 comments on commit 4ba217d

Please sign in to comment.