Skip to content

Instantly share code, notes, and snippets.

@implementation UITableViewCell (ProgressIndicator)
- (void)showProgress:(BOOL)show {
if(show) {
UIActivityIndicatorView *progress = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
UIView *progressView = [[UIView alloc] initWithFrame:CGRectMake(0,0,20,20)];
[progressView addSubview: progress];
if(self.accessoryView) {
progressView.frame = self.accessoryView.bounds;
}
progress.center = progressView.center;
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row%2 == 0) {
UIColor *altCellColor = [UIColor colorWithWhite:0.7 alpha:0.1];
cell.backgroundColor = altCellColor;
}
}
//discount BG
_discountBackgroundView = [[UIImageView alloc] initWithImage:[UIImage MSRetailScannerImageNamed:@"Bargain"]];
UIImage* mask = [UIImage MSRetailScannerImageNamed:@"Bargain-mask"];
if (mask)
{
_discountBackgroundView.layer.mask = [CALayer layer];
_discountBackgroundView.layer.mask.frame = _discountBackgroundView.layer.bounds;
_discountBackgroundView.layer.mask.contents = (__bridge id)[mask CGImage];
}
@jinqian
jinqian / rotation.xml
Last active December 17, 2015 01:49
android rotation animation
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true"
android:fillEnabled="true">
<rotate
android:duration="1600"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="10"
@jinqian
jinqian / progress_bar.xml
Created May 20, 2013 15:26
simple android progress bar drawable
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@android:id/background">
<shape>
<corners android:radius="5dip" />
<gradient
android:angle="270"
android:centerColor="#ff5a5d5a"
@jinqian
jinqian / progressbar_updating.java
Created May 22, 2013 16:19
set progress bar progress
// Start lengthy operation in a background thread
new Thread(new Runnable() {
public void run() {
while (mProgressStatus < 100) {
mProgressStatus = doWork();
// Update the progress bar
mHandler.post(new Runnable() {
public void run() {
mProgress.setProgress(mProgressStatus);
@jinqian
jinqian / w3c_color_code.xml
Created May 22, 2013 16:21
w3c color code list
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="white">#FFFFFF</color>
<color name="yellow">#FFFF00</color>
<color name="fuchsia">#FF00FF</color>
<color name="red">#FF0000</color>
<color name="silver">#C0C0C0</color>
<color name="gray">#808080</color>
<color name="olive">#808000</color>
<color name="purple">#800080</color>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="White">#FFFFFF</color>
<color name="Ivory">#FFFFF0</color>
<color name="LightYellow">#FFFFE0</color>
<color name="Yellow">#FFFF00</color>
<color name="Snow">#FFFAFA</color>
<color name="FloralWhite">#FFFAF0</color>
<color name="LemonChiffon">#FFFACD</color>
<color name="Cornsilk">#FFF8DC</color>
@jinqian
jinqian / color_button_with_shadow.xml
Created May 29, 2013 15:59
color button with shadow
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle" >
<solid android:color="#33000000" />
<corners android:radius="4dip" />
</shape>
</item>
@jinqian
jinqian / rename.sh
Created June 13, 2013 17:36
my 1st bash
#!/bin/bash
match="large"
for i in ./cover/*/*; do
folder=$(dirname $i)
fname=$(basename $i)
if [[ "$fname" == *$match* ]]; then
#tgt=$(echo $i | sed -e "s/$re_match/$replace/")
mv "$i" "$folder/large_cover.jpg"