├── .gitignore
├── .gitmodules
├── .idea
├── caches
│ └── build_file_checksums.ser
├── codeStyles
│ └── Project.xml
├── encodings.xml
├── gradle.xml
├── markdown-navigator.xml
├── markdown-navigator
│ └── profiles_settings.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── GraphView-Demos.iml
├── README.md
├── app
├── .gitignore
├── app.iml
├── build.gradle
├── manifest-merger-release-report.txt
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── jjoe64
│ │ └── graphview_demos
│ │ └── ApplicationTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── jjoe64
│ │ └── graphview_demos
│ │ ├── FullscreenActivity.java
│ │ ├── FullscreenExample.java
│ │ ├── ItemDetailActivity.java
│ │ ├── ItemDetailFragment.java
│ │ ├── ItemListActivity.java
│ │ ├── MenuContent.java
│ │ ├── categories
│ │ ├── BarGraphFragment.java
│ │ ├── HelloWorldFragment.java
│ │ ├── LineGraphFragment.java
│ │ ├── OthersFragment.java
│ │ ├── PointsGraphFragment.java
│ │ ├── RealtimeFragment.java
│ │ ├── SecondScaleAndLabelsFragment.java
│ │ ├── StylingExamplesFragment.java
│ │ ├── TapListenerGraphFragment.java
│ │ ├── TimeAndDatesFragment.java
│ │ └── ZoomingAndScrollingFragment.java
│ │ └── examples
│ │ ├── AddSeriesAtRuntime.java
│ │ ├── AdvancedBarGraph.java
│ │ ├── AdvancedLineGraph.java
│ │ ├── BaseExample.java
│ │ ├── CustomLabelsGraph.java
│ │ ├── Dates.java
│ │ ├── FixedFrame.java
│ │ ├── HelloWorld.java
│ │ ├── MultipleBarGraph.java
│ │ ├── NoLabelsGraph.java
│ │ ├── RealtimeScrolling.java
│ │ ├── ScalingX.java
│ │ ├── ScalingXY.java
│ │ ├── ScrollingX.java
│ │ ├── SecondScaleGraph.java
│ │ ├── SimpleBarGraph.java
│ │ ├── SimpleLineGraph.java
│ │ ├── SimplePointsGraph.java
│ │ ├── SnapshotShareGraph.java
│ │ ├── StaticLabelsGraph.java
│ │ ├── StylingColors.java
│ │ ├── StylingLabels.java
│ │ ├── TapListenerGraph.java
│ │ ├── TitlesExample.java
│ │ └── UniqueLegendLineGraph.java
│ └── res
│ ├── drawable-xxhdpi
│ ├── fullscreen.png
│ ├── ic_public_white_24dp.png
│ ├── preview.png
│ └── source.png
│ ├── layout
│ ├── activity_item_detail.xml
│ ├── activity_item_list.xml
│ ├── bar_graph_content.xml
│ ├── fullscreen_example_add_series.xml
│ ├── fullscreen_example_simple.xml
│ ├── hello_world_content.xml
│ ├── item_detail.xml
│ ├── item_list.xml
│ ├── item_list_content.xml
│ ├── item_list_twopane.xml
│ ├── line_graph_content.xml
│ ├── others_content.xml
│ ├── points_graph_content.xml
│ ├── realtime_content.xml
│ ├── second_scale_and_labels_content.xml
│ ├── styling_examples_content.xml
│ ├── tap_listener_graph_content.xml
│ ├── time_and_dates_content.xml
│ └── zooming_and_scrolling_content.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ ├── values-v21
│ └── styles.xml
│ ├── values-w900dp
│ └── refs.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── captures
└── Allocations_2015.03.26_18.59.43.alloc
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── license.txt
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "GraphView"]
2 | path = GraphView
3 | url = https://github.com/jjoe64/GraphView
4 |
--------------------------------------------------------------------------------
/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jjoe64/GraphView-Demos/708bcdfa6ee421c6675faca5ae526a0aeca4881e/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/markdown-navigator.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/.idea/markdown-navigator/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/GraphView-Demos.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Chart and Graph Library for Android
2 | ====================================
3 |
4 | ### GraphView - open source graph plotting library for Android
5 |
6 | GraphView is a library for Android to programmatically create
7 | flexible and nice-looking diagrams.
8 | It is easy to understand, to integrate and to customize.
9 |
10 | Create Line Graphs, Bar Graphs, Point Graphs
11 | or implement your own custom types.
12 |
13 |
14 |
15 |
16 |
17 | ## Try the Demo app at Play Store
18 |
19 | [https://play.google.com/store/apps/details?id=com.jjoe64.graphview_demos]
20 |
21 | ## Visit the project homepage
22 |
23 | [http://www.android-graphview.org/]
24 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 27
5 | buildToolsVersion '27.0.3'
6 |
7 | defaultConfig {
8 | applicationId "com.jjoe64.graphview_demos"
9 | minSdkVersion 14
10 | targetSdkVersion 27
11 | versionCode 12
12 | versionName "4.2-2"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | implementation fileTree(dir: 'libs', include: ['*.jar'])
23 | implementation 'com.android.support:appcompat-v7:27.1.1'
24 | implementation 'com.android.support:support-v4:27.1.1'
25 | implementation 'com.android.support:cardview-v7:27.1.1'
26 | implementation 'com.android.support:recyclerview-v7:27.1.1'
27 | implementation 'com.android.support:design:27.1.1'
28 |
29 | // graphview
30 | //implementation project(':GraphView')
31 | implementation 'com.jjoe64:graphview:4.2.2'
32 | }
33 |
--------------------------------------------------------------------------------
/app/manifest-merger-release-report.txt:
--------------------------------------------------------------------------------
1 | -- Merging decision tree log ---
2 | manifest
3 | ADDED from AndroidManifest.xml:2:1
4 | package
5 | ADDED from AndroidManifest.xml:3:5
6 | INJECTED from AndroidManifest.xml:0:0
7 | INJECTED from AndroidManifest.xml:0:0
8 | android:versionName
9 | INJECTED from AndroidManifest.xml:0:0
10 | INJECTED from AndroidManifest.xml:0:0
11 | xmlns:android
12 | ADDED from AndroidManifest.xml:2:11
13 | android:versionCode
14 | INJECTED from AndroidManifest.xml:0:0
15 | INJECTED from AndroidManifest.xml:0:0
16 | application
17 | ADDED from AndroidManifest.xml:5:5
18 | MERGED from com.android.support:appcompat-v7:20.0.0:17:5
19 | MERGED from com.android.support:support-v4:20.0.0:17:5
20 | MERGED from com.jjoe64:GraphView:4.0.0:11:5
21 | MERGED from com.android.support:appcompat-v7:20.0.0:17:5
22 | MERGED from com.android.support:support-v4:20.0.0:17:5
23 | android:label
24 | ADDED from AndroidManifest.xml:8:9
25 | android:allowBackup
26 | ADDED from AndroidManifest.xml:6:9
27 | android:icon
28 | ADDED from AndroidManifest.xml:7:9
29 | android:theme
30 | ADDED from AndroidManifest.xml:9:9
31 | activity#com.jjoe64.graphview_demos.MainActivity
32 | ADDED from AndroidManifest.xml:10:9
33 | android:label
34 | ADDED from AndroidManifest.xml:12:13
35 | android:name
36 | ADDED from AndroidManifest.xml:11:13
37 | intent-filter#android.intent.action.MAIN+android.intent.category.LAUNCHER
38 | ADDED from AndroidManifest.xml:13:13
39 | action#android.intent.action.MAIN
40 | ADDED from AndroidManifest.xml:14:17
41 | android:name
42 | ADDED from AndroidManifest.xml:14:25
43 | category#android.intent.category.LAUNCHER
44 | ADDED from AndroidManifest.xml:16:17
45 | android:name
46 | ADDED from AndroidManifest.xml:16:27
47 | uses-sdk
48 | INJECTED from AndroidManifest.xml:0:0 reason: use-sdk injection requested
49 | MERGED from com.android.support:appcompat-v7:20.0.0:16:5
50 | MERGED from com.android.support:support-v4:20.0.0:16:5
51 | MERGED from com.jjoe64:GraphView:4.0.0:7:5
52 | MERGED from com.android.support:appcompat-v7:20.0.0:16:5
53 | MERGED from com.android.support:support-v4:20.0.0:16:5
54 | android:targetSdkVersion
55 | INJECTED from AndroidManifest.xml:0:0
56 | INJECTED from AndroidManifest.xml:0:0
57 | android:minSdkVersion
58 | INJECTED from AndroidManifest.xml:0:0
59 | INJECTED from AndroidManifest.xml:0:0
60 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/jonas/android-sdk/android-sdk-macosx/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/jjoe64/graphview_demos/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.jjoe64.graphview_demos;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
13 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
28 |
31 |
32 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jjoe64/graphview_demos/FullscreenActivity.java:
--------------------------------------------------------------------------------
1 | package com.jjoe64.graphview_demos;
2 |
3 | import android.content.pm.PackageManager;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.widget.Toast;
8 |
9 | import com.jjoe64.graphview_demos.examples.BaseExample;
10 | import com.jjoe64.graphview_demos.examples.SnapshotShareGraph;
11 |
12 | /**
13 | * Created by jonas on 10.09.16.
14 | */
15 | public class FullscreenActivity extends AppCompatActivity {
16 | private BaseExample mLogic;
17 |
18 | @Override
19 | public void onCreate(@Nullable Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 |
22 | String name = getIntent().getStringExtra(FullscreenExample.ARG_ID);
23 | FullscreenExample example = FullscreenExample.valueOf(name);
24 |
25 | setContentView(example.contentView);
26 | try {
27 | mLogic = example.exampleClass.newInstance();
28 | mLogic.onCreate(this);
29 | } catch (InstantiationException e) {
30 | e.printStackTrace();
31 | } catch (IllegalAccessException e) {
32 | e.printStackTrace();
33 | }
34 | }
35 |
36 | @Override
37 | protected void onResume() {
38 | super.onResume();
39 | mLogic.onResume();
40 | }
41 |
42 | @Override
43 | protected void onPause() {
44 | mLogic.onPause();
45 | super.onPause();
46 | }
47 |
48 | @Override
49 | public void onRequestPermissionsResult(int requestCode,
50 | String permissions[], int[] grantResults) {
51 | switch (requestCode) {
52 | case SnapshotShareGraph.REQUEST_CODE_PERMISSION: {
53 | // If request is cancelled, the result arrays are empty.
54 | if (grantResults.length > 0
55 | && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
56 |
57 | SnapshotShareGraph example = (SnapshotShareGraph) mLogic;
58 | example.snapshot();
59 |
60 | } else {
61 | Toast.makeText(this, "Permission denied. Not possible to show example.", Toast.LENGTH_SHORT).show();
62 | }
63 | return;
64 | }
65 | }
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jjoe64/graphview_demos/FullscreenExample.java:
--------------------------------------------------------------------------------
1 | package com.jjoe64.graphview_demos;
2 |
3 | import android.support.annotation.LayoutRes;
4 |
5 | import com.jjoe64.graphview_demos.examples.AddSeriesAtRuntime;
6 | import com.jjoe64.graphview_demos.examples.AdvancedBarGraph;
7 | import com.jjoe64.graphview_demos.examples.AdvancedLineGraph;
8 | import com.jjoe64.graphview_demos.examples.BaseExample;
9 | import com.jjoe64.graphview_demos.examples.CustomLabelsGraph;
10 | import com.jjoe64.graphview_demos.examples.Dates;
11 | import com.jjoe64.graphview_demos.examples.FixedFrame;
12 | import com.jjoe64.graphview_demos.examples.HelloWorld;
13 | import com.jjoe64.graphview_demos.examples.MultipleBarGraph;
14 | import com.jjoe64.graphview_demos.examples.NoLabelsGraph;
15 | import com.jjoe64.graphview_demos.examples.RealtimeScrolling;
16 | import com.jjoe64.graphview_demos.examples.ScalingX;
17 | import com.jjoe64.graphview_demos.examples.ScalingXY;
18 | import com.jjoe64.graphview_demos.examples.ScrollingX;
19 | import com.jjoe64.graphview_demos.examples.SecondScaleGraph;
20 | import com.jjoe64.graphview_demos.examples.SimpleBarGraph;
21 | import com.jjoe64.graphview_demos.examples.SimpleLineGraph;
22 | import com.jjoe64.graphview_demos.examples.SimplePointsGraph;
23 | import com.jjoe64.graphview_demos.examples.SnapshotShareGraph;
24 | import com.jjoe64.graphview_demos.examples.StaticLabelsGraph;
25 | import com.jjoe64.graphview_demos.examples.StylingColors;
26 | import com.jjoe64.graphview_demos.examples.StylingLabels;
27 | import com.jjoe64.graphview_demos.examples.TapListenerGraph;
28 | import com.jjoe64.graphview_demos.examples.TitlesExample;
29 | import com.jjoe64.graphview_demos.examples.UniqueLegendLineGraph;
30 |
31 | /**
32 | * Created by jonas on 10.09.16.
33 | */
34 | public enum FullscreenExample {
35 | HELLO_WORLD(R.layout.fullscreen_example_simple, HelloWorld.class),
36 | SCALING_XY(R.layout.fullscreen_example_simple, ScalingXY.class),
37 | SCALING_X(R.layout.fullscreen_example_simple, ScalingX.class),
38 | SCROLLING_X(R.layout.fullscreen_example_simple, ScrollingX.class),
39 | FIXED_FRAME(R.layout.fullscreen_example_simple, FixedFrame.class),
40 | REALTIME_SCROLLING(R.layout.fullscreen_example_simple, RealtimeScrolling.class),
41 | DATES(R.layout.fullscreen_example_simple, Dates.class),
42 | SIMPLE_LINE_GRAPH(R.layout.fullscreen_example_simple, SimpleLineGraph.class),
43 | ADVANCED_LINE_GRAPH(R.layout.fullscreen_example_simple, AdvancedLineGraph.class),
44 | UNIQUE_LEGEND_LINE_GRAPH(R.layout.fullscreen_example_simple, UniqueLegendLineGraph.class),
45 | SIMPLE_BAR_GRAPH(R.layout.fullscreen_example_simple, SimpleBarGraph.class),
46 | ADVANCED_BAR_GRAPH(R.layout.fullscreen_example_simple, AdvancedBarGraph.class),
47 | MULTIPLE_BAR_GRAPH(R.layout.fullscreen_example_simple, MultipleBarGraph.class),
48 | SIMPLE_POINTS_GRAPH(R.layout.fullscreen_example_simple, SimplePointsGraph.class),
49 | SECOND_SCALE_GRAPH(R.layout.fullscreen_example_simple, SecondScaleGraph.class),
50 | CUSTOM_LABELS(R.layout.fullscreen_example_simple, CustomLabelsGraph.class),
51 | NO_LABELS(R.layout.fullscreen_example_simple, NoLabelsGraph.class),
52 | STATIC_LABELS(R.layout.fullscreen_example_simple, StaticLabelsGraph.class),
53 | TAP_LISTENER(R.layout.fullscreen_example_simple, TapListenerGraph.class),
54 | STYLING_LABELS(R.layout.fullscreen_example_simple, StylingLabels.class),
55 | STYLING_COLORS(R.layout.fullscreen_example_simple, StylingColors.class),
56 | ADD_SERIES(R.layout.fullscreen_example_add_series, AddSeriesAtRuntime.class),
57 | TITLES_EXAMPLE(R.layout.fullscreen_example_simple, TitlesExample.class),
58 | SNAPSHOT_SHARE(R.layout.fullscreen_example_add_series, SnapshotShareGraph.class),
59 | ;
60 |
61 | public static final String ARG_ID = "FEID";
62 | static final String URL_PREFIX = "https://github.com/jjoe64/GraphView-Demos/blob/master/app/src/main/java/com/jjoe64/graphview_demos/examples/";
63 |
64 | public final @LayoutRes int contentView;
65 | public final Class extends BaseExample> exampleClass;
66 | public final String url;
67 |
68 | FullscreenExample(@LayoutRes int contentView, Class extends BaseExample> exampleClass) {
69 | this.contentView = contentView;
70 | this.exampleClass = exampleClass;
71 | this.url = URL_PREFIX+exampleClass.getSimpleName()+".java";
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jjoe64/graphview_demos/ItemDetailActivity.java:
--------------------------------------------------------------------------------
1 | package com.jjoe64.graphview_demos;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.design.widget.FloatingActionButton;
6 | import android.support.design.widget.Snackbar;
7 | import android.support.v4.app.Fragment;
8 | import android.support.v7.widget.Toolbar;
9 | import android.view.View;
10 | import android.support.v7.app.AppCompatActivity;
11 | import android.support.v7.app.ActionBar;
12 | import android.support.v4.app.NavUtils;
13 | import android.view.MenuItem;
14 |
15 | /**
16 | * An activity representing a single Item detail screen. This
17 | * activity is only used narrow width devices. On tablet-size devices,
18 | * item details are presented side-by-side with a list of items
19 | * in a {@link ItemListActivity}.
20 | */
21 | public class ItemDetailActivity extends AppCompatActivity {
22 |
23 | @Override
24 | protected void onCreate(Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | setContentView(R.layout.activity_item_detail);
27 | Toolbar toolbar = (Toolbar) findViewById(R.id.detail_toolbar);
28 | setSupportActionBar(toolbar);
29 |
30 | // Show the Up button in the action bar.
31 | ActionBar actionBar = getSupportActionBar();
32 | if (actionBar != null) {
33 | actionBar.setDisplayHomeAsUpEnabled(true);
34 | }
35 |
36 | // savedInstanceState is non-null when there is fragment state
37 | // saved from previous configurations of this activity
38 | // (e.g. when rotating the screen from portrait to landscape).
39 | // In this case, the fragment will automatically be re-added
40 | // to its container so we don't need to manually add it.
41 | // For more information, see the Fragments API guide at:
42 | //
43 | // http://developer.android.com/guide/components/fragments.html
44 | //
45 | if (savedInstanceState == null) {
46 | // Create the detail fragment and add it to the activity
47 | // using a fragment transaction.
48 | Bundle arguments = new Bundle();
49 | arguments.putString(ItemDetailFragment.ARG_ITEM_ID,
50 | getIntent().getStringExtra(ItemDetailFragment.ARG_ITEM_ID));
51 | MenuContent.MenuItem mItem = MenuContent.ITEM_MAP.get(getIntent().getStringExtra(ItemDetailFragment.ARG_ITEM_ID));
52 |
53 | try {
54 | Fragment fragment;
55 | fragment = mItem.fragmentClass.newInstance();
56 | fragment.setArguments(arguments);
57 | getSupportFragmentManager().beginTransaction()
58 | .add(R.id.item_detail_container, fragment)
59 | .commit();
60 | } catch (InstantiationException e) {
61 | e.printStackTrace();
62 | } catch (IllegalAccessException e) {
63 | e.printStackTrace();
64 | }
65 | }
66 | }
67 |
68 | @Override
69 | public boolean onOptionsItemSelected(MenuItem item) {
70 | int id = item.getItemId();
71 | if (id == android.R.id.home) {
72 | // This ID represents the Home or Up button. In the case of this
73 | // activity, the Up button is shown. Use NavUtils to allow users
74 | // to navigate up one level in the application structure. For
75 | // more details, see the Navigation pattern on Android Design:
76 | //
77 | // http://developer.android.com/design/patterns/navigation.html#up-vs-back
78 | //
79 | NavUtils.navigateUpTo(this, new Intent(this, ItemListActivity.class));
80 | return true;
81 | }
82 | return super.onOptionsItemSelected(item);
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jjoe64/graphview_demos/ItemDetailFragment.java:
--------------------------------------------------------------------------------
1 | package com.jjoe64.graphview_demos;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.net.Uri;
6 | import android.support.design.widget.CollapsingToolbarLayout;
7 | import android.os.Bundle;
8 | import android.support.v4.app.Fragment;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.widget.TextView;
13 | import android.widget.Toast;
14 |
15 | import com.jjoe64.graphview_demos.examples.BaseExample;
16 |
17 | /**
18 | * A fragment representing a single Item detail screen.
19 | * This fragment is either contained in a {@link ItemListActivity}
20 | * in two-pane mode (on tablets) or a {@link ItemDetailActivity}
21 | * on handsets.
22 | */
23 | public abstract class ItemDetailFragment extends Fragment {
24 | /**
25 | * The fragment argument representing the item ID that this fragment
26 | * represents.
27 | */
28 | public static final String ARG_ITEM_ID = "item_id";
29 |
30 | /**
31 | * The dummy content this fragment is presenting.
32 | */
33 | private MenuContent.MenuItem mItem;
34 |
35 | /**
36 | * Mandatory empty constructor for the fragment manager to instantiate the
37 | * fragment (e.g. upon screen orientation changes).
38 | */
39 | public ItemDetailFragment() {
40 | }
41 |
42 | @Override
43 | public void onCreate(Bundle savedInstanceState) {
44 | super.onCreate(savedInstanceState);
45 |
46 | if (getArguments().containsKey(ARG_ITEM_ID)) {
47 | // Load the dummy content specified by the fragment
48 | // arguments. In a real-world scenario, use a Loader
49 | // to load content from a content provider.
50 | mItem = MenuContent.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID));
51 |
52 | Activity activity = this.getActivity();
53 | CollapsingToolbarLayout appBarLayout = (CollapsingToolbarLayout) activity.findViewById(R.id.toolbar_layout);
54 | if (appBarLayout != null) {
55 | appBarLayout.setTitle(mItem.content);
56 | //appBarLayout.setBackgroundResource(mItem.background);
57 | }
58 | }
59 | }
60 |
61 | protected void openFullscreen(FullscreenExample helloWorld) {
62 | Intent intent = new Intent(getActivity(), FullscreenActivity.class);
63 | intent.putExtra(FullscreenExample.ARG_ID, helloWorld.name());
64 | startActivity(intent);
65 | }
66 |
67 | protected void openSource(FullscreenExample helloWorld) {
68 | Intent i = new Intent("android.intent.action.VIEW");
69 | i.setData(Uri.parse(helloWorld.url));
70 | startActivity(i);
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jjoe64/graphview_demos/ItemListActivity.java:
--------------------------------------------------------------------------------
1 | package com.jjoe64.graphview_demos;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.net.Uri;
6 | import android.os.Bundle;
7 | import android.support.annotation.NonNull;
8 | import android.support.v4.app.Fragment;
9 | import android.support.v7.app.AppCompatActivity;
10 | import android.support.v7.widget.RecyclerView;
11 | import android.support.v7.widget.Toolbar;
12 | import android.support.design.widget.FloatingActionButton;
13 | import android.support.design.widget.Snackbar;
14 | import android.view.LayoutInflater;
15 | import android.view.View;
16 | import android.view.ViewGroup;
17 | import android.widget.TextView;
18 |
19 |
20 | import java.util.List;
21 |
22 | /**
23 | * An activity representing a list of Items. This activity
24 | * has different presentations for handset and tablet-size devices. On
25 | * handsets, the activity presents a list of items, which when touched,
26 | * lead to a {@link ItemDetailActivity} representing
27 | * item details. On tablets, the activity presents the list of items and
28 | * item details side-by-side using two vertical panes.
29 | */
30 | public class ItemListActivity extends AppCompatActivity {
31 |
32 | /**
33 | * Whether or not the activity is in two-pane mode, i.e. running on a tablet
34 | * device.
35 | */
36 | private boolean mTwoPane;
37 |
38 | @Override
39 | protected void onCreate(Bundle savedInstanceState) {
40 | super.onCreate(savedInstanceState);
41 | setContentView(R.layout.activity_item_list);
42 |
43 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
44 | setSupportActionBar(toolbar);
45 | toolbar.setTitle(getTitle());
46 |
47 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.visitHP);
48 | fab.setOnClickListener(new View.OnClickListener() {
49 | @Override
50 | public void onClick(View view) {
51 | Intent i = new Intent("android.intent.action.VIEW");
52 | i.setData(Uri.parse("http://www.android-graphview.org"));
53 | startActivity(i);
54 | }
55 | });
56 |
57 | View recyclerView = findViewById(R.id.item_list);
58 | assert recyclerView != null;
59 | setupRecyclerView((RecyclerView) recyclerView);
60 |
61 | if (findViewById(R.id.item_detail_container) != null) {
62 | // The detail container view will be present only in the
63 | // large-screen layouts (res/values-w900dp).
64 | // If this view is present, then the
65 | // activity should be in two-pane mode.
66 | mTwoPane = true;
67 | }
68 | }
69 |
70 | private void setupRecyclerView(@NonNull RecyclerView recyclerView) {
71 | recyclerView.setAdapter(new SimpleItemRecyclerViewAdapter(MenuContent.ITEMS));
72 | }
73 |
74 | public class SimpleItemRecyclerViewAdapter
75 | extends RecyclerView.Adapter {
76 |
77 | private final List mValues;
78 |
79 | public SimpleItemRecyclerViewAdapter(List items) {
80 | mValues = items;
81 | }
82 |
83 | @Override
84 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
85 | View view = LayoutInflater.from(parent.getContext())
86 | .inflate(R.layout.item_list_content, parent, false);
87 | return new ViewHolder(view);
88 | }
89 |
90 | @Override
91 | public void onBindViewHolder(final ViewHolder holder, int position) {
92 | holder.mItem = mValues.get(position);
93 | holder.mIdView.setText(mValues.get(position).id);
94 | holder.mContentView.setText(mValues.get(position).content);
95 |
96 | holder.mView.setOnClickListener(new View.OnClickListener() {
97 | @Override
98 | public void onClick(View v) {
99 | if (mTwoPane) {
100 | Bundle arguments = new Bundle();
101 | arguments.putString(ItemDetailFragment.ARG_ITEM_ID, holder.mItem.id);
102 | try {
103 | Fragment fragment;
104 | fragment = holder.mItem.fragmentClass.newInstance();
105 | fragment.setArguments(arguments);
106 | getSupportFragmentManager().beginTransaction()
107 | .replace(R.id.item_detail_container, fragment)
108 | .commit();
109 | } catch (InstantiationException e) {
110 | e.printStackTrace();
111 | } catch (IllegalAccessException e) {
112 | e.printStackTrace();
113 | }
114 | } else {
115 | Context context = v.getContext();
116 | Intent intent = new Intent(context, ItemDetailActivity.class);
117 | intent.putExtra(ItemDetailFragment.ARG_ITEM_ID, holder.mItem.id);
118 |
119 | context.startActivity(intent);
120 | }
121 | }
122 | });
123 | }
124 |
125 | @Override
126 | public int getItemCount() {
127 | return mValues.size();
128 | }
129 |
130 | public class ViewHolder extends RecyclerView.ViewHolder {
131 | public final View mView;
132 | public final TextView mIdView;
133 | public final TextView mContentView;
134 | public MenuContent.MenuItem mItem;
135 |
136 | public ViewHolder(View view) {
137 | super(view);
138 | mView = view;
139 | mIdView = (TextView) view.findViewById(R.id.id);
140 | mContentView = (TextView) view.findViewById(R.id.content);
141 | }
142 |
143 | @Override
144 | public String toString() {
145 | return super.toString() + " '" + mContentView.getText() + "'";
146 | }
147 | }
148 | }
149 | }
150 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jjoe64/graphview_demos/MenuContent.java:
--------------------------------------------------------------------------------
1 | package com.jjoe64.graphview_demos;
2 |
3 | import android.support.annotation.DrawableRes;
4 | import android.support.v4.app.Fragment;
5 |
6 | import com.jjoe64.graphview_demos.categories.BarGraphFragment;
7 | import com.jjoe64.graphview_demos.categories.HelloWorldFragment;
8 | import com.jjoe64.graphview_demos.categories.OthersFragment;
9 | import com.jjoe64.graphview_demos.categories.PointsGraphFragment;
10 | import com.jjoe64.graphview_demos.categories.RealtimeFragment;
11 | import com.jjoe64.graphview_demos.categories.LineGraphFragment;
12 | import com.jjoe64.graphview_demos.categories.SecondScaleAndLabelsFragment;
13 | import com.jjoe64.graphview_demos.categories.StylingExamplesFragment;
14 | import com.jjoe64.graphview_demos.categories.TapListenerGraphFragment;
15 | import com.jjoe64.graphview_demos.categories.TimeAndDatesFragment;
16 | import com.jjoe64.graphview_demos.categories.ZoomingAndScrollingFragment;
17 |
18 | import java.util.ArrayList;
19 | import java.util.HashMap;
20 | import java.util.List;
21 | import java.util.Map;
22 |
23 | /**
24 | * Helper class for providing sample content for user interfaces created by
25 | * Android template wizards.
26 | */
27 | public class MenuContent {
28 |
29 | /**
30 | * An array of sample (dummy) items.
31 | */
32 | public static final List