Skip to content

Instantly share code, notes, and snippets.

View ContentView.swift
import SwiftUI
struct ContentView: View {
@ObservedObject var myViewModel = MyViewModel()
var body: some View {
ScrollView {
VStack {
View MainActivity.java
RecyclerView recyclerView = findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
final MyAdapter adapter = new MyAdapter();
adapter.endLessScrolled(recyclerView);
adapter.addItems(getTempItems());
recyclerView.setAdapter(adapter);
// handled click item in recyclerView
View MyAdapter.java
public class MyAdapter extends AdapterRecyclerView<String> {
@Override
public int getItemLayout(int viewType) {
return R.layout.my_item;
}
// optional method override layout progress custom
@Override
public int onProgressLayout() {
View DataBinding.gradle
android {
dataBinding {
enabled = true
}
...
defaultConfig {
...
}
buildTypes {
...
View CustomAdapter.gradle
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'ir.farshid_roohi:customAdapterRecycleView:1.0.4'
@FarshidRoohi
FarshidRoohi / PrettyTime.swift
Last active May 1, 2018
show persian times ago e.x input method String date format : "yyyy-MM-dd HH:mm:ss"
View PrettyTime.swift
import Foundation
class PrettyTime {
// example uses : PrettyTime.timesAgo(strDate : "2018-03-10 13:19:13" , numericDates : false)
static func timesAgo(strDate:String, numericDates:Bool) -> String {