Merge pull request #220 from wangyupeng1-iri/master

Simplify the demo3 code
This commit is contained in:
erhu 2017-07-17 05:18:12 -05:00 committed by GitHub
commit 2440dcab6d
24 changed files with 10 additions and 738 deletions

View File

@ -55,89 +55,13 @@
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar" />
<!-- NoTitleBar -->
<activity
android:name="com.qihoo360.replugin.sample.demo3.activity.theme.ThemeDialogActivity"
android:exported="false"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Holo.Light.Dialog" />
<!-- NoTitleBarFullScreen -->
<activity
android:name="com.qihoo360.replugin.sample.demo3.activity.theme.ThemeBlackNoTitleBarFullscreenActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="com.qihoo360.replugin.sample.demo1.action.theme_fullscreen" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="com.qihoo360.repluginapp.replugin.demo1.CATEGORY1" />
</intent-filter>
</activity>
<!-- receivers -->
<receiver android:name="com.qihoo360.replugin.sample.demo3.receivers.PluginDemo1Receiver">
<receiver android:name="com.qihoo360.replugin.sample.demo3.receivers.PluginDemo3Receiver">
<intent-filter>
<action android:name="com.qihoo360.repluginapp.replugin.receiver.ACTION1" />
<action android:name="com.qihoo360.repluginapp.replugin.receiver.ACTION3" />
</intent-filter>
</receiver>
<!-- service -->
<service
android:name="com.qihoo360.replugin.sample.demo3.service.PluginDemoService1"
android:process=":bg" />
<!-- TaskAffinity -->
<activity
android:name="com.qihoo360.replugin.sample.demo3.activity.task_affinity.TAActivity1"
android:launchMode="singleTask"
android:taskAffinity=":ta_1"
android:theme="@android:style/Theme.Black.NoTitleBar" />
<activity
android:name="com.qihoo360.replugin.sample.demo3.activity.task_affinity.TAActivity2"
android:launchMode="singleTask"
android:taskAffinity=":ta_1"
android:theme="@android:style/Theme.Black.NoTitleBar" />
<activity
android:name="com.qihoo360.replugin.sample.demo3.activity.task_affinity.TAActivity3"
android:launchMode="singleTask"
android:taskAffinity=":ta_1"
android:theme="@android:style/Theme.Black.NoTitleBar" />
<activity
android:name="com.qihoo360.replugin.sample.demo3.activity.task_affinity.TAActivity4"
android:launchMode="singleTask"
android:taskAffinity=":ta_1"
android:theme="@android:style/Theme.Black.NoTitleBar" />
<!-- TaskAffinity-end -->
<activity
android:name="com.qihoo360.replugin.sample.demo3.activity.single_instance.TIActivity1"
android:launchMode="singleInstance"
android:theme="@android:style/Theme.Black.NoTitleBar" />
<!-- SingleTop -->
<activity
android:name="com.qihoo360.replugin.sample.demo3.activity.single_top.SingleTopActivity1"
android:launchMode="singleTop"
android:theme="@android:style/Theme.Black.NoTitleBar" />
<!-- IntentFilter -->
<activity
android:name="com.qihoo360.replugin.sample.demo3.activity.intent_filter.IntentFilterDemoActivity1"
android:theme="@android:style/Theme.Black.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.demo1" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="category_demo" />
</intent-filter>
</activity>
<provider
android:name="com.qihoo360.replugin.sample.demo3.provider.Provider2"
android:authorities="com.qihoo360.replugin.sample.demo3.provider2" />
<activity android:name="com.qihoo360.replugin.sample.demo3.activity.for_result.ForResultActivity"/>
</application>
</manifest>

View File

