This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static boolean isConnectedToInternet(Context context) { | |
ConnectivityManager connectivity = (ConnectivityManager) context | |
.getSystemService(Context.CONNECTIVITY_SERVICE); | |
if (connectivity != null) { | |
NetworkInfo[] info = connectivity.getAllNetworkInfo(); | |
if (info != null) | |
for (int i = 0; i < info.length; i++) | |
if (info[i].getState() == NetworkInfo.State.CONNECTED) { | |
return true; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StoreUserData { | |
private SharedPreferences pref = null; | |
private Context parentActivity; | |
public static String APP_KEY; | |
public StoreUserData(Context context) { | |
parentActivity = context; | |
APP_KEY = context.getPackageName().replaceAll("\\.", "_").toLowerCase(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static ProgressDialog progressDialog; | |
public static void showProgress(Activity activity) { | |
progressDialog = new ProgressDialog(activity); | |
progressDialog.setIndeterminate(false); | |
progressDialog.setCancelable(false); | |
progressDialog.setMessage("Loading..."); | |
progressDialog.show(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Utils { | |
static ProgressDialog progressDialog; | |
public static void showProgress(Activity activity) { | |
progressDialog = new ProgressDialog(activity); | |
progressDialog.setIndeterminate(false); | |
progressDialog.setCancelable(false); | |
progressDialog.setMessage("Loading..."); | |
progressDialog.show(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends AppCompatActivity{ | |
List<String> permissionsList = new ArrayList<>(); | |
boolean askOnceAgain = false; | |
Activity activity; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
activity = this; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | |
<item | |
android:bottom="0dp" | |
android:left="-6dp" | |
android:right="-6dp" | |
android:top="-6dp"> | |
<shape android:shape="rectangle"> | |
<solid android:color="@android:color/transparent" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NewsDetailActivity extends AppCompatActivity implements View.OnClickListener { | |
Activity activity; | |
Toolbar toolbar; | |
File TEMP_FILE_SAVE_PATH = Environment.getExternalStorageDirectory(); | |
String TEMP_FILE_NAME = "news_"; | |
String URL=""; | |
private DownloadManager downloadManager; | |
@Override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void expand(final View v) { | |
v.measure(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); | |
final int targetHeight = v.getMeasuredHeight(); | |
// Older versions of android (pre API 21) cancel animations for views with a height of 0. | |
v.getLayoutParams().height = 1; | |
v.setVisibility(View.VISIBLE); | |
Animation a = new Animation() { | |
@Override | |
protected void applyTransformation(float interpolatedTime, Transformation t) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ImageFilePath | |
{ | |
/** | |
* Method for return file path of Gallery image | |
* | |
* @param context | |
* @param uri | |
* @return path of the selected image file from gallery |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Uri ImagefileUri; | |
int hasStoragePermission, hasCameraPermission, GALLERY_CLICK = 100, CAMERA_CLICK = 101; | |
File appImageFolder; | |
boolean askOnceAgain = false; | |
hasStoragePermission = ContextCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE); | |
if (hasStoragePermission != PackageManager.PERMISSION_GRANTED) { | |
ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, | |
11); | |
} else { |
OlderNewer