This file contains 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
import android.content.Context; | |
import android.util.AttributeSet; | |
import android.widget.LinearLayout; | |
public class SquareLinearLayout extends LinearLayout { | |
public SquareLinearLayout(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
} |
This file contains 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 ArrayList<View> getViewsByTag(ViewGroup root, String tag) { | |
ArrayList<View> views = new ArrayList<View>(); | |
final int childCount = root.getChildCount(); | |
for (int i = 0; i < childCount; i++) { | |
final View child = root.getChildAt(i); | |
if (child instanceof ViewGroup) { | |
views.addAll(getViewsByTag((ViewGroup) child, tag)); | |
} | |
final Object tagObj = child.getTag(); |
This file contains 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 int dpToPx(Context context, int dp) { | |
Resources r = context.getResources(); | |
float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics()); | |
return (int) px; | |
} | |
public static int pxToDp(Context context, int px) { | |
final float scale = context.getResources().getDisplayMetrics().density; | |
int dp = (int) (px * scale + 0.5f); | |
return dp; |
This file contains 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
100% — FF | |
95% — F2 | |
90% — E6 | |
85% — D9 | |
80% — CC | |
75% — BF | |
70% — B3 | |
65% — A6 | |
60% — 99 | |
55% — 8C |
This file contains 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
/** | |
* Returns the difference between the provided date and now. | |
* The difference is in actual calendar days rather than time difference based. | |
* This means 01/Jan/2015 23:50 and 02/Jan/2015 00:01AM has a difference of 1 day. | |
* | |
* @param date The date from which the difference to today has to be calculated. | |
* @return difference in calendar days. | |
*/ | |
public static int getRealDayDifference(Date date) { | |
String timeString = null; |
This file contains 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
import android.content.Intent; | |
import android.os.Bundle; | |
import android.support.v7.app.AppCompatActivity; | |
import android.view.View; | |
import android.widget.ArrayAdapter; | |
import android.widget.Button; | |
import android.widget.ListView; | |
public class TransitionThemeActivity extends AppCompatActivity implements View.OnClickListener { |
This file contains 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 NetworkHelper extends Fragment { | |
public static final String TAG = "NetworkHelper"; | |
public static final String CHECK_INTERNET = "network_connection"; | |
private Activity mActivity; | |
AlertDialog mAlertDialog = null; | |
private BroadcastReceiver onNotice = new BroadcastReceiver() { | |
@Override |
This file contains 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
/** | |
* Copyright 2016 Ali Muzaffar | |
* <p/> | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* <p/> | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* <p/> | |
* Unless required by applicable law or agreed to in writing, software |
This file contains 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
/* | |
* Copyright 2013 The Android Open Source Project | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
OlderNewer