parent
428aa208b3
commit
6900b74cd1
@ -0,0 +1,60 @@ |
||||
package com.github.catvod.bean.ali; |
||||
|
||||
import com.google.gson.Gson; |
||||
import com.google.gson.annotations.SerializedName; |
||||
|
||||
public class Code { |
||||
|
||||
@SerializedName("data") |
||||
private Data data; |
||||
@SerializedName("pds_login_result") |
||||
private Data result; |
||||
|
||||
public static Code objectFrom(String str) { |
||||
try { |
||||
return new Gson().fromJson(str, Code.class); |
||||
} catch (Exception e) { |
||||
return new Code(); |
||||
} |
||||
} |
||||
|
||||
public Data getData() { |
||||
return data == null ? new Data() : data; |
||||
} |
||||
|
||||
public Data getResult() { |
||||
return result == null ? new Data() : result; |
||||
} |
||||
|
||||
public boolean hasToken() { |
||||
return getResult().getRefreshToken().length() > 0; |
||||
} |
||||
|
||||
public static class Data { |
||||
|
||||
@SerializedName("t") |
||||
private String t; |
||||
@SerializedName("ck") |
||||
private String ck; |
||||
@SerializedName("codeContent") |
||||
private String codeContent; |
||||
@SerializedName("refreshToken") |
||||
private String refreshToken; |
||||
|
||||
public String getT() { |
||||
return t; |
||||
} |
||||
|
||||
public String getCk() { |
||||
return ck; |
||||
} |
||||
|
||||
public String getCodeContent() { |
||||
return codeContent == null ? "" : codeContent; |
||||
} |
||||
|
||||
public String getRefreshToken() { |
||||
return refreshToken == null ? "" : refreshToken; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,43 @@ |
||||
package com.github.catvod.utils; |
||||
|
||||
import android.graphics.Bitmap; |
||||
|
||||
import com.google.zxing.BarcodeFormat; |
||||
import com.google.zxing.EncodeHintType; |
||||
import com.google.zxing.MultiFormatWriter; |
||||
import com.google.zxing.common.BitMatrix; |
||||
|
||||
import java.util.EnumMap; |
||||
import java.util.Map; |
||||
|
||||
public class QRCode { |
||||
|
||||
private static final int WHITE = 0xFFFFFFFF; |
||||
private static final int BLACK = 0xFF000000; |
||||
|
||||
public static Bitmap createBitmap(BitMatrix matrix) { |
||||
int width = matrix.getWidth(); |
||||
int height = matrix.getHeight(); |
||||
int[] pixels = new int[width * height]; |
||||
for (int y = 0; y < height; y++) { |
||||
int offset = y * width; |
||||
for (int x = 0; x < width; x++) { |
||||
pixels[offset + x] = matrix.get(x, y) ? BLACK : WHITE; |
||||
} |
||||
} |
||||
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); |
||||
bitmap.setPixels(pixels, 0, width, 0, 0, width, height); |
||||
return bitmap; |
||||
} |
||||
|
||||
public static Bitmap getBitmap(String contents, int size, int margin) { |
||||
try { |
||||
Map<EncodeHintType, Object> hints = new EnumMap<>(EncodeHintType.class); |
||||
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8"); |
||||
hints.put(EncodeHintType.MARGIN, margin); |
||||
return createBitmap(new MultiFormatWriter().encode(contents, BarcodeFormat.QR_CODE, Misc.dp2px(size), Misc.dp2px(size), hints)); |
||||
} catch (Exception e) { |
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
Binary file not shown.
@ -1 +1 @@ |
||||
6aa710655b59e0b3f88a283a3c4668ec |
||||
7071a7598ea9bffccc4fc76684f9b529 |
||||
|
||||
Loading…
Reference in new issue