├── 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 | 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 | 24 | 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 | 70 | 71 | 72 | 73 | 74 | 75 | 80 | 81 | 82 | 83 | 84 | 85 | 1.8 (1) 86 | 87 | 92 | 93 | 94 | 95 | 96 | 97 | 1.8 98 | 99 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 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 | 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 |