2019년 7월 31일 수요일

Firebase, Coustom objects 사용

Coustom 객체를 사용한 조회

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
db.collection("company")
      .get()
      .addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
           @Override
           public void onComplete(@NonNull Task<QuerySnapshot> task) {
                 if (task.isSuccessful()) {
                      for (QueryDocumentSnapshot document : task.getResult()) {
                          companyList.add(document.toObject(Company.class));
                      }
                  } else {
                      Log.w(TAG, "Error getting company documents.", task.getException());
                  }
              }
        });

1
2
// 조회된 데이터 매핑
Company company = document.toObject(Company.class);


Coustom 객체를 사용한 추가

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
db.collection("company")
        .add(company)   // 객체를 넣어준다.
        .addOnSuccessListener(new OnSuccessListener<DocumentReference>() {
            @Override
            public void onSuccess(DocumentReference documentReference) {
                finish();
            }
        })
        .addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {
                Log.w(TAG, "Failure save");
            }
       });

2019년 7월 26일 금요일

circularImageView-안드로이드에서 간단하게 원형 이미지 생성

Web site
https://github.com/lopspower/CircularImageView

build.gradle(Module:app)에 추가
1
2
3
dependencies {
    implementation 'com.mikhaellopez:circularimageview:4.0.1'
}

Properties
  • app:civ_circle_color (color) -> default WHITE
  • app:civ_border (boolean) -> default true
  • app:civ_border_color (color) -> default WHITE
  • app:civ_border_width (dimension) -> default 4dp
  • app:civ_shadow (boolean) -> default false
  • app:civ_shadow_color (color) -> default BLACK
  • app:civ_shadow_radius (float) -> default 8.0f
  • app:civ_shadow_gravity (center, top, bottom, start or end) -> default bottom

XML
1
2
3
4
5
6
7
8
9
<com.mikhaellopez.circularimageview.CircularImageView
        android:layout_width="250dp"
        android:layout_height="250dp"
        android:src="@drawable/image"
        app:civ_border_color="#3f51b5"
        app:civ_border_width="4dp"
        app:civ_shadow="true"
        app:civ_shadow_radius="10"
        app:civ_shadow_color="#3f51b5"/>

JAVA

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
CircularImageView circularImageView = findViewById(R.id.circularImageView);
// Set Circle color for transparent image
circularImageView.setCircleColor(Color.WHITE);
// Set Border
circularImageView.setBorderColor(Color.RED);
circularImageView.setBorderWidth(10);
// Add Shadow with default param
circularImageView.setShadowEnable(true);
// or with custom param
circularImageView.setShadowRadius(15);
circularImageView.setShadowColor(Color.RED);
circularImageView.setBackgroundColor(Color.RED);
circularImageView.setShadowGravity(CircularImageView.ShadowGravity.CENTER);

안드로이드에서 Picasso사용




Last version
https://github.com/square/picasso

build.gradle 추가
1
2
3
dependencies {
    implementation 'com.squareup.picasso:picasso:2.71828'
}



1
Picasso.get().load("http://i.imgur.com/DvpvklR.png").into(imageView);

JavaScript, Array.some(), Array.every()

 Array.every(callbackfn: (value: T, index: number, array: T[]) => unknow, thisArg?: any): boolean      const   array  = [ 'A' ,  ...