Aglio

How to run API document
1. Install aglio
npm install aglio -g

2. Run API Document
aglio -i api.md -s -p 8081

2.1. Export file
aglio -i api.md -o api.html

Advertisements

Swift 3 – some snippets..

  • if let paypal = user.paypal {
    // paypal != nil
    } else {
    // paypal == nil
    }
  • guard let paypal = user.paypal else {
    // paypal == nil
    return
    }
  • Handler :
    • VC 1: (CashoutContentVC)

      var loadTotalBalanceHandler: (()->())?  

      if (condition) {

                           if let callback = self.loadTotalBalanceHandler {

                              callback()

                         }
      }

    • VC 2:

      let cashoutVC = storyboard.instantiateViewController(withIdentifier: “CASH OUT”) as! CashoutContentVC

              cashoutVC.loadTotalBalanceHandler = {[weak self] in

                  self?.loadTotalBalance() //things need to do when callback

              }

      //example 2 :  pass a Double from vc1 -> vc2 

    • VC1:
      var
      ratingScoreHandler: ((_ score: Double) -> ())?

      if (condition) {

                     if let callback = self.ratingScoreHandler {

                          callback(rating)

                      }
      }

    • VC 2:

      let ratingVC = RatingVC(nibName: “RatingVC”, bundle: nil)

      ratingVC.ratingScoreHandler = { [weak self] (score) in

                  if let strongSelf = self {

                      strongSelf.ratingScore = Int(score) //things need to do when callback

                  }

              }

UICollectionView set num of colums

I implemented UICollectionViewDelegateFlowLayout on my UICollectionViewController and override the method responsible for determining the size of the Cell. I then took the screen width and divided it with my column requirement. For example, I wanted to have 3 columns on each screen size. So here’s what my code looks like –

– (CGSize)collectionView:(UICollectionView *)collectionView

                  layout:(UICollectionViewLayout *)collectionViewLayout

  sizeForItemAtIndexPath:(NSIndexPath *)indexPath

{

    CGRect screenRect = [[UIScreen mainScreen] bounds];

    CGFloat screenWidth = screenRect.size.width;

    float cellWidth = screenWidth / 3.0; //Replace the divisor with the column count requirement. Make sure to have it in float.

    CGSize size = CGSizeMake(cellWidth, cellWidth);

    return size;

}

Mobile trends + techniques

Demo App: (support both Android/iOS/Hybrid)

  • Will submit this app to the stores – easier for presentation, help client can install and try to use….
  • Should have a Content Team to build the content data about NashTech capabilities, activities (We will request company support us)
  • Should have Design Team to build cool UI for us (We will request company support us)

 

  • Build UI sample:
    • Use social network register/login (should request permission for team and for client when they visit)
    • Navigation behavior
    • Sliding menu (contain all features menu at here)
    • Setting pages
    • List view: swipe item left/right to show item menu, swipe actions
    • Popup : confirm popup, selection option popup, warning popup,….
    • Database sample: create data and save to dB then load to a list (done, should build the real content to make sense)
    • SSL & OAuth 2 authentication sample (done – should be integrate to demo app)
    • Push Notifications
    • Camera action
    • QR code action
    • Chat feature (optional)
    • API to get traveller App data  (reuse exiting source)
    • DateTime converter (reuse exiting source)
    • Animation examples (flying, transparent, scale, transittion,….)
    • Build analytics pages to show the installed user, user activities,…
    • Build questionnaire structure to show that we can build the dynamic pages,..
    • Like/share app to social network…
    • Chart samples
  • Build Bluetooth sample (should purchase some fitness devices such as Xiaomi band, Apple watch, samsung watch, Google fit.. and sync data with them
  • Material design for UI
  • Big data visualization
  • Ad Targeting (showing ads for a specific target group which selected by user)
  • Deep Linking
  • Location based service

Create QR code image from String

public Bitmap createBitmap(String str, Context context) throws WriterException {

    int wd = UiUtil.getPixelFromDp(100);
    int pinkColor = context.getResources().getColor(R.color.black);
    int whiteColor = context.getResources().getColor(R.color.white);

    Map<EncodeHintType, Object> hints = new HashMap<EncodeHintType, Object>(1);

    hints.put(EncodeHintType.MARGIN, 0);


    BitMatrix result;
    try {
        result = new MultiFormatWriter().encode(str,
                BarcodeFormat.QR_CODE, wd, wd, hints);
    } catch (IllegalArgumentException iae) {
        // TODO Unsupported format
        return null;
    }

    //Change color pixel
    int w = result.getWidth();
    int h = result.getHeight();
    int[] pixels = new int[w * h];
    for (int y = 0; y < h; y++) {
        int offset = y * w;
        for (int x = 0; x < w; x++) {
            pixels[offset + x] = result.get(x, y) ? pinkColor : whiteColor;
        }
    }

    Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
    bitmap.setPixels(pixels, 0, wd, 0, 0, w, h);

    return bitmap;
}

Layout of Parallax Toolbar + Pull to refresh list view

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:contentScrim="@color/white"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_collapseMode="parallax">

                <include layout="@layout/curator_cover" />

            </RelativeLayout>

            <android.support.v7.widget.Toolbar
                android:id="@+id/mm_toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin">

                <ImageView
                    android:id="@+id/ivSearch"
                    android:layout_width="@dimen/badge_menu_item_size"
                    android:layout_height="@dimen/badge_menu_item_size"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp"
                    android:background="?attr/selectableItemBackground"
                    android:clickable="true"
                    android:gravity="center"
                    android:scaleType="fitCenter"
                    android:src="@drawable/search_wht"
                    tools:ignore="ContentDescription" />
            </android.support.v7.widget.Toolbar>

        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/swipe_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/rvPost"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scrollbars="vertical" />
    </android.support.v4.widget.SwipeRefreshLayout>
</android.support.design.widget.CoordinatorLayout>