├── AndroidTicker
├── .gitignore
├── .idea
│ ├── caches
│ │ ├── build_file_checksums.ser
│ │ └── gradle_models.ser
│ ├── codeStyles
│ │ └── Project.xml
│ ├── compiler.xml
│ ├── copyright
│ │ └── profiles_settings.xml
│ ├── encodings.xml
│ ├── gradle.xml
│ ├── misc.xml
│ ├── modules.xml
│ ├── runConfigurations.xml
│ └── vcs.xml
├── MyApplication.zip
├── app
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── aliahmed
│ │ │ └── myapplication
│ │ │ └── ExampleInstrumentedTest.java
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── aliahmed
│ │ │ │ └── myapplication
│ │ │ │ ├── AutoScrollActivity.java
│ │ │ │ ├── AutoScrollFragment.java
│ │ │ │ ├── FragmentContainerActivity.java
│ │ │ │ ├── MainActivity.java
│ │ │ │ ├── OnItemClickListener.java
│ │ │ │ ├── ScrollCustomAdapter.java
│ │ │ │ ├── ScrollStockAdapter.java
│ │ │ │ └── StockListModel.java
│ │ └── res
│ │ │ ├── drawable
│ │ │ ├── app_icon_new.png
│ │ │ └── shadow.xml
│ │ │ ├── layout
│ │ │ ├── activity_auto_scroll.xml
│ │ │ ├── activity_fragment_container.xml
│ │ │ ├── activity_main.xml
│ │ │ ├── fragment_auto_scroll.xml
│ │ │ ├── layout_histories.xml
│ │ │ └── layout_scroll_stock.xml
│ │ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ ├── down.png
│ │ │ ├── ic_launcher.png
│ │ │ └── up.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── values-w820dp
│ │ │ └── dimens.xml
│ │ │ └── values
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── aliahmed
│ │ └── myapplication
│ │ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
├── LICENSE.md
├── README.md
├── _config.yml
├── ezgif.com-crop.gif
└── share bazar.PNG
/AndroidTicker/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/AndroidTicker/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliahmedbd/Ticker-Using-Recycler-View-Android/227bf596e314a3a1b410d82e61a764cf6379a8ea/AndroidTicker/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/AndroidTicker/.idea/caches/gradle_models.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliahmedbd/Ticker-Using-Recycler-View-Android/227bf596e314a3a1b410d82e61a764cf6379a8ea/AndroidTicker/.idea/caches/gradle_models.ser
--------------------------------------------------------------------------------
/AndroidTicker/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | xmlns:android
14 |
15 | ^$
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | xmlns:.*
25 |
26 | ^$
27 |
28 |
29 | BY_NAME
30 |
31 |
32 |
33 |
34 |
35 |
36 | .*:id
37 |
38 | http://schemas.android.com/apk/res/android
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | .*:name
48 |
49 | http://schemas.android.com/apk/res/android
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | name
59 |
60 | ^$
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | style
70 |
71 | ^$
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | .*
81 |
82 | ^$
83 |
84 |
85 | BY_NAME
86 |
87 |
88 |
89 |
90 |
91 |
92 | .*
93 |
94 | http://schemas.android.com/apk/res/android
95 |
96 |
97 | ANDROID_ATTRIBUTE_ORDER
98 |
99 |
100 |
101 |
102 |
103 |
104 | .*
105 |
106 | .*
107 |
108 |
109 | BY_NAME
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/AndroidTicker/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/AndroidTicker/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/AndroidTicker/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/AndroidTicker/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
22 |
23 |
--------------------------------------------------------------------------------
/AndroidTicker/.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 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | Java
51 |
52 |
53 | Java language level migration aidsJava
54 |
55 |
56 |
57 |
58 | General
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 | 1.8 (1)
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 | 1.8
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
--------------------------------------------------------------------------------
/AndroidTicker/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/AndroidTicker/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/AndroidTicker/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/AndroidTicker/MyApplication.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliahmedbd/Ticker-Using-Recycler-View-Android/227bf596e314a3a1b410d82e61a764cf6379a8ea/AndroidTicker/MyApplication.zip
--------------------------------------------------------------------------------
/AndroidTicker/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/AndroidTicker/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 | buildToolsVersion '26.0.3'
6 | defaultConfig {
7 | applicationId "com.example.bs058.myapplication"
8 | minSdkVersion 15
9 | targetSdkVersion 28
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 |
21 | compileOptions {
22 | sourceCompatibility JavaVersion.VERSION_1_8
23 | targetCompatibility JavaVersion.VERSION_1_8
24 | }
25 | }
26 |
27 | dependencies {
28 | implementation fileTree(dir: 'libs', include: ['*.jar'])
29 | implementation 'androidx.appcompat:appcompat:1.0.0'
30 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
31 | implementation 'androidx.legacy:legacy-support-v4:1.0.0'
32 | testImplementation 'junit:junit:4.12'
33 |
34 | implementation 'androidx.recyclerview:recyclerview:1.0.0'
35 | implementation 'androidx.cardview:cardview:1.0.0'
36 | implementation 'com.jakewharton:butterknife:10.1.0'
37 | annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
38 | implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
39 | implementation 'com.squareup.picasso:picasso:2.5.2'
40 | implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.47'
41 | }
42 |
--------------------------------------------------------------------------------
/AndroidTicker/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 C:\Users\BS058\Downloads\android-sdk-windows/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 |
--------------------------------------------------------------------------------
/AndroidTicker/app/src/androidTest/java/com/example/aliahmed/myapplication/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.aliahmed.myapplication;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.example.bs058.myapplication", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/java/com/example/aliahmed/myapplication/AutoScrollActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.aliahmed.myapplication;
2 |
3 | import android.os.Handler;
4 | import android.os.Bundle;
5 | import android.util.DisplayMetrics;
6 | import android.view.View;
7 | import android.widget.Toast;
8 |
9 | import androidx.appcompat.app.AppCompatActivity;
10 | import androidx.recyclerview.widget.LinearLayoutManager;
11 | import androidx.recyclerview.widget.LinearSmoothScroller;
12 | import androidx.recyclerview.widget.RecyclerView;
13 |
14 | import com.chad.library.adapter.base.BaseQuickAdapter;
15 |
16 | import java.util.ArrayList;
17 | import java.util.List;
18 |
19 | import butterknife.BindView;
20 | import butterknife.ButterKnife;
21 |
22 | public class AutoScrollActivity extends AppCompatActivity {
23 |
24 | @BindView(R.id.rec_scroll_stock)
25 | RecyclerView rvTickerList;
26 |
27 | List stockListModels = new ArrayList<>();
28 | private ScrollStockAdapter scrollStockAdapter;
29 | StockListModel model = new StockListModel();
30 | int scrollCount = 0;
31 |
32 | @Override
33 | protected void onCreate(Bundle savedInstanceState) {
34 | super.onCreate(savedInstanceState);
35 | setContentView(R.layout.activity_auto_scroll);
36 | ButterKnife.bind(this);
37 |
38 | //Dummy Value
39 | model.setAskerName("Ali Ahmed");
40 | model.setBidderName("Tanzim");
41 | model.setId("abc");
42 | model.setType("BUY");
43 | model.setIsSyncedWithServer(true);
44 | model.setTransactionTime("12/12/2016");
45 | model.setShortName("ABC");
46 | model.setShareQuantity(10);
47 |
48 | //add to the list
49 | stockListModels.add(model);
50 | stockListModels.add(model);
51 | stockListModels.add(model);
52 | stockListModels.add(model);
53 | stockListModels.add(model);
54 | stockListModels.add(model);
55 | stockListModels.add(model);
56 | stockListModels.add(model);
57 | stockListModels.add(model);
58 | stockListModels.add(model);
59 | stockListModels.add(model);
60 | stockListModels.add(model);
61 | stockListModels.add(model);
62 | stockListModels.add(model);
63 | stockListModels.add(model);
64 | stockListModels.add(model);
65 | stockListModels.add(model);
66 | stockListModels.add(model);
67 | stockListModels.add(model);
68 | stockListModels.add(model);
69 | }
70 |
71 |
72 | @Override
73 | protected void onResume() {
74 | super.onResume();
75 | scrollStockAdapter = new ScrollStockAdapter(stockListModels);
76 | rvTickerList.setAdapter(scrollStockAdapter);
77 |
78 | LinearLayoutManager layoutManager = new LinearLayoutManager(AutoScrollActivity.this) {
79 |
80 | @Override
81 | public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
82 | LinearSmoothScroller smoothScroller = new LinearSmoothScroller(AutoScrollActivity.this) {
83 | private static final float SPEED = 3500f;// Change this value (default=25f)
84 |
85 | @Override
86 | protected float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
87 | return SPEED / displayMetrics.densityDpi;
88 | }
89 | };
90 | smoothScroller.setTargetPosition(position);
91 | startSmoothScroll(smoothScroller);
92 | }
93 | };
94 | // LinearLayoutManager layoutManager = new LinearLayoutManager(this);
95 | autoScrollAnother();
96 | layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
97 | rvTickerList.setLayoutManager(layoutManager);
98 | rvTickerList.setHasFixedSize(true);
99 | rvTickerList.setItemViewCacheSize(1000);
100 | rvTickerList.setDrawingCacheEnabled(true);
101 | rvTickerList.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
102 | rvTickerList.setAdapter(scrollStockAdapter);
103 |
104 | scrollStockAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
105 | @Override
106 | public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
107 | Toast.makeText(AutoScrollActivity.this, "Item clicked", Toast.LENGTH_LONG).show();
108 | }
109 | });
110 | }
111 |
112 | /**
113 | * Autoscroll detected from here, where counter, time and runnable is declared.
114 | */
115 | public void autoScrollAnother() {
116 | scrollCount = 0;
117 | final Handler handler = new Handler();
118 | final Runnable runnable = new Runnable() {
119 | @Override
120 | public void run() {
121 | rvTickerList.smoothScrollToPosition((scrollCount++));
122 | if (scrollCount == scrollStockAdapter.getData().size() - 4) {
123 | stockListModels.addAll(stockListModels);
124 | scrollStockAdapter.notifyDataSetChanged();
125 | }
126 | handler.postDelayed(this, 2000);
127 | }
128 | };
129 | handler.postDelayed(runnable, 2000);
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/java/com/example/aliahmed/myapplication/AutoScrollFragment.java:
--------------------------------------------------------------------------------
1 | package com.example.aliahmed.myapplication;
2 |
3 |
4 | import android.os.Bundle;
5 |
6 | import androidx.fragment.app.Fragment;
7 | import androidx.recyclerview.widget.LinearLayoutManager;
8 | import androidx.recyclerview.widget.LinearSmoothScroller;
9 | import androidx.recyclerview.widget.RecyclerView;
10 |
11 | import android.os.Handler;
12 | import android.util.DisplayMetrics;
13 | import android.view.LayoutInflater;
14 | import android.view.View;
15 | import android.view.ViewGroup;
16 | import android.widget.Toast;
17 |
18 | import com.chad.library.adapter.base.BaseQuickAdapter;
19 |
20 | import java.util.ArrayList;
21 | import java.util.List;
22 | import java.util.Objects;
23 |
24 | import butterknife.BindView;
25 | import butterknife.ButterKnife;
26 |
27 |
28 | /**
29 | * A simple {@link Fragment} subclass.
30 | */
31 | public class AutoScrollFragment extends Fragment {
32 | @BindView(R.id.rec_scroll_stock)
33 | RecyclerView rvTickerList;
34 |
35 | List stockListModels = new ArrayList<>();
36 | private ScrollStockAdapter scrollStockAdapter;
37 | StockListModel model = new StockListModel();
38 | int scrollCount = 0;
39 |
40 | public AutoScrollFragment() {
41 | // Required empty public constructor
42 | }
43 |
44 |
45 | @Override
46 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
47 | Bundle savedInstanceState) {
48 | // Inflate the layout for this fragment
49 | View view = inflater.inflate(R.layout.fragment_auto_scroll, container, false);
50 | ButterKnife.bind(this, view);
51 | return view;
52 | }
53 |
54 | @Override
55 | public void onResume() {
56 | super.onResume();
57 |
58 | //Dummy Value
59 | model.setAskerName("Ali Ahmed");
60 | model.setBidderName("Tanzim");
61 | model.setId("abc");
62 | model.setType("BUY");
63 | model.setIsSyncedWithServer(true);
64 | model.setTransactionTime("12/12/2016");
65 | model.setShortName("ABC");
66 | model.setShareQuantity(10);
67 |
68 | //add to the list
69 | stockListModels.add(model);
70 | stockListModels.add(model);
71 | stockListModels.add(model);
72 | stockListModels.add(model);
73 | stockListModels.add(model);
74 | stockListModels.add(model);
75 | stockListModels.add(model);
76 | stockListModels.add(model);
77 | stockListModels.add(model);
78 | stockListModels.add(model);
79 | stockListModels.add(model);
80 | stockListModels.add(model);
81 | stockListModels.add(model);
82 | stockListModels.add(model);
83 | stockListModels.add(model);
84 | stockListModels.add(model);
85 | stockListModels.add(model);
86 | stockListModels.add(model);
87 | stockListModels.add(model);
88 | stockListModels.add(model);
89 |
90 | scrollStockAdapter = new ScrollStockAdapter(stockListModels);
91 | rvTickerList.setAdapter(scrollStockAdapter);
92 |
93 | LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()) {
94 |
95 | @Override
96 | public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
97 | try {
98 | LinearSmoothScroller smoothScroller = new LinearSmoothScroller(Objects.requireNonNull(getContext())) {
99 | private static final float SPEED = 3500f;// Change this value (default=25f)
100 |
101 | @Override
102 | protected float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
103 | return SPEED / displayMetrics.densityDpi;
104 | }
105 | };
106 | smoothScroller.setTargetPosition(position);
107 | startSmoothScroll(smoothScroller);
108 | } catch (Exception e) {
109 | e.printStackTrace();
110 | }
111 | }
112 | };
113 | // LinearLayoutManager layoutManager = new LinearLayoutManager(this);
114 | autoScrollAnother();
115 | layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
116 | rvTickerList.setLayoutManager(layoutManager);
117 | rvTickerList.setHasFixedSize(true);
118 | rvTickerList.setItemViewCacheSize(1000);
119 | rvTickerList.setDrawingCacheEnabled(true);
120 | rvTickerList.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
121 | rvTickerList.setAdapter(scrollStockAdapter);
122 |
123 | scrollStockAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
124 | @Override
125 | public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
126 | Toast.makeText(getContext(), "Item clicked", Toast.LENGTH_LONG).show();
127 | }
128 | });
129 |
130 |
131 | }
132 |
133 | /**
134 | * Autoscroll detected from here, where counter, time and runnable is declared.
135 | */
136 | public void autoScrollAnother() {
137 | scrollCount = 0;
138 | final Handler handler = new Handler();
139 | final Runnable runnable = new Runnable() {
140 | @Override
141 | public void run() {
142 | rvTickerList.smoothScrollToPosition((scrollCount++));
143 | if (scrollCount == scrollStockAdapter.getData().size() - 4) {
144 | stockListModels.addAll(stockListModels);
145 | scrollStockAdapter.notifyDataSetChanged();
146 | }
147 | handler.postDelayed(this, 2000);
148 | }
149 | };
150 | handler.postDelayed(runnable, 2000);
151 | }
152 |
153 | }
154 |
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/java/com/example/aliahmed/myapplication/FragmentContainerActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.aliahmed.myapplication;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 | import androidx.fragment.app.FragmentTransaction;
5 |
6 | import android.os.Bundle;
7 | import android.widget.FrameLayout;
8 |
9 | import butterknife.BindView;
10 | import butterknife.ButterKnife;
11 |
12 | public class FragmentContainerActivity extends AppCompatActivity {
13 |
14 | @BindView(R.id.fragment_container)
15 | FrameLayout fragmentContainer;
16 | AutoScrollFragment autoScrollFragment;
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.activity_fragment_container);
22 | ButterKnife.bind(this);
23 | autoScrollFragment = new AutoScrollFragment();
24 |
25 | FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
26 | fragmentTransaction.add(R.id.fragment_container, autoScrollFragment).commit();
27 | }
28 |
29 | @Override
30 | public void onBackPressed() {
31 | FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
32 | fragmentTransaction.remove(autoScrollFragment);
33 | fragmentTransaction.commit();
34 | super.onBackPressed();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/java/com/example/aliahmed/myapplication/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.aliahmed.myapplication;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 | import android.view.View;
8 | import android.widget.Button;
9 |
10 | import butterknife.BindView;
11 | import butterknife.ButterKnife;
12 |
13 | public class MainActivity extends AppCompatActivity {
14 |
15 | @BindView(R.id.btnFromActivity)
16 | Button btnFromActivity;
17 |
18 | @BindView(R.id.btnFromFragment)
19 | Button btnFromFragment;
20 |
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.activity_main);
25 | ButterKnife.bind(this);
26 |
27 | btnFromActivity.setOnClickListener(v -> {
28 | Intent intent = new Intent(MainActivity.this, AutoScrollActivity.class);
29 | startActivity(intent);
30 | });
31 |
32 | btnFromFragment.setOnClickListener(v -> {
33 | Intent intent = new Intent(MainActivity.this, FragmentContainerActivity.class);
34 | startActivity(intent);
35 | });
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/java/com/example/aliahmed/myapplication/OnItemClickListener.java:
--------------------------------------------------------------------------------
1 | package com.example.aliahmed.myapplication;
2 |
3 | public interface OnItemClickListener {
4 | void onItemClick(StockListModel item);
5 | void onChildItemClick(StockListModel item);
6 | }
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/java/com/example/aliahmed/myapplication/ScrollCustomAdapter.java:
--------------------------------------------------------------------------------
1 | package com.example.aliahmed.myapplication;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 |
11 | import androidx.recyclerview.widget.RecyclerView;
12 |
13 | import com.squareup.picasso.Picasso;
14 |
15 | import java.text.DecimalFormat;
16 | import java.util.List;
17 | import java.util.Random;
18 |
19 | /**
20 | * Created by BS058 on 12/18/2016.
21 | */
22 |
23 | public abstract class ScrollCustomAdapter extends RecyclerView.Adapter {
24 | public List stockListModels;
25 | private OnItemClickListener onItemClickListener;
26 | Context mContext;
27 |
28 | Random randomGenerator = new Random();
29 | float min = -0.5f;
30 | float max = 0.5f;
31 | DecimalFormat df = new DecimalFormat();
32 |
33 | public OnItemClickListener getOnItemClickListener() {
34 | return onItemClickListener;
35 | }
36 |
37 | public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
38 | this.onItemClickListener = onItemClickListener;
39 | }
40 |
41 | public ScrollCustomAdapter(Context context, List stockListModels) {
42 | this.stockListModels = stockListModels;
43 | this.mContext = context;
44 | }
45 |
46 | public abstract void load();
47 |
48 | @Override
49 | public CustomViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
50 | View view = LayoutInflater.from(mContext).inflate(R.layout.layout_scroll_stock, null);
51 | // RecyclerView.LayoutParams lp = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
52 | //view.setLayoutParams(lp);
53 | CustomViewHolder viewHolder = new CustomViewHolder(view);
54 | return viewHolder;
55 | }
56 |
57 | @Override
58 | public void onBindViewHolder(CustomViewHolder holder, int position) {
59 |
60 | if ((position >= getItemCount() - 1)) {
61 | load();
62 | } else {
63 | df.setMaximumFractionDigits(3);
64 | float percantage = randomGenerator.nextFloat() * (max - min) + min;
65 | holder.txt_percantage_price.setText(df.format(percantage) + " %");
66 | holder.txt_stock_name.setText(stockListModels.get(position).getShortName());
67 |
68 | if (percantage < 0) {
69 | Picasso.with(mContext).load(R.mipmap.down).into(holder.img_up);
70 | holder.txt_percantage_price.setTextColor(Color.parseColor("#EC3030"));
71 | } else {
72 | Picasso.with(mContext).load(R.mipmap.up).into(holder.img_up);
73 | holder.txt_percantage_price.setTextColor(Color.parseColor("#8DCF5F"));
74 | }
75 | }
76 | }
77 |
78 | @Override
79 | public int getItemCount() {
80 | return stockListModels.size();
81 | }
82 |
83 | class CustomViewHolder extends RecyclerView.ViewHolder {
84 | TextView txt_percantage_price;
85 | TextView txt_stock_name;
86 | ImageView img_up;
87 |
88 | public CustomViewHolder(View itemView) {
89 | super(itemView);
90 | this.txt_percantage_price = (TextView) itemView.findViewById(R.id.txt_percantage_price);
91 | this.txt_stock_name = (TextView) itemView.findViewById(R.id.txt_stock_name);
92 | this.img_up = (ImageView) itemView.findViewById(R.id.img_up);
93 | }
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/java/com/example/aliahmed/myapplication/ScrollStockAdapter.java:
--------------------------------------------------------------------------------
1 | package com.example.aliahmed.myapplication;
2 |
3 | import android.graphics.Color;
4 |
5 | import com.chad.library.adapter.base.BaseQuickAdapter;
6 | import com.chad.library.adapter.base.BaseViewHolder;
7 |
8 | import java.text.DecimalFormat;
9 | import java.util.List;
10 | import java.util.Random;
11 |
12 | /**
13 | * Created by BS058 on 10/19/2016.
14 | */
15 |
16 | public class ScrollStockAdapter extends BaseQuickAdapter {
17 | Random randomGenerator = new Random();
18 | float min = -0.5f;
19 | float max = 0.5f;
20 | DecimalFormat df = new DecimalFormat();
21 |
22 | public ScrollStockAdapter(List data) {
23 | super(R.layout.layout_scroll_stock, data);
24 | }
25 |
26 | @Override
27 | protected void convert(BaseViewHolder helper, StockListModel item) {
28 | df.setMaximumFractionDigits(3);
29 | float percantage = randomGenerator.nextFloat() * (max - min) + min;
30 | helper.setText(R.id.txt_stock_name,item.getShortName())
31 | .setText(R.id.txt_current_price,randomGenerator.nextInt(10)+"");
32 |
33 | if(percantage < 0){
34 | helper.setImageResource(R.id.img_up,R.mipmap.down);
35 | helper.setTextColor(R.id.txt_percantage_price, Color.parseColor("#EC3030"));
36 | helper.setText(R.id.txt_percantage_price, df.format(percantage) +"%" );
37 | }
38 | else{
39 | helper.setImageResource(R.id.img_up,R.mipmap.up);
40 | helper.setTextColor(R.id.txt_percantage_price, Color.parseColor("#8DCF5F"));
41 | helper.setText(R.id.txt_percantage_price,"+"+ df.format(percantage) +"%" );
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/java/com/example/aliahmed/myapplication/StockListModel.java:
--------------------------------------------------------------------------------
1 | package com.example.aliahmed.myapplication;
2 |
3 | import com.google.gson.annotations.Expose;
4 | import com.google.gson.annotations.SerializedName;
5 |
6 | import java.io.Serializable;
7 |
8 | public class StockListModel implements Serializable {
9 |
10 | @SerializedName("id")
11 | @Expose
12 | private String id;
13 | @SerializedName("shortName")
14 | @Expose
15 | private String shortName;
16 | @SerializedName("bidderName")
17 | @Expose
18 | private String bidderName;
19 | @SerializedName("askerName")
20 | @Expose
21 | private String askerName;
22 | @SerializedName("type")
23 | @Expose
24 | private String type;
25 | @SerializedName("shareQuantity")
26 | @Expose
27 | private Integer shareQuantity;
28 | @SerializedName("transactionTime")
29 | @Expose
30 | private String transactionTime;
31 | @SerializedName("isSyncedWithServer")
32 | @Expose
33 | private Boolean isSyncedWithServer;
34 |
35 | /**
36 | *
37 | * @return
38 | * The id
39 | */
40 | public String getId() {
41 | return id;
42 | }
43 |
44 | /**
45 | *
46 | * @param id
47 | * The id
48 | */
49 | public void setId(String id) {
50 | this.id = id;
51 | }
52 |
53 | /**
54 | *
55 | * @return
56 | * The shortName
57 | */
58 | public String getShortName() {
59 | return shortName;
60 | }
61 |
62 | /**
63 | *
64 | * @param shortName
65 | * The shortName
66 | */
67 | public void setShortName(String shortName) {
68 | this.shortName = shortName;
69 | }
70 |
71 | /**
72 | *
73 | * @return
74 | * The bidderName
75 | */
76 | public String getBidderName() {
77 | return bidderName;
78 | }
79 |
80 | /**
81 | *
82 | * @param bidderName
83 | * The bidderName
84 | */
85 | public void setBidderName(String bidderName) {
86 | this.bidderName = bidderName;
87 | }
88 |
89 | /**
90 | *
91 | * @return
92 | * The askerName
93 | */
94 | public String getAskerName() {
95 | return askerName;
96 | }
97 |
98 | /**
99 | *
100 | * @param askerName
101 | * The askerName
102 | */
103 | public void setAskerName(String askerName) {
104 | this.askerName = askerName;
105 | }
106 |
107 | /**
108 | *
109 | * @return
110 | * The type
111 | */
112 | public String getType() {
113 | return type;
114 | }
115 |
116 | /**
117 | *
118 | * @param type
119 | * The type
120 | */
121 | public void setType(String type) {
122 | this.type = type;
123 | }
124 |
125 | /**
126 | *
127 | * @return
128 | * The shareQuantity
129 | */
130 | public Integer getShareQuantity() {
131 | return shareQuantity;
132 | }
133 |
134 | /**
135 | *
136 | * @param shareQuantity
137 | * The shareQuantity
138 | */
139 | public void setShareQuantity(Integer shareQuantity) {
140 | this.shareQuantity = shareQuantity;
141 | }
142 |
143 | /**
144 | *
145 | * @return
146 | * The transactionTime
147 | */
148 | public String getTransactionTime() {
149 | return transactionTime;
150 | }
151 |
152 | /**
153 | *
154 | * @param transactionTime
155 | * The transactionTime
156 | */
157 | public void setTransactionTime(String transactionTime) {
158 | this.transactionTime = transactionTime;
159 | }
160 |
161 | /**
162 | *
163 | * @return
164 | * The isSyncedWithServer
165 | */
166 | public Boolean getIsSyncedWithServer() {
167 | return isSyncedWithServer;
168 | }
169 |
170 | /**
171 | *
172 | * @param isSyncedWithServer
173 | * The isSyncedWithServer
174 | */
175 | public void setIsSyncedWithServer(Boolean isSyncedWithServer) {
176 | this.isSyncedWithServer = isSyncedWithServer;
177 | }
178 |
179 | }
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/res/drawable/app_icon_new.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliahmedbd/Ticker-Using-Recycler-View-Android/227bf596e314a3a1b410d82e61a764cf6379a8ea/AndroidTicker/app/src/main/res/drawable/app_icon_new.png
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/res/drawable/shadow.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
14 | -
15 |
16 |
17 |
23 |
24 |
-
25 |
26 |
27 |
28 |
29 |
30 |
31 | -
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/res/layout/activity_auto_scroll.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
15 |
16 |
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/res/layout/activity_fragment_container.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
22 |
23 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/res/layout/fragment_auto_scroll.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
15 |
16 |
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/res/layout/layout_histories.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
22 |
23 |
32 |
33 |
38 |
39 |
44 |
45 |
46 |
47 |
48 |
49 |
55 |
56 |
62 |
63 |
73 |
74 |
83 |
84 |
92 |
93 |
94 |
95 |
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/res/layout/layout_scroll_stock.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
16 |
25 |
26 |
35 |
36 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliahmedbd/Ticker-Using-Recycler-View-Android/227bf596e314a3a1b410d82e61a764cf6379a8ea/AndroidTicker/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliahmedbd/Ticker-Using-Recycler-View-Android/227bf596e314a3a1b410d82e61a764cf6379a8ea/AndroidTicker/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/res/mipmap-xhdpi/down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliahmedbd/Ticker-Using-Recycler-View-Android/227bf596e314a3a1b410d82e61a764cf6379a8ea/AndroidTicker/app/src/main/res/mipmap-xhdpi/down.png
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliahmedbd/Ticker-Using-Recycler-View-Android/227bf596e314a3a1b410d82e61a764cf6379a8ea/AndroidTicker/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/res/mipmap-xhdpi/up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliahmedbd/Ticker-Using-Recycler-View-Android/227bf596e314a3a1b410d82e61a764cf6379a8ea/AndroidTicker/app/src/main/res/mipmap-xhdpi/up.png
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliahmedbd/Ticker-Using-Recycler-View-Android/227bf596e314a3a1b410d82e61a764cf6379a8ea/AndroidTicker/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliahmedbd/Ticker-Using-Recycler-View-Android/227bf596e314a3a1b410d82e61a764cf6379a8ea/AndroidTicker/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | My Application
3 | From Activity
4 | From Fragment
5 |
6 |
7 | Hello blank fragment
8 |
9 |
--------------------------------------------------------------------------------
/AndroidTicker/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/AndroidTicker/app/src/test/java/com/example/aliahmed/myapplication/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.aliahmed.myapplication;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/AndroidTicker/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | google()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:3.5.1'
10 |
11 | // NOTE: Do not place your application dependencies here; they belong
12 | // in the individual module build.gradle files
13 | }
14 | }
15 |
16 | allprojects {
17 | repositories {
18 | google()
19 | jcenter()
20 | maven { url "https://jitpack.io" }
21 | }
22 | }
23 |
24 | task clean(type: Delete) {
25 | delete rootProject.buildDir
26 | }
27 |
--------------------------------------------------------------------------------
/AndroidTicker/gradle.properties:
--------------------------------------------------------------------------------
1 | ## Project-wide Gradle settings.
2 | #
3 | # For more details on how to configure your build environment visit
4 | # http://www.gradle.org/docs/current/userguide/build_environment.html
5 | #
6 | # Specifies the JVM arguments used for the daemon process.
7 | # The setting is particularly useful for tweaking memory settings.
8 | # Default value: -Xmx1024m -XX:MaxPermSize=256m
9 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
10 | #
11 | # When configured, Gradle will run in incubating parallel mode.
12 | # This option should only be used with decoupled projects. More details, visit
13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
14 | # org.gradle.parallel=true
15 | #Sun Apr 09 22:41:42 BDT 2017
16 | org.gradle.jvmargs=-Xmx1536m
17 | android.useAndroidX=true
18 | android.enableJetifier=true
19 |
--------------------------------------------------------------------------------
/AndroidTicker/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliahmedbd/Ticker-Using-Recycler-View-Android/227bf596e314a3a1b410d82e61a764cf6379a8ea/AndroidTicker/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/AndroidTicker/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Nov 06 11:39:06 BDT 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
7 |
--------------------------------------------------------------------------------
/AndroidTicker/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/AndroidTicker/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/AndroidTicker/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Ali Ahmed
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Creating a Autoscrolled RecyclerView like Marquee text in Android also known as "Ticker in android"
2 |
3 | ### Why this article?
4 | Sometimes in our android apps need a marquee text effect like smooth autoscroll horizontally or vertically.
5 | ##### Example:
6 | For breaking news app there is a most necessary functionality which is show the breaking news like a horizontal scroll.
7 | Again, In share market app in top app should give a auto scroll effect for show the text.
8 |
9 | Stock exchange scroll:
10 | 
11 |
12 |
13 | But in android there is no perfect library for marquee text but in this article I will give a simplest solution for marquee text.
14 |
15 | ### Procedure:
16 | #### Add RecyclerView:
17 | Add RecyclerView as your desire place and also add dependency in gradle.
18 |
19 | #### XML:
20 | ```xml
21 |
28 |
29 | ```
30 | #### Gradle :
31 | ```java
32 | compile 'com.android.support:recyclerview-v7:24.2.0'
33 |
34 | ```
35 |
36 |
37 | #### Create adapter for RecyclerView
38 | Create adapter for RecyclerView. If you don't know how to create adapter please follow this link: [Click Here](http://antonioleiva.com/recyclerview/ )
39 |
40 | #### Make horizontal scroll
41 | For RecyclerView we have to use LayoutManager there is a method which is :
42 |
43 | ```java
44 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(MainActivity.this);
45 | linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
46 | ```
47 | Then use this in RecyclerView :
48 |
49 | ```java
50 | yourRecyclerView.setLayoutManager(linearLayoutManager );
51 | ```
52 |
53 | Then your RecyclerView will srolled in horizontally.
54 |
55 | #### Creating auto scroll for RecyclerView
56 | Here I use a thread which will perform autoscroll the items of RecyclerView. There is a method in RecyclerView which is smoothScrollToPosition() which take position of recyclerview to scroll that position to current position. So I use a thread to increment the position automatically so an autoscroll is happening because position is incremented automatically. When all incremented position will equal to the total item size then start from beginning. In this way an autoscroll effect is happened.
57 | Here is the code :
58 |
59 | ```java
60 | public void autoScroll(){
61 | final int speedScroll = 0;
62 | final Handler handler = new Handler();
63 | final Runnable runnable = new Runnable() {
64 | int count = 0;
65 | @Override
66 | public void run() {
67 | if(count == scrollStockAdapter.getItemCount())
68 | count =0;
69 | if(count < scrollStockAdapter.getItemCount()){
70 | rec_scroll_stock.smoothScrollToPosition(++count);
71 | handler.postDelayed(this,speedScroll);
72 | }
73 | }
74 | };
75 | handler.postDelayed(runnable,speedScroll);
76 | }
77 | ```
78 |
79 | #### Create Smooth scroll automatically
80 | Now main problem is auto scroll speed which is too fast. For RecyclerView we have to declare a LayoutManager. In LayoutManager there is a method which is smoothScrollToPosition() which is responsible for smooth scrolling. But for scrolling there is a velocity which default speed is 25f. To change this velocity you have to override this method. If you want a smooth scroll then increase this value as you want. In my case I use 4000f.
81 | ```java
82 | LinearLayoutManager layoutManager = new LinearLayoutManager(MainActivity.this) {
83 | @Override
84 | public void smoothScrollToPosition(RecyclerView recyclerView,RecyclerView.State state, int position) {
85 | LinearSmoothScroller smoothScroller = newLinearSmoothScroller(MainActivity.this) {
86 | private static final float SPEED = 4000f;// Change this value (default=25f)
87 | @Override
88 | protected float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
89 | return SPEED / displayMetrics.densityDpi;
90 | }
91 | };
92 | smoothScroller.setTargetPosition(position);
93 | startSmoothScroll(smoothScroller);
94 | }
95 |
96 | };
97 | ```
98 | Then set this LayoutManager to your RecyclerView like this :
99 | yourRecyclerView.setLayoutManager(layoutManager);
100 |
101 | #### Conclusion:
102 | In this way you can get a look and feel like Marquee text or like news feed.
103 |
104 | ### Using this repository in your project?
105 | If you are using this repository in your project, and happy about it, please send me a [email](mailto:aliahmedaiub@gmail.com) and let me know, I'll add a references of your app. Thanks :)
106 |
107 |
108 | ## License
109 |
110 | This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.
111 |
112 |
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-cayman
--------------------------------------------------------------------------------
/ezgif.com-crop.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliahmedbd/Ticker-Using-Recycler-View-Android/227bf596e314a3a1b410d82e61a764cf6379a8ea/ezgif.com-crop.gif
--------------------------------------------------------------------------------
/share bazar.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliahmedbd/Ticker-Using-Recycler-View-Android/227bf596e314a3a1b410d82e61a764cf6379a8ea/share bazar.PNG
--------------------------------------------------------------------------------