@ -31,12 +31,7 @@ import android.widget.ListView
import android.widget.Toast
import com.qihoo360.replugin.RePlugin
import com.qihoo360.replugin.sample.demo3.activity.single_instance.TIActivity1
import com.qihoo360.replugin.sample.demo3.activity.single_top.SingleTopActivity1
import com.qihoo360.replugin.sample.demo3.activity.task_affinity.TAActivity1
import com.qihoo360.replugin.sample.demo3.activity.theme.ThemeBlackNoTitleBarActivity
import com.qihoo360.replugin.sample.demo3.activity.theme.ThemeBlackNoTitleBarFullscreenActivity
import com.qihoo360.replugin.sample.demo3.activity.theme.ThemeDialogActivity
import java.util.ArrayList
@ -70,16 +65,6 @@ class MainActivity : Activity() {
v.context.startActivity(intent)
}))
mItems.add(TestItem("Kotlin Activity: By Action", View.OnClickListener { v ->
val intent = Intent()
intent.action = "com.qihoo360.replugin.sample.demo1.action.theme_fullscreen"
/*
Intent 中声明 category, manifest 中未声明则无法找到 Activity;
manifest 中声明 category, Intent 中未声明则可以找到 Activity;
*/
intent.addCategory("com.qihoo360.repluginapp.replugin.demo1.CATEGORY1")
v.context.startActivity(intent)
}))
// =========
@ -87,26 +72,11 @@ class MainActivity : Activity() {
// =========
mItems.add(TestItem("Kotlin Broadcast: Send (to All)", View.OnClickListener { v ->
val intent = Intent()
intent.action = "com.qihoo360.repluginapp.replugin.receiver.ACTION1"
intent.action = "com.qihoo360.repluginapp.replugin.receiver.ACTION3"
intent.putExtra("name", "jerry")
v.context.sendBroadcast(intent)
}))
mItems.add(TestItem("Kotlin Provider: Query (at UI process)", View.OnClickListener { v ->
val uri = Uri.parse("content://com.qihoo360.replugin.sample.demo1.provider2/" + "test")
val cv = ContentValues()
cv.put("name", "RePlugin Team")
cv.put("address", "beijing")
val urii = v.context.contentResolver.insert(uri, cv)
Log.d("a4", "result=" + urii!!)
if (urii != null) {
Toast.makeText(v.context, urii.toString(), Toast.LENGTH_SHORT).show()
} else {
Toast.makeText(v.context, "null", Toast.LENGTH_SHORT).show()
}
}))
// =========
// Communication
@ -123,7 +93,7 @@ class MainActivity : Activity() {
try {
val clz = cl.loadClass("com.qihoo360.replugin.sample.demo2.MainApp")
val m = clz.getDeclaredMethod("helloFromDemo1", Context::class.java, String::class.java)
m.invoke(null, v.context, "Demo1")
m.invoke(null, v.context, "Demo3")
} catch (e: Exception) {
// 有可能Demo2根本没有这个类也有可能没有相应方法通常出现在"插件版本升级"的情况)
Toast.makeText(v.context, "", Toast.LENGTH_SHORT).show()

View File

@ -1,22 +0,0 @@
package com.qihoo360.replugin.sample.demo3.activity.for_result
import android.content.Intent
import android.os.Bundle
import com.qihoo360.replugin.loader.a.PluginActivity
/**
* @author RePlugin Team
*/
class ForResultActivity : PluginActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val intent = Intent()
intent.putExtra("data", "data from demo1 plugin, resultCode is 0x012")
setResult(0x012, intent)
finish()
}
}

View File

@ -1,25 +0,0 @@
/*
* Copyright (C) 2005-2017 Qihoo 360 Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.qihoo360.replugin.sample.demo3.activity.intent_filter
import com.qihoo360.replugin.sample.demo3.BaseActivity
/**
* @author RePlugin Team
*/
class IntentFilterDemoActivity1 : BaseActivity() {
}

View File

@ -1,25 +0,0 @@
/*
* Copyright (C) 2005-2017 Qihoo 360 Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.qihoo360.replugin.sample.demo3.activity.single_instance
import com.qihoo360.replugin.sample.demo3.BaseActivity
/**
* @author RePlugin Team
*/
class TIActivity1 : BaseActivity() {
}

View File

@ -1,25 +0,0 @@
/*
* Copyright (C) 2005-2017 Qihoo 360 Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.qihoo360.replugin.sample.demo3.activity.single_top
import com.qihoo360.replugin.sample.demo3.BaseActivity
/**
* @author RePlugin Team
*/
class SingleTopActivity1 : BaseActivity() {
}

View File

@ -1,25 +0,0 @@
/*
* Copyright (C) 2005-2017 Qihoo 360 Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.qihoo360.replugin.sample.demo3.activity.task_affinity
import com.qihoo360.replugin.sample.demo3.BaseActivity
/**
* @author RePlugin Team
*/
class TAActivity1 : BaseActivity() {
}

View File

@ -1,26 +0,0 @@
/*
* Copyright (C) 2005-2017 Qihoo 360 Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.qihoo360.replugin.sample.demo3.activity.task_affinity
import com.qihoo360.replugin.sample.demo3.BaseActivity
/**
* @author RePlugin Team
*/
class TAActivity2 : BaseActivity() {
}

View File

@ -1,25 +0,0 @@
/*
* Copyright (C) 2005-2017 Qihoo 360 Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.qihoo360.replugin.sample.demo3.activity.task_affinity
import com.qihoo360.replugin.sample.demo3.BaseActivity
/**
* @author RePlugin Team
*/
class TAActivity3 : BaseActivity() {
}

View File

@ -1,25 +0,0 @@
/*
* Copyright (C) 2005-2017 Qihoo 360 Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.qihoo360.replugin.sample.demo3.activity.task_affinity
import com.qihoo360.replugin.sample.demo3.BaseActivity
/**
* @author RePlugin Team
*/
class TAActivity4 : BaseActivity() {
}

View File

@ -1,43 +0,0 @@
/*
* Copyright (C) 2005-2017 Qihoo 360 Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.qihoo360.replugin.sample.demo3.activity.task_affinity
/**
* 测试 两个 TaskAffinity
* MainActivity : Standard
* TA1Activity : SingleTask + ta_1
* TA2Activity : SingleTask + ta_1
* TA3Activity : SingleTask + ta_2
* TA4Activity : SingleTask + ta_2
* Path | Stack
* Main --(start)--> TA1 | TA1
* ...................... | Main
* TA1 --(start)--> TA3 | TA3
* ........................| TA1
* ........................| Main
* TA3 --(start)--> TA2 | Ta1 > TA2
* ........................| TA3
* ........................| Main
* TA2 --(start)--> TA4 | TA3 > TA4
* ........................| Ta1 > TA2
* ........................| Main
*/

View File

@ -1,25 +0,0 @@
/*
* Copyright (C) 2005-2017 Qihoo 360 Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.qihoo360.replugin.sample.demo3.activity.task_affinity_2
import com.qihoo360.replugin.sample.demo3.BaseActivity
/**
* @author RePlugin Team
*/
class TA2Activity1 : BaseActivity() {
}

View File

@ -1,26 +0,0 @@
/*
* Copyright (C) 2005-2017 Qihoo 360 Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.qihoo360.replugin.sample.demo3.activity.task_affinity_2
import com.qihoo360.replugin.sample.demo3.BaseActivity
/**
* @author RePlugin Team
*/
class TA2Activity2 : BaseActivity() {
}

View File

@ -1,26 +0,0 @@
/*
* Copyright (C) 2005-2017 Qihoo 360 Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.qihoo360.replugin.sample.demo3.activity.task_affinity_2
import com.qihoo360.replugin.sample.demo3.BaseActivity
/**
* @author RePlugin Team
*/
class TA2Activity3 : BaseActivity() {
}

View File

@ -1,25 +0,0 @@
/*
* Copyright (C) 2005-2017 Qihoo 360 Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.qihoo360.replugin.sample.demo3.activity.task_affinity_2
import com.qihoo360.replugin.sample.demo3.BaseActivity
/**
* @author RePlugin Team
*/
class TA2Activity4 : BaseActivity() {
}

View File

@ -1,43 +0,0 @@
/*
* Copyright (C) 2005-2017 Qihoo 360 Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.qihoo360.replugin.sample.demo3.activity.task_affinity_2
/**
* 测试 两个 TaskAffinity
* MainActivity : Standard
* TA1Activity : SingleTask + ta_3
* TA2Activity : SingleTask + ta_3
* TA3Activity : Standard + ta_3
* TA4Activity : Standard + ta_3
* Path | Stack
* Main --(start)--> TA1 | TA1
* ...................... | Main
* TA1 --(start)--> TA2 | TA1 > TA2
* ........................| Main
* TA2 --(start)--> TA3 | Ta1 > TA2 > T3
* ........................| Main
* TA3 --(start)--> TA4 | Ta1 > TA2 > T3 > T4
* ........................| Main
* TA4 --(start)--> TA3 | Ta1 > TA2 > T3 > T4 > T3
* ........................| Main
*/

View File

@ -19,12 +19,11 @@ package com.qihoo360.replugin.sample.demo3.activity.theme
import android.app.Activity
import android.os.Bundle
import android.view.Gravity
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import android.widget.FrameLayout
import android.widget.LinearLayout
import android.widget.TextView
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
/**
* @author RePlugin Team
*/
@ -43,7 +42,7 @@ class ThemeBlackNoTitleBarActivity : Activity() {
val textView = TextView(this)
textView.gravity = Gravity.CENTER
textView.textSize = 30f
textView.text = "Theme: BlackNoTitleBar"
textView.text = "Theme3: BlackNoTitleBar"
val lp2 = LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)
textView.layoutParams = lp2
root.addView(textView)

View File

@ -1,52 +0,0 @@
/*
* Copyright (C) 2005-2017 Qihoo 360 Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.qihoo360.replugin.sample.demo3.activity.theme
import android.app.Activity
import android.os.Bundle
import android.view.Gravity
import android.widget.FrameLayout
import android.widget.LinearLayout
import android.widget.TextView
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
/**
* @author RePlugin Team
*/
class ThemeBlackNoTitleBarFullscreenActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val root = LinearLayout(this)
root.setPadding(30, 30, 30, 30)
val lp = FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)
root.layoutParams = lp
setContentView(root)
// textView
val textView = TextView(this)
textView.gravity = Gravity.CENTER
textView.textSize = 30f
textView.text = "Theme: BlackNoTitleBarFullScreen"
val lp2 = LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)
textView.layoutParams = lp2
root.addView(textView)
}
}

