[go: nahoru, domu]

Skip to content

Commit

Permalink
move WPUnderlineSpan.java and MediaGalleryImageSpan.java to WPUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
maxme committed Feb 12, 2015
1 parent 8dbc12f commit 374a7c3
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@

package org.wordpress.android.util.helpers;

import java.io.Serializable;
import java.util.ArrayList;

/**
* A model representing a Media Gallery.
* A unique id is not used on the website, but only in this app.
* It is used to uniquely determining the instance of the object, as it is
* passed between post and media gallery editor.
*/
public class MediaGallery implements Serializable {
private static final long serialVersionUID = 2359176987182027508L;

private long uniqueId;
private boolean isRandom;
private String type;
private int numColumns;
private ArrayList<String> ids;

public MediaGallery(boolean isRandom, String type, int numColumns, ArrayList<String> ids) {
this.isRandom = isRandom;
this.type = type;
this.numColumns = numColumns;
this.ids = ids;
this.uniqueId = System.currentTimeMillis();
}

public MediaGallery() {
isRandom = false;
type = "";
numColumns = 3;
ids = new ArrayList<String>();
this.uniqueId = System.currentTimeMillis();
}

public boolean isRandom() {
return isRandom;
}

public void setRandom(boolean isRandom) {
this.isRandom = isRandom;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public int getNumColumns() {
return numColumns;
}

public void setNumColumns(int numColumns) {
this.numColumns = numColumns;
}

public ArrayList<String> getIds() {
return ids;
}

public String getIdsStr() {
String ids_str = "";
if (ids.size() > 0) {
for (String id : ids) {
ids_str += id + ",";
}
ids_str = ids_str.substring(0, ids_str.length() - 1);
}
return ids_str;
}

public void setIds(ArrayList<String> ids) {
this.ids = ids;
}

/**
* An id to uniquely identify a media gallery object, so that the same object can be edited in the post editor
*/
public long getUniqueId() {
return uniqueId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.wordpress.android.util.helpers;

import android.content.Context;
import android.text.style.ImageSpan;

public class MediaGalleryImageSpan extends ImageSpan {
private MediaGallery mMediaGallery;

public MediaGalleryImageSpan(Context context, MediaGallery mediaGallery, int placeHolder) {
super(context, placeHolder);
setMediaGallery(mediaGallery);
}

public MediaGallery getMediaGallery() {
return mMediaGallery;
}

public void setMediaGallery(MediaGallery mediaGallery) {
this.mMediaGallery = mediaGallery;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (C) 2006 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
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.wordpress.android.util.helpers;

import android.os.Parcel;
import android.text.ParcelableSpan;
import android.text.TextPaint;
import android.text.style.CharacterStyle;
import android.text.style.UpdateAppearance;

public class WPUnderlineSpan extends CharacterStyle
implements UpdateAppearance, ParcelableSpan {
public WPUnderlineSpan() {
}

public WPUnderlineSpan(Parcel src) {
}

public int getSpanTypeId() {
return 6;
}

public int describeContents() {
return 0;
}

public void writeToParcel(Parcel dest, int flags) {
}

@Override
public void updateDrawState(TextPaint ds) {
ds.setUnderlineText(true);
}
}

0 comments on commit 374a7c3

Please sign in to comment.