Skip to content

Instantly share code, notes, and snippets.

@ankuryadav7
ankuryadav7 / CipherUtil.java
Last active February 26, 2023 08:24
Updated CipherUtil class to avoid Unsafe cipher mode Error/Warning on playstore
import android.util.Base64;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.util.Arrays;
import javax.crypto.Cipher;
Add below files in Gradle
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.6.0'
Create Api Client
public class ApiClient {
private static Retrofit retrofit = null;
private static final String CACHE_CONTROL = "Cache-Control";
@ankuryadav7
ankuryadav7 / Volley GET request
Last active December 28, 2017 12:52
Call GET method with parameters via volley. YouTube search API used for demo.
String URL="https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UCN2W5ND2GDEqw4NSauNmbRw&maxResults=25&key=API KEY PASTE HERE&type=video";
StringRequest stringRequest=new StringRequest(Request.Method.GET, URL, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject jsonObject=new JSONObject(response);
JSONArray jsonArray=jsonObject.getJSONArray("items");
for(int i=0;i<jsonArray.length();i++){
JSONObject jsonObject1 = jsonArray.getJSONObject(i);
@ankuryadav7
ankuryadav7 / Heterogenous Recyclerview
Last active December 8, 2017 13:30
Adapter for implement heterogenous layouts in recyclerview.
package com.example;
import android.app.Activity;
import android.graphics.Typeface;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;