View File

@ -1,52 +0,0 @@
/*
* Copyright (C) 2005-2017 Qihoo 360 Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.qihoo360.replugin.sample.demo3.activity.theme
import android.app.Activity
import android.os.Bundle
import android.view.Gravity
import android.widget.FrameLayout
import android.widget.LinearLayout
import android.widget.TextView
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
/**
* @author RePlugin Team
*/
class ThemeDialogActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val root = LinearLayout(this)
root.setPadding(30, 30, 30, 30)
val lp = FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)
root.layoutParams = lp
setContentView(root)
// textView
val textView = TextView(this)
textView.text = "Theme: Dialog"
textView.gravity = Gravity.CENTER
textView.textSize = 30f
val lp2 = LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)
textView.layoutParams = lp2
root.addView(textView)
}
}

View File

@ -1,33 +0,0 @@
/*
* Copyright (C) 2005-2017 Qihoo 360 Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.qihoo360.replugin.sample.demo3.fragment
import android.os.Bundle
import android.view.View
import android.widget.TextView
import com.qihoo360.replugin.sample.demo3.R
/**
* @author RePlugin Team
*/
class DemoCodeFragment : DemoFragment() {
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val textView = view!!.findViewById(R.id.text) as TextView
textView.text = "DemoCodeFragment from plugin demo1"
}
}

