This repository has been archived by the owner on Sep 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 260
Added a clickable event to Line, Bar, Pie #155
Open
hillyoung
wants to merge
6
commits into
capitalone:master
Choose a base branch
from
hillyoung:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4a0f513
Added a clickable event to Line, Bar, Pie
9325334
merge capitalone's repository
c252abf
merge capitalone's repository
a57152b
Merge branch 'master' of https://github.com/hillyoung/react-native-pa…
36827ea
remove debug info
0421066
Added a clickable event to Line, Bar, Pie without other code
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,7 +115,7 @@ android { | |
variant.outputs.each { output -> | ||
// For each separate APK per architecture, set a unique version code as described here: | ||
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits | ||
def versionCodes = ["armeabi-v7a":1, "x86":2] | ||
def versionCodes = ["armeabi-v7a": 1, "x86": 2] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whitespace additions necessary? |
||
def abi = output.getFilter(OutputFile.ABI) | ||
if (abi != null) { // null for the universal-debug, universal-release variants | ||
output.versionCodeOverride = | ||
|
@@ -128,8 +128,10 @@ android { | |
dependencies { | ||
compile project(':react-native-svg') | ||
compile fileTree(dir: "libs", include: ["*.jar"]) | ||
compile "com.android.support:appcompat-v7:23.0.1" | ||
compile "com.facebook.react:react-native:+" // From node_modules | ||
// From node_modules | ||
compile 'com.android.support:appcompat-v7:23.4.0' | ||
compile 'com.facebook.react:react-native:+' | ||
compile 'com.android.support:design:23.4.0' | ||
} | ||
|
||
// Run this once to be able to run the application with BUCK | ||
|
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 |
---|---|---|
@@ -1,23 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.example" | ||
android:versionCode="1" | ||
android:versionName="1.0"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/> | ||
|
||
<uses-sdk | ||
android:minSdkVersion="16" | ||
android:targetSdkVersion="22" /> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> | ||
|
||
<android:uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
<android:uses-permission android:name="android.permission.READ_PHONE_STATE" /> | ||
<android:uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | ||
|
||
<application | ||
android:name=".MainApplication" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. None of this builds cleanly. You get this kind of an error message:
|
||
android:allowBackup="true" | ||
android:label="@string/app_name" | ||
android:icon="@mipmap/ic_launcher" | ||
android:theme="@style/AppTheme"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:name=".MainApplication" | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize" | ||
android:windowSoftInputMode="adjustResize"> | ||
|
@@ -29,4 +30,4 @@ | |
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" /> | ||
</application> | ||
|
||
</manifest> | ||
</manifest> |
39 changes: 39 additions & 0 deletions
39
example/android/app/src/main/java/com/example/ExampleReactPackage.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,39 @@ | ||
package com.example; | ||
|
||
/** | ||
* Created by young on 2017/5/10. | ||
*/ | ||
|
||
import com.facebook.react.ReactPackage; | ||
import com.facebook.react.bridge.JavaScriptModule; | ||
import com.facebook.react.bridge.NativeModule; | ||
import com.facebook.react.bridge.ReactApplicationContext; | ||
import com.facebook.react.uimanager.ViewManager; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class ExampleReactPackage implements ReactPackage { | ||
|
||
@Override | ||
public List<Class<? extends JavaScriptModule>> createJSModules() { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public List<NativeModule> createNativeModules( | ||
ReactApplicationContext reactContext) { | ||
List<NativeModule> modules = new ArrayList<>(); | ||
|
||
modules.add(new RNBridge(reactContext)); | ||
|
||
return modules; | ||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
example/android/app/src/main/java/com/example/HomeActivity.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,52 @@ | ||
package com.example; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.design.widget.FloatingActionButton; | ||
import android.support.design.widget.Snackbar; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.Toolbar; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.widget.Button; | ||
|
||
import java.io.IOError; | ||
|
||
public class HomeActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_home); | ||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); | ||
setSupportActionBar(toolbar); | ||
|
||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); | ||
fab.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) | ||
.setAction("Action", null).show(); | ||
} | ||
}); | ||
|
||
Button bt = (Button) findViewById(R.id.button); | ||
bt.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
Log.i("匿名内部类", "点击事件"); | ||
|
||
|
||
try { | ||
Intent intent = new Intent(); | ||
intent.setClass(HomeActivity.this, MainActivity.class); | ||
startActivity(intent); | ||
} catch (IOError error) { | ||
error.printStackTrace(); | ||
} | ||
|
||
} | ||
}); | ||
} | ||
|
||
} |
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 |
---|---|---|
|
@@ -14,11 +14,23 @@ | |
|
||
public class MainApplication extends Application implements ReactApplication { | ||
|
||
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { | ||
@Override | ||
public boolean getUseDeveloperSupport() { | ||
return BuildConfig.DEBUG; | ||
} | ||
// private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove comments |
||
// @Override | ||
// public boolean getUseDeveloperSupport() { | ||
// return BuildConfig.DEBUG; | ||
// } | ||
// | ||
// @Override | ||
// protected List<ReactPackage> getPackages() { | ||
// return Arrays.<ReactPackage>asList( | ||
// new MainReactPackage(), | ||
// new RNSvgPackage(), | ||
// new ExampleReactPackage() | ||
// ); | ||
// } | ||
// }; | ||
|
||
private final ReactNativeHost mReactNativeHost = new RNHost(this); | ||
|
||
@Override | ||
protected List<ReactPackage> getPackages() { | ||
|
@@ -29,7 +41,7 @@ protected List<ReactPackage> getPackages() { | |
} | ||
}; | ||
|
||
@Override | ||
@Override | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary whitespace addition. |
||
public ReactNativeHost getReactNativeHost() { | ||
return mReactNativeHost; | ||
} | ||
|
113 changes: 113 additions & 0 deletions
113
example/android/app/src/main/java/com/example/RNActivity.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,113 @@ | ||
package com.example; | ||
|
||
import android.app.Activity; | ||
import android.content.Intent; | ||
import android.net.Uri; | ||
import android.os.Build; | ||
import android.os.Bundle; | ||
import android.provider.Settings; | ||
import android.util.Log; | ||
import android.view.KeyEvent; | ||
|
||
import com.facebook.react.*; | ||
import com.facebook.react.BuildConfig; | ||
import com.facebook.react.common.LifecycleState; | ||
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler; | ||
import com.facebook.react.shell.MainReactPackage; | ||
|
||
/** | ||
* Created by young on 2017/5/10. | ||
*/ | ||
|
||
public class RNActivity extends Activity implements DefaultHardwareBackBtnHandler { | ||
|
||
private ReactRootView rnRootView; | ||
private ReactInstanceManager rnInstanceManager; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | ||
// if (!Settings.canDrawOverlays(this)) { | ||
// Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, | ||
// Uri.parse("package:" + getPackageName())); | ||
// startActivityForResult(intent, OVERLAY_PERMISSION_REQ_CODE); | ||
// } | ||
// } | ||
|
||
rnRootView = new ReactRootView(this); | ||
Log.i("加载RN模块", "测试"); | ||
ReactInstanceManagerBuilder builder = ReactInstanceManager.builder().setApplication(getApplication()) | ||
.setBundleAssetName("index.android.bundle") | ||
.setJSMainModuleName("index.android") | ||
.addPackage(new MainReactPackage()) | ||
.setUseDeveloperSupport(true) | ||
.setInitialLifecycleState(LifecycleState.RESUMED); | ||
|
||
RNHost host = (RNHost) ((ReactApplication) getApplication()).getReactNativeHost(); | ||
|
||
for (ReactPackage reactPackage : host.packages()) { | ||
builder.addPackage(reactPackage); | ||
} | ||
|
||
rnInstanceManager = builder.build(); | ||
rnRootView.startReactApplication(rnInstanceManager, "example", null); | ||
|
||
setContentView(rnRootView); | ||
} | ||
|
||
@Override | ||
public void invokeDefaultOnBackPressed() { | ||
super.onBackPressed(); | ||
} | ||
|
||
|
||
@Override | ||
protected void onPause() { | ||
super.onPause(); | ||
|
||
if (rnInstanceManager != null) { | ||
rnInstanceManager.onHostPause(this); | ||
} | ||
} | ||
|
||
@Override | ||
protected void onResume() { | ||
super.onResume(); | ||
|
||
if (rnInstanceManager != null) { | ||
rnInstanceManager.onHostResume(this, this); | ||
} | ||
} | ||
|
||
@Override | ||
protected void onDestroy() { | ||
super.onDestroy(); | ||
|
||
if (rnInstanceManager != null) { | ||
rnInstanceManager.onHostDestroy(this); | ||
} | ||
} | ||
|
||
@Override | ||
public void onBackPressed() { | ||
|
||
if (rnInstanceManager != null) { | ||
rnInstanceManager.onBackPressed(); | ||
} else { | ||
super.onBackPressed(); | ||
} | ||
} | ||
|
||
|
||
@Override | ||
public boolean onKeyUp(int keyCode, KeyEvent event) { | ||
|
||
if (keyCode == KeyEvent.KEYCODE_MENU && rnInstanceManager != null) { | ||
rnInstanceManager.showDevOptionsDialog(); | ||
return true; | ||
} | ||
return super.onKeyUp(keyCode, event); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
example/android/app/src/main/java/com/example/RNBridge.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,40 @@ | ||
package com.example; | ||
|
||
/** | ||
* Created by young on 2017/5/10. | ||
*/ | ||
|
||
|
||
import com.facebook.react.bridge.NativeModule; | ||
import com.facebook.react.bridge.ReactApplicationContext; | ||
import com.facebook.react.bridge.ReactContext; | ||
import com.facebook.react.bridge.ReactContextBaseJavaModule; | ||
import com.facebook.react.bridge.ReactMethod; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
public class RNBridge extends ReactContextBaseJavaModule { | ||
|
||
public RNBridge(ReactApplicationContext reactContext) { | ||
super(reactContext); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "RNBridge"; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public Map<String, Object> getConstants() { | ||
|
||
final Map<String, Object> constants = new HashMap<>(); | ||
constants.put("abc", "ABC"); | ||
constants.put("bcd", "BCD"); | ||
|
||
return constants; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is unnecessary as the line above it matches files in
example/node_modules
. Can we remove it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok! I will to remove it