mirror of
https://gitee.com/replugin/RePlugin.git
synced 2024-12-02 03:38:06 +08:00
Merge pull request #215 from SkyEric/master
Support plugin to use the host's common library
This commit is contained in:
commit
2017872d14
BIN
replugin-sample/host/app/libs/common-utils-lib-1.0.0.jar
Normal file
BIN
replugin-sample/host/app/libs/common-utils-lib-1.0.0.jar
Normal file
Binary file not shown.
Binary file not shown.
@ -14,4 +14,4 @@
|
||||
* the License.
|
||||
*/
|
||||
|
||||
include ':app'
|
||||
include ':app', ':utils'
|
||||
|
53
replugin-sample/host/utils/build.gradle
Normal file
53
replugin-sample/host/utils/build.gradle
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 25
|
||||
buildToolsVersion "25.0.2"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.qihoo360.replugin.common.utils"
|
||||
minSdkVersion 9
|
||||
targetSdkVersion 22
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||
compile 'com.android.support:support-v4:25.3.1'
|
||||
}
|
||||
|
||||
task makeJar(type: Jar, dependsOn: ['build']) {
|
||||
destinationDir = file('build/outputs/jar/')
|
||||
baseName = "common-utils-lib"
|
||||
version = "1.0.0"
|
||||
from('build/intermediates/classes/debug')
|
||||
exclude('**/BuildConfig.class')
|
||||
exclude('**/BuildConfig\$*.class')
|
||||
exclude('**/R.class')
|
||||
exclude('**/R\$*.class')
|
||||
include('**/*.class')
|
||||
}
|
25
replugin-sample/host/utils/proguard-rules.pro
vendored
Normal file
25
replugin-sample/host/utils/proguard-rules.pro
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in D:\Liuzhiwei-ms\Android\sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# 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
|
20
replugin-sample/host/utils/src/main/AndroidManifest.xml
Normal file
20
replugin-sample/host/utils/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.qihoo360.replugin.common.utils">
|
||||
<application/>
|
||||
</manifest>
|
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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.common.utils;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* @author RePlugin Team
|
||||
*/
|
||||
public class TimeUtils {
|
||||
|
||||
private static final DateFormat DEFAULT_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
|
||||
|
||||
/**
|
||||
* 将时间戳转为时间字符串
|
||||
* 格式为yyyy-MM-dd HH:mm:ss </p>
|
||||
*
|
||||
* @param millis 毫秒时间戳
|
||||
* @return 时间字符串
|
||||
*/
|
||||
public static String millis2String(final long millis) {
|
||||
return millis2String(millis, DEFAULT_FORMAT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将时间戳转为时间字符串
|
||||
* 格式为format </p>
|
||||
*
|
||||
* @param millis 毫秒时间戳
|
||||
* @param format 时间格式
|
||||
* @return 时间字符串
|
||||
*/
|
||||
public static String millis2String(final long millis, final DateFormat format) {
|
||||
return format.format(new Date(millis));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前时间字符串
|
||||
* 格式为yyyy-MM-dd HH:mm:ss </p>
|
||||
*
|
||||
* @return 时间字符串
|
||||
*/
|
||||
public static String getNowString() {
|
||||
return millis2String(System.currentTimeMillis(), DEFAULT_FORMAT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前时间字符串
|
||||
* 格式为format </p>
|
||||
*
|
||||
* @param format 时间格式
|
||||
* @return 时间字符串
|
||||
*/
|
||||
public static String getNowString(final DateFormat format) {
|
||||
return millis2String(System.currentTimeMillis(), format);
|
||||
}
|
||||
}
|
@ -55,4 +55,5 @@ apply plugin: 'replugin-plugin-gradle'
|
||||
dependencies {
|
||||
compile 'com.qihoo360.replugin:replugin-plugin-lib:2.1.5'
|
||||
provided files('libs/fragment.jar')//这个jar就是从Support-fragment中提取出来的并非特制包目的是为了骗过编译期
|
||||
provided files('libs/common-utils-lib-1.0.0.jar')//这个jar就是从Host的utils中编译生成的,其目的是为了骗过编译期
|
||||
}
|
||||
|
Binary file not shown.
@ -27,6 +27,7 @@ import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -37,6 +38,7 @@ import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.qihoo360.replugin.RePlugin;
|
||||
import com.qihoo360.replugin.common.utils.TimeUtils;
|
||||
import com.qihoo360.replugin.sample.demo1.activity.single_instance.TIActivity1;
|
||||
import com.qihoo360.replugin.sample.demo1.activity.single_top.SingleTopActivity1;
|
||||
import com.qihoo360.replugin.sample.demo1.activity.task_affinity.TAActivity1;
|
||||
@ -257,6 +259,21 @@ public class MainActivity extends Activity {
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
// =========
|
||||
// 使用Host公共库
|
||||
// =========
|
||||
mItems.add(new TestItem("Current time (Use common-lib from host)", new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final String curTime = TimeUtils.getNowString();
|
||||
if (!TextUtils.isEmpty(curTime)) {
|
||||
Toast.makeText(v.getContext(), "current time: " + TimeUtils.getNowString(), Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toast.makeText(v.getContext(), "Failed to obtain current time(from host)", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private static final int REQUEST_CODE_DEMO2 = 0x021;
|
||||
|
Loading…
Reference in New Issue
Block a user