View File

@ -1,45 +0,0 @@
/*
* Copyright (C) 2005-2017 Qihoo 360 Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.qihoo360.replugin.sample.demo3.fragment
import android.os.Bundle
import android.support.v4.app.Fragment
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.qihoo360.replugin.RePlugin
import com.qihoo360.replugin.sample.demo3.R
/**
* @author RePlugin Team
*/
open class DemoFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
Log.d(TAG, "onCreateView() called with: inflater = [$inflater], container = [$container], savedInstanceState = [$savedInstanceState]")
/**
* 需要注意不能使用inflater及container因为他们的Context是宿主的
*/
return LayoutInflater.from(RePlugin.getPluginContext()).inflate(R.layout.main_fragment, container, false)
}
companion object {
private val TAG = "DemoFragment"
}
}

View File

@ -1,53 +0,0 @@
/*
* Copyright (C) 2005-2017 Qihoo 360 Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.qihoo360.replugin.sample.demo3.provider
import android.content.ContentProvider
import android.content.ContentValues
import android.database.Cursor
import android.net.Uri
/**
* @author RePlugin Team
*/
class Provider2 : ContentProvider() {
override fun onCreate(): Boolean {
return false
}
override fun query(uri: Uri, projection: Array<String>?, selection: String?, selectionArgs: Array<String>?, sortOrder: String?): Cursor? {
return null
}
override fun getType(uri: Uri): String? {
return null
}
override fun insert(uri: Uri, values: ContentValues?): Uri? {
val u = Uri.parse("a://provider ok")
return u
}
override fun delete(uri: Uri, selection: String?, selectionArgs: Array<String>?): Int {
return 0
}
override fun update(uri: Uri, values: ContentValues?, selection: String?, selectionArgs: Array<String>?): Int {
return 0
}
}

View File

@ -25,20 +25,20 @@ import android.widget.Toast
/**
* @author RePlugin Team
*/
class PluginDemo1Receiver : BroadcastReceiver() {
class PluginDemo3Receiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
val action = intent.action
if (!TextUtils.isEmpty(action)) {
if (action == ACTION) {
val name = intent.getStringExtra("name")
Toast.makeText(context, "Plugin1-action: $action, name = $name", Toast.LENGTH_LONG).show()
Toast.makeText(context, "Plugin3-action: $action, name = $name", Toast.LENGTH_LONG).show()
}
}
}
companion object {
val ACTION = "com.qihoo360.repluginapp.replugin.receiver.ACTION1"
val ACTION = "com.qihoo360.repluginapp.replugin.receiver.ACTION3"
}
}

View File

@ -20,7 +20,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.qihoo360.replugin:replugin-plugin-gradle:3.1.7'
classpath 'com.qihoo360.replugin:replugin-plugin-gradle:2.1.5'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}