-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move WPUnderlineSpan.java and MediaGalleryImageSpan.java to WPUtils
- Loading branch information
Showing
3 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
87 changes: 87 additions & 0 deletions
87
WordPressUtils/src/main/java/org/wordpress/android/util/helpers/MediaGallery.java
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
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; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
WordPressUtils/src/main/java/org/wordpress/android/util/helpers/MediaGalleryImageSpan.java
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
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; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
WordPressUtils/src/main/java/org/wordpress/android/util/helpers/WPUnderlineSpan.java
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
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); | ||
} | ||